Created
July 24, 2014 03:15
-
-
Save aikar/628a0dd9fa5d85ac10cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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