Java Code Examples for org.bukkit.event.inventory.InventoryClickEvent#getSlot()
The following examples show how to use
org.bukkit.event.inventory.InventoryClickEvent#getSlot() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Gui.java From IF with The Unlicense | 6 votes |
/** * Calls the specified consumer (if it's not null) with the specified parameter, * catching and logging all exceptions it might throw. * * @param callback the consumer to call if it isn't null * @param event the value the consumer should accept * @param callbackName the name of the action, used for logging * @param <T> the type of the value the consumer is accepting */ private <T extends InventoryEvent> void callCallback(@Nullable Consumer<T> callback, @NotNull T event, @NotNull String callbackName) { if (callback == null) { return; } try { callback.accept(event); } catch (Throwable t) { Logger logger = JavaPlugin.getProvidingPlugin(getClass()).getLogger(); String message = "Exception while handling " + callbackName + " in inventory '" + title + "', state=" + state; if (event instanceof InventoryClickEvent) { InventoryClickEvent clickEvent = (InventoryClickEvent) event; message += ", slot=" + clickEvent.getSlot(); } logger.log(Level.SEVERE, message, t); } }
Example 2
Source File: LanguagesGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
@Override @EventHandler public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().equals(getInventory())) { e.setCancelled(true); if (e.getClickedInventory() == null || !e.getClickedInventory().equals(getInventory())) return; if (languages.containsKey(e.getSlot())) { IridiumSkyblock.getInstance().setLanguage(languages.get(e.getSlot()), (Player) e.getWhoClicked()); } else if (e.getSlot() == getInventory().getSize() - 7) { if (root.pages.containsKey(page - 1)) { e.getWhoClicked().openInventory(root.pages.get(page - 1).getInventory()); } } else if (e.getSlot() == getInventory().getSize() - 3) { if (root.pages.containsKey(page + 1)) { e.getWhoClicked().openInventory(root.pages.get(page + 1).getInventory()); } } } }
Example 3
Source File: IslandAdminGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
@Override @EventHandler public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().equals(getInventory())) { e.setCancelled(true); if (e.getClickedInventory() == null || !e.getClickedInventory().equals(getInventory())) return; Player p = (Player) e.getWhoClicked(); for (Inventories.Item item : IridiumSkyblock.getInventories().menu.keySet()) { if (item.slot == e.getSlot()) { p.closeInventory(); Bukkit.getServer().dispatchCommand(e.getWhoClicked(), IridiumSkyblock.getInventories().menu.get(item).replace("is", "is admin " + islandID)); return; } } } }
Example 4
Source File: MobSelector.java From CloudNet with Apache License 2.0 | 6 votes |
@EventHandler public void handleInventoryClick(InventoryClickEvent e) { if (!(e.getWhoClicked() instanceof Player)) { return; } if (inventories().contains(e.getInventory()) && e.getCurrentItem() != null && e.getSlot() == e.getRawSlot()) { e.setCancelled(true); if (ItemStackBuilder.getMaterialIgnoreVersion(mobConfig.getItemLayout().getItemName(), mobConfig.getItemLayout().getItemId()) == e.getCurrentItem().getType()) { MobImpl mob = find(e.getInventory()); if (mob.getServerPosition().containsKey(e.getSlot())) { if (CloudAPI.getInstance().getServerId().equalsIgnoreCase(mob.getServerPosition().get(e.getSlot()))) { return; } ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput(); byteArrayDataOutput.writeUTF("Connect"); byteArrayDataOutput.writeUTF(mob.getServerPosition().get(e.getSlot())); ((Player) e.getWhoClicked()).sendPluginMessage(CloudServer.getInstance().getPlugin(), "BungeeCord", byteArrayDataOutput.toByteArray()); } } } }
Example 5
Source File: IntegerEditMenu.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@Override public boolean onClick(InventoryClickEvent event) { if (!(event.getInventory().getHolder() instanceof UltimateHolder) || ((UltimateHolder) event.getInventory().getHolder()).getTitle() == null || !stripFormatting(((UltimateHolder) event.getInventory().getHolder()).getTitle()).contains(stripFormatting(getTitle()))) { return false; } if (event.getSlotType() != InventoryType.SlotType.CONTAINER) { return true; } Player player = (Player) event.getWhoClicked(); Inventory menu = event.getInventory(); ItemStack returnItem = menu.getItem(getIndex(5, 0)); String configName = returnItem.getItemMeta().getLore().get(0); String path = returnItem.getItemMeta().getLore().get(1); int page = getPage(returnItem.getItemMeta().getLore().get(2)); int slot = event.getSlot(); int row = slot / 9; int col = slot % 9; ItemStack clickedItem = event.getCurrentItem(); if (slot >= getIndex(3, 0) && slot <= getIndex(3, 8)) { // increment buttons YmlConfiguration config = FileUtil.getYmlConfiguration(configName); int value = config.getInt(path, 0); int increment = getDisplayNameAsInt(clickedItem); if (event.getClick() == ClickType.LEFT) { value += increment; } else if (event.getClick() == ClickType.RIGHT) { value = increment; } config.set(path, value); config.set("dirty", true); } if (slot != getIndex(5,0)) { player.openInventory(createEditMenu(configName, path, page)); } else { player.openInventory(parent.createEditMenu(configName, path, page)); } return true; }
Example 6
Source File: SkyBlockMenu.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public void onClick(InventoryClickEvent event) { ItemStack currentItem = event != null ? event.getCurrentItem() : null; if (event == null || currentItem == null) { return; // Bail out, nothing we can do anyway } Player p = (Player) event.getWhoClicked(); ItemMeta meta = currentItem.getItemMeta(); SkullMeta skull = meta instanceof SkullMeta ? (SkullMeta) meta : null; if (!(event.getInventory().getHolder() instanceof UltimateHolder)) return; String inventoryName = stripFormatting(((UltimateHolder) event.getInventory().getHolder()).getTitle()); int slotIndex = event.getSlot(); int menuSize = event.getInventory().getSize(); if (inventoryName.equalsIgnoreCase(stripFormatting(tr("Island Group Members")))) { onClickPartyMenu(event, currentItem, p, meta, skull, slotIndex); } else if (inventoryName.contains(stripFormatting(tr("Permissions")))) { onClickPermissionMenu(event, currentItem, p, inventoryName, slotIndex); } else if (inventoryName.equalsIgnoreCase(stripFormatting(tr("Island Biome")))) { onClickBiomeMenu(event, currentItem, p, slotIndex); } else if (inventoryName.contains(stripFormatting(tr("Challenge Menu")))) { onClickChallengeMenu(event, currentItem, p, inventoryName); } else if (inventoryName.equalsIgnoreCase(stripFormatting(tr("Island Log")))) { onClickLogMenu(event, p, slotIndex); } else if (inventoryName.equalsIgnoreCase(stripFormatting(tr("Island Menu")))) { onClickMainMenu(event, currentItem, p, slotIndex); } else if (inventoryName.equalsIgnoreCase(stripFormatting(tr("Island Create Menu")))) { onClickCreateMenu(event, p, meta, slotIndex, menuSize); } else if (inventoryName.equalsIgnoreCase(stripFormatting(tr("Island Restart Menu")))) { onClickRestartMenu(event, p, meta, slotIndex, currentItem); } else if (inventoryName.startsWith(stripFormatting(tr("Config:"))) && event.getWhoClicked() instanceof Player) { plugin.getConfigMenu().onClick(event); } }
Example 7
Source File: LifeskillingListener.java From EnchantmentsEnhance with GNU General Public License v3.0 | 5 votes |
/** * Fix a bukkit bug where shift click doesn't register. * * @param e * @return */ @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) public void onSmelting2(InventoryClickEvent e) { Inventory clickedInventory = null; Player player = (Player) e.getWhoClicked(); if (e.getSlot() < 0) { clickedInventory = null; } else if (e.getView().getTopInventory() != null && e.getSlot() < e .getView().getTopInventory().getSize()) { clickedInventory = e.getView().getTopInventory(); } else { clickedInventory = e.getView().getBottomInventory(); } if (clickedInventory == null) { return; } if (!clickedInventory.getType().equals(InventoryType.FURNACE)) { return; } if (e.getCurrentItem() == null || e.getCurrentItem().getType() == Material.AIR) { return; } FurnaceInventory fi = (FurnaceInventory) clickedInventory; boolean click = e.getClick().isShiftClick() || e.getClick() .isLeftClick() && e.getRawSlot() == 2; boolean item = fi.getResult() != null; if (click && item && !fi.getResult().getType().isFuel() && !fi.getResult().getType().isBurnable() && !Util.invFull(player)) { for (int i = 0; i < fi.getResult().getAmount(); i++) { if (DropManager.smeltingChance > random.nextDouble()) { DropManager.randomDrop(player, DropManager.smeltingLootTable); } } } }
Example 8
Source File: MenuHandler.java From EnchantmentsEnhance with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = false, priority = EventPriority.HIGHEST) public void onClick(InventoryClickEvent e) { // Handles invalid clicks. if (e.getSlot() < 0) { return; } // Handles invalid entity. if (!(e.getWhoClicked() instanceof Player)) { return; } // Handles empty slot. if (e.getCurrentItem() != null && e.getCurrentItem().getType() == (Material.AIR)) { return; } Player player = (Player) e.getWhoClicked(); String playerName = player.getName(); GUIAbstract gui = GUIManager.getMap().get(playerName); if (gui != null && gui.getInventory().equals(e.getInventory())) { e.setCancelled(true); if (!MainMenu.itemOnEnhancingSlot.containsKey(playerName) && MainMenu.enhancingMode.containsKey(playerName)) { if (MainMenu.enhancingMode.get(playerName).equals(MainMenu.gear)) { if (Enhance.getValidationOfItem(e.getCurrentItem()) && e.getRawSlot() >= 54) { MainMenu.itemOnEnhancingSlot.put(playerName, e.getCurrentItem()); gui.update(); } } else if (MainMenu.enhancingMode.get(playerName).equals(MainMenu.tool)) { if (Enhance.getValidationOfToolItem(e.getCurrentItem()) && e.getRawSlot() >= 54) { MainMenu.itemOnEnhancingSlot.put(playerName, e.getCurrentItem()); gui.update(); } } } } }
Example 9
Source File: SpectateListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.NORMAL) public void onInventoryClick(InventoryClickEvent e) { final Player player = (Player) e.getWhoClicked(); final GameMap gameMap = MatchManager.get().getSpectatorMap(player); if (gameMap == null) { return; } int slot = e.getSlot(); if (slot == 8) { player.closeInventory(); gameMap.getSpectators().remove(player.getUniqueId()); MatchManager.get().removeSpectator(player); } else if (slot >= 9 && slot <= 35) { player.closeInventory(); ItemStack item = e.getCurrentItem(); if (item != null && !item.getType().equals(Material.AIR)) { String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()); Player toSpec = SkyWarsReloaded.get().getServer().getPlayer(name); if (toSpec != null) { if (!gameMap.mapContainsDead(toSpec.getUniqueId()) && player != null) { player.teleport(toSpec.getLocation(), TeleportCause.END_PORTAL); } } } } }
Example 10
Source File: GUIListeners.java From CratesPlus with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onInventoryClick(InventoryClickEvent event) { if (GUI.guis.containsKey(event.getWhoClicked().getUniqueId())) { event.setCancelled(true); if (event.getCurrentItem() == null || event.getRawSlot() != event.getSlot() || event.getCurrentItem().getType().equals(Material.AIR)) return; GUI gui = GUI.guis.get(event.getWhoClicked().getUniqueId()); gui.handleClick((Player) event.getWhoClicked(), event.getSlot()); } }
Example 11
Source File: AbstractGUIInventory.java From NovaGuilds with GNU General Public License v3.0 | 5 votes |
@Override public void onClick(InventoryClickEvent event) { for(GUIInventory.Executor executor : new HashSet<>(getExecutors())) { if(executor.getSlot() == event.getSlot()) { executor.execute(); } } }
Example 12
Source File: VisitGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler @Override public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().equals(getInventory())) { e.setCancelled(true); if (e.getClickedInventory() == null || !e.getClickedInventory().equals(getInventory())) return; if (islands.containsKey(e.getSlot())) { Island island = IridiumSkyblock.getIslandManager().getIslandViaId(islands.get(e.getSlot())); User u = User.getUser((OfflinePlayer) e.getWhoClicked()); if (island.isVisit() || u.bypassing) { if (e.getClick() == ClickType.RIGHT) { if (island.hasVoted(u)) { island.removeVote(u); } else { island.addVote(u); } } else { e.getWhoClicked().closeInventory(); island.teleportHome((Player) e.getWhoClicked()); } } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().playersIslandIsPrivate.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else if (e.getSlot() == getInventory().getSize() - 7) { if (IridiumSkyblock.visitGUI.containsKey(page - 1)) e.getWhoClicked().openInventory(IridiumSkyblock.visitGUI.get(page - 1).getInventory()); } else if (e.getSlot() == getInventory().getSize() - 3) { if (IridiumSkyblock.visitGUI.containsKey(page + 1)) e.getWhoClicked().openInventory(IridiumSkyblock.visitGUI.get(page + 1).getInventory()); } } }
Example 13
Source File: GUIListener.java From EnchantmentsEnhance with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onClick(InventoryClickEvent e) { // Handles invalid clicks. if (e.getSlot() < 0) { return; } // Handles invalid entity. if (!(e.getWhoClicked() instanceof Player)) { return; } // Handles empty slot. if (e.getCurrentItem() != null && e.getCurrentItem().getType() == (Material.AIR)) { return; } // Handles non-gui inventory. if (e.getRawSlot() > 53) { return; } Player player = (Player) e.getWhoClicked(); String playerName = player.getName(); GUIAbstract gui = GUIManager.getMap().get(playerName); if (gui != null && gui.getInventory().equals(e.getInventory())) { e.setCancelled(true); GUIAbstract.GUIAction action = gui.getActions().get(e.getSlot()); if (action != null) { action.click(e.getClick()); gui.update(); } } else { if (isCreatedGUI(e.getInventory())) { e.setCancelled(true); player.closeInventory(); } } }
Example 14
Source File: ConfirmationGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler @Override public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().equals(getInventory())) { e.setCancelled(true); if (e.getClickedInventory() == null || !e.getClickedInventory().equals(getInventory())) return; if (e.getSlot() == 12) { e.getWhoClicked().closeInventory(); runnable.run(); } else if (e.getSlot() == 14) { e.getWhoClicked().closeInventory(); } } }
Example 15
Source File: BiomeGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@EventHandler @Override public void onInventoryClick(InventoryClickEvent e) { if (getInventory() == null) { for (BiomeGUI gui : pages.values()) { gui.onInventoryClick(e); } } else { if (e.getInventory().equals(getInventory())) { e.setCancelled(true); if (e.getClickedInventory() == null || !e.getClickedInventory().equals(getInventory())) return; if (e.getSlot() == getInventory().getSize() - 3) { if (root.pages.containsKey(page + 1)) { e.getWhoClicked().openInventory(root.pages.get(page + 1).getInventory()); } } if (e.getSlot() == getInventory().getSize() - 7) { if (root.pages.containsKey(page - 1)) { e.getWhoClicked().openInventory(root.pages.get(page - 1).getInventory()); } } if (biomes.containsKey(e.getSlot())) { getIsland().setBiome(biomes.get(e.getSlot())); } } } }
Example 16
Source File: InventoryUtils.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public static Inventory clickedInventory(InventoryClickEvent event) { return event.getSlot() == event.getRawSlot() ? event.getView().getTopInventory() : event.getView().getBottomInventory(); }
Example 17
Source File: SpectatorTools.java From CardinalPGM with MIT License | 4 votes |
@EventHandler public void onInventoryClick(InventoryClickEvent event) { ItemStack item = event.getCurrentItem(); Player player = (Player) event.getWhoClicked(); String locale = player.getLocale(); if (item == null) return; if (event.getInventory().getName().equals(getSpectatorMenuTitle(event.getActor().getLocale()))) { if (item.isSimilar(getTeleportItem(locale))) { player.openInventory(getTeamsMenu(player)); } else if (item.isSimilar(getVisibilityItem(locale))) { Bukkit.dispatchCommand(player, "toggle obs"); player.closeInventory(); } else if (item.isSimilar(getElytraItem(locale))) { Bukkit.dispatchCommand(player, "toggle elytra"); player.closeInventory(); } else if (item.isSimilar(getEffectsItem(locale))) { player.openInventory(getEffectsMenu(player)); } else if (item.isSimilar(getGamemodeItem(locale))) { player.setGameMode(player.getGameMode().equals(GameMode.CREATIVE) ? GameMode.SPECTATOR : GameMode.CREATIVE); if (player.getGameMode().equals(GameMode.CREATIVE)) Bukkit.dispatchCommand(player, "!"); player.closeInventory(); } } else if (event.getInventory().getName().equals(getTeamsMenuTitle(locale))) { if (item.isSimilar(getGoBackItem(locale))) { player.openInventory(getSpectatorMenu(player)); } else if (item.getType().equals(Material.LEATHER_HELMET) && item.getItemMeta().hasDisplayName() && !item.isSimilar(TeamPicker.getTeamPicker(locale))){ TeamModule team = Teams.getTeamByName(ChatColor.stripColor(Strings.removeLastWord(item.getItemMeta().getDisplayName()))).orNull(); if (team != null) { player.openInventory(getTeleportMenu(player, team)); } } } else if (event.getInventory().getName().equals(getTeleportMenuTitle(locale))) { if (item.isSimilar(getGoBackItem(locale))) { player.openInventory(getTeamsMenu(player)); } else if (item.getType().equals(Material.SKULL_ITEM) && item.getItemMeta().hasDisplayName()) { Player teleport = Bukkit.getPlayer(((SkullMeta) item.getItemMeta()).getOwner()); if (teleport != null) { player.teleport(teleport); player.closeInventory(); } } } else if (event.getInventory().getName().equals(getEffectsMenuTitle(locale))) { if (item.isSimilar(getGoBackItem(locale))) { player.openInventory(getSpectatorMenu(player)); } else if (item.isSimilar(getNightVisionItem(player.getLocale()))) { if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) { player.removePotionEffect(PotionEffectType.NIGHT_VISION); } else { player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false)); } player.closeInventory(); } else if (item.getType().equals(Material.SUGAR) && item.getItemMeta().hasDisplayName()) { int value = event.getSlot(); Setting setting = Settings.getSettingByName("Speed"); Bukkit.dispatchCommand(player, "set speed " + setting.getValues().get(value).getValue()); player.closeInventory(); } } }
Example 18
Source File: Recipes.java From ProRecipes with GNU General Public License v2.0 | 4 votes |
public void fixCancel(final InventoryClickEvent event){ //First try right here event.setCancelled(true); //System.out.println("BEING CANCELLED"); //Need to know if picking up item switch(event.getAction()){ case COLLECT_TO_CURSOR: case PICKUP_ALL: case PICKUP_HALF: case PICKUP_ONE: case PICKUP_SOME: case HOTBAR_SWAP: case HOTBAR_MOVE_AND_READD: final ItemStack pickedup = event.getCursor().clone(); final int slot = event.getSlot(); //Need to know what item picked up, where it was picked up from //Reset item, take off of cursor ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){ @Override public void run() { event.getWhoClicked().setItemOnCursor(null); event.getInventory().setItem(slot, pickedup); resetBorders(event.getInventory()); } }, 0); return; case PLACE_ONE: case PLACE_SOME: case PLACE_ALL: case UNKNOWN: case DROP_ALL_CURSOR: case DROP_ALL_SLOT: case DROP_ONE_CURSOR: case DROP_ONE_SLOT: case MOVE_TO_OTHER_INVENTORY: case SWAP_WITH_CURSOR: //System.out.println("SOMETHING DROPPED"); final ItemStack dropped = event.getCurrentItem().clone(); //System.out.println(dropped.getType()); final ItemStack swapped = event.getCursor().clone(); final int s = event.getSlot(); ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){ @Override public void run() { if(swapped != null && event.getAction().equals(InventoryAction.SWAP_WITH_CURSOR)){ //there was a swap event.getWhoClicked().setItemOnCursor(dropped); event.getInventory().setItem(s, swapped); }else if(swapped != null && dropped != null && !swapped.getType().equals(Material.AIR)){ if(swapped.isSimilar(dropped)){ // System.out.println("Is similar"); event.getInventory().setItem(s, null); ItemStack t = dropped.clone(); t.setAmount(dropped.getAmount() + swapped.getAmount()); event.getWhoClicked().setItemOnCursor(t); } }else{ //System.out.println("else"); event.getInventory().setItem(s, null); event.getWhoClicked().setItemOnCursor(dropped); } } }, 0); return; } //Need to know if dropping item(s) //This isn't as much of a problem (Come back later if it is) }
Example 19
Source File: BoosterGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler @Override public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().equals(getInventory())) { Player p = (Player) e.getWhoClicked(); Island island = IridiumSkyblock.getIslandManager().islands.get(islandID); e.setCancelled(true); if (e.getClickedInventory() == null || !e.getClickedInventory().equals(getInventory())) return; if (e.getSlot() == IridiumSkyblock.getBoosters().spawnerBooster.slot && IridiumSkyblock.getBoosters().spawnerBooster.enabled) { if (getIsland().getSpawnerBooster() == 0) { if (Utils.canBuy(p, IridiumSkyblock.getBoosters().spawnerBooster.vaultCost, IridiumSkyblock.getBoosters().spawnerBooster.crystalsCost)) { getIsland().setSpawnerBooster(IridiumSkyblock.getBoosters().spawnerBooster.time); } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().notEnoughCrystals.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().spawnerBoosterActive.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } if (e.getSlot() == IridiumSkyblock.getBoosters().farmingBooster.slot && IridiumSkyblock.getBoosters().farmingBooster.enabled) { if (getIsland().getFarmingBooster() == 0) { if (Utils.canBuy(p, IridiumSkyblock.getBoosters().farmingBooster.vaultCost, IridiumSkyblock.getBoosters().farmingBooster.crystalsCost)) { getIsland().setFarmingBooster(IridiumSkyblock.getBoosters().farmingBooster.time); } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().notEnoughCrystals.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().farmingBoosterActive.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } if (e.getSlot() == IridiumSkyblock.getBoosters().experianceBooster.slot && IridiumSkyblock.getBoosters().experianceBooster.enabled) { if (getIsland().getExpBooster() == 0) { if (Utils.canBuy(p, IridiumSkyblock.getBoosters().experianceBooster.vaultCost, IridiumSkyblock.getBoosters().experianceBooster.crystalsCost)) { getIsland().setExpBooster(IridiumSkyblock.getBoosters().experianceBooster.time); } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().notEnoughCrystals.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().expBoosterActive.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } if (e.getSlot() == IridiumSkyblock.getBoosters().flightBooster.slot && IridiumSkyblock.getBoosters().flightBooster.enabled) { if (getIsland().getFlightBooster() == 0) { if (Utils.canBuy(p, IridiumSkyblock.getBoosters().flightBooster.vaultCost, IridiumSkyblock.getBoosters().flightBooster.crystalsCost)) { getIsland().setFlightBooster(IridiumSkyblock.getBoosters().flightBooster.time); } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().notEnoughCrystals.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { e.getWhoClicked().sendMessage(Utils.color(IridiumSkyblock.getMessages().flightBoosterActive.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } } }
Example 20
Source File: SchematicSelectGUI.java From IridiumSkyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler @Override public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().equals(getInventory())) { e.setCancelled(true); if (e.getClickedInventory() == null || !e.getClickedInventory().equals(getInventory())) return; for (Schematics.FakeSchematic fakeSchematic : IridiumSkyblock.getSchematics().schematics) { if (e.getSlot() == fakeSchematic.slot && (fakeSchematic.permission.isEmpty() || e.getWhoClicked().hasPermission(fakeSchematic.permission))) { e.getWhoClicked().closeInventory(); if (getIsland().getSchematic() != null) { for (String player : getIsland().getMembers()) { User user = User.getUser(player); Player p = Bukkit.getPlayer(user.name); if (p != null) { p.sendMessage(Utils.color(IridiumSkyblock.getMessages().regenIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } } if (getIsland().getSchematic() == null) { getIsland().setSchematic(fakeSchematic.name); getIsland().setNetherschematic(fakeSchematic.netherisland); getIsland().pasteSchematic((Player) e.getWhoClicked(), false); } else { getIsland().setSchematic(fakeSchematic.name); getIsland().setNetherschematic(fakeSchematic.netherisland); getIsland().pasteSchematic(true); } getIsland().setHome(getIsland().getHome().add(fakeSchematic.x, fakeSchematic.y, fakeSchematic.z)); getIsland().setNetherhome(getIsland().getNetherhome().add(fakeSchematic.x, fakeSchematic.y, fakeSchematic.z)); if (IridiumSkyblock.getConfiguration().restartUpgradesOnRegen) { getIsland().resetMissions(); getIsland().setSizeLevel(1); getIsland().setMemberLevel(1); getIsland().setWarpLevel(1); getIsland().setOreLevel(1); getIsland().setFlightBooster(0); getIsland().setExpBooster(0); getIsland().setFarmingBooster(0); getIsland().setSpawnerBooster(0); } return; } } } }