package mineplex.hub.modules; import java.util.ArrayList; import java.util.HashMap; import mineplex.core.MiniPlugin; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.hub.HubManager; import mineplex.hub.commands.HorseSpawn; import org.bukkit.Material; import org.bukkit.entity.Horse; import org.bukkit.entity.Player; import org.bukkit.entity.Horse.Color; import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Variant; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; public class AdminMountManager extends MiniPlugin { private HubManager Manager; private HashMap _mounts = new HashMap(); public AdminMountManager(HubManager manager) { super("Mount Manager", manager.GetPlugin()); Manager = manager; } @Override public void AddCommands() { AddCommand(new HorseSpawn(this)); } @EventHandler public void HorseInteract(PlayerInteractEntityEvent event) { if (!(event.getRightClicked() instanceof Horse)) return; Player player = event.getPlayer(); Horse horse = (Horse)event.getRightClicked(); //Not Owner if (!_mounts.containsKey(player) || !_mounts.get(player).equals(horse)) { UtilPlayer.message(player, F.main("Mount", "This is not your mount!")); event.setCancelled(true); return; } } @EventHandler public void PlayerQuit(PlayerQuitEvent event) { Horse horse = _mounts.remove(event.getPlayer()); if (horse != null) horse.remove(); } public void HorseCommand(Player caller, String[] args) { if (args == null || args.length == 0) { UtilPlayer.message(caller, F.main("Mount", "Mount Commands;")); UtilPlayer.message(caller, "spawn / kill / leash / unleash"); UtilPlayer.message(caller, "age / color / style / armor"); return; } if (args[0].equalsIgnoreCase("spawn")) { Variant var = Variant.HORSE; if (args.length > 1) { try { var = Variant.valueOf(args[1].toUpperCase());; } catch (Exception e) { } } Spawn(caller, var); return; } Horse horse = _mounts.get(caller); if (horse == null) { UtilPlayer.message(caller, F.main("Mount", "You do not have a mount.")); return; } //Leash else if (args[0].equalsIgnoreCase("leash")) { horse.setLeashHolder(caller); } //UnLeash else if (args[0].equalsIgnoreCase("unleash")) { horse.setLeashHolder(null); } //Kill else if (args[0].equalsIgnoreCase("kill")) { horse.remove(); _mounts.remove(caller); } //Age else if (args[0].equalsIgnoreCase("age")) { if (args.length >= 2) { try { if (args[1].equalsIgnoreCase("adult")) { horse.setAdult(); } else if (args[1].equalsIgnoreCase("baby")) { horse.setBaby(); } return; } catch (Exception e) { } } UtilPlayer.message(caller, F.main("Mount", F.value("Age", "baby adult"))); } //Color else if (args[0].equalsIgnoreCase("color")) { if (args.length >= 2) { Color color = GetColor(caller, args[1]); if (color != null) horse.setColor(color); } } //Style else if (args[0].equalsIgnoreCase("style")) { if (args.length >= 2) { Style style = GetStyle(caller, args[1]); if (style != null) horse.setStyle(style); } } //Variant else if (args[0].equalsIgnoreCase("variant") || args[0].equalsIgnoreCase("var")) { if (args.length >= 2) { Variant variant = GetVariant(caller, args[1]); if (variant != null) horse.setVariant(variant); } } //Armor else if (args[0].equalsIgnoreCase("armor")) { if (args.length >= 2) { try { if (args[1].equalsIgnoreCase("iron")) { horse.getInventory().setArmor(new ItemStack(Material.IRON_BARDING)); return; } if (args[1].equalsIgnoreCase("gold")) { horse.getInventory().setArmor(new ItemStack(Material.GOLD_BARDING)); return; } if (args[1].equalsIgnoreCase("diamond")) { horse.getInventory().setArmor(new ItemStack(Material.DIAMOND_BARDING)); return; } } catch (Exception e) { } } UtilPlayer.message(caller, F.main("Mount", F.value("Armor", "iron gold diamond"))); } } public Style GetStyle(Player caller, String arg) { ArrayList