本文整理汇总了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 ;
}
}
}
示例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);
}
}
}
}
}
示例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);
}
}
}
示例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!");
}
示例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);
}
}
}
示例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!");
}
示例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));
}
示例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);
}
示例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);
}
示例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());
}
}
示例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);
}
示例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);
}
}
示例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!");
}
示例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);
}
示例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);
}