org.bukkit.entity.Player#openInventory ( )源码实例Demo

下面列出了org.bukkit.entity.Player#openInventory ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Shopkeepers   文件: BookPlayerShopkeeper.java
@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;
}
 
源代码2 项目: IridiumSkyblock   文件: WarpsCommand.java
@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)));
        }
    }
}
 
源代码3 项目: uSkyBlock   文件: PartyCommand.java
@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);
}
 
源代码4 项目: SuperVanish   文件: SilentOpenChest.java
@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);
}
 
源代码5 项目: IridiumSkyblock   文件: TopCommand.java
@Override
public void execute(CommandSender sender, String[] args) {
    Player p = (Player) sender;
    p.openInventory(IridiumSkyblock.topGUI.getInventory());
}
 
源代码6 项目: UhcCore   文件: UhcItems.java
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);
}
 
源代码7 项目: Crazy-Crates   文件: CSGO.java
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);
    }
}
 
源代码8 项目: IridiumSkyblock   文件: TransferCommand.java
@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)));
    }
}
 
源代码9 项目: UhcCore   文件: TeamInventoryCommandExecutor.java
@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;
}
 
源代码10 项目: UhcCore   文件: ScenarioCommandExecutor.java
@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;
    }
}
 
源代码11 项目: SkyWarsReloaded   文件: ChestManager.java
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));
}
 
源代码12 项目: uSkyBlock   文件: IslandCommand.java
@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);
}
 
源代码13 项目: StaffPlus   文件: ExamineGui.java
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);
}
 
源代码14 项目: IridiumSkyblock   文件: MissionsCommand.java
@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)));
    }
}
 
源代码15 项目: Crazy-Crates   文件: Preview.java
public static void openPreview(Player player) {
    player.openInventory(playerCrate.get(player.getUniqueId()).getPreview(player));
}
 
源代码16 项目: CratesPlus   文件: BasicGUIOpener.java
@Override
public void doReopen(Player player, Crate crate, Location location) {
    player.openInventory(guis.get(player.getUniqueId()));
}
 
源代码17 项目: civcraft   文件: Buildable.java
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);
}
 
源代码18 项目: Crazy-Crates   文件: Preview.java
public static void openPreview(Player player, Crate crate) {
    playerCrate.put(player.getUniqueId(), crate);
    player.openInventory(crate.getPreview(player));
}
 
源代码19 项目: CardinalPGM   文件: SpectatorTools.java
@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();
        }
    }
}
 
源代码20 项目: uSkyBlock   文件: LogCommand.java
@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;
}