@EventHandler public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) { if ((isEnabled()) && (event.getDestination().getType().equals(InventoryType.BREWING))) { if ((event.getItem().getType().equals(Material.SULPHUR)) && (UHCutils.getMainConfig().getBoolean("features.potionNerfs.disableSplash"))) event.setCancelled(true); if ((event.getItem().getType().equals(Material.GLOWSTONE_DUST)) && (UHCutils.getMainConfig().getBoolean("features.potionNerfs.disableGlowstone"))) event.setCancelled(true); } }
@EventHandler public void onPlayerEatEvent(PlayerItemConsumeEvent event) { if ((isEnabled()) && (UHCutils.getMainConfig().getBoolean("features.potionNerfs.disableAbsorb"))) { ItemStack localItemStack = event.getItem(); if (localItemStack.getType().equals(Material.GOLDEN_APPLE)) { final String name = event.getPlayer().getName(); Bukkit.getScheduler() .scheduleSyncDelayedTask( UHCutils.getUHCutils(), new Runnable() { public void run() { Player p = Bukkit.getPlayerExact(name); p.removePotionEffect(PotionEffectType.ABSORPTION); } }); } } }
@EventHandler public void onInventoryClickEvent(InventoryClickEvent event) { if ((isEnabled()) && (event.getInventory().getType().equals(InventoryType.BREWING))) { boolean disableSplash = UHCutils.getMainConfig().getBoolean("features.potionNerfs.disableSplash"); boolean disableGlowstone = UHCutils.getMainConfig().getBoolean("features.potionNerfs.disableGlowstone"); if (event.isShiftClick()) { if ((disableSplash) && (event.getCurrentItem().getType().equals(Material.SULPHUR))) cancel(event); if ((disableGlowstone) && (event.getCurrentItem().getType().equals(Material.GLOWSTONE_DUST))) cancel(event); } else if (event.getSlotType().equals(InventoryType.SlotType.FUEL)) { if ((disableSplash) && (event.getView().getCursor().getType().equals(Material.SULPHUR))) cancel(event); if ((disableGlowstone) && (event.getView().getCursor().getType().equals(Material.GLOWSTONE_DUST))) cancel(event); } } }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (sender instanceof Player) { UHCPlayer player = UHCutils.getUHCPlayerManager().getPlayer((Player) sender); if (label.equalsIgnoreCase("join")) { if (args.length == 1) { sender.sendMessage(UHCutils.prefix() + ChatColor.RED + "Invalid use of command!"); return true; } else if (args.length == 2) { // TODO add support for admins to move a user if (args[0].equalsIgnoreCase("team")) { try { int id = Integer.parseInt(args[0]); Team t = UHCutils.getTeams().getTeamByID(id); if (t == null) { sender.sendMessage( UHCutils.prefix() + ChatColor.RED + "No Team found with ID: " + id); return true; } else { boolean added = t.addPlayer(player); if (added) { sender.sendMessage( UHCutils.prefix() + ChatColor.WHITE + "You successfully joined team: " + id); if (t.getTeamSize() > 1) { sender.sendMessage( UHCutils.prefix() + ChatColor.WHITE + "Your team members are: "); for (UHCPlayer member : t.getPlayerList()) { sender.sendMessage( UHCutils.prefix() + ChatColor.WHITE + "Player: " + member.getName()); } } return true; } else { return false; } } } catch (Exception e) { sender.sendMessage( UHCutils.prefix() + ChatColor.RED + "The first argument hast do be a number!"); return true; } } else if (args[0].equalsIgnoreCase("player")) { // TODO add command to join player to a team return true; } else { sender.sendMessage( UHCutils.prefix() + ChatColor.RED + "unkown parameter: " + args[0] + "!"); return true; } } else { return false; } } else { sender.sendMessage(UHCutils.prefix() + ChatColor.RED + "Unknow command\"" + label + "\"!"); return true; } } else { sender.sendMessage( UHCutils.prefix() + ChatColor.RED + "Only a player can execute this command!"); return true; } }
public TeamCommands() { super(UHCutils.getUHCutils(), "join"); }