当前位置: 首页>>代码示例>>Java>>正文


Java Player.updateInventory方法代码示例

本文整理汇总了Java中org.bukkit.entity.Player.updateInventory方法的典型用法代码示例。如果您正苦于以下问题:Java Player.updateInventory方法的具体用法?Java Player.updateInventory怎么用?Java Player.updateInventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Player的用法示例。


在下文中一共展示了Player.updateInventory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onUseBackpack

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST)
public void onUseBackpack(PlayerInteractEvent event) {
    ItemStack item = event.getItem();
    if (!event.hasItem() || !ItemUtils.hasTag(item, ItemUtils.BACKPACK_TAG)) {
        return;
    }

    Player player = event.getPlayer();
    Action action = event.getAction();
    if ((action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
            && InventoryManager.isQuickSlot(player.getInventory().getHeldItemSlot())) {
        BackpackManager.open(player, item);
    }

    event.setCancelled(true);
    player.updateInventory();
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:19,代码来源:BackpackListener.java

示例2: executePlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(final Player p, PlayerDataRPG pd, String[] args) {
    if (args.length != 1) {
        p.sendMessage(ChatColor.RED + "Incorrect command format!");
        p.sendMessage(ChatColor.RED + ">> /swap <name>");
    } else if (args.length == 1) {
        String s = args[0];
        Player target = plugin.getServer().getPlayerExact(s);
        if (target != null && target.isOnline()) {
            ItemStack mainhand = target.getInventory().getItemInMainHand();
            ItemStack offhand = target.getInventory().getItemInOffHand();
            target.getInventory().setItemInMainHand(offhand);
            target.getInventory().setItemInOffHand(mainhand);
            target.updateInventory();
            p.sendMessage("Swapped items for target.");
            target.sendMessage("Your main and offhand were swapped by " + p.getName() + ".");
        } else {
            p.sendMessage(ChatColor.RED + "Could not find online player '" + s + "'.");
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:22,代码来源:SwapCommand.java

示例3: stopSpectating

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void stopSpectating(Player player, boolean sendMsg) {
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    profile.getSpectatingMatch().getSpectators().remove(player.getUniqueId());
    profile.setStatus(PlayerStatus.LOBBY);
    profile.setSpectatingMatch(null);

    GameUtils.resetPlayer(player);

    player.getInventory().setContents(GameUtils.getLobbyInventory());
    player.updateInventory();
    player.setAllowFlight(false);
    player.setShowEntities(new ArrayList<>());

    ManagerHandler.getConfig().teleportToSpawn(player);
    ManagerHandler.getEntityHider().showAllPlayers(player);

    if (sendMsg) {
        player.sendMessage(ChatColor.RED + "You are no longer spectating the match.");
    }
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:22,代码来源:SpectateManager.java

示例4: finishEditing

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void finishEditing(Player player) {
    this.editKits.remove(player.getUniqueId());

    ManagerHandler.getEntityHider().showAllPlayers(player);
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);
    profile.setStatus(PlayerStatus.LOBBY);

    GameUtils.resetPlayer(player);
    player.updateInventory();

    new BukkitRunnable() {
        public void run() {
            player.getInventory().setContents(GameUtils.getLobbyInventory());
            player.updateInventory();
        }
    }.runTaskLater(PracticePlugin.getInstance(), 2L);

    ManagerHandler.getConfig().teleportToSpawn(player);
    player.sendMessage(ChatColor.GRAY + "You have been returned to spawn.");
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:21,代码来源:KitEditManager.java

示例5: setPage

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Sets a specific GUI page
 *
 * @param player  player
 * @param page    page
 * @param petMeta meta
 */
public void setPage(Player player, GUIPage page, PetMeta petMeta) {
    if (!this.manager.inventories.containsKey(player)) {
        return;
    }
    final Inventory inventory = this.manager.inventories.get(player);
    inventory.clear();
    if (page == GUIPage.MAIN) {
        this.setOtherItems(player, inventory, petMeta, GUIPage.MAIN);
        this.manager.pages.put(player, new GuiPageContainer(GUIPage.MAIN, null));
    } else if (page == GUIPage.WARDROBE) {
        this.setOtherItems(player, inventory, petMeta, page);
        this.manager.pages.put(player, new GuiPageContainer(page, this.manager.pages.get(player)));
    } else {
        this.setListAble(player, page, 0);
    }
    final GUIItemContainer backGuiItemContainer = Config.getInstance().getGuiItemsController().getGUIItemByName("back");
    inventory.setItem(backGuiItemContainer.getPosition(), (ItemStack) backGuiItemContainer.generate(player));
    this.fillEmptySlots(inventory);
    player.updateInventory();
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:28,代码来源:GUI.java

示例6: onCommand

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
protected void onCommand(CommandSender sender, String[] args) {
    Player player = (Player) sender;
    for (int i = 0; i < 36; i++) {
        ItemStack item = player.getInventory().getItem(i);
        if (Utils.isAir(item))
            continue;

        ItemStack c = CONDENSE.keySet().stream().filter(item::isSimilar).findAny().orElse(null);
        List<ItemStack> condenseResults = new ArrayList<>();
        if (c != null) {
            ItemStack add = new ItemStack(CONDENSE.get(c), 0);
            while (item.getAmount() >= c.getAmount()) { // If there's enough to equal one condensed item.
                item.setAmount(item.getAmount() - c.getAmount()); //Remove the items needed to create a condensed item.
                add.setAmount(add.getAmount() + 1); // Add 1 to the condensed item.
            }
            condenseResults.add(add);
        }

        addItem(player, item, i); // Add the leftover ingredient.
        condenseResults.forEach(condense -> addItem(player, condense, -1));
    }
    player.updateInventory();
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:25,代码来源:CommandCondense.java

示例7: onCreateParty

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onCreateParty(PlayerCreatePartyEvent event) {
    Player player = event.getPlayer();
    ManagerHandler.getPartyManager().addParty(event.getParty());

    GameUtils.resetPlayer(player);

    player.getInventory().setContents(GameUtils.getPartyLeaderInventory());
    player.updateInventory();
    player.sendMessage(ChatColor.GRAY + "You have created a new party.");
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:12,代码来源:PartyListener.java

示例8: cancelMatch

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void cancelMatch(String cancelReason) {
    this.sendMessage(ChatColor.DARK_RED + "The match has been canceled for: " + ChatColor.RED + cancelReason);

    for (Player player : getPlayers()) {
    	if (this.leftMatch.contains(player.getUniqueId())) continue;

    	GameUtils.resetPlayer(player);

        PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);
        profile.setStatus(PlayerStatus.LOBBY);
        profile.setCurrentMatch(null);

        if (profile.getParty() != null) {
        	if (profile.getParty().getLeader() == player) {
                player.getInventory().setContents(GameUtils.getPartyLeaderInventory());
        	}
        	else {
                player.getInventory().setContents(GameUtils.getPartyMemberInventory());
        	}
        }
        else {
            player.getInventory().setContents(GameUtils.getLobbyInventory());
        }

        player.setMaximumNoDamageTicks(19);
        player.setAllowFlight(false);
        player.updateInventory();

        ManagerHandler.getEntityHider().showAllPlayers(player);
        ManagerHandler.getConfig().teleportToSpawn(player);
        ManagerHandler.getScoreboardHandler().getPlayerBoard(player.getUniqueId()).addUpdates(getPlayers());
    }

    cleanSpectators();

    ManagerHandler.getMatchManager().getMatches().remove(this.identifier);

    this.matchStatus = MatchStatus.CANCELED;
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:41,代码来源:FfaMatch.java

示例9: handleRewards

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void handleRewards(Player p, PlayerDataRPG pd) {
    ArrayList<ItemStack> list = new ArrayList<ItemStack>();
    for (DungeonReward dr : this.rewardsList) {
        list.addAll(dr.roll());
    }
    if (RUtils.hasEmptySpaces(p, list.size())) {
        if (rewarded.contains(p.getName())) {
            p.sendMessage(ChatColor.RED + "You have already claimed your rewards for this dungeon run!");
        } else {
            p.sendMessage("");
            p.sendMessage("");
            p.sendMessage(ChatColor.GRAY + "> " + ChatColor.AQUA + ChatColor.BOLD + "Dungeon rewards received!");
            for (ItemStack i : list) {
                p.sendMessage(ChatColor.GRAY + ">> " + ChatColor.WHITE + "You received " + i.getItemMeta().getDisplayName() + ChatColor.WHITE + ".");
                p.getInventory().addItem(i);
            }
            p.updateInventory();
            rewarded.add(p.getName());
        }
        p.sendMessage(ChatColor.GRAY + "> " + ChatColor.GREEN + "Leave the dungeon by talking to the " + ChatColor.RED + "Dungeon Master" + ChatColor.GREEN + ".");
        if (this.dungeonSpawn != null)
            p.teleport(this.dungeonSpawn);
        else
            p.teleport(this.dungeonMaster.getTPLoc());
    } else {
        p.sendMessage("");
        p.sendMessage("");
        p.sendMessage(ChatColor.GRAY + "> " + ChatColor.RED + ChatColor.BOLD + "Not enough inventory space!");
        p.sendMessage(ChatColor.GRAY + "> " + ChatColor.RED + "You need " + ChatColor.YELLOW + list.size() + ChatColor.RED + " inventory spaces for your dungeon rewards.");
        p.sendMessage(ChatColor.GRAY + "> " + ChatColor.RED + "Please clear out some space and try again.");
        givenRewards.put(p.getUniqueId(), list);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:34,代码来源:Dungeon.java

示例10: startEditing

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void startEditing(Player player, Ladder ladder) {
    this.editKits.put(player.getUniqueId(), ladder);

    ManagerHandler.getEntityHider().hideAllPlayers(player);
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getStatus() != PlayerStatus.LOBBY) {
        player.sendMessage(ChatColor.RED + "You must be in the lobby to edit your kits.");
        return;
    }

    profile.setStatus(PlayerStatus.EDITING_KITS);

    GameUtils.resetPlayer(player);
    player.updateInventory();

    if (ladder.getDefaultInventory() != null) {
        if (ladder.getDefaultInventory().getArmorContents() != null) {
            player.getInventory().setArmorContents(ladder.getDefaultInventory().getArmorContents());
        }

        if (ladder.getDefaultInventory().getContents() != null) {
            player.getInventory().setContents(ladder.getDefaultInventory().getContents());
        }
    }

    player.updateInventory();

    ManagerHandler.getConfig().teleportToEditor(player);
    player.sendMessage(ChatColor.GRAY + "You are now kits your " + ChatColor.AQUA + ladder.getName() + ChatColor.GRAY + " kits.");
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:32,代码来源:KitEditManager.java

示例11: fillInventory

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void fillInventory(Player p) {
    PlayerInventory inv = p.getInventory();
    for (int i = 0; i <= 35; i++) {
        inv.setItem(i, ItemManager.getForbidden(1));
    }
    for (int i = 2; i <= 4; i++) {
        inv.setItem(i, ItemManager.getForbidden(i + 1));
    }
    flushSkillSelection(p);
    p.updateInventory();
    p.setLevel(0);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:13,代码来源:Utils.java

示例12: onShootWithoutArrows

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onShootWithoutArrows(EntityShootBowEvent event)
{
	if(event.getEntity() instanceof Player)
	{
		Player player = (Player)event.getEntity();
		if(player.getInventory().getItemInMainHand().getType() == event.getBow().getType())
		{
			if
			(
				player.getInventory().getItemInOffHand().getType() == Material.ARROW
				|| player.getInventory().getItemInOffHand().getType() == Material.SPECTRAL_ARROW
				|| player.getInventory().getItemInOffHand().getType() == Material.TIPPED_ARROW
			)
			{
				event.setCancelled(false);
			}
			else
			{
				event.setCancelled(true);
				player.sendMessage(ChatColor.RED + Survival.Words.get("Must load Arrows on off hand"));
				player.updateInventory();
			}
		}
		else
		{
			event.setCancelled(true);
			player.sendMessage(ChatColor.RED + Survival.Words.get("Must use a Bow with main hand"));
			player.updateInventory();
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:34,代码来源:Bow.java

示例13: addToQueue

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void addToQueue(Object object) {
    Party party = (Party) object;

    List<Player> players = party.getPlayers();

    if (players.size() != 2) {
        party.sendMessage(ChatColor.RED + "Tried to put this party in 2v2 queue, but the party size doesn't equal 2 players.");
        return;
    }

    QueueData data = new QueueData(party.getIdentifier(), this, 0);

    for (Player p : players) {
        PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(p);

        profile.setCurrentQueue(this);
        profile.setQueueData(data);
        profile.setStatus(PlayerStatus.QUEUEING);

        if (p.getUniqueId().equals(party.getLeaderUuid())) {
            GameUtils.resetPlayer(p);
            p.getInventory().setContents(GameUtils.getQueueInventory());
            p.updateInventory();
        }

        if (p.getGameMode() == GameMode.CREATIVE) {
            p.setGameMode(GameMode.SURVIVAL);
        }
    }

    this.searchList.offer(data);

    party.sendMessage(ChatColor.GRAY + "You have been added to the " + ChatColor.AQUA + this.ladder.getName() + " 1v1 " + ChatColor.GRAY + "queue, please wait while we find you an opponent.");
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:36,代码来源:TvTQueue.java

示例14: update

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void update(Player player) {
	InventoryView inventory = player.getOpenInventory();
	if (inventory != null) {
        for (int iii = 0; iii < this.optionIcons.length; iii++) {
            if (this.optionIcons[iii] != null) {
                inventory.setItem(iii, this.optionIcons[iii]);
            }
        }
        player.updateInventory();
	}
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:12,代码来源:IconMenu.java

示例15: onInventoryOpen

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onInventoryOpen(InventoryOpenEvent event) {
    final Player player = (Player) event.getPlayer();
    if (!InventoryManager.playerIsLoaded(player)
            || event.getInventory().getType() != InventoryType.WORKBENCH
            || isNotNeededHere(player)) {
        return;
    }

    //noinspection deprecation
    player.updateInventory();
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:13,代码来源:CraftListener.java


注:本文中的org.bukkit.entity.Player.updateInventory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。