當前位置: 首頁>>代碼示例>>Java>>正文


Java Player.closeInventory方法代碼示例

本文整理匯總了Java中org.bukkit.entity.Player.closeInventory方法的典型用法代碼示例。如果您正苦於以下問題:Java Player.closeInventory方法的具體用法?Java Player.closeInventory怎麽用?Java Player.closeInventory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.Player的用法示例。


在下文中一共展示了Player.closeInventory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onClick

import org.bukkit.entity.Player; //導入方法依賴的package包/類
public static void onClick(Player p, ItemStack item)
{
    if (item.getType() == Material.WOOD_DOOR)
        p.closeInventory();
    if (item.getType() != Material.WOOL)
        return ;
    for (TeamColor color : getColors(AgarMC.get().getGame().getGameType()))
        if (color.getData() == item.getDurability())
        {
            CPlayer cplayer = AgarMC.get().getGame().getCPlayer(p);
            if (cplayer != null)
            {
                cplayer.setColor(color.getChatColor());
                cplayer.updateColor();
                p.sendMessage(ChatColor.YELLOW + "Vous êtes maintenant" + (AgarMC.get().getGame().getGameType() == GameType.TEAMS ? " dans l'équipe" : "") + " : " + color.getDisplayName());
                return ;
            }
        }
}
 
開發者ID:SamaGames,項目名稱:AgarMC,代碼行數:20,代碼來源:TeamSelectorGui.java

示例2: onInventoryClick2

import org.bukkit.entity.Player; //導入方法依賴的package包/類
@EventHandler
public void onInventoryClick2(InventoryClickEvent event) {
	Player player = (Player) event.getWhoClicked();
	ItemStack is = event.getCurrentItem();
	if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
		if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Here Menu - Page 1")) {
			event.setCancelled(true);
            for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {   
                Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
                Location location = player.getLocation();
                if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.YELLOW + " to you."))) {
                    player.closeInventory();
                    targetPlayer.teleport(player);
            		player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + " to you!");
            		player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
            		player.playEffect(location, Effect.ENDER_SIGNAL, 1);
            		targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);	
                }
               }
           }
       }
   }
 
開發者ID:SlamTheHam,項目名稱:UltraCore,代碼行數:23,代碼來源:Events.java

示例3: onClick

import org.bukkit.entity.Player; //導入方法依賴的package包/類
/**
 * Handle the GUI stuff.
 */
@EventHandler
public void onClick(InventoryClickEvent event) {

    Inventory inventory = event.getInventory();
    if (inventory.getTitle().contains("Summary for ")) {
        event.setCancelled(true);

        ItemStack item = event.getCurrentItem();
        Player viewer = (Player) event.getWhoClicked();
        if (item.getType() == Material.IRON_SWORD) {
            Player player = Bukkit.getPlayer(inventory.getTitle().split(" ")[2]);
            if (player == null) {
                viewer.sendMessage(ChatColor.RED + "This player has logged out.");
                viewer.closeInventory();
                return;
            }

            Arc.getArcPlayerManager().scheduleBan(player);
        }

    }

}
 
開發者ID:Vrekt,項目名稱:Arc-v2,代碼行數:27,代碼來源:InventoryListener.java

示例4: handlePlotPurchase

import org.bukkit.entity.Player; //導入方法依賴的package包/類
private void handlePlotPurchase(Player player) {
	player.closeInventory();
	// Already bought the upgrade
	if(!GodTokensInventory.canBuyPlot(player)) {
		player.sendMessage(Lang.HEADERS_TOKENS.toString() + "No more upgrades!");
		return;
	}
	if(!plugin.getPlayerManager().hasTokens(player, 25)) {
		player.sendMessage(Lang.HEADERS_TOKENS.toString()
				+ Lang.TOKENS_SHOP_NOT_ENOUGH.toString()
					.replaceAll("%d", "25"));
		return;
	}
	
	plugin.getPlayerManager().setTokens(player, plugin.getPlayerManager().getTokens(player) - 25);
	Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() + " remove plots.plot.1");
	Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() + " add plots.plot.2");
	player.sendMessage(Lang.HEADERS_TOKENS.toString() + "You now have one more available plot!");
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:20,代碼來源:GodTokensInventoryListener.java

示例5: onInventoryClick

