当前位置: 首页>>代码示例>>Java>>正文


Java PlayerInteractEvent.getPlayer方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerInteractEvent.getPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent.getPlayer方法的具体用法?Java PlayerInteractEvent.getPlayer怎么用?Java PlayerInteractEvent.getPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerInteractEvent的用法示例。


在下文中一共展示了PlayerInteractEvent.getPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onChestOpen

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onChestOpen(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    Game game = Skywars.getInstance().getGame(player);
    if (game != null && game.getGamePlayer(player) != null) {
        if (game.isState(Game.GameState.LOBBY) || game.isState(Game.GameState.PREPARATION) || game.isState(Game.GameState.STARTING)) {
            event.setCancelled(true);
            return;
        }

        GamePlayer gamePlayer = game.getGamePlayer(player);

        if (gamePlayer.isTeamClass()) {
            if (gamePlayer.getTeam().isPlayer(player)) {
                handle(event, game);
            }
        } else {
            if (gamePlayer.getPlayer() == player) {
                handle(event, game);
            }
        }
    }
}
 
开发者ID:JordanOsterberg,项目名称:SkywarsSeries,代码行数:25,代码来源:ChestInteract.java

示例2: checkCombos

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
public void checkCombos(PlayerInteractEvent e){
	Player p = (Player) e.getPlayer();
	List<String> parry = new ArrayList<String>();
	parry.add(0, "Right");
	parry.add(1, "Left");
	parry.add(2, "Right");
	if (Datafiles.getCombos(p.getName()).equals(parry)) {
	Effects.heartBeam(e);
	}
	List<String> watercombo = new ArrayList<String>();
	watercombo.add(0, "Right");
	watercombo.add(1, "Left");
	watercombo.add(2, "Left");
	if (Datafiles.getCombos(p.getName()).equals(watercombo)) {
	Effects.fireBarrier(e);
	}
}
 
开发者ID:MohibMirza,项目名称:RPGPlus,代码行数:18,代码来源:Combos.java

示例3: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {   
    if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { // This check needs to be there, 'cause RightClickAction has only the getType function, LeftClickAction doesnt and boooom!!
        Player player = (Player) e.getPlayer();
        ItemStack item = e.getItem();
        Block block = e.getClickedBlock();
        String bankId = BukkitUtils.getNBTTag(item, "bankid");
        
        if (item == null || block == null) return;
        
        if (bankId != null && bankId.length() > 0 && item.getType() == Material.PAPER && block.getType() == Material.ENDER_STONE) {
            // got a foreign card?
            if (!bankId.equals(player.getUniqueId().toString())) {
                player.getInventory().remove(item);
                BankomatCommand.appendCreditCardToUser(player); 
            } 
            
            player.openInventory(bankUi); // Dispatch our event by opening bankUi here:
        }   
    }
}
 
开发者ID:srbinas,项目名称:bankomat,代码行数:22,代码来源:BankMenuListener.java

示例4: grenadeEvent

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void grenadeEvent(PlayerInteractEvent e){
	final Player p = e.getPlayer();
	if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
		if(p.getItemInHand().hasItemMeta()){
			if(p.getItemInHand().getItemMeta().getLore() == null) return;
			if(p.getItemInHand().getItemMeta().getLore().contains(ChatColor.GRAY + "Grenade I")){
				p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() - 4));
				final Item grenade = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.CLAY_BALL));
				grenade.setVelocity(p.getEyeLocation().getDirection().normalize().multiply(0.8D));
				Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
					public void run(){
						p.getWorld().createExplosion(grenade.getLocation().getX(), grenade.getLocation().getY(), 
								grenade.getLocation().getZ(), 3, false, false);
						grenade.remove();
					}
				},30L);
			}
		}
	}
}
 
开发者ID:OverloadedCore,项目名称:chaoticWeapons,代码行数:23,代码来源:Core.java

示例5: onInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onInteract(PlayerInteractEvent event) {
    if ((event.getAction() == Action.RIGHT_CLICK_BLOCK) && (event.hasItem()) && (event.getItem().getType() == Material.ENDER_PEARL)) {
        Block block = event.getClickedBlock();

        if ((block.getType().isSolid()) && (!(block.getState() instanceof InventoryHolder))) {
            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem());
        }
    }
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:13,代码来源:PearlFix.java

示例6: onThrowTNT

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onThrowTNT(PlayerInteractEvent event) {
	Player p = event.getPlayer();
	Gamer g = Gamer.get(p.getName());
	if (g.getVariable("spectator") != null)
		return;

	if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
		if (p.getItemInHand().getType() == Material.TNT) {
			// Frag Grenades
			TNTPrimed e = (TNTPrimed) event.getPlayer().getWorld().spawnEntity(p.getEyeLocation(),	EntityType.PRIMED_TNT);
			e.setFuseTicks(38);
			e.setYield(2.5F);
			e.setVelocity(event.getPlayer().getEyeLocation().getDirection());
			e.setMetadata("Player", new FixedMetadataValue(Nexus.getPlugin(), g.getPlayer().getName()));
			e.setMetadata("Cause", new FixedMetadataValue(Nexus.getPlugin(), CustomDamageCause.TNT_GRENADE.name()));
			
			event.setUseItemInHand(Event.Result.DENY);
			ItemStack stack = null;
			if (event.getItem().getAmount() > 1) {
				ItemStack s = event.getItem();
				s.setAmount(event.getItem().getAmount() - 1);
				stack = s;
			}
			p.getInventory().setItem(p.getInventory().getHeldItemSlot(), stack);
			event.setCancelled(true);
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:30,代码来源:KitEvents.java

示例7: onMyPetItemUse

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onMyPetItemUse(PlayerInteractEvent event) {
    if (event.getItem() != null) {
        Player player = event.getPlayer();

        if (!InventoryManager.playerIsLoaded(player)) {
            return;
        }

        Inventory inventory = InventoryManager.get(player).getInventory();

        if (isMyPetItem(event.getItem())
                && (event.getAction() == Action.RIGHT_CLICK_BLOCK
                || event.getAction() == Action.RIGHT_CLICK_AIR)) {
            Slot petSlot = getMyPetSlot();

            ItemStack currentPet = inventory.getItem(petSlot.getSlotId());
            boolean hasPet = !petSlot.isCup(currentPet);
            ItemStack newPet = event.getItem();

            if (!hasPet) {
                currentPet = null;
            }

            player.getEquipment().setItemInMainHand(currentPet);
            inventory.setItem(petSlot.getSlotId(), newPet);

            swapMyPets(player, hasPet, newPet);
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:32,代码来源:MyPetManager.java

示例8: onSignClick

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onSignClick(PlayerInteractEvent event) {
	if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR)
		return;
	
	Block b = event.getClickedBlock();
	if (b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN) {
		Sign sign = (Sign) b.getState();
		SignClickEvent ev = new SignClickEvent(event.getPlayer(), sign, event.getClickedBlock(), event.getAction() == Action.RIGHT_CLICK_BLOCK);
		Bukkit.getServer().getPluginManager().callEvent(ev);
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:13,代码来源:GeneralEvents.java

示例9: onSkullClick

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onSkullClick(PlayerInteractEvent event) {
    if(event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
    if(!LocationUtils.center(event.getClickedBlock().getLocation())
            .equals(LocationUtils.center(this.location))) return;
    if(this.claim(event.getPlayer().getUniqueId())) {
        if(this.getPlugin().getSkullCount(event.getPlayer().getUniqueId()) >= this.getPlugin().getGhostSkulls().size()) {
            event.getPlayer().playSound(event.getPlayer().getLocation(), Sounds.LEVEL_UP.spigot(), 10, 0.9f);
            event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', this.getPlugin().getMessageFile().getString("ghosts-found-message")));
            this.getPlugin().getConfig().getStringList("reward-commands").forEach(command -> {
                this.getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(),
                        command.replace("{name}", event.getPlayer().getName())
                                .replace("{uuid}", event.getPlayer().getUniqueId().toString())
                                .replace("{total}", "" + this.getPlugin().getSkullCount(event.getPlayer().getUniqueId())));
            });
        } else {
            event.getPlayer().playSound(event.getPlayer().getLocation(), Sounds.GHAST_FIREBALL.spigot(), 10, 1.2f);
            event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', this.getPlugin().getMessageFile().getString("ghost-found-message"))
                    .replace("{found}", "" + this.getPlugin().getSkullCount(event.getPlayer().getUniqueId()))
                    .replace("{total}", "" + this.getPlugin().getGhostSkulls().size()));
            event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', this.getPlugin().getMessageFile().getString("find-message")));
            this.getPlugin().getConfig().getConfigurationSection("single-reward-commands").getKeys(false).forEach(needed -> {
                if(this.getPlugin().getSkullCount(event.getPlayer().getUniqueId()) == Integer.parseInt(needed)) {
                    this.getPlugin().getConfig().getStringList("single-reward-commands." + needed).forEach(command -> {
                        this.getPlugin().getServer().dispatchCommand(Bukkit.getConsoleSender(),
                                command.replace("{name}", event.getPlayer().getName())
                                        .replace("{uuid}", event.getPlayer().getUniqueId().toString())
                                        .replace("{total}", "" + this.getPlugin().getSkullCount(event.getPlayer().getUniqueId())));
                    });
                }
            });
        }
        new ClaimAnimation(event.getPlayer(), this);
    } else {
        event.getPlayer().playSound(event.getPlayer().getLocation(), Sounds.NOTE_BASS.spigot(), 10, 1);
        event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', this.getPlugin().getMessageFile().getString("already-found-message")));
    }
}
 
开发者ID:redraskal,项目名称:GhostScavengerHunt,代码行数:39,代码来源:GhostSkull.java

示例10: onInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteract(PlayerInteractEvent evt) {
    if (evt.getAction() != Action.RIGHT_CLICK_BLOCK && evt.getAction() != Action.RIGHT_CLICK_AIR)
        return;
    Block bk = evt.getPlayer().getTargetBlock((Set<Material>) null, 25);
    Player p = evt.getPlayer();
    if (bk != null && !BANNED.contains(bk.getType())) // Boosting others.
        bk.getWorld().getNearbyEntities(bk.getLocation(), 2, 2, 2).stream().filter(e -> !e.equals(p)).forEach(e -> boost(p, e));

    if (evt.hasBlock() && p.getLocation().distance(evt.getClickedBlock().getLocation()) <= 3 && !BANNED.contains(evt.getClickedBlock().getType()))
        boost(p, p); // Boosting themselves.
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:13,代码来源:Boost.java

示例11: onAttemptRespawn

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onAttemptRespawn(PlayerInteractEvent event) {
	Player player = event.getPlayer();
	ItemStack item = event.getItem();
	
	if (item == null || item.getType() != Material.END_CRYSTAL) return;
	if (plugin.getConfig().getBoolean("allow-crystal-respawns")) return;
	
	World world = player.getWorld();
	EndWorldWrapper worldWrapper = plugin.getDEDManager().getWorldWrapper(world);
	if (worldWrapper.isRespawnInProgress() || !world.getEntitiesByClass(EnderDragon.class).isEmpty()) {
		Set<EnderCrystal> crystals = PortalCrystal.getAllSpawnedCrystals(world);
		
		// Check for 3 crystals because PlayerInteractEvent is fired first
		if (crystals.size() < 3) return;
		
		for (EnderCrystal crystal : crystals) {
			crystal.getLocation().getBlock().setType(Material.AIR); // Remove fire
			world.dropItem(crystal.getLocation(), END_CRYSTAL_ITEM);
			crystal.remove();
		}
		
		plugin.getNMSAbstract().sendActionBar(ChatColor.RED + "You cannot manually respawn a dragon!", player);
		player.sendMessage(ChatColor.RED + "You cannot manually respawn a dragon!");
		event.setCancelled(true);
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:28,代码来源:DragonLifeListeners.java

示例12: onFoodEat

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onFoodEat(PlayerInteractEvent event) {
	if(!(event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
		return;
	}
	if(!event.getPlayer().isSneaking() || event.getPlayer().getInventory().getItemInMainHand() == null) {
		return;
	}
	
	Player player = event.getPlayer();
	List<Integer> ids = GodFoodFile.getFoodId(player.getInventory().getItemInMainHand().getTypeId());
	for(int id : ids) {
		byte data = (byte)GodFoodFile.getData(id);
		
		if(player.getInventory().getItemInMainHand().getData().getData() != data || id == 0)
			continue;
		
		if(player.getInventory().getItemInMainHand().getAmount() > GodFoodFile.getAmount(id)) {
			ItemStack item = player.getInventory().getItemInMainHand();
			item.setAmount(item.getAmount() - GodFoodFile.getAmount(id));
			player.setItemInHand(item);
		} else if(player.getInventory().getItemInMainHand().getAmount() == GodFoodFile.getAmount(id)) {
			player.setItemInHand(new ItemStack(Material.AIR));
		} else {
			return;
		}
		event.setCancelled(true);
		
		addPotionEffects(player, id);
		player.sendMessage(Lang.HEADERS_FOG.toString() + "You used " 
				+ ChatColor.RED + GodFoodFile.getName(id) + ChatColor.GRAY + "!");
	}
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:35,代码来源:GodFoodListener.java

示例13: onSpawn

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSpawn(PlayerInteractEvent e){
    Player p = e.getPlayer();

    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if(e.getHand() != EquipmentSlot.HAND) return;
        if (e.getItem() == null || !e.getItem().hasItemMeta() || !e.getItem().getItemMeta().hasDisplayName() || e.getItem().getType() != Material.MONSTER_EGG) return;
        if (!ChatColor.stripColor(e.getItem().getItemMeta().getDisplayName()).contains("Spawn")) return;
        int id = Integer.parseInt(e.getItem().getItemMeta().getLore().get(0));
        String s = e.getItem().getItemMeta().getLore().get(1);

        boolean canCatch = true;
        ApplicableRegionSet region = plugin.getWg().getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation());
        for (ProtectedRegion r : region.getRegions()) if (!r.getOwners().contains(p.getName())) canCatch = false;

        if (!canCatch) {
            p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No puedes spawnear un mob en parcelas ajenas");
            return;
        }

        SNMob mob = new SNMob(p);
        if (!mob.isOwner(id)) {
           p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No eres el dueño de este huevo");
            return;
        }
        mob.spawnMob(id, s);
        p.getInventory().getItemInMainHand().setAmount(-1);
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:30,代码来源:SpawnMob.java

示例14: anvilStuff

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void anvilStuff(PlayerInteractEvent e){
	if(e.getClickedBlock() == null)return;
	if(e.getClickedBlock().getType().equals(Material.ANVIL)){
		e.setCancelled(true);
		Player p = e.getPlayer();
		String uuid = p.getUniqueId().toString();
		long tokens = getTokens(uuid);
		if(p.getItemInHand().getType() == Material.AIR ||
				p.getItemInHand().getType() == Material.GOLDEN_APPLE ||
				p.getItemInHand().getType() == Material.ARROW ||
				p.getItemInHand().getType() == Material.POTION){
			
			p.sendMessage(tag + ChatColor.RED + "You can\'t repair that!");
		}else{
			if(tokens < 1){
				p.sendMessage(tag + ChatColor.RED + "You need at least 1 token to repair things!!");
			}else{
				if(p.getItemInHand().getDurability() > 0){
					p.getItemInHand().setDurability((short) 0);
					setTokens(uuid, getTokens(uuid)-1);
					p.sendMessage(tag + ChatColor.BLUE + "Your item has been repaired");
				}else{
					p.sendMessage(tag + ChatColor.RED + "This item isn\'t broken");
				}
			}
		}
	}
}
 
开发者ID:OverloadedCore,项目名称:kaosEssentials,代码行数:31,代码来源:Core.java

示例15: Fireman

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void Fireman(PlayerInteractEvent event) {
	// LAVA: 12
	Player p = event.getPlayer();
	if (!Kit.getKit(p).getName().equalsIgnoreCase("fireman") && event.getItem() != null	&& event.getItem().getType() == Material.LAVA_BUCKET) {
		event.setCancelled(true);
		Chat.player(p, "&cOnly players with the \"Fireman\" kit can use lava!");
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:10,代码来源:KitEvents.java


注:本文中的org.bukkit.event.player.PlayerInteractEvent.getPlayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。