Skip to content

Instantly share code, notes, and snippets.

@aikar
Created July 24, 2014 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aikar/628a0dd9fa5d85ac10cf to your computer and use it in GitHub Desktop.
Save aikar/628a0dd9fa5d85ac10cf to your computer and use it in GitHub Desktop.
@EmpireSubcommand("fixitem")
public static void fixVote(Player player, String[] args) {
final ItemStack item = player.getItemInHand();
boolean valid = false;
if (Util.color("&6&l&nVoting Reward").equals(ItemUtil.getLore(item, 3))) {
switch (item.getType()) {
case DIAMOND_PICKAXE:
case DIAMOND_AXE:
case DIAMOND_SPADE:
case IRON_PICKAXE:
case IRON_AXE:
case IRON_SPADE:
case SHEARS:
case DIAMOND_HOE:
if (item.getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS) != 0) {
valid = true;
}
break;
}
}
if (!valid) {
Util.sendMsg(player, "&cInvalid Item");
Util.sendMsg(player, "&aThis command can only be used on Voting Reward items that mistakenly has");
return;
} else {
switch (item.getType()) {
case DIAMOND_PICKAXE:
case DIAMOND_AXE:
case DIAMOND_SPADE:
case IRON_PICKAXE:
case IRON_AXE:
case IRON_SPADE:
item.removeEnchantment(Enchantment.LOOT_BONUS_MOBS);
item.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
break;
case SHEARS:
item.removeEnchantment(Enchantment.LOOT_BONUS_MOBS);
item.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
break;
case DIAMOND_HOE:
item.setType(Material.IRON_HOE);
item.removeEnchantment(Enchantment.LOOT_BONUS_MOBS);
item.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 1);
break;
}
player.setItemInHand(item);
player.updateInventory();
Util.sendMsg(player, "&aItem in hand has been fixed.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment