本文整理汇总了Java中org.bukkit.event.player.PlayerInteractEvent.getItem方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent.getItem方法的具体用法?Java PlayerInteractEvent.getItem怎么用?Java PlayerInteractEvent.getItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerInteractEvent
的用法示例。
在下文中一共展示了PlayerInteractEvent.getItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCompassClick
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onCompassClick(PlayerInteractEvent event) {
if (event.getItem() == null || event.getItem().getType() != Material.COMPASS)
return;
Player p = event.getPlayer();
ItemStack stack = event.getItem();
if (stack.getItemMeta().hasDisplayName()) {
String display = Chat.stripColor(stack.getItemMeta().getDisplayName());
if (display.equalsIgnoreCase("game picker")) {
Inventory inv = Bukkit.getServer().createInventory(p, 9, Chat.colors("&oMC Zone Games"));
for (int i = 1; i < 12; i++) {
int number = i - 1;
if (i > GameIcon.getList().size())
break;
inv.setItem(i, GameIcon.getList().get(number).getItemStack());
}
p.openInventory(inv);
}
}
}
示例2: onClick
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(PlayerInteractEvent e) {
Action act = e.getAction();
if (!(act.equals(Action.RIGHT_CLICK_AIR) || act.equals(Action.RIGHT_CLICK_BLOCK)))
return;
ItemStack item = e.getItem();
if (item == null)
return;
if (!item.hasItemMeta())
return;
if (!item.getItemMeta().hasDisplayName())
return;
if (!item.getItemMeta().getDisplayName().contains(ConfigManager.getInstance().getBackpackName()))
return;
Player p = e.getPlayer();
String name = p.getName();
if (BackpackCooldown.getInstance().isReady(name, 500)) {
BackpackCooldown.getInstance().put(name);
} else {
e.setCancelled(true);
p.closeInventory();
p.sendMessage(Messages.getMessages().getNoQuickOpen().replace("&", "§"));
}
}
示例3: onUseBackpack
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST)
public void onUseBackpack(PlayerInteractEvent event) {
ItemStack item = event.getItem();
if (!event.hasItem() || !ItemUtils.hasTag(item, ItemUtils.BACKPACK_TAG)) {
return;
}
Player player = event.getPlayer();
Action action = event.getAction();
if ((action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
&& InventoryManager.isQuickSlot(player.getInventory().getHeldItemSlot())) {
BackpackManager.open(player, item);
}
event.setCancelled(true);
player.updateInventory();
}
示例4: playerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void playerInteract(final PlayerInteractEvent event) {
if(event.getAction() == Action.PHYSICAL
|| !(Gizmos.gizmoMap.get(event.getPlayer()) instanceof GunGizmo)
|| event.getItem() == null || event.getItem().getType() != this.getIcon()) return;
final Player player = event.getPlayer();
RaindropUtil.giveRaindrops(Users.playerId(player), -1, new RaindropResult() {
@Override
public void run() {
if(success) {
Vector velocity = player.getLocation().getDirection().multiply(1.75D);
Item item = player.getWorld().dropItem(event.getPlayer().getEyeLocation(), new ItemStack(Material.GHAST_TEAR));
item.setVelocity(velocity);
item.setTicksLived((5 * 60 * 20) - (5 * 20)); // 5 minutes - 5 seconds
items.put(item, player.getUniqueId());
} else {
player.sendMessage(ChatColor.RED + LobbyTranslations.get().t("gizmo.gun.empty", player));
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 1f, 1f);
}
}
}, null, false, true, false);
}
示例5: onInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onInteract(PlayerInteractEvent event) {
if(link.isEmpty())return;
ItemStack stack = event.getItem();
if(stack == null)
return;
NBTItem item = new NBTItem(stack);
Integer cmdId = item.getInteger("cmd");
if(cmdId == null)
return;
Link cmd = link.get(cmdId);
if(cmd==null)
return;
VPPlayer sender = VanillaPlusCore.getPlayerManager().getPlayer(event.getPlayer());
if(cmd.cmd.hasRequirement(sender)){
cmd.onExecute(sender);
event.setCancelled(cmd.cancel);
}
}
示例6: onInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
/**
* Give strength on spinash use
* @param event Event
*/
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (event.getItem() != null && event.getItem().isSimilar(this.spinash))
{
event.getPlayer().addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(this.bonusTime * 20, 1));
event.getPlayer().setItemInHand(new ItemStack(Material.AIR));
event.setCancelled(true);
}
}
示例7: InteractCheck
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
@SuppressWarnings("deprecation")
public void InteractCheck(PlayerInteractEvent event) {
if (ConfigPatch.noInfItem) {
Player player = event.getPlayer();
if (event.getItem() != null) {
if (event.getItem().getAmount() <= 0) {
event.setCancelled(true);
player.setItemInHand(null);
AzureAPI.log(player, ConfigPatch.AntiInfItemClickcWarnMessage);
}
}
}
}
示例8: onUseBonemeal
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onUseBonemeal(PlayerInteractEvent e) {
if (cm.isAntiBonemealDupe && e.getAction() == Action.RIGHT_CLICK_BLOCK && VersionUtils.isLowerThan(VersionUtils.V1_8)) {
if (e.getItem() == null || e.getItem().getType() != Material.INK_SACK) {
return;
}
if (cm.antiBonemealBlackList.contains(e.getClickedBlock().getTypeId())) {
e.setCancelled(true);
}
}
}
示例9: 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);
}
}
示例10: onInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteract(PlayerInteractEvent e) {
final TOAUser u = TOA.getPlayer(e.getPlayer());
if (e.getItem() != null) {
Material m = e.getItem().getType();
if (m == Material.WRITTEN_BOOK || m == Material.BOW || m == Material.SHEARS || m == Material.DIAMOND_SWORD) return;
Ability.useAbility(u, e.getItem().getType());
e.setCancelled(true);
}
if (!u.isOnRank(PACmd.Grupo.Builder)) {
if (e.getClickedBlock() != null) {
if (e.getClickedBlock().getType().equals(Material.TRAP_DOOR) || e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)
|| e.getClickedBlock().getType().equals(Material.FENCE_GATE) || e.getClickedBlock().getType().equals(Material.FIRE)
|| e.getClickedBlock().getType().equals(Material.CAULDRON) || e.getClickedBlock().getRelative(BlockFace.UP).getType().equals(Material.FIRE)
|| e.getClickedBlock().getType() == Material.CHEST || e.getClickedBlock().getType() == Material.TRAPPED_CHEST
|| e.getClickedBlock().getType() == Material.DROPPER || e.getClickedBlock().getType() == Material.DISPENSER
|| e.getClickedBlock().getType() == Material.BED_BLOCK || e.getClickedBlock().getType() == Material.BED
|| e.getClickedBlock().getType() == Material.WORKBENCH || e.getClickedBlock().getType() == Material.BREWING_STAND
|| e.getClickedBlock().getType() == Material.ANVIL || e.getClickedBlock().getType() == Material.DARK_OAK_FENCE_GATE
|| e.getClickedBlock().getType() == Material.SPRUCE_FENCE_GATE || e.getClickedBlock().getType() == Material.FURNACE
|| e.getClickedBlock().getType() == Material.BURNING_FURNACE || e.getClickedBlock().getType() == Material.HOPPER
|| e.getClickedBlock().getType() == Material.STONE_BUTTON || e.getClickedBlock().getType() == Material.WOOD_BUTTON) {
e.setCancelled(true);
}
}
}
}
示例11: onPlayerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event){
Player player = event.getPlayer();
ItemStack item = event.getItem();
if(isEnchantmentItem(item)){
event.setCancelled(true);
enchantGUI(player);
}
}
示例12: onInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
/**
* Give invisibility on ring use
* @param event Event
*/
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (event.getItem() != null && event.getItem().isSimilar(this.ring))
{
event.getPlayer().addPotionEffect(PotionEffectType.INVISIBILITY.createEffect(this.bonusTime * 20, 1));
event.getPlayer().setItemInHand(new ItemStack(Material.AIR));
event.setCancelled(true);
}
}
示例13: onInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void onInteract(PlayerInteractEvent e, Entity en) {
ElevatorInstance ei = ((ElevatorInstance) CustomBlockInstance.getBlockInstance((ArmorStand) en));
if (e.getItem() != null && e.getItem().getType() == Material.INK_SACK) {
ei.setColor(ei.getColor().mixColors(DyeColor.getByDyeData(e.getItem().getData().getData()).getFireworkColor()));
}
}
示例14: onPlayerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (Walls.getSpectators().contains(event.getPlayer().getName())) {
event.setCancelled(true);
return;
}
if (event.getItem()==null)
return;
if (!State.PVP && (event.getItem().getType()==Material.FLINT_AND_STEEL || event.getItem().getType()==Material.FIREBALL || event.getItem().getType()==Material.LAVA_BUCKET)) {
Chat.player(event.getPlayer(), "&cYou are not allowed to use fire before the walls drop!");
event.setCancelled(true);
}
}
示例15: onPlayerInteract
import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
if (event.getItem() == null || !event.getItem().equals(QUIT_STACK))
return;
this.tutorial.onPlayerQuits(event.getPlayer());
}