Esempio n. 1
0
 public BaseTransaction(Inventory inventory, int slot, Item sourceItem, Item targetItem) {
   this.inventory = inventory;
   this.slot = slot;
   this.sourceItem = sourceItem.clone();
   this.targetItem = targetItem.clone();
   this.creationTime = System.currentTimeMillis();
 }
Esempio n. 2
0
 @Override
 public int[][] getDrops(Item item) {
   if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) {
     return new int[][] {{Item.BRICKS_BLOCK, 0, 1}};
   } else {
     return new int[0][0];
   }
 }
Esempio n. 3
0
 @Override
 public boolean execute(CommandSender sender, String commandLabel, String[] args) {
   if (!this.testPermission(sender)) {
     return true;
   }
   if (args.length < 2) {
     sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
     return true;
   }
   Player player = sender.getServer().getPlayer(args[0]);
   if (player == null) {
     sender.sendMessage(
         new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
     return true;
   }
   int enchantId;
   int enchantLevel;
   try {
     enchantId = Integer.parseInt(args[1]);
     enchantLevel = args.length == 3 ? Integer.parseInt(args[2]) : 1;
   } catch (NumberFormatException e) {
     sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
     return true;
   }
   Enchantment enchantment = Enchantment.getEnchantment(enchantId);
   if (enchantment == null) {
     sender.sendMessage(
         new TranslationContainer("commands.enchant.notFound", String.valueOf(enchantId)));
     return true;
   }
   enchantment.setLevel(enchantLevel);
   Item item = player.getInventory().getItemInHand();
   if (item.getId() <= 0) {
     sender.sendMessage(new TranslationContainer("commands.enchant.noItem"));
     return true;
   }
   item.addEnchantment(enchantment);
   player.getInventory().setItemInHand(item);
   Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.enchant.success"));
   return true;
 }
Esempio n. 4
0
 @Override
 public Item getTargetItem() {
   return targetItem.clone();
 }
Esempio n. 5
0
 @Override
 public Item getSourceItem() {
   return sourceItem.clone();
 }