org.spongepowered.api.data.type.HandTypes Java Examples
The following examples show how to use
org.spongepowered.api.data.type.HandTypes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemloreCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, ItemPermissions.UC_ITEM_ITEMLORE_BASE); Player p = (Player) sender; if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) { throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand")); } ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND); Text unsplitlore = Messages.toText(args.<String>getOne("lore").get()); stack.offer(Keys.ITEM_LORE, unsplitlore.toPlain().contains("|") ? TextUtil.split(unsplitlore, "|") : Arrays.asList(unsplitlore)); p.setItemInHand(HandTypes.MAIN_HAND, stack); Messages.send(sender, "item.command.itemlore.success", "%arg%", unsplitlore); return CommandResult.success(); }
Example #2
Source File: TakeExecutor.java From EssentialCmds with MIT License | 6 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { Player target = ctx.<Player> getOne("target").get(); if (src instanceof Player) { Player player = (Player) src; if (target.getItemInHand(HandTypes.MAIN_HAND).isPresent()) { player.getInventory().offer(target.getItemInHand(HandTypes.MAIN_HAND).get()); target.setItemInHand(HandTypes.MAIN_HAND, null); player.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Took " + target.getName() + "'s held item.")); } else { player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Target is not holding anything!")); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be an in-game player to take other players items!")); } return CommandResult.success(); }
Example #3
Source File: ItemInfoExecutor.java From EssentialCmds with MIT License | 6 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { if (src instanceof Player) { Player player = (Player) src; if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) { ItemStack itemInHand = player.getItemInHand(HandTypes.MAIN_HAND).get(); player.sendMessage(Text.of(TextColors.GOLD, "The name of the item in your hand is: ", TextColors.GRAY, itemInHand.getTranslation().get())); player.sendMessage(Text.of(TextColors.GOLD, "The ID of the item in your hand is: ", TextColors.GRAY, itemInHand.getItem().getId())); player.sendMessage(Text.of(TextColors.GOLD, "The meta of the item in your hand is: ", TextColors.GRAY, itemInHand.toContainer().get(DataQuery.of("UnsafeDamage")).get().toString())); } else { player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must hold an item.")); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be an in-game player to use this command.")); } return CommandResult.success(); }
Example #4
Source File: InteractPermListener.java From Nations with MIT License | 6 votes |
@Listener(order=Order.FIRST, beforeModifications = true) public void onInteract(InteractBlockEvent event, @First Player player) { if (!ConfigHandler.getNode("worlds").getNode(player.getWorld().getName()).getNode("enabled").getBoolean()) { return; } if (player.hasPermission("nations.admin.bypass.perm.interact")) { return; } Optional<ItemStack> optItem = player.getItemInHand(HandTypes.MAIN_HAND); if (optItem.isPresent() && (ConfigHandler.isWhitelisted("use", optItem.get().getItem().getId()) || optItem.get().getItem().equals(ItemTypes.GOLDEN_AXE) && ConfigHandler.getNode("others", "enableGoldenAxe").getBoolean(true))) return; event.getTargetBlock().getLocation().ifPresent(loc -> { if (!DataHandler.getPerm("interact", player.getUniqueId(), loc)) { event.setCancelled(true); if (loc.getBlockType() != BlockTypes.STANDING_SIGN && loc.getBlockType() != BlockTypes.WALL_SIGN) player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_INTERACT)); } }); }
Example #5
Source File: ItemdurabilityCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, ItemPermissions.UC_ITEM_ITEMDURABILITY_BASE); Player p = (Player) sender; if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) { throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand")); } ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND); int durability = args.<Integer>getOne("durability").get(); if (!stack.supports(DurabilityData.class)) { throw new ErrorMessageException(Messages.getFormatted(sender, "item.command.itemdurability.notsupported")); } if (durability < stack.get(DurabilityData.class).get().durability().getMinValue() || durability > stack.get(DurabilityData.class).get().durability().getMaxValue()) { throw new ErrorMessageException(Messages.getFormatted(sender, "item.numberinvalid", "%number%", durability)); } stack.offer(Keys.ITEM_DURABILITY, durability); p.setItemInHand(HandTypes.MAIN_HAND, stack); Messages.send(sender, "item.command.itemdurability.success", "%arg%", durability); return CommandResult.success(); }
Example #6
Source File: ItemcanbreakCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, ItemPermissions.UC_ITEM_ITEMCANBREAK_BASE); Player p = (Player) sender; if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) { throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand")); } ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND); Set<BlockType> types = new HashSet<>(args.<BlockType>getAll("blocktypes")); stack.offer(Keys.BREAKABLE_BLOCK_TYPES, types); p.setItemInHand(HandTypes.MAIN_HAND, stack); Text items = Text.joinWith(Text.of(", "), types.stream().map(type -> Text.of(type.getName())).collect(Collectors.toList())); Messages.send(sender, "item.command.itemcanbreak.success", "%arg%", items); return CommandResult.success(); }
Example #7
Source File: ItemcanplaceonCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, ItemPermissions.UC_ITEM_ITEMCANPLACEON_BASE); Player p = (Player) sender; if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) { throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand")); } ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND); Set<BlockType> types = new HashSet<>(args.<BlockType>getAll("blocktypes")); stack.offer(Keys.PLACEABLE_BLOCKS, types); p.setItemInHand(HandTypes.MAIN_HAND, stack); Text items = Text.joinWith(Text.of(", "), types.stream().map(type -> Text.of(type.getName())).collect(Collectors.toList())); Messages.send(sender, "item.command.itemcanplaceon.success", "%arg%", items); return CommandResult.success(); }
Example #8
Source File: ItemhidetagsCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, ItemPermissions.UC_ITEM_ITEMHIDETAGS_BASE); Player p = (Player) sender; if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) { throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand")); } ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND); Key<Value<Boolean>> key = args.<Key<Value<Boolean>>>getOne("tag").get(); boolean value = args.<Boolean>getOne("enabled").get(); stack.offer(key, value); p.setItemInHand(HandTypes.MAIN_HAND, stack); Messages.send(sender, "item.command.itemhidetags.success", "%tag%", key.getName(), "%status%", Messages.getFormatted(value ? "item.command.itemhidetags.hidden" : "item.command.itemhidetags.shown")); return CommandResult.success(); }
Example #9
Source File: ItemunbreakableCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, ItemPermissions.UC_ITEM_ITEMUNBREAKABLE_BASE); Player p = (Player) sender; Boolean value = args.<Boolean>getOne("enabled/disabled").get(); if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) { throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand")); } ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND); if (!stack.supports(Keys.UNBREAKABLE)) { throw new ErrorMessageException(Messages.getFormatted(sender, "item.command.itemunbreakable.notsupported")); } stack.offer(Keys.UNBREAKABLE, value); p.setItemInHand(HandTypes.MAIN_HAND, stack); Messages.send(sender, "item.command.itemunbreakable.success", "%arg%", value); return CommandResult.success(); }
Example #10
Source File: ItemquantityCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, ItemPermissions.UC_ITEM_ITEMDURABILITY_BASE); Player p = (Player) sender; if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) { throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand")); } ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND); int quantity = args.<Integer>getOne("quantity").get(); if (quantity > stack.getMaxStackQuantity()) { throw new ErrorMessageException(Messages.getFormatted(sender, "item.numberinvalid", "%number%", quantity)); } stack.setQuantity(quantity); p.setItemInHand(HandTypes.MAIN_HAND, stack); Messages.send(sender, "item.command.itemquantity.success", "%arg%", quantity); return CommandResult.success(); }
Example #11
Source File: ItemnameCommand.java From UltimateCore with MIT License | 6 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, ItemPermissions.UC_ITEM_ITEMNAME_BASE); Player p = (Player) sender; if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) { throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand")); } ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND); Text name = Messages.toText(args.<String>getOne("name").get()); stack.offer(Keys.DISPLAY_NAME, name); p.setItemInHand(HandTypes.MAIN_HAND, stack); Messages.send(sender, "item.command.itemname.success", "%arg%", name); return CommandResult.success(); }
Example #12
Source File: ItemenchantCommand.java From UltimateCore with MIT License | 5 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, ItemPermissions.UC_ITEM_ITEMENCHANT_BASE); Player p = (Player) sender; if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) { throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand")); } ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND); EnchantmentType ench = args.<EnchantmentType>getOne("enchantment").get(); int level = args.hasAny("level") ? args.<Integer>getOne("level").get() : 1; if (level > ItemPermissions.UC_ITEM_ITEMENCHANT_MAXLEVEL.getIntFor(p)) { throw Messages.error(p, "item.command.itemenchant.maxlevel", "%max%", ItemPermissions.UC_ITEM_ITEMENCHANT_MAXLEVEL.getIntFor(p)); } List<Enchantment> enchs = stack.get(Keys.ITEM_ENCHANTMENTS).orElse(new ArrayList<>()); if (level > 0) { enchs.add(Enchantment.builder().type(ench).level(level).build()); stack.offer(Keys.ITEM_ENCHANTMENTS, enchs); p.setItemInHand(HandTypes.MAIN_HAND, stack); Messages.send(sender, "item.command.itemenchant.success", "%enchant%", ench.getTranslation().get(), "%level%", level); return CommandResult.success(); } else { enchs = enchs.stream().filter(e -> !e.getType().equals(ench)).collect(Collectors.toList()); stack.offer(Keys.ITEM_ENCHANTMENTS, enchs); p.setItemInHand(HandTypes.MAIN_HAND, stack); Messages.send(sender, "item.command.itemenchant.success2", "%enchant%", ench.getTranslation().get(), "%level%", level); return CommandResult.success(); } }
Example #13
Source File: VersionHelper8.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public ItemType getItemInHand(Player player) { if (!player.getItemInHand(HandTypes.MAIN_HAND).isEmpty()) { return player.getItemInHand(HandTypes.MAIN_HAND).getType(); } else if (!player.getItemInHand(HandTypes.OFF_HAND).isEmpty()) { return player.getItemInHand(HandTypes.OFF_HAND).getType(); } return ItemTypes.NONE; }
Example #14
Source File: VersionHelper8.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getItemOffHand(Player player) { if (!player.getItemInHand(HandTypes.OFF_HAND).isEmpty()) return player.getItemInHand(HandTypes.OFF_HAND); return ItemStack.empty(); }
Example #15
Source File: VersionHelper8.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getItemMainHand(Player player) { if (!player.getItemInHand(HandTypes.MAIN_HAND).isEmpty()) return player.getItemInHand(HandTypes.MAIN_HAND); return ItemStack.empty(); }
Example #16
Source File: VersionHelper7.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public ItemType getItemInHand(Player player) { if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) { return player.getItemInHand(HandTypes.MAIN_HAND).get().getType(); } else if (player.getItemInHand(HandTypes.OFF_HAND).isPresent()) { return player.getItemInHand(HandTypes.OFF_HAND).get().getType(); } return ItemTypes.NONE; }
Example #17
Source File: VersionHelper7.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getItemOffHand(Player player) { if (player.getItemInHand(HandTypes.OFF_HAND).isPresent()) return player.getItemInHand(HandTypes.OFF_HAND).get(); return ItemStack.empty(); }
Example #18
Source File: MoreCommand.java From UltimateCore with MIT License | 5 votes |
@Override public CommandResult execute(CommandSource sender, CommandContext args) throws CommandException { checkIfPlayer(sender); checkPermission(sender, ItemPermissions.UC_ITEM_MORE_BASE); Player p = (Player) sender; if (p.getItemInHand(HandTypes.MAIN_HAND).getType().equals(ItemTypes.NONE)) { throw new ErrorMessageException(Messages.getFormatted(p, "item.noiteminhand")); } ItemStack stack = p.getItemInHand(HandTypes.MAIN_HAND); stack.setQuantity(stack.getMaxStackQuantity()); p.setItemInHand(HandTypes.MAIN_HAND, stack); Messages.send(p, "item.command.more.success", "%amount%", stack.getMaxStackQuantity()); return CommandResult.success(); }
Example #19
Source File: VersionHelper7.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getItemMainHand(Player player) { if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) return player.getItemInHand(HandTypes.MAIN_HAND).get(); return ItemStack.empty(); }
Example #20
Source File: VersionHelper56.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public ItemType getItemInHand(Player player) { if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) { return player.getItemInHand(HandTypes.MAIN_HAND).get().getItem(); } else if (player.getItemInHand(HandTypes.OFF_HAND).isPresent()) { return player.getItemInHand(HandTypes.OFF_HAND).get().getItem(); } return ItemTypes.NONE; }
Example #21
Source File: VersionHelper56.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getItemOffHand(Player player) { if (player.getItemInHand(HandTypes.OFF_HAND).isPresent()) return player.getItemInHand(HandTypes.OFF_HAND).get(); return ItemStack.empty(); }
Example #22
Source File: VersionHelper56.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@Override public ItemStack getItemMainHand(Player player) { if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) return player.getItemInHand(HandTypes.MAIN_HAND).get(); return ItemStack.empty(); }
Example #23
Source File: PlayerClickListener.java From EssentialCmds with MIT License | 5 votes |
@Listener public void onPlayerClick(InteractEvent event, @Root Player player) { if (EssentialCmds.frozenPlayers.contains(player.getUniqueId())) { player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot click while frozen.")); event.setCancelled(true); return; } if (EssentialCmds.jailedPlayers.contains(player.getUniqueId())) { player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot click while jailed.")); event.setCancelled(true); return; } Powertool foundTool = null; for (Powertool powertool : EssentialCmds.powertools) { if (powertool.getPlayer().equals(player)) { if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent() && powertool.getItemID().equals(player.getItemInHand(HandTypes.MAIN_HAND).get().getItem().getName())) { foundTool = powertool; break; } } } if (foundTool != null) { Sponge.getGame().getCommandManager().process(player, foundTool.getCommand()); } }
Example #24
Source File: LoreBase.java From EssentialCmds with MIT License | 5 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { int number = ctx.<Integer> getOne("number").get(); if (src instanceof Player) { Player player = (Player) src; if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) { ItemStack stack = player.getItemInHand(HandTypes.MAIN_HAND).get(); LoreData loreData = stack.getOrCreate(LoreData.class).get(); List<Text> newLore = loreData.lore().get(); newLore.remove(number - 1); DataTransactionResult dataTransactionResult = stack.offer(Keys.ITEM_LORE, newLore); if (dataTransactionResult.isSuccessful()) { player.setItemInHand(HandTypes.MAIN_HAND, stack); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Removed lore from item.")); } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Could not remove lore from item.")); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be holding an item!")); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be a player to name items.")); } return CommandResult.success(); }
Example #25
Source File: LoreBase.java From EssentialCmds with MIT License | 5 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { String lore = ctx.<String> getOne("lore").get(); if (src instanceof Player) { Player player = (Player) src; if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) { ItemStack stack = player.getItemInHand(HandTypes.MAIN_HAND).get(); LoreData loreData = stack.getOrCreate(LoreData.class).get(); Text textLore = TextSerializers.FORMATTING_CODE.deserialize(lore); List<Text> newLore = loreData.lore().get(); newLore.add(textLore); DataTransactionResult dataTransactionResult = stack.offer(Keys.ITEM_LORE, newLore); if (dataTransactionResult.isSuccessful()) { player.setItemInHand(HandTypes.MAIN_HAND, stack); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Added lore to item.")); } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Could not add lore to item.")); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be holding an item!")); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be a player to name items.")); } return CommandResult.success(); }
Example #26
Source File: PlayerUtil.java From GriefDefender with MIT License | 5 votes |
public boolean hasItemInOneHand(Player player) { ItemStack mainHand = player.getItemInHand(HandTypes.MAIN_HAND).orElse(null); ItemStack offHand = player.getItemInHand(HandTypes.OFF_HAND).orElse(null); if (mainHand != null || offHand != null) { return true; } return false; }
Example #27
Source File: SetNameExecutor.java From EssentialCmds with MIT License | 5 votes |
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { String name = ctx.<String> getOne("name").get(); if (src instanceof Player) { Player player = (Player) src; if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) { ItemStack stack = player.getItemInHand(HandTypes.MAIN_HAND).get(); Text textName = TextSerializers.FORMATTING_CODE.deserialize(name); DataTransactionResult dataTransactionResult = stack.offer(Keys.DISPLAY_NAME, textName); if(dataTransactionResult.isSuccessful()) { player.setItemInHand(HandTypes.MAIN_HAND, stack); src.sendMessage(Text.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Set name on item.")); } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "Could not set name on item.")); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be holding an item!")); } } else { src.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be a player to name items.")); } return CommandResult.success(); }
Example #28
Source File: SpongeDeathListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private Runnable handlePlayerKill(long time, UUID victimUUID, Player killer) { Optional<ItemStack> inMainHand = killer.getItemInHand(HandTypes.MAIN_HAND); ItemStack inHand = inMainHand.orElse(killer.getItemInHand(HandTypes.OFF_HAND).orElse(ItemStack.empty())); ItemType type = inHand.isEmpty() ? ItemTypes.AIR : inHand.getType(); return victimUUID != null ? new PlayerKillProcessor(killer.getUniqueId(), time, victimUUID, new ItemNameFormatter().apply(type.getName())) : new MobKillProcessor(killer.getUniqueId()); }
Example #29
Source File: Sponge5ArmorListener.java From ViaVersion with MIT License | 5 votes |
@Listener public void onInteract(InteractEvent event, @Root Player player) { if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) { if (ArmorType.isArmor(player.getItemInHand(HandTypes.MAIN_HAND).get().getItem().getId())) sendDelayedArmorUpdate(player); } }
Example #30
Source File: ProtectionManagerImpl.java From EagleFactions with MIT License | 5 votes |
private boolean isHoldingEagleFeather(final User user) { return user.getItemInHand(HandTypes.MAIN_HAND).isPresent() && user.getItemInHand(HandTypes.MAIN_HAND).get().getType() == ItemTypes.FEATHER && user.getItemInHand(HandTypes.MAIN_HAND).get().get(Keys.DISPLAY_NAME).isPresent() && user.getItemInHand(HandTypes.MAIN_HAND).get().get(Keys.DISPLAY_NAME).get().equals(EagleFeather.getDisplayName()); }