Java Code Examples for org.bukkit.entity.Player#openInventory()
The following examples show how to use
org.bukkit.entity.Player#openInventory() .
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: BookPlayerShopkeeper.java From Shopkeepers with GNU General Public License v3.0 | 8 votes |
@Override protected boolean openWindow(Player player) { final BookPlayerShopkeeper shopkeeper = this.getShopkeeper(); Inventory inv = Bukkit.createInventory(player, 27, Settings.editorTitle); List<ItemStack> books = shopkeeper.getBooksFromChest(); for (int column = 0; column < books.size() && column < 8; column++) { String bookTitle = getTitleOfBook(books.get(column)); if (bookTitle != null) { int price = 0; BookOffer offer = shopkeeper.getOffer(bookTitle); if (offer != null) { price = offer.getPrice(); } inv.setItem(column, books.get(column)); this.setEditColumnCost(inv, column, price); } } // add the special buttons: this.setActionButtons(inv); // show editing inventory: player.openInventory(inv); return true; }
Example 2
Source File: WarpsCommand.java From IridiumSkyblock with GNU General Public License v2.0 | 8 votes |
@Override public void execute(CommandSender sender, String[] args) { Player p = (Player) sender; User user = User.getUser(p); Island island; if (args.length == 2) { island = User.getUser(Bukkit.getOfflinePlayer(args[1])).getIsland(); } else { island = user.getIsland(); } if (island != null) { if (island.getPermissions(user.islandID == island.getId() ? user.role : Role.Visitor).useWarps || user.bypassing) { p.openInventory(island.getWarpGUI().getInventory()); } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().noPermission.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { if (user.getIsland() != null) { p.openInventory(user.getIsland().getWarpGUI().getInventory()); } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } }
Example 3
Source File: TopCommand.java From IridiumSkyblock with GNU General Public License v2.0 | 6 votes |
@Override public void execute(CommandSender sender, String[] args) { Player p = (Player) sender; p.openInventory(IridiumSkyblock.topGUI.getInventory()); }
Example 4
Source File: SilentOpenChest.java From SuperVanish with Mozilla Public License 2.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onChestInteract(PlayerInteractEvent e) { Player p = e.getPlayer(); if (!plugin.getVanishStateMgr().isVanished(p.getUniqueId())) return; if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (p.getGameMode() == GameMode.SPECTATOR) return; //noinspection deprecation if (p.isSneaking() && p.getItemInHand() != null && (p.getItemInHand().getType().isBlock() || p.getItemInHand().getType() == ITEM_FRAME) && p.getItemInHand().getType() != Material.AIR) return; Block block = e.getClickedBlock(); if (block == null) return; if (block.getType() == ENDER_CHEST) { e.setCancelled(true); p.openInventory(p.getEnderChest()); return; } if (!(block.getType() == CHEST || block.getType() == TRAPPED_CHEST || plugin.getVersionUtil().isOneDotXOrHigher(11) && shulkerBoxes.contains(block.getType()))) return; StateInfo stateInfo = StateInfo.extract(p); playerStateInfoMap.put(p, stateInfo); p.setGameMode(GameMode.SPECTATOR); }
Example 5
Source File: PartyCommand.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@Override public boolean execute(CommandSender sender, String alias, Map<String, Object> data, String... args) { if (!(sender instanceof Player)) { sender.sendMessage(I18nUtil.tr("\u00a74This command can only be executed by a player")); return false; } Player player = (Player) sender; PlayerInfo playerInfo = plugin.getPlayerInfo(player); if (playerInfo == null || !playerInfo.getHasIsland()) { player.sendMessage(I18nUtil.tr("\u00a74No Island. \u00a7eUse \u00a7b/is create\u00a7e to get one")); return true; } if (args.length == 0) { player.openInventory(menu.displayPartyGUI(player)); return true; } return super.execute(sender, alias, data, args); }
Example 6
Source File: TransferCommand.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@Override public void execute(CommandSender sender, String[] args) { if (args.length != 2) { sender.sendMessage(Utils.color(IridiumSkyblock.getConfiguration().prefix) + "/is transfer <player>"); return; } Player p = (Player) sender; User user = User.getUser(p); if (user.getIsland() != null) { Island island = user.getIsland(); if (island.getOwner().equals(p.getUniqueId().toString())) { OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]); if (player != null) { if (User.getUser(player).getIsland() == island) { p.openInventory(new ConfirmationGUI(user.getIsland(), () -> island.setOwner(player), IridiumSkyblock.getMessages().transferAction.replace("%player%", player.getName())).getInventory()); } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().notInYourIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().playerOffline.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().mustBeIslandOwner.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } }
Example 7
Source File: MissionsCommand.java From IridiumSkyblock with GNU General Public License v2.0 | 5 votes |
@Override public void admin(CommandSender sender, String[] args, Island island) { Player p = (Player) sender; if (island != null) { p.openInventory(island.getMissionsGUI().getInventory()); } else { sender.sendMessage(Utils.color(IridiumSkyblock.getMessages().noIsland.replace("%prefix%", IridiumSkyblock.getConfiguration().prefix))); } }
Example 8
Source File: ExamineGui.java From StaffPlus with GNU General Public License v3.0 | 5 votes |
public ExamineGui(Player player, Player targetPlayer, String title) { super(SIZE, title); setInventoryContents(targetPlayer); if(options.modeExamineFood >= 0) { setItem(options.modeExamineFood, foodItem(targetPlayer), null); } if(options.modeExamineIp >= 0) { setItem(options.modeExamineIp, ipItem(targetPlayer), null); } if(options.modeExamineGamemode >= 0) { setItem(options.modeExamineGamemode, gameModeItem(targetPlayer), null); } if(options.modeExamineInfractions >= 0) { setItem(options.modeExamineInfractions, infractionsItem(userManager.get(targetPlayer.getUniqueId())), null); } setInteractiveItems(targetPlayer); player.openInventory(getInventory()); userManager.get(player.getUniqueId()).setCurrentGui(this); }
Example 9
Source File: IslandCommand.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) { if (!plugin.isRequirementsMet(sender, this, args)) { return true; } if (sender instanceof Player) { Player player = (Player) sender; if (args.length == 0) { player.openInventory(menu.displayIslandGUI(player)); return true; } } return super.onCommand(sender, command, alias, args); }
Example 10
Source File: ChestManager.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public void editChest(ChestType ct, int percent, Player player) { Map<Integer, Inventory> toEdit = getItemMap(ct); String fileName = getFileName(ct); if (!toEdit.containsKey(percent)) { toEdit.put(percent, Bukkit.createInventory(null, 54, fileName + " " + percent)); } player.openInventory(toEdit.get(percent)); }
Example 11
Source File: ScenarioCommandExecutor.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { if (sender instanceof Player){ Player p = ((Player) sender).getPlayer(); // get inventory p.openInventory(sm.getScenarioMainInventory(p.hasPermission("uhc-core.scenarios.edit"))); return true; }else { sender.sendMessage("Only players can use this command."); return true; } }
Example 12
Source File: TeamInventoryCommandExecutor.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { if (!(sender instanceof Player)){ sender.sendMessage("Only players can use this command!"); return true; } Player player = (Player) sender; if (!sm.isActivated(Scenario.TEAMINVENTORY)){ player.sendMessage(Lang.SCENARIO_TEAMINVENTORY_DISABLED); return true; } GameManager gm = GameManager.getGameManager(); UhcPlayer uhcPlayer = gm.getPlayersManager().getUhcPlayer(player); if (args.length == 1 && player.hasPermission("scenarios.teaminventory.other")){ try { uhcPlayer = GameManager.getGameManager().getPlayersManager().getUhcPlayer(args[0]); }catch (UhcPlayerDoesntExistException ex){ player.sendMessage(ChatColor.RED + "That player cannot be found!"); return true; } if (uhcPlayer.getState() != PlayerState.PLAYING){ player.sendMessage(ChatColor.RED + "That player is currently not playing!"); return true; } } if (uhcPlayer.getState() != PlayerState.PLAYING){ player.sendMessage(Lang.SCENARIO_TEAMINVENTORY_ERROR); return true; } player.sendMessage(Lang.SCENARIO_TEAMINVENTORY_OPEN); player.openInventory(uhcPlayer.getTeam().getTeamInventory()); return true; }
Example 13
Source File: UhcItems.java From UhcCore with GNU General Public License v3.0 | 5 votes |
public static void openTeamInviteInventory(Player player){ int maxSlots = 6*9; Inventory inv = Bukkit.createInventory(null, maxSlots, Lang.TEAM_INVENTORY_INVITE_PLAYER); int slot = 0; GameManager gm = GameManager.getGameManager(); List<UhcTeam> teams = gm.getPlayersManager().listUhcTeams(); for(UhcTeam team : teams){ // If team leader is spectating don't add skull to list. if (team.isSpectating()){ continue; } // Only solo players if (!team.isSolo()){ continue; } // Don't show self if (team.getLeader().getUuid().equals(player.getUniqueId())){ continue; } if(slot < maxSlots){ UhcPlayer leader = team.getLeader(); ItemStack item = VersionUtils.getVersionUtils().createPlayerSkull(leader.getName(), leader.getUuid()); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(ChatColor.GREEN + leader.getName()); item.setItemMeta(meta); inv.setItem(slot, item); slot++; } } inv.setItem(maxSlots-1, GameItem.TEAM_INVITE_PLAYER_SEARCH.getItem()); player.openInventory(inv); }
Example 14
Source File: CSGO.java From Crazy-Crates with MIT License | 5 votes |
public static void openCSGO(Player player, Crate crate, KeyType keyType, boolean checkHand) { Inventory inv = Bukkit.createInventory(null, 27, Methods.sanitizeColor(crate.getFile().getString("Crate.CrateName"))); setGlass(inv); for (int i = 9; i > 8 && i < 18; i++) { inv.setItem(i, crate.pickPrize(player).getDisplayItem()); } player.openInventory(inv); if (cc.takeKeys(1, player, crate, keyType, checkHand)) { startCSGO(player, inv, crate); } else { Methods.failedToTakeKey(player, crate); cc.removePlayerFromOpeningList(player); } }
Example 15
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 16
Source File: LogCommand.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
@Override protected boolean doExecute(String alias, Player player, PlayerInfo pi, IslandInfo island, Map<String, Object> data, String... args) { player.openInventory(menu.displayLogGUI(player)); return true; }
Example 17
Source File: Preview.java From Crazy-Crates with MIT License | 4 votes |
public static void openPreview(Player player, Crate crate) { playerCrate.put(player.getUniqueId(), crate); player.openInventory(crate.getPreview(player)); }
Example 18
Source File: Buildable.java From civcraft with GNU General Public License v2.0 | 4 votes |
public static void buildVerifyStatic(Player player, ConfigBuildableInfo info, Location centerLoc, CallbackInterface callback) throws CivException { Resident resident = CivGlobal.getResident(player); /* Look for any custom template perks and ask the player if they want to use them. */ LinkedList<Perk> perkList = resident.getPersonalTemplatePerks(info); if (perkList.size() != 0) { /* Store the pending buildable. */ resident.pendingBuildableInfo = info; resident.pendingCallback = callback; /* Build an inventory full of templates to select. */ Inventory inv = Bukkit.getServer().createInventory(player, CivTutorial.MAX_CHEST_SIZE*9); ItemStack infoRec = LoreGuiItem.build("Default "+info.displayName, ItemManager.getId(Material.WRITTEN_BOOK), 0, CivColor.Gold+"<Click To Build>"); infoRec = LoreGuiItem.setAction(infoRec, "BuildWithDefaultPersonalTemplate"); inv.addItem(infoRec); for (Perk perk : perkList) { infoRec = LoreGuiItem.build(perk.getDisplayName(), perk.configPerk.type_id, perk.configPerk.data, CivColor.Gold+"<Click To Build>", CivColor.Gray+"Provided by: "+CivColor.LightBlue+"Yourself :)"); infoRec = LoreGuiItem.setAction(infoRec, "BuildWithPersonalTemplate"); infoRec = LoreGuiItem.setActionData(infoRec, "perk", perk.getIdent()); inv.addItem(infoRec); player.openInventory(inv); } /* We will resume by calling buildPlayerPreview with the template when a gui item is clicked. */ return; } String path = Template.getTemplateFilePath(info.template_base_name, Template.getDirection(player.getLocation()), TemplateType.STRUCTURE, "default"); Template tpl; try { tpl = Template.getTemplate(path, player.getLocation()); } catch (IOException e) { e.printStackTrace(); return; } centerLoc = repositionCenterStatic(centerLoc, info, tpl.dir(), tpl.size_x, tpl.size_z); //validate(player, null, tpl, centerLoc, callback); TaskMaster.asyncTask(new StructureValidator(player, tpl.getFilepath(), centerLoc, callback), 0); }
Example 19
Source File: BasicGUIOpener.java From CratesPlus with GNU General Public License v3.0 | 4 votes |
@Override public void doReopen(Player player, Crate crate, Location location) { player.openInventory(guis.get(player.getUniqueId())); }
Example 20
Source File: Preview.java From Crazy-Crates with MIT License | 4 votes |
public static void openPreview(Player player) { player.openInventory(playerCrate.get(player.getUniqueId()).getPreview(player)); }