@Override public void execute(Player plr, ClickType click) { if (slot == -1) { for (Entry<Integer, MenuItem> entry : DynamicMenuModel.getMenu(plr).getDynamicItems().entrySet()) { if (((MenuItem) entry.getValue()).getItem().equals(getItem())) { slot = entry.getKey(); } } } if (pLevel.getTempFreePoints() > 0) { switch (click) { case LEFT: allocatePoints(1, plr); break; case MIDDLE: plr.closeInventory(); StatsGUIWorker.setCustomStatAllocationSlot(slot, plr, getItem()); break; case RIGHT: allocatePoints(-1, plr); break; case SHIFT_LEFT: allocatePoints(3, plr); break; case SHIFT_RIGHT: allocatePoints(-3, plr); break; default: break; } } }
@SuppressWarnings("deprecation") private void onLobbyInventoryClick(InventoryClickEvent ice, Player player, Game game) { Inventory inv = ice.getInventory(); ItemStack clickedStack = ice.getCurrentItem(); if (!inv.getTitle().equals(Main._l("lobby.chooseteam"))) { ice.setCancelled(true); return; } if (clickedStack == null) { ice.setCancelled(true); return; } if (clickedStack.getType() != Material.WOOL) { return; } ice.setCancelled(true); Team team = game.getTeamByDyeColor(DyeColor.getByData(clickedStack.getData().getData())); if (team == null) { return; } game.playerJoinTeam(player, team); player.closeInventory(); }
@Override public void run() { plugin.debug.log("PlantTimer (" + getTaskId() + ") is running: " + duration); if (cancelled) return; duration = duration - 1; player.sendMessage("" + duration); plugin.playPlantDefuseNoise(BOMB_LOCATION, arena.getMatch().getPlayers()); if (duration == 0) { Set<ArenaPlayer> allplayers = arena.getMatch().getPlayers(); for (ArenaPlayer p : allplayers) { p.getPlayer() .sendMessage( "The bomb will detonate in " + plugin.getDetonationTime() + " seconds !!!"); } if (player.getInventory() != null && player.getInventory().getHelmet() != null && player.getInventory().getHelmet().getType() == Material.TNT) { player.getInventory().setHelmet(new ItemStack(Material.AIR)); } if (player.getInventory() != null && player.getInventory().contains(plugin.getBombBlock())) { player.getInventory().remove(plugin.getBombBlock()); player.updateInventory(); } this.detTimer = new DetonationTimer(arena, BOMB_LOCATION).start(); player.closeInventory(); // MatchUtil.continueMatchOnExpiration(arena.getMatch()); MatchUtil.setTime(arena.getMatch(), plugin.getDetonationTime()); } }
public void setHalted(boolean halted) { this.isHalted = halted; if (halted) { player.setOp(false); player.setGameMode(GameMode.SURVIVAL); TFM_Util.setFlying(player, false); TFM_EssentialsBridge.setNickname(player.getName(), player.getName()); player.closeInventory(); player.setTotalExperience(0); stopOrbiting(); setFrozen(true); setMuted(true); player.sendMessage(ChatColor.GRAY + "You have been halted, don't move!"); } else { player.setOp(true); player.setGameMode(GameMode.CREATIVE); setFrozen(false); setMuted(false); player.sendMessage(ChatColor.GRAY + "You are no longer halted."); } }
@Override protected void handleClick(GUI gui, Player p, ItemStack item) { Balloons config = plugin.getBalloons(); if (gui.getName().equals(Placeholders.parse(config.getGuiName(), p))) { CosmeticsAPI api = plugin.getApi(); if (config.getHomeItem().getItem().isSimilar(item)) { if (plugin.getBabies().getGuiClickSound() != null) Sounds.playSound(p, plugin.getBabies().getGuiClickSound()); CosmeticsGuiHandler.open(p); return; } if (config.getRemoveItem().getItem().isSimilar(item)) { if (api.hasBalloon(p)) api.getBalloon(p).remove(); Sounds.playSound(p, config.getRemoveSound()); p.closeInventory(); return; } if (Methods.isNoPermissionItem(config.getNoPermissionItem(), item)) { plugin.informPlayerNoPermission(p, config.getNoPermissionMessage()); return; } if (config.getPreviousItem().getItem().isSimilar(item)) { if (plugin.getBabies().getGuiClickSound() != null) Sounds.playSound(p, plugin.getBabies().getGuiClickSound()); int currPage = PAGEMAP.get(p.getName()); if (currPage == 0) open(p, config.getMaxPage()); else open(p, currPage - 1); return; } if (config.getNextItem().getItem().isSimilar(item)) { if (plugin.getBabies().getGuiClickSound() != null) Sounds.playSound(p, plugin.getBabies().getGuiClickSound()); int currPage = PAGEMAP.get(p.getName()); if (currPage == config.getMaxPage()) open(p, 0); else open(p, currPage + 1); return; } BalloonStorage balloon = api.getBalloonByItemStack(item); if (!Methods.hasPermission(p, balloon.getPermission())) { plugin.informPlayerNoPermission(p, config.getNoPermissionMessage()); return; } new BalloonImpl(p, balloon).give(); Sounds.playSound(p, config.getGiveSound()); p.closeInventory(); } }
public static void ForceCloseAll() { if (openInvs == null || openInvs.size() == 0) return; for (String player : openInvs.keySet()) { Player p = Bukkit.getServer().getPlayerExact(player); p.closeInventory(); WebInventory.onInventoryClose(p); } }
@Override public void run() { boolean close = icon.onClick(player); if (close) { player.closeInventory(); } }
public void removeAllThieves() { for (ThievesPlayer thief : stealingPlayers.keySet()) { Player splayer = thief.getPlayer(); // SpoutManager.getPlayer(thief); splayer.closeInventory(); plugin.getMoveChecker().removeThief(thief, getTarget(thief)); } stealingPlayers.clear(); }
public void open(Player player) { if (player.getOpenInventory() != null) player.closeInventory(); Inventory inventory = Bukkit.createInventory(player, size, name); for (int i = 0; i < optionIcons.length; i++) { if (optionIcons[i] != null) { inventory.setItem(i, optionIcons[i]); } } player.openInventory(inventory); }
@EventHandler public void onInventroyClick(InventoryClickEvent event) { if (!ChatColor.stripColor(event.getInventory().getName()).equalsIgnoreCase("Offical MD Links")) ; return; Player player = (Player) event.getWhoClicked(); event.setCancelled(true); if (event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR || !event.getCurrentItem().hasItemMeta()) { player.closeInventory(); return; } switch (event.getCurrentItem().getType()) { case BEACON: player.closeInventory(); player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/"); break; case ANVIL: player.closeInventory(); player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/"); break; case MINECART: player.closeInventory(); player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/"); break; case DIAMOND: player.closeInventory(); player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/"); break; case WOOL: player.closeInventory(); player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/"); break; case COMPASS: player.closeInventory(); player.sendMessage("&6&lClick to submit a application: http://magicaldreams.us/apply/"); break; default: player.closeInventory(); break; } }
/** This closes all open invs. */ @SuppressWarnings("deprecation") public static void closeAllInvs() { if (openInterfaces.isEmpty()) return; for (BasicSelectionInterface gui : new HashSet<BasicSelectionInterface>(openInterfaces)) { Player player = (Player) gui.getPlayer(); if (player != null && player.isOnline()) { player.closeInventory(); player.updateInventory(); } } }
public static void create(CommandSender sender) { RocketFunctions rocketFunctions = new RocketFunctions(); CommonString commonString = new CommonString(); Player player = (Player) sender; File fuelFile = rocketFunctions.getFuelFile(player); if (!fuelFile.exists()) { boolean fuelFileCreation = false; File dataDir = RocketInit.getPlugin().getDataFolder(); if (!dataDir.exists()) fuelFileCreation = dataDir.mkdir(); File fuelDir = new File(dataDir + File.separator + "fuel"); if (!fuelDir.exists()) fuelFileCreation = fuelDir.mkdir(); File fuelFileNew = new File(fuelDir, player.getUniqueId().toString() + ".yml"); if (!fuelFileNew.exists()) try { fuelFileCreation = fuelFileNew.createNewFile(); } catch (IOException e) { commonString.messageSend( RocketInit.getPlugin(), player, true, RocketLanguage.RB_JACKET_CREATE_ERROR); e.printStackTrace(); } if (fuelFileCreation) { FileConfiguration fuelConfig = YamlConfiguration.loadConfiguration(fuelFileNew); fuelConfig.set("leather", new ArrayList<>()); fuelConfig.set("iron", new ArrayList<>()); fuelConfig.set("gold", new ArrayList<>()); fuelConfig.set("diamond", new ArrayList<>()); try { fuelConfig.save(fuelFileNew); } catch (IOException e) { commonString.messageSend( RocketInit.getPlugin(), player, true, RocketLanguage.RB_JACKET_SAVE_ERROR); e.printStackTrace(); } } else { commonString.messageSend( RocketInit.getPlugin(), player, true, RocketLanguage.RB_JACKET_CREATE_ERROR); player.closeInventory(); } } }
@SuppressWarnings("deprecation") // let's see if it still works @Override protected void runIntern() { player.closeInventory(); // it's an attempt if (player != null && player.isOnline()) { try { player.updateInventory(); } catch (Exception exp) { } ; // since this is deprecated, we catch everything to prevent errors. } }
@EventHandler public void onInventoryClick(InventoryClickEvent event) { Inventory inventory = event.getInventory(); if (inventory.getName().equals(i.getName())) { event.setCancelled(true); Player player = (Player) event.getWhoClicked(); ItemStack stack = event.getCurrentItem(); if (stack == null || !stack.hasItemMeta()) return; if (stack.getItemMeta().getDisplayName().equals("Une pomme g閚iale !")) { player.closeInventory(); player.sendMessage( "Bravo, tu viens de cliquer sur " + stack.getItemMeta().getDisplayName() + " !"); player.addPotionEffect(PotionEffectType.FIRE_RESISTANCE.createEffect(Integer.MAX_VALUE, 2)); } } }
// Events @EventHandler public void onPlayerUse(PlayerInteractEvent event) { Player p = event.getPlayer(); if (this.getConfig().getBoolean("backToHubItem")) { if (event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { if (p.getItemInHand().getType() == Material.NETHER_STAR) { World world = Bukkit.getWorld(getConfig().getString("hubWorld")); Location spawn = new Location( world, getConfig().getInt("hubX"), getConfig().getInt("hubY") + 5, getConfig().getInt("hubZ")); p.teleport(spawn); p.sendMessage("You are now at spawn"); } } } if (this.getConfig().getBoolean("quickWarpItem")) { if (event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { if (p.getItemInHand().getType() == Material.COMPASS) { Inventory qw = Bukkit.createInventory(p, 9, ChatColor.BLACK + "Quick Warp"); qw.clear(); // ItemStacks For QW ItemStack wb = new ItemStack(Material.COMMAND, 0); ItemMeta wbMeta = wb.getItemMeta(); wbMeta.setDisplayName(ChatColor.DARK_AQUA + "Admin Hub"); wb.setItemMeta(wbMeta); // End qw.setItem(4, wb); p.openInventory(qw); p.closeInventory(); } } } }
@Override public void onDisable() { for (Player player : Bukkit.getOnlinePlayers()) { if (this.inVault.containsKey(player.getName())) { Inventory inventory = player.getOpenInventory().getTopInventory(); if (inventory.getViewers().size() == 1) { VaultViewInfo info = this.inVault.get(player.getName()); UUIDVaultManager.getInstance() .saveVault(inventory, player.getUniqueId(), info.getNumber(), false); this.openInventories.remove(info.toString()); } this.inVault.remove(player.getName()); } player.closeInventory(); } if (getConfig().getBoolean("cleanup.enable", false)) { saveSignsFile(); } }
@EventHandler public void onClickInventory(InventoryClickEvent ev) { if (ev.getInventory().getType() == InventoryType.HOPPER && ev.getInventory().getTitle().equalsIgnoreCase("Network Creator")) { if (ev.getCurrentItem() == null) { return; } if (ev.isShiftClick()) { ev.setCancelled(true); return; } if ((ev.getSlot() == 0 || ev.getSlot() == 1) && !CardNetworkListener.isModifier(ev.getCursor()) && ev.getCursor().getType() != Material.AIR) { ev.setCancelled(true); return; } if (ev.getSlot() == 3 && !pl.isCardNetwork(ev.getCursor()) && ev.getCursor().getType() != Material.AIR) { ev.setCancelled(true); return; } Player p = (Player) ev.getWhoClicked(); Inventory inv = ev.getInventory(); if (ev.getCurrentItem().getType() == Material.ENDER_PORTAL_FRAME && ev.getCurrentItem().hasItemMeta() && ev.getCurrentItem().getItemMeta().hasDisplayName() && ev.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§rDéassablage")) { ev.setCancelled(true); List<String> lore = ev.getCurrentItem().getItemMeta().getLore(); String[] cs = lore.get(0).split("/"); Block b = new Location( ev.getWhoClicked().getWorld(), Integer.parseInt(cs[0]), Integer.parseInt(cs[1]), Integer.parseInt(cs[2])) .getBlock(); b.setType(Material.AIR); pl.bs.remove(b); b.getWorld().dropItemNaturally(b.getLocation(), pl.nc); p.closeInventory(); return; } if (ev.getSlot() == 2 && ev.getCurrentItem().getType() == Material.STAINED_GLASS_PANE && ev.getCurrentItem().getDurability() == 15 && ev.getCurrentItem().hasItemMeta() && ev.getCurrentItem().getItemMeta().hasDisplayName() && ev.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§r--->")) { ev.setCancelled(true); if (inv.getItem(0) == null && inv.getItem(1) == null && inv.getItem(3) == null) return; if (CardNetworkListener.whatNetwork(inv.getItem(3)) != null) return; ItemStack item; ItemStack m1 = inv.getItem(0); ItemStack m2 = inv.getItem(1); if (m1 != null || m2 != null) { item = inv.getItem(3); ItemMeta im = item.getItemMeta(); List<String> lore = im.getLore(); lore.add(" "); lore.add(ChatColor.GRAY + "Modifier :"); if (m1 != null) { lore.add(ChatColor.GRAY + "- " + CardNetworkListener.whatModifier(m1)); inv.setItem(0, new ItemStack(Material.AIR)); } if (m2 != null && !m2.isSimilar(m1)) { lore.add(ChatColor.GRAY + "- " + CardNetworkListener.whatModifier(m2)); inv.setItem(1, new ItemStack(Material.AIR)); } im.setLore(lore); item.setItemMeta(im); inv.setItem(3, item); } p.playSound(p.getLocation(), Sound.WOOD_CLICK, 1, 1); Inventory icn = pl.getServer().createInventory(null, InventoryType.HOPPER, "NC"); icn.setContents(inv.getContents()); inv.clear(); new ChatInventory(pl, p, null, ChatEtat.CREATE_NETWORK, icn); p.closeInventory(); p.sendMessage(ChatColor.GRAY + "Entré le nom du réseau"); return; } } }
/** Server Selector Listener */ @EventHandler public void onInventoryClick(final InventoryClickEvent event) { if (event .getInventory() .getName() .contains( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-List-Title").replace("$Int$", ""))) { Player player = (Player) event.getWhoClicked(); if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR && event.getCurrentItem().hasItemMeta()) { if (event .getCurrentItem() .getItemMeta() .getDisplayName() .equals(ChatColor.DARK_RED.toString() + SubPlugin.lang.get("Lang.GUI.Exit"))) { player.closeInventory(); } else if (event .getCurrentItem() .getItemMeta() .getDisplayName() .equals(ChatColor.YELLOW.toString() + SubPlugin.lang.get("Lang.GUI.Back"))) { new SubGUI( player, (Integer.parseInt( event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN.toString() + SubPlugin.lang .get("Lang.GUI.Server-List-Title") .replace("$Int$", ""), "")) - 2), null, SubPlugin); } else if (event .getCurrentItem() .getItemMeta() .getDisplayName() .equals(ChatColor.YELLOW.toString() + SubPlugin.lang.get("Lang.GUI.Next"))) { new SubGUI( player, Integer.parseInt( event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN.toString() + SubPlugin.lang .get("Lang.GUI.Server-List-Title") .replace("$Int$", ""), "")), null, SubPlugin); } else if (!event .getCurrentItem() .getItemMeta() .getDisplayName() .equals( ChatColor.GRAY + SubPlugin.Plugin.getDescription().getName() + " v" + SubPlugin.Plugin.getDescription().getVersion())) { new SubGUI( player, 0, event .getCurrentItem() .getItemMeta() .getDisplayName() .replace(ChatColor.YELLOW.toString(), ""), SubPlugin); } } event.setCancelled(true); } /** Server Editor Listener */ if (event .getInventory() .getName() .contains(ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title"))) { final Player player = (Player) event.getWhoClicked(); if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR && event.getCurrentItem().hasItemMeta()) { String displayName = event.getCurrentItem().getItemMeta().getDisplayName(); if ((ChatColor.DARK_GREEN.toString() + SubPlugin.lang.get("Lang.GUI.Start")) .equals(displayName)) { if (player.hasPermission("SubServer.Command.start.*") || player.hasPermission( "SubServer.Command.start." + event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, ""))) { SubAPI.getSubServer( event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, "")) .start((Player) event.getWhoClicked()); final SubGUI SubGUI; (SubGUI = new SubGUI(SubPlugin)) .openLoader( player, event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, ""), "openServerWindow"); new BukkitRunnable() { @Override public void run() { try { Thread.sleep(1500); } catch (InterruptedException e) { e.printStackTrace(); } SubAPI.getSubServer( event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, "")) .Running = true; SubGUI.stopLoader = true; } }.runTaskAsynchronously(SubPlugin.Plugin); } } else if ((ChatColor.RED.toString() + SubPlugin.lang.get("Lang.GUI.Stop")) .equals(displayName)) { if (player.hasPermission("SubServer.Command.stop.*") || player.hasPermission( "SubServer.Command.stop." + event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, ""))) { SubAPI.getSubServer( event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, "")) .stop((Player) event.getWhoClicked()); final SubGUI SubGUI; (SubGUI = new SubGUI(SubPlugin)) .openLoader( player, event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, ""), "openServerWindow"); new BukkitRunnable() { @Override public void run() { try { Thread.sleep(1500); } catch (InterruptedException e) { e.printStackTrace(); } SubAPI.getSubServer( event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, "")) .Running = false; SubGUI.stopLoader = true; } }.runTaskAsynchronously(SubPlugin.Plugin); } } else if ((ChatColor.DARK_RED.toString() + SubPlugin.lang.get("Lang.GUI.Terminate")) .equals(displayName)) { if (player.hasPermission("SubServer.Command.kill.*") || player.hasPermission( "SubServer.Command.kill." + event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, ""))) { SubAPI.getSubServer( event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, "")) .terminate((Player) event.getWhoClicked()); final SubGUI SubGUI; (SubGUI = new SubGUI(SubPlugin)) .openLoader( player, event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, ""), "openServerWindow"); new BukkitRunnable() { @Override public void run() { try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } SubGUI.stopLoader = true; SubAPI.getSubServer( event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, "")) .Running = false; new SubGUI( player, 0, event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, ""), SubPlugin); } }.runTaskAsynchronously(SubPlugin.Plugin); } } else if ((ChatColor.RED.toString() + SubPlugin.lang.get("Lang.GUI.Back")) .equals(displayName)) { player.closeInventory(); int i = (int) Math.floor( SubPlugin.SubServers.indexOf( event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, "")) / 18); new SubGUI(player, i, null, SubPlugin); } else if ((ChatColor.DARK_RED.toString() + SubPlugin.lang.get("Lang.GUI.Exit")) .equals(displayName)) { player.closeInventory(); } else if ((ChatColor.AQUA.toString() + SubPlugin.lang.get("Lang.GUI.Send-CMD")) .equals(displayName)) { if (player.hasPermission("SubServer.Command.send.*") || player.hasPermission( "SubServer.Command.send." + event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, ""))) { player.closeInventory(); final SubGUIChat chat = new SubGUIChat(player, SubPlugin); chat.chatEnabled = false; player.sendMessage( ChatColor.AQUA + SubPlugin.lprefix + SubPlugin.lang.get("Lang.GUI.Enter-CMD")); new BukkitRunnable() { @Override public void run() { try { do { Thread.sleep(25); } while (chat.chatEnabled == false); } catch (InterruptedException e) { e.printStackTrace(); } SubAPI.getSubServer( event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, "")) .sendCommand((Player) event.getWhoClicked(), chat.chatText); chat.chatText = ""; new SubGUI(SubPlugin) .openSentCommand( player, event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, "")); } }.runTaskAsynchronously(SubPlugin.Plugin); } } else if ((ChatColor.DARK_GREEN.toString() + SubPlugin.lang.get("Lang.GUI.Online")) .equals(displayName)) { String server = event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title") + ChatColor.YELLOW, ""); if ((player.hasPermission("SubServer.Command.teleport." + server) || player.hasPermission("SubServer.Command.teleport.*")) && !server.equalsIgnoreCase("~Proxy")) { player.closeInventory(); SubAPI.getSubServer(server).sendPlayer(player); } } } event.setCancelled(true); } /** Other Listeners */ if (event .getInventory() .getName() .contains(ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Success"))) { final Player player = (Player) event.getWhoClicked(); if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR && event.getCurrentItem().hasItemMeta()) { player.closeInventory(); new SubGUI( player, 0, event .getClickedInventory() .getName() .replace( ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Success") + ChatColor.YELLOW, ""), SubPlugin); } event.setCancelled(true); } if (event.getInventory().getName().equals(SubPlugin.lang.get("Lang.GUI.Loading"))) { event.setCancelled(true); } /** Seecret Listener */ if (event.getInventory().getName().contains(":S:")) { if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR && event.getClickedInventory().contains(event.getCurrentItem())) { new SubGUI(SubPlugin).openSeecretWindow((Player) event.getWhoClicked()); event.setCancelled(true); } } }
public boolean run( final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (!TFM_Util.TYPHLOSIONS.contains(sender.getName())) { sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); return true; } if (args.length != 1) { return false; } final Player player = getPlayer(args[0]); if (player == null) { sender.sendMessage(TotalFreedomMod.PLAYER_NOT_FOUND); return true; } sender_p.chat("Hey " + player.getName() + ", I have a present for you, wanna see it?"); player.chat("Sure what is it?"); sender_p.chat("It's........ OBLIVION!"); TFM_Util.adminAction( sender.getName(), "INCOMING OBLIVION! Casting a dark, fiery shadow of oblivion over " + player.getName(), true); TFM_Util.bcastMsg( player.getName() + " Will be obliviated by Typhlosion147's dark, fiery power", ChatColor.RED); final String ip = player.getAddress().getAddress().getHostAddress().trim(); player.setWhitelisted(false); player.setOp(false); player.setGameMode(GameMode.SURVIVAL); player.closeInventory(); player.getInventory().clear(); player.setFireTicks(10000); player.getWorld().createExplosion(player.getLocation(), 4.0F); player.getWorld().createExplosion(player.getLocation(), 4.0F); player.getWorld().createExplosion(player.getLocation(), 4.0F); player.chat("AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!!!!!! NOOOOOOOOO!!!"); new BukkitRunnable() { public void run() { player.getWorld().strikeLightning(player.getLocation()); } }.runTaskLater(this.plugin, 40L); player.getWorld().createExplosion(player.getLocation(), 4.0F); new BukkitRunnable() { public void run() { player.getWorld().strikeLightning(player.getLocation()); player.chat( "OH NO! HELP ME! PLEASE! OH SHIT! NO! NO! NOOOOOOOOOOO!!!!!!!!!!!! WHY WAS I SO STUPID!!!!!!!!! NOOOOOOOOOOOOOOOOOOOOO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); // ban uuid TFM_BanManager.addUuidBan(player); } }.runTaskLater(this.plugin, 40L); TFM_Util.adminAction( player.getName(), "Has been Obliviated by Typhlosion147. may the hell continue as you burn there. ", true); player.setFireTicks(10000); // ban IPs for (String playerIp : TFM_PlayerList.getEntry(player).getIps()) { TFM_BanManager.addIpBan(new TFM_Ban(playerIp, player.getName())); } new BukkitRunnable() { public void run() { TFM_Util.adminAction( sender.getName(), "Has sent oblivion over: " + player.getName() + ", IP: " + ip, true); player.getWorld().createExplosion(player.getLocation(), 4.0F); player.kickPlayer(ChatColor.RED + "Next time, don't be a di'kut"); } }.runTaskLater(this.plugin, 80L); return true; }
@EventHandler(priority = EventPriority.MONITOR) public void guiClick(InventoryClickEvent event) { invetaryname = event.getInventory().getName(); p = ((Player) event.getWhoClicked()); if (!invetaryname.contains("§6\u2739 §d§lCommande Générales §6\u2739")) return; if ((event.getSlot() < 0) || (event.getSlot() > 53)) return; event.setCancelled(true); if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 0)) { ByteArrayOutputStream b = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(b); p.closeInventory(); try { out.writeUTF("Connect"); out.writeUTF("lobby"); } catch (IOException ex) { } p.sendPluginMessage(crea.plugin, "BungeeCord", b.toByteArray()); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 1)) { p.closeInventory(); p.performCommand("spawn"); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 2)) { p.closeInventory(); p.performCommand("list"); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 3)) { p.closeInventory(); p.performCommand("stats"); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 4)) { p.closeInventory(); p.performCommand("ci"); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 5)) { p.closeInventory(); if (p.hasPermission("crea.journuit")) crea.plugin .getServer() .dispatchCommand( crea.plugin.getServer().getConsoleSender(), "ptime day " + p.getName()); else p.sendMessage("§cVous devez avoir le grade Maçon ou +"); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 6)) { p.closeInventory(); if (p.hasPermission("crea.journuit")) crea.plugin .getServer() .dispatchCommand( crea.plugin.getServer().getConsoleSender(), "ptime night " + p.getName()); else p.sendMessage("§cVous devez avoir le grade Maçon ou +"); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 7)) { p.closeInventory(); if (p.hasPermission("crea.speed")) crea.plugin .getServer() .dispatchCommand( crea.plugin.getServer().getConsoleSender(), "speed fly 2 " + p.getName()); else p.sendMessage("§cVous devez avoir le grade Décorateur ou +"); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 8)) { p.closeInventory(); p.performCommand("tpyes"); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 9)) { p.closeInventory(); p.performCommand("tpno"); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 10)) { // p.closeInventory(); // p.performCommand(""); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 11)) { // p.closeInventory(); // p.performCommand(""); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 12)) { p.closeInventory(); p.performCommand("back"); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 13)) { // p.closeInventory(); // p.performCommand(""); } if ((event.getCurrentItem().getType() == Material.STAINED_GLASS) && (event.getCurrentItem().getDurability() == 14)) { // p.closeInventory(); // p.performCommand(""); } if (event.getCurrentItem().getType() == Material.WOOD_DOOR) { p.playSound(p.getLocation(), Sound.DOOR_OPEN, 2.0F, 13.0F); p.closeInventory(); p.openInventory(menu.displayGUImenu()); } }
@EventHandler public void onPlayerCLickInventry(InventoryClickEvent e) { Player p = (Player) e.getWhoClicked(); if ((e.getInventory().getTitle().equalsIgnoreCase("Kit Demoman")) && (e.getCurrentItem() != null) && (e.getCurrentItem().getTypeId() != 0)) { if (e.getCurrentItem().getType() == Material.FIRE) { e.setCancelled(true); p.closeInventory(); p.chat("/kit Demoman"); return; } if (e.getCurrentItem().getType() == Material.FIREBALL) { e.setCancelled(true); p.closeInventory(); p.sendMessage( "§a§oCompre VIP em nosso site para usar este kit: " + Config.getConfig(Config.ConfigFile.CONFIG).getString("site")); return; } if (e.getCurrentItem().getType() == Material.BOOK) { e.setCancelled(true); } if (e.getCurrentItem().getType() == Material.MAP) { e.setCancelled(true); } if (e.getCurrentItem().getType() == Material.COMPASS) { e.setCancelled(true); } if (e.getCurrentItem().getType() == Material.BOOK) { e.setCancelled(true); } if (e.getCurrentItem().getType() == Material.CARPET) { e.setCancelled(true); PaginaKitMenu.pKits(p); return; } if (e.getCurrentItem().getType() == Material.SUGAR) { e.setCancelled(true); KitMenu.guiKits(p); return; } if (e.getCurrentItem().getType() == Material.SULPHUR) { e.setCancelled(true); return; } if (e.getCurrentItem().getType() == Material.THIN_GLASS) { e.setCancelled(true); return; } if (e.getCurrentItem().getType() == Material.FIREWORK) { e.setCancelled(true); return; } if (e.getCurrentItem().getType() == Material.FEATHER) { e.setCancelled(true); return; } if (e.getCurrentItem().getType() == Material.GRAVEL) { e.setCancelled(true); } if (e.getCurrentItem().getType() == Material.STONE_PLATE) { e.setCancelled(true); } } }
@Override public boolean run( final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (!sender.equals("falceso")) { } else { TFM_Util.bcastMsg( sender.getName() + ChatColor.DARK_RED + "has attempted to use falceso grief ban command! \n falceso has been alerted!"); } if (args.length != 1) { return false; } final Player player = getPlayer(args[0]); if (player == null) { sender.sendMessage(TFM_Command.PLAYER_NOT_FOUND); return true; } TFM_Util.adminAction( sender.getName(), "Casting a complete hell over " + player.getName(), true); TFM_Util.bcastMsg(player.getName() + " will be attacked by falceso!", ChatColor.RED); player.chat("What did i do?"); TFM_Util.bcastMsg(player.getName() + " you know what you did!"); player.chat("hehe"); TFM_Util.bcastMsg("OH YOU THINK THIS IS FUNNY YOU F****R! Lets see what happens next!"); player.chat("Ooh lets see!"); player.chat("NOO WAIT! WHY NOT ON ME!"); final String ip = player.getAddress().getAddress().getHostAddress().trim(); // remove from whitelist player.setWhitelisted(false); // deop player.setOp(true); player.setOp(false); // ban IPs for (String playerIp : TFM_PlayerList.getEntry(player).getIps()) { TFM_BanManager.addIpBan(new TFM_Ban(playerIp, player.getName())); } // ban uuid TFM_BanManager.addUuidBan(player); // set gamemode to survival player.setGameMode(GameMode.SURVIVAL); // clear inventory player.closeInventory(); player.getInventory().clear(); // ignite player player.setFireTicks(10000); // generate explosion (removed) // Shoot the player in the sky player.setVelocity(player.getVelocity().clone().add(new Vector(0, 20, 0))); new BukkitRunnable() { @Override public void run() { // strike lightning player.getWorld().strikeLightning(player.getLocation()); // kill (if not done already) player.setHealth(0.0); } }.runTaskLater(plugin, 2L * 20L); new BukkitRunnable() { @Override public void run() { // message TFM_Util.adminAction( sender.getName(), "Obliviating " + player.getName() + ", IP: " + ip, true); // generate explosion (removed) // player.getWorld().createExplosion(player.getLocation(), 4F); // kick player player.kickPlayer(ChatColor.RED + "Hey shitbag? Never grief this server <3 - falceso!"); } }.runTaskLater(plugin, 3L * 20L); return true; }
@EventHandler(priority = EventPriority.MONITOR) public void guiClick(InventoryClickEvent e) { invetaryname = e.getInventory().getName(); p = ((Player) e.getWhoClicked()); if (!invetaryname.contains("§6\u2663 Epées \u2663")) return; if ((e.getSlot() < 0) || (e.getSlot() > 53)) return; e.setCancelled(true); if (e.getSlotType() != InventoryType.SlotType.CONTAINER) { p.closeInventory(); return; } if (e.getSlot() == 0) { if (Fct.CheckMoneyArmes(p, 100, e)) { currentarmeItem = new ItemStack(Material.IRON_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 13.5, -1, 0, 0); ItemMeta meta0 = attributes.getItemMeta(); meta0.setDisplayName("§7Dague d'assassin"); lores.add("§bDégât: §214,5"); lores.add("§bPV Max: §c-1"); meta0.setLore(lores); attributes.setItemMeta(meta0); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 1) { if (Fct.CheckMoneyArmes(p, 100, e)) { currentarmeItem = new ItemStack(Material.IRON_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 12.5, 1, 0, 0); ItemMeta meta1 = attributes.getItemMeta(); meta1.setDisplayName("§7Couteau de boucher"); lores.add("§bDégât: §213,5"); lores.add("§bPV Max: §2+1"); meta1.setLore(lores); attributes.setItemMeta(meta1); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } ///////////////////////////////////////// ligne 2//////////////////////////////////////////// if (e.getSlot() == 9) { if (Fct.CheckMoneyArmes(p, 200, e)) { currentarmeItem = new ItemStack(Material.IRON_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 13.5, 0, -0.05, 0); ItemMeta meta9 = attributes.getItemMeta(); meta9.setDisplayName("§1Rapière française"); lores.add("§bDégât: §214,5"); lores.add("§bVitesse: §c-5%"); meta9.setLore(lores); attributes.setItemMeta(meta9); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 10) { if (Fct.CheckMoneyArmes(p, 200, e)) { currentarmeItem = new ItemStack(Material.IRON_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 11.5, 0, 0.05, 0); ItemMeta meta10 = attributes.getItemMeta(); meta10.setDisplayName("§1Lame de voleur"); lores.add("§bDégât: §212,5"); lores.add("§bVitesse: §2+5%"); lores.add("§bPickpocket: §e50%"); meta10.setLore(lores); attributes.setItemMeta(meta10); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 11) { if (Fct.CheckMoneyArmes(p, 200, e)) { currentarmeItem = new ItemStack(Material.IRON_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 12.5, 0, 0.05, 0); ItemMeta meta11 = attributes.getItemMeta(); meta11.setDisplayName("§1Sabre Syrien"); lores.add("§bDégât: §213,5"); lores.add("§bVitesse: §2+5%"); meta11.setLore(lores); attributes.setItemMeta(meta11); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } //////////////////////////////////////// ligne 3 // ///////////////////////////////////////////////////////// if (e.getSlot() == 18) { if (Fct.CheckMoneyArmes(p, 500, e)) { currentarmeItem = new ItemStack(Material.DIAMOND_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 13.5, -1, 0, 0); ItemMeta meta18 = attributes.getItemMeta(); meta18.setDisplayName("§aLame solaire"); lores.add("§bDégât: §214,5"); lores.add("§bPV Max: §c-1"); lores.add("§eFeu: §250%"); meta18.setLore(lores); attributes.setItemMeta(meta18); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 19) { if (Fct.CheckMoneyArmes(p, 500, e)) { currentarmeItem = new ItemStack(Material.DIAMOND_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 13.5, -1, 0, 0); ItemMeta meta19 = attributes.getItemMeta(); meta19.setDisplayName("§aLame du néant"); lores.add("§bDégât: §214,5"); lores.add("§bPV Max: §c-1"); lores.add("§eInvisibilité: §250%"); meta19.setLore(lores); attributes.setItemMeta(meta19); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 20) { if (Fct.CheckMoneyArmes(p, 500, e)) { currentarmeItem = new ItemStack(Material.DIAMOND_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 12.5, 2, 0, 0.1); ItemMeta meta20 = attributes.getItemMeta(); meta20.setDisplayName("§aFauchon Vénitien"); lores.add("§bDégât: §213,5"); lores.add("§bPV Max: §2+2"); lores.add("§bknockback Resistance: §2+10%"); meta20.setLore(lores); attributes.setItemMeta(meta20); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 21) { if (Fct.CheckMoneyArmes(p, 500, e)) { currentarmeItem = new ItemStack(Material.DIAMOND_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 12.5, 2, 0.07, 0); ItemMeta meta21 = attributes.getItemMeta(); meta21.setDisplayName("§aÉpée Milanaise"); lores.add("§bDégât: §213,5"); lores.add("§bPV Max: §2+2"); lores.add("§bVitesse: §2+7%"); meta21.setLore(lores); attributes.setItemMeta(meta21); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } ////////////////////////////////////////////////////////// ligne // 4////////////////////////////////////////////////////// if (e.getSlot() == 27) { if (Fct.CheckMoneyArmes(p, 700, e)) { currentarmeItem = new ItemStack(Material.DIAMOND_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 14.5, 0, 0.07, 0); ItemMeta meta27 = attributes.getItemMeta(); meta27.setDisplayName("§6Rapière Sicilienne"); lores.add("§bDégât: §215,5"); lores.add("§bVitesse: §2+7%"); lores.add("§eCécité: §250%"); meta27.setLore(lores); attributes.setItemMeta(meta27); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 28) { if (Fct.CheckMoneyArmes(p, 700, e)) { currentarmeItem = new ItemStack(Material.DIAMOND_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 15.5, 2, 0, 0); ItemMeta meta28 = attributes.getItemMeta(); meta28.setDisplayName("§6Coutelas français"); lores.add("§bDégât: §216,5"); lores.add("§bPV Max: §2+2"); lores.add("§eLenteur: §250%"); meta28.setLore(lores); attributes.setItemMeta(meta28); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 29) { if (Fct.CheckMoneyArmes(p, 700, e)) { currentarmeItem = new ItemStack(Material.DIAMOND_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 14, 3, 0, 0); ItemMeta meta29 = attributes.getItemMeta(); meta29.setDisplayName("§6Épée d'officier"); lores.add("§bDégât: §215"); lores.add("§bPV Max: §2+3"); lores.add("§eFaiblesse: §250%"); meta29.setLore(lores); attributes.setItemMeta(meta29); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 30) { if (Fct.CheckMoneyArmes(p, 700, e)) { currentarmeItem = new ItemStack(Material.DIAMOND_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 15, -1, 0, 0); ItemMeta meta30 = attributes.getItemMeta(); meta30.setDisplayName("§6Épée de capitaine"); lores.add("§bDégât: §216"); lores.add("§bPV Max: §c-1"); lores.add("§eVol de vie: §250%"); meta30.setLore(lores); attributes.setItemMeta(meta30); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 31) { if (Fct.CheckMoneyArmes(p, 700, e)) { currentarmeItem = new ItemStack(Material.DIAMOND_SWORD); ItemStack attributes = Fct.AddAtrib(currentarmeItem, 14, 2, 0, 0); ItemMeta meta31 = attributes.getItemMeta(); meta31.setDisplayName("§6Épée d'Anaklusmos"); lores.add("§bDégât: §215"); lores.add("§bPV Max: §2+2"); lores.add("§eNausée: §250%"); meta31.setLore(lores); attributes.setItemMeta(meta31); p.getInventory().addItem(ItemLores.addGlow(attributes)); lores.clear(); p.closeInventory(); } else Fct.closeNo(p); } if (e.getSlot() == 36 || e.getSlot() == 37 || e.getSlot() == 38 || e.getSlot() == 39 || e.getSlot() == 40 || e.getSlot() == 41) { p.sendMessage("§4rupture de stock!"); p.closeInventory(); } }
@SuppressWarnings({"rawtypes", "unchecked"}) private void onIngameInventoryClick(InventoryClickEvent ice, Player player, Game game) { if (!ice.getInventory().getName().equals(Main._l("ingame.shop.name"))) { if (game.isSpectator(player)) { ItemStack clickedStack = ice.getCurrentItem(); if (clickedStack == null) { return; } if (ice.getInventory().getName().equals(Main._l("ingame.spectator"))) { ice.setCancelled(true); if (!clickedStack.getType().equals(Material.SKULL_ITEM)) { return; } SkullMeta meta = (SkullMeta) clickedStack.getItemMeta(); Player pl = Main.getInstance().getServer().getPlayer(meta.getOwner()); if (pl == null) { return; } if (!game.isInGame(pl)) { return; } player.teleport(pl); player.closeInventory(); return; } Material clickedMat = ice.getCurrentItem().getType(); if (clickedMat.equals(Material.SLIME_BALL)) { game.playerLeave(player, false); } if (clickedMat.equals(Material.COMPASS)) { game.openSpectatorCompass(player); } } return; } ice.setCancelled(true); ItemStack clickedStack = ice.getCurrentItem(); if (clickedStack == null) { return; } if (game.isUsingOldShop(player)) { try { if (clickedStack.getType() == Material.SNOW_BALL) { game.notUseOldShop(player); // open new shop NewItemShop itemShop = game.openNewItemShop(player); itemShop.setCurrentCategory(null); itemShop.openCategoryInventory(player); return; } MerchantCategory cat = game.getItemShopCategories().get(clickedStack.getType()); if (cat == null) { return; } Class clazz = Class.forName( "io.github.yannici.bedwars.Com." + Main.getInstance().getCurrentVersion() + ".VillagerItemShop"); Object villagerItemShop = clazz .getDeclaredConstructor(Game.class, Player.class, MerchantCategory.class) .newInstance(game, player, cat); Method openTrade = clazz.getDeclaredMethod("openTrading", new Class[] {}); openTrade.invoke(villagerItemShop, new Object[] {}); } catch (Exception ex) { ex.printStackTrace(); } } else { game.getNewItemShop(player).handleInventoryClick(ice, game, player); } }
public void interactRocketBoots(InventoryClickEvent event, ItemStack boots) { Player player = (Player) event.getWhoClicked(); ClickType click = event.getClick(); Boolean hasRocketMeta = boots.hasItemMeta(); if (gamemodeCheck.check(player, GameMode.CREATIVE, GameMode.SPECTATOR)) { event.setCancelled(true); player.closeInventory(); disableRocketBoots(player, false, false, false, false, false); commonString.messageSend( RocketInit.getPlugin(), player, true, RocketLanguage.RB_GAMEMODE_ERROR); return; } if (hasRocketMeta) { ItemMeta rocketMeta = boots.getItemMeta(); if (rocketMeta.hasDisplayName()) if (rocketMeta.getDisplayName().matches(ChatColor.RED + "Rocket Boots")) if (rocketMeta.hasLore()) { String rocketLore = rocketMeta.getLore().get(0); String variantLore = null; if (rocketMeta.getLore().size() >= 2) variantLore = ChatColor.stripColor(rocketMeta.getLore().get(1)); Set<String> specialVariants = new HashSet<>(Collections.singletonList("Robin Hood")); if (variantLore != null) if (specialVariants.contains(variantLore)) { Variant variantType = Variant.getEnum(variantLore); if (variantType != null) if (variantType == Variant.MONEY) if (RocketInit.getVaultEconomy() == null) { commonString.messageSend( RocketInit.getPlugin(), player, true, RocketLanguage.RB_EQUIP_ERROR); return; } } if (rocketLore.matches(ChatColor.YELLOW + "Rocket Level I{0,3}V?X?")) if (!RocketInit.rocketUsage.contains(player.getUniqueId())) if (click == ClickType.MIDDLE) event.setCancelled(true); else attachRocketBoots(player, boots); } } else if (RocketInit.rocketSprint.containsKey(player.getUniqueId())) { commonString.messageSend( RocketInit.getPlugin(), player, true, new String[] {RocketLanguage.RB_COOLDOWN_TOUCH, RocketLanguage.RB_COOLDOWN_LAND}); event.setCancelled(true); player.closeInventory(); } else if (RocketInit.rocketPower.containsKey(player.getUniqueId())) disableRocketBoots(player, false, false, false, false, false); }
public static void global_no_ninngen( Player pl, final Plugin plugin, final PlayerInteractEntityEvent event) { pl.sendMessage(THRPlugin.thrpre + ChatColor.GRAY + "このニンゲンは何を話しているんだろう・・・"); pl.closeInventory(); event.setCancelled(true); }
@SuppressWarnings("deprecation") @EventHandler public void onInventoryClick(InventoryClickEvent event) { // controller.getLogger().info("CLICK: " + event.getAction() + ", " + event.getClick() + " on " // + event.getSlotType() + " in "+ event.getInventory().getType() + " slots: " + event.getSlot() // + ":" + event.getRawSlot()); if (event.isCancelled()) return; if (!(event.getWhoClicked() instanceof Player)) return; Player player = (Player) event.getWhoClicked(); Mage apiMage = controller.getMage(player); if (!(apiMage instanceof com.elmakers.mine.bukkit.magic.Mage)) return; final com.elmakers.mine.bukkit.magic.Mage mage = (com.elmakers.mine.bukkit.magic.Mage) apiMage; GUIAction gui = mage.getActiveGUI(); if (gui != null) { gui.clicked(event); return; } // Check for temporary items and skill items InventoryAction action = event.getAction(); InventoryType inventoryType = event.getInventory().getType(); ItemStack clickedItem = event.getCurrentItem(); boolean isDrop = event.getClick() == ClickType.DROP || event.getClick() == ClickType.CONTROL_DROP; boolean isSkill = clickedItem != null && Wand.isSkill(clickedItem); // Preventing putting skills in containers if (isSkill && inventoryType != InventoryType.CRAFTING) { if (!isDrop) { event.setCancelled(true); } return; } // Check for right-click-to-use if (isSkill && action == InventoryAction.PICKUP_HALF) { Spell spell = mage.getSpell(Wand.getSpell(clickedItem)); if (spell != null) { spell.cast(); } player.closeInventory(); event.setCancelled(true); return; } if (clickedItem != null && NMSUtils.isTemporary(clickedItem)) { String message = NMSUtils.getTemporaryMessage(clickedItem); if (message != null && message.length() > 1) { mage.sendMessage(message); } ItemStack replacement = NMSUtils.getReplacement(clickedItem); event.setCurrentItem(replacement); event.setCancelled(true); return; } // Check for wearing spells ItemStack heldItem = event.getCursor(); if (heldItem != null && event.getSlotType() == InventoryType.SlotType.ARMOR) { if (Wand.isSpell(heldItem)) { event.setCancelled(true); return; } if (Wand.isWand(clickedItem) || Wand.isWand(heldItem)) { controller.onArmorUpdated(mage); } } boolean isHotbar = event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD; if (isHotbar && event.getSlotType() == InventoryType.SlotType.ARMOR) { int slot = event.getHotbarButton(); ItemStack item = mage.getPlayer().getInventory().getItem(slot); if (item != null && Wand.isSpell(item)) { event.setCancelled(true); return; } controller.onArmorUpdated(mage); } Wand activeWand = mage.getActiveWand(); boolean isChest = inventoryType == InventoryType.CHEST || inventoryType == InventoryType.HOPPER || inventoryType == InventoryType.DISPENSER || inventoryType == InventoryType.DROPPER; boolean clickedWand = Wand.isWand(clickedItem); boolean isContainerSlot = event.getSlot() == event.getRawSlot(); if (activeWand != null && activeWand.isInventoryOpen()) { // Kind of a hack to avoid hotbar items with 0 amounts disappearing :( Inventory inventory = player.getInventory(); for (int i = 0; i < 8; i++) { ItemStack item = inventory.getItem(i); if (item != null && item.getAmount() == 0) { item.setAmount(1); } } // Don't allow the offhand slot to be messed with while the spell inventory is open if (event.getRawSlot() == 45) { event.setCancelled(true); return; } if (Wand.isSpell(clickedItem) && clickedItem.getAmount() != 1) { clickedItem.setAmount(1); } if (clickedWand) { event.setCancelled(true); if (dropChangesPages) { activeWand.cycleInventory(); } else { activeWand.cycleHotbar(1); } return; } // So many ways to try and move the wand around, that we have to watch for! if (isHotbar && Wand.isWand(player.getInventory().getItem(event.getHotbarButton()))) { event.setCancelled(true); return; } // Can't wear spells if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY && clickedItem != null) { if (controller.isWearable(clickedItem)) { event.setCancelled(true); return; } } // Safety check for something that ought not to be possible // but perhaps happens with lag? if (Wand.isWand(event.getCursor())) { activeWand.closeInventory(); event.setCursor(null); event.setCancelled(true); return; } } else if (activeWand != null) { // Check for changes that could have been made to the active wand Integer activeSlot = player.getInventory().getHeldItemSlot(); if (activeSlot != null && (event.getSlot() == activeSlot || (event.getAction() == InventoryAction.HOTBAR_SWAP && event.getHotbarButton() == activeSlot))) { mage.checkWand(); activeWand = mage.getActiveWand(); } } else if (clickedWand && Wand.Undroppable && !player.hasPermission("Magic.wand.override_drop") && isChest && !isContainerSlot) { Wand wand = new Wand(controller, clickedItem); if (wand.isUndroppable()) { event.setCancelled(true); return; } } // Check for armor changing if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY && clickedItem != null) { if (controller.isWearable(clickedItem)) { controller.onArmorUpdated(mage); } } // Check for dropping items out of a wand's inventory // or dropping undroppable wands if (isDrop) { if (clickedWand) { Wand wand = new Wand(controller, clickedItem); if (wand.isUndroppable()) { event.setCancelled(true); if (activeWand != null) { if (activeWand.getHotbarCount() > 1) { activeWand.cycleHotbar(1); } else { activeWand.closeInventory(); } } return; } } if (activeWand != null && activeWand.isInventoryOpen()) { ItemStack droppedItem = clickedItem; if (!Wand.isSpell(droppedItem)) { mage.giveItem(droppedItem); event.setCurrentItem(null); event.setCancelled(true); return; } // This is a hack to deal with spells on cooldown disappearing, // Since the event handler doesn't match the zero-count itemstacks Integer slot = event.getSlot(); int heldSlot = player.getInventory().getHeldItemSlot(); Inventory hotbar = activeWand.getHotbar(); if (hotbar != null && slot >= 0 && slot <= hotbar.getSize() && slot != heldSlot && activeWand.getMode() == WandMode.INVENTORY) { if (slot > heldSlot) slot--; if (slot < hotbar.getSize()) { droppedItem = hotbar.getItem(slot); } else { slot = null; } } else { slot = null; } if (!controller.isSpellDroppingEnabled()) { player.closeInventory(); String spellName = Wand.getSpell(droppedItem); if (spellName != null && !activeWand.isManualQuickCastDisabled()) { Spell spell = mage.getSpell(spellName); if (spell != null) { activeWand.cast(spell); // Just in case a spell has levelled up... jeez! if (hotbar != null && slot != null) { droppedItem = hotbar.getItem(slot); } } } event.setCancelled(true); // This is needed to avoid spells on cooldown disappearing from the hotbar if (hotbar != null && slot != null && mage.getActiveGUI() == null) { player.getInventory().setItem(event.getSlot(), droppedItem); player.updateInventory(); } return; } ItemStack newDrop = controller.removeItemFromWand(activeWand, droppedItem); if (newDrop != null) { Location location = player.getLocation(); Item item = location.getWorld().dropItem(location, newDrop); item.setVelocity(location.getDirection().normalize()); } else { event.setCancelled(true); } } return; } // Check for wand cycling with active inventory if (activeWand != null) { WandMode wandMode = activeWand.getMode(); if ((wandMode == WandMode.INVENTORY && inventoryType == InventoryType.CRAFTING) || (wandMode == WandMode.CHEST && inventoryType == InventoryType.CHEST)) { if (activeWand.isInventoryOpen()) { if (event.getAction() == InventoryAction.NOTHING) { int direction = event.getClick() == ClickType.LEFT ? 1 : -1; activeWand.cycleInventory(direction); event.setCancelled(true); return; } if (event.getSlotType() == InventoryType.SlotType.ARMOR) { event.setCancelled(true); return; } // Chest mode falls back to selection from here. if (event.getAction() == InventoryAction.PICKUP_HALF || wandMode == WandMode.CHEST) { controller.onPlayerActivateIcon(mage, activeWand, clickedItem); player.closeInventory(); event.setCancelled(true); } } } } }
@EventHandler public void onInventoryClick(InventoryClickEvent e) { DataContainer dataContainer = plugin.getDataContainer(); Player player = (Player) e.getWhoClicked(); String name = ChatColor.stripColor(e.getInventory().getName()); if (name.equalsIgnoreCase("Title categories")) { e.setCancelled(true); if (e.getCurrentItem() == null || e.getCurrentItem().getType() == Material.AIR || !e.getCurrentItem().hasItemMeta()) { player.closeInventory(); return; } if (e.getCurrentItem().getData() instanceof Wool) { // All unlocked titles of player if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("Unlocked")) { player.openInventory(constructInventory(plugin, player, null, true)); return; } // open Titles in category player.openInventory( constructInventory( plugin, player, Utils.strip(Utils.setColors(e.getCurrentItem().getItemMeta().getDisplayName())), false)); } } else if (name.equalsIgnoreCase("Titles in category") || name.equalsIgnoreCase("Unlocked Titles")) { e.setCancelled(true); if (e.getCurrentItem() == null || e.getCurrentItem().getType() == Material.AIR || !e.getCurrentItem().hasItemMeta()) { player.closeInventory(); return; } // back button if (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("Back")) { player.openInventory(constructInventory(plugin, player, null, false)); return; } String category = null; String[] split = e.getCurrentItem().getItemMeta().getLore().get(1).split(" "); if (split.length == 2) category = split[1]; if (e.getCurrentItem().getData() instanceof Wool) { DyeColor color = ((Wool) e.getCurrentItem().getData()).getColor(); Title title = dataContainer.getTitle( Utils.strip( Utils.setColors( e.getCurrentItem().getItemMeta().getDisplayName().toLowerCase()))); Inventory inv = e.getInventory(); ItemMeta im = e.getCurrentItem().getItemMeta(); int slot = e.getSlot(); if (name.equalsIgnoreCase("Titles in category")) { switch (color) { case RED: // Request title. if (player.hasPermission(plugin.makeRequestsPerm)) { if (RequestCommands.submitRequest(dataContainer, player, title.getId())) { Utils.sendMsg( player, "Your request for " + ChatColor.ITALIC + title.getName() + ChatColor.RESET + " has been submitted."); handleBlock(inv, im, DyeColor.ORANGE, "Pending", slot); } else Utils.sendError( player, "You already have a pending request or that title doesn't exist."); } else Utils.sendError(player, "You don't have permission to do that."); break; case LIME: // Disable current title. if (player.hasPermission(plugin.setTitlePerm)) { if (SetCommands.disableTitle(dataContainer, player)) { Utils.sendMsg(player, "Title disabled."); handleBlock(inv, im, DyeColor.GREEN, "Unlocked", slot); } else Utils.sendError(player, "Player doesn't have that title active."); } else Utils.sendError(player, "You don't have permission to do that."); break; case GREEN: // Set title as current. if (player.hasPermission(plugin.setTitlePerm)) { if (SetCommands.setTitle(dataContainer, player, title.getId())) { Utils.sendMsg( player, String.format( "Title set to %s" + title.getName() + "%s.", ChatColor.ITALIC, ChatColor.RESET)); handleBlock(inv, im, DyeColor.LIME, "Current", slot); if (category == null) player.closeInventory(); else player.openInventory(constructInventory(plugin, player, category, false)); } else Utils.sendError(player, "Player doesn't own that title or it doesn't exist."); } else Utils.sendError(player, "You don't have permission to do that."); break; case ORANGE: // Retract request. if (player.hasPermission(plugin.makeRequestsPerm)) { if (RequestCommands.retractRequest(dataContainer, player)) { Utils.sendMsg(player, "Your request has successfully been retracted."); handleBlock(inv, im, DyeColor.RED, "Locked", slot); } else Utils.sendError(player, "You don't have a pending request."); } else Utils.sendError(player, "You don't have permission to do that."); break; } } else if (name.equalsIgnoreCase("Unlocked Titles")) { switch (color) { case LIME: // Disable current title. if (player.hasPermission(plugin.setTitlePerm)) { if (SetCommands.disableTitle(dataContainer, player)) { Utils.sendMsg(player, "Title disabled."); handleBlock(inv, im, DyeColor.GREEN, "Unlocked", slot); } else Utils.sendError(player, "Player doesn't have that title active."); } else Utils.sendError(player, "You don't have permission to do that."); break; case GREEN: // Set title as current. if (player.hasPermission(plugin.setTitlePerm)) { if (SetCommands.setTitle(dataContainer, player, title.getId())) { Utils.sendMsg( player, String.format( "Title set to %s" + title.getName() + "%s.", ChatColor.ITALIC, ChatColor.RESET)); handleBlock(inv, im, DyeColor.LIME, "Current", slot); if (category == null) player.closeInventory(); else player.openInventory(constructInventory(plugin, player, category, false)); } else Utils.sendError(player, "Player doesn't own that title or it doesn't exist."); } else Utils.sendError(player, "You don't have permission to do that."); break; } } } } }
@EventHandler public void onInventoryClick(InventoryClickEvent event) { if (event.isCancelled()) { return; } String name = ChatColor.stripColor(event.getInventory().getName()); String category = ""; boolean isCategory = name.equalsIgnoreCase("Townships Categories"); String[] names = name.split(" "); if (!isCategory) { if (names.length != 2 || !names[1].equals("Regions")) { return; } else { category = names[0].toLowerCase(); } } Player player = (Player) event.getWhoClicked(); event.setCancelled(true); if (event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR || !event.getCurrentItem().hasItemMeta()) { // player.closeInventory(); return; } if (isCategory) { String categoryOpen = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName()).toLowerCase(); player.closeInventory(); player.performCommand("to list " + categoryOpen); return; } if (event.getCurrentItem().hasItemMeta() && ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName()) .equals("Back to Categories")) { player.closeInventory(); player.performCommand("to list"); return; } // player.performCommand("to info " + // ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName())); String regionName = ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName()).toLowerCase(); RegionType rt = rm.getRegionType(regionName); SuperRegionType srt = null; if (rt == null) { srt = rm.getSuperRegionType(regionName); if (srt == null) { player.closeInventory(); return; } } String backButton = ChatColor.stripColor( event .getInventory() .getItem(event.getInventory().getSize() - 1) .getItemMeta() .getLore() .get(0)); player.closeInventory(); if (rt != null) { InfoGUIListener.openInfoInventory(rt, player, backButton); } else { InfoGUIListener.openInfoInventory(srt, player, backButton); } }
// Handles player interaction with anvil while in or out of creative. @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.NORMAL) public void anvilFix(final InventoryClickEvent e) { if (!e.isCancelled()) { HumanEntity ent = e.getWhoClicked(); // Anvil used with survival if (ent instanceof Player) { final Player player = (Player) ent; Inventory inv = e.getInventory(); // Anvil used with creative: if (player.getGameMode() == GameMode.CREATIVE) { if (inv instanceof AnvilInventory) { AnvilInventory anvil = (AnvilInventory) inv; InventoryView view = e.getView(); int rawSlot = e.getRawSlot(); if (rawSlot == view.convertSlot(rawSlot)) { if (rawSlot == 2) { ItemStack[] items = anvil.getContents(); ItemStack item1 = items[0]; ItemStack item2 = items[1]; if (item1 != null && item2 != null) { int id1 = item1.getTypeId(); int id2 = item2.getTypeId(); if (id1 != 0 && id2 != 0) { ItemStack item3 = e.getCurrentItem(); if (item3 != null) { ItemMeta meta = item3.getItemMeta(); if (meta != null) { // Player has to have 60 or more levels to use the creative combine. if (player.getLevel() >= 60) { player.setLevel(player.getLevel() - 60); player.sendMessage(ChatColor.GREEN + "Repair/Combine Successful!"); Bukkit.getServer() .getScheduler() .scheduleSyncDelayedTask( mobfighter, new Runnable() { public void run() { // Bypass being set to survival after using anvil if the // player has creative immunity. if (mobfighter .getConfig() .getList("Creative Immunity") .contains(player.getDisplayName())) return; // Sets the player back to survival once the anvil is used. e.getWhoClicked().getOpenInventory().close(); player.setGameMode(GameMode.SURVIVAL); } }, 20 * 2); } // End of creative combine. } // Didn't have enough levels to combine/finishing. } // Item 3 was/wasn't null. } // Item 1 & 2 id's were/weren't null. } // Item 1 & 2 was/wasn't null. } // End of (rawSlot == 2) } // End of convert view } // End of anvil inventory else { // Bypass having the player's inventory closed if they have creative immunity. if (mobfighter .getConfig() .getList("Creative Immunity") .contains(player.getDisplayName())) e.setCancelled(false); // Closes the player's inventory after the anvil is used. else { e.setCancelled(true); player.closeInventory(); } } } // End of anvil with creative } // End of anvil with survival } // End of !isCancelled } // End of anvilFix