import org.bukkit.entity.Player; //導入方法依賴的package包/類
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
	Player p = (Player) event.getWhoClicked();
	Inventory inv = event.getInventory();
	if (Chat.stripColor(inv.getTitle()).equalsIgnoreCase("Voting Panel")) {
		event.setCancelled(true);
		if (event.getRawSlot() > 9 || event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR)
			return;
		ItemStack i = event.getCurrentItem();
		Map m = Map.getByTitle(Chat.stripColor(i.getItemMeta().getDisplayName()));
		if (m != null) {
			m.addVote(p);
			p.closeInventory();
			event.setCancelled(true);
		}
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:18,代碼來源:VotePanelEvents.java

示例6: handleApplePurchase

import org.bukkit.entity.Player; //導入方法依賴的package包/類
private void handleApplePurchase(Player player) {
	player.closeInventory();
	if(!plugin.getPlayerManager().hasTokens(player, 1)) {
		player.sendMessage(Lang.HEADERS_TOKENS.toString()
				+ Lang.TOKENS_SHOP_NOT_ENOUGH.toString()
					.replaceAll("%d", "1"));
		return;
	}
	
	plugin.getPlayerManager().withdrawTokens(player, 1);
	player.getInventory().addItem(
		ItemStackGenerator.createItem(Material.GOLDEN_APPLE, 0, 1,
				ChatColor.LIGHT_PURPLE + "" + ChatColor.UNDERLINE + "Odins Apple",
				Arrays.asList(ChatColor.GRAY + "Genuine apple of Odin")));
	player.sendMessage(Lang.HEADERS_TOKENS.toString() + "You've bought a Odins Apple!");
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:17,代碼來源:GodTokensInventoryListener.java

示例7: reset

import org.bukkit.entity.Player; //導入方法依賴的package包/類
public void reset() {
    final Player bukkit = getBukkit();
    bukkit.closeInventory();
    clearInventory();
    bukkit.setExhaustion(0);
    bukkit.setFallDistance(0);
    bukkit.setFireTicks(0);
    bukkit.setFoodLevel(20); // full
    bukkit.setMaxHealth(20);
    bukkit.setHealth(bukkit.getMaxHealth());
    bukkit.setAbsorption(0);
    bukkit.setLevel(0);
    bukkit.setExp(0); // clear xp
    bukkit.setSaturation(5); // default
    bukkit.setFastNaturalRegeneration(false);
    bukkit.setSlowNaturalRegeneration(true);
    bukkit.setAllowFlight(false);
    bukkit.setFlying(false);
    bukkit.setSneaking(false);
    bukkit.setSprinting(false);
    bukkit.setFlySpeed(0.1f);
    bukkit.setKnockbackReduction(0);
    bukkit.setWalkSpeed(WalkSpeedKit.BUKKIT_DEFAULT);
    AttributeUtils.removeAllModifiers(bukkit);
    resetPotions();

    // we only reset bed spawn here so people don't have to see annoying messages when they respawn
    bukkit.setBedSpawnLocation(null);

    match.callEvent(new PlayerResetEvent(this));
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:32,代碼來源:MatchPlayer.java

示例8: open

import org.bukkit.entity.Player; //導入方法依賴的package包/類
public static void open(Player player) {
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getParty() == null) {
        player.sendMessage(ChatColor.RED + "You must be in a party to open the event menu.");
        return;
    }

    if (profile.getParty().getPlayers().size() < 2) {
        player.sendMessage(ChatColor.RED + "You must have more than 2 players in your party to start an event.");
        player.closeInventory();
        return;
    }

    Inventory inv = Bukkit.createInventory(null, ManagerHandler.getLadderManager().getLadderAmount(), ChatColor.AQUA + "Party Events - Select an event");
    inv.setItem(2, new ItemBuilder(Material.DIAMOND, ChatColor.AQUA + "Team Deathmatch", ChatColor.GRAY + "Click to select the", ChatColor.GRAY + "Team Deathmatch event.").getItem());
    inv.setItem(6, new ItemBuilder(Material.DIAMOND, ChatColor.AQUA + "Free-for-All", ChatColor.GRAY + "Click to select the", ChatColor.GRAY + "Free-for-All event.").getItem());

    player.openInventory(inv);
}
 
開發者ID:ijoeleoli,項目名稱:ZorahPractice,代碼行數:21,代碼來源:PartyEventMenu.java

示例9: close

import org.bukkit.entity.Player; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void close(Player player) {
    InventoryManager manager = SmartInvsPlugin.manager();

    listeners.stream()
            .filter(listener -> listener.getType() == InventoryCloseEvent.class)
            .forEach(listener -> ((InventoryListener<InventoryCloseEvent>) listener)
                    .accept(new InventoryCloseEvent(player.getOpenInventory())));

    manager.setInventory(player, null);
    player.closeInventory();

    manager.setContents(player, null);
}
 
開發者ID:MinusKube,項目名稱:SmartInvs,代碼行數:15,代碼來源:SmartInventory.java

示例10: closeGui

import org.bukkit.entity.Player; //導入方法依賴的package包/類
@Override
public void closeGui(Player player)
{
    if (this.playersGui.containsKey(player.getUniqueId()))
    {
        player.closeInventory();
        this.playersGui.remove(player.getUniqueId());
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:10,代碼來源:GuiManager.java

示例11: handleItemRepair

import org.bukkit.entity.Player; //導入方法依賴的package包/類
private void handleItemRepair(Player player) {
	player.closeInventory();
	if(!plugin.getPlayerManager().hasTokens(player, 1)) {
		player.sendMessage(Lang.HEADERS_TOKENS.toString()
				+ Lang.TOKENS_SHOP_NOT_ENOUGH.toString()
					.replaceAll("%d", "1"));
		return;
	}
	
	player.sendMessage(Lang.HEADERS_TOKENS.toString() + "Your item in hand was successfully repaired!");
	plugin.getPlayerManager().withdrawTokens(player, 1);
	player.getInventory().getItemInMainHand().setDurability((short)0);
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:14,代碼來源:GodTokensInventoryListener.java

示例12: open

import org.bukkit.entity.Player; //導入方法依賴的package包/類
/**
 * Opens the gui for a player
 *
 * @param player player
 */
public void open(Player player) {
    if (!this.manager.inventories.containsKey(player)) {
        if (player.getOpenInventory() != null) {
            player.closeInventory();
        }
        if (this.manager.headDatabasePlayers.contains(player)) {
            this.manager.headDatabasePlayers.remove(player);
        }
        final Inventory inventory = Bukkit.getServer().createInventory(player, 54, Config.getInstance().getGUITitle());
        this.manager.inventories.put(player, inventory);
        player.openInventory(inventory);
    }
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:19,代碼來源:GUI.java

示例13: handleCratePurchase

import org.bukkit.entity.Player; //導入方法依賴的package包/類
private void handleCratePurchase(Player player) {
	player.closeInventory();
	if(!plugin.getPlayerManager().hasTokens(player, 8)) {
		player.sendMessage(Lang.HEADERS_TOKENS.toString()
				+ Lang.TOKENS_SHOP_NOT_ENOUGH.toString()
					.replaceAll("%d", "8"));
		return;
	}
	plugin.getPlayerManager().setTokens(player, plugin.getPlayerManager().getTokens(player) - 8);
	Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "cr givekey " + player.getName() + " key 1");
	player.sendMessage(Lang.HEADERS_TOKENS.toString() + "You've bought a crate!");
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:13,代碼來源:GodTokensInventoryListener.java

示例14: openGui

import org.bukkit.entity.Player; //導入方法依賴的package包/類
/**
 * Open a given GUI to a given Player
 *
 * @param player The player to show the GUI
 * @param gui The AbstractGui to show
 */
public void openGui(Player player, AbstractGui gui)
{
    if(this.playersGui.containsKey(player.getUniqueId()))
    {
        player.closeInventory();
        this.playersGui.remove(player.getUniqueId());
    }

    this.playersGui.put(player.getUniqueId(), gui);
    gui.display(player);
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:18,代碼來源:GameGuiManager.java

示例15: openGui

import org.bukkit.entity.Player; //導入方法依賴的package包/類
@Override
public void openGui(Player player, AbstractGui gui)
{
    if (this.playersGui.containsKey(player.getUniqueId()))
    {
        player.closeInventory();
        this.playersGui.remove(player.getUniqueId());
    }

    this.playersGui.put(player.getUniqueId(), gui);
    gui.display(player);
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:13,代碼來源:GuiManager.java


注:本文中的org.bukkit.entity.Player.closeInventory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。