本文整理匯總了Java中org.bukkit.event.inventory.InventoryCloseEvent類的典型用法代碼示例。如果您正苦於以下問題:Java InventoryCloseEvent類的具體用法?Java InventoryCloseEvent怎麽用?Java InventoryCloseEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
InventoryCloseEvent類屬於org.bukkit.event.inventory包,在下文中一共展示了InventoryCloseEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onInventoryClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
UUID uuid = event.getPlayer().getUniqueId();
if (currentTrade.containsKey(uuid)) {
UUID other = currentTrade.remove(uuid);
Player otherP = plugin.getServer().getPlayer(other);
if (otherP != null && otherP.isOnline() && otherP.isValid()) {
if (currentTrade.containsKey(other))
currentTrade.remove(other);
event.getPlayer().sendMessage(ChatColor.RED + "The trade with " + otherP.getName() + " was canceled.");
otherP.sendMessage(ChatColor.RED + "The trade with " + event.getPlayer().getName() + " was canceled.");
otherP.closeInventory();
} else {
event.getPlayer().sendMessage(ChatColor.RED + "The trade was canceled.");
}
}
}
示例2: onInventoryClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryClose(InventoryCloseEvent e)
{
if(!(e.getPlayer() instanceof Player))
return;
Inventory inv = e.getInventory();
InventoryHolder holder = inv.getHolder();
if(holder != null && holder instanceof Menu)
{
Menu menu = (Menu) holder;
menu.viewers.remove(e.getPlayer());
if(menu.viewers.size() == 0)
openMenus.remove(menu);
}
}
示例3: onInventoryCloseEvent
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryCloseEvent(InventoryCloseEvent e) {
if (e.getPlayer().getGameMode() == GameMode.SPECTATOR) {
if (e.getInventory().getName().equalsIgnoreCase(wm1.inv.getName())) {
Bukkit.getScheduler().scheduleSyncDelayedTask(SuperiorCraft.plugin, new Runnable() {
@Override
public void run() {
e.getPlayer().openInventory(wm2.inv);
}
}, 1);
}
else if (e.getInventory().getName().equalsIgnoreCase(wm2.inv.getName())) {
if (e.getInventory().getName().equalsIgnoreCase(wm2.inv.getName())) {
Bukkit.getScheduler().scheduleSyncDelayedTask(SuperiorCraft.plugin, new Runnable() {
@Override
public void run() {
e.getPlayer().setGameMode(GameMode.ADVENTURE);
}
}, 1);
}
}
}
}
示例4: onInventoryClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onInventoryClose(InventoryCloseEvent e) {
Player p = (Player) e.getPlayer();
if(!inventories.containsKey(p))
return;
SmartInventory inv = inventories.get(p);
inv.getListeners().stream()
.filter(listener -> listener.getType() == InventoryCloseEvent.class)
.forEach(listener -> ((InventoryListener<InventoryCloseEvent>) listener).accept(e));
if(inv.isCloseable()) {
e.getInventory().clear();
inventories.remove(p);
}
else
Bukkit.getScheduler().runTask(plugin, () -> p.openInventory(e.getInventory()));
}
示例5: onBackpackClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onBackpackClose(InventoryCloseEvent event) {
Inventory inventory = event.getInventory();
Player player = (Player) event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)
|| !(inventory.getHolder() instanceof BackpackHolder)) {
return;
}
PlayerWrapper playerWrapper = InventoryManager.get(player);
Backpack backpack = playerWrapper.getBackpack();
if (backpack == null) {
return;
}
backpack.onUse();
playerWrapper.setBackpack(null);
}
示例6: onSupplyDropInventoryClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onSupplyDropInventoryClose(InventoryCloseEvent e) {
Location loc = e.getInventory().getLocation();
Block b = loc.getBlock();
if (b.getType() == Material.CHEST) {
if (core.getSupplyDropManager().isSupplyDrop(b.getLocation())) {
if (core.getSupplyDropManager().isEmpty(loc)) {
core.getSupplyDropManager().removeSupplyDrop(loc);
b.setType(Material.AIR);
loc.getWorld().playSound(loc, Sound.BLOCK_WOOD_BREAK, 1, 1);
}
}
}
}
示例7: onClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onClose(InventoryCloseEvent e) {
Player p = (Player) e.getPlayer();
if (ChatColor.stripColor(e.getInventory().getTitle()).equals("장신구 장착")) {
ItemStack slot1 = e.getInventory().getItem(20);
ItemMeta slot1m = slot1.getItemMeta();
ArrayList list = Effect.effects;
Iterator<Effect> i = list.iterator();
while (i.hasNext()) {
try {
Effect ee = i.next();
String lastWord = slot1m.getLore().get(0).substring(slot1m.getLore().get(0).lastIndexOf(" ")+1);
if (ChatColor.stripColor(ee.getDisplayName()).equals(ChatColor.stripColor(slot1m.getLore().get(0).replace(lastWord,"{0}")))) {
Effect.eventType(p,ee,"summon");
}
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
}
示例8: onClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onClose(InventoryCloseEvent event) {
if (!(event.getInventory().getHolder() instanceof MenuLink))
return;
final VPPlayer player = VanillaPlusCore.getPlayerManager().getPlayer((Player) event.getPlayer());
final MenuLink menu = ((MenuLink) event.getInventory().getHolder());
Bukkit.getScheduler().scheduleSyncDelayedTask(VanillaPlus.getInstance(), new Runnable() {
@Override
public void run() {
if(player.getPlayer().getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING){
menu.getIconMenu().closed(player, menu);
}else{
menu.getIconMenu().changed(player, menu);
}
}
});
}
示例9: onInventoryClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
UUID uuid = event.getPlayer().getUniqueId();
if (invClickables.containsKey(uuid)) {
HashMap<String, HashMap<String, Runnable>> invs = invClickables.get(uuid);
String invName = event.getInventory().getName();
if (invName != null && invs.containsKey(invName)) {
HashMap<String, Runnable> map = invs.remove(invName);
map.clear();
map = null;
}
generalClickables.remove(uuid);
}
if (plugin.getPD((Player) event.getPlayer()) != null)
plugin.getPD((Player) event.getPlayer()).currentModifiableInventory = null;
}
示例10: onClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onClose(InventoryCloseEvent event)
{
final Player player = (Player) event.getPlayer();
User user = userManager.get(player.getUniqueId());
if(user.isFrozen() && options.modeFreezePrompt)
{
new BukkitRunnable()
{
@Override
public void run()
{
new FreezeGui(player, options.modeFreezePromptTitle);
}
}.runTaskLater(StaffPlus.get(), 1L);
return;
}else if(user.getCurrentGui() != null)
{
user.setCurrentGui(null);
}
}
示例11: updateWorth
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void updateWorth(InventoryCloseEvent event) {
// Do nothing if a player did not close the inventory or if chest
// events are disabled.
if (!(event.getPlayer() instanceof Player) || plugin.getSettings().isDisableChestEvents()) {
return;
}
// Get cached values from when chest was opened and add the difference
// to the worth manager.
if (event.getInventory().getHolder() instanceof DoubleChest) {
DoubleChest chest = (DoubleChest) event.getInventory().getHolder();
updateWorth((Chest) chest.getLeftSide());
updateWorth((Chest) chest.getRightSide());
}
if (event.getInventory().getHolder() instanceof Chest) {
updateWorth((Chest) event.getInventory().getHolder());
}
}
示例12: onClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onClose(InventoryCloseEvent event){
Inventory inv = event.getInventory();
if(inv.getName().equals("Equip Inventory")){
Player player = (Player) event.getPlayer();
Account account = new Account(player);
ca.damocles.accountsystem.Character character = account.getLoadedCharacter();
player.getInventory().setHelmet(inv.getItem(1));
character.setEquip(Slot.HELMET, inv.getItem(1));
player.getInventory().setChestplate(inv.getItem(2));
character.setEquip(Slot.CHESTPLATE, inv.getItem(2));
player.getInventory().setLeggings(inv.getItem(6));
character.setEquip(Slot.LEGGINGS, inv.getItem(6));
player.getInventory().setBoots(inv.getItem(7));
character.setEquip(Slot.BOOTS, inv.getItem(7));
character.setEquip(Slot.BELT, inv.getItem(19));
character.setEquip(Slot.GLOVES, inv.getItem(20));
character.setEquip(Slot.RING1, inv.getItem(24));
character.setEquip(Slot.RING2, inv.getItem(25));
character.setEquip(Slot.SPELLBOOK, inv.getItem(37));
character.setEquip(Slot.BANK, inv.getItem(38));
character.setEquip(Slot.RING3, inv.getItem(42));
character.setEquip(Slot.RING4, inv.getItem(43));
}
}
示例13: onInventoryClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryClose(InventoryCloseEvent event){
for(Anvil an : animating){
if(event.getPlayer().equals(an.getPlayer())){
return;
}
}
for(Anvil anvil : anvils){
if(event.getPlayer().equals(anvil.getPlayer())){
event.getPlayer().getInventory().setItemInMainHand(anvil.getItemStack());
anvil.deleteShowItem();
anvils.remove(anvil);
return;
}
}
}
示例14: onInventoryClose
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onInventoryClose(InventoryCloseEvent event)
{
Inventory bottomInventory = event.getView().getBottomInventory();
if(bottomInventory == null) return;
if(bottomInventory.getType() != InventoryType.PLAYER) return;
HumanEntity holder = ((PlayerInventory)bottomInventory).getHolder();
if(!(holder instanceof Player)) return;
Player player = (Player)holder;
PlayerData playerData = PlayerData.FromPlayer(player);
sortPlayerIfEnabled(player, playerData, bottomInventory);
if(player.getGameMode() != GameMode.CREATIVE && Math.random() < .1 && !playerData.isGotDepositAllInfo() && featureEnabled(Features.DepositAll, player))
{
Inventory topInventory = event.getView().getTopInventory();
if(topInventory != null && topInventory.getType() == InventoryType.CHEST)
{
AutomaticInventory.sendMessage(player, TextMode.Instr, Messages.DepositAllAdvertisement);
playerData.setGotDepositAllInfo(true);
}
}
}
示例15: restoreWoolChests
import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void restoreWoolChests(InventoryCloseEvent event) {
HumanEntity human = event.getPlayer();
if (human instanceof Player) {
GamePlayer player = this.game.getGame().getPlayer((Player) human);
if (player == null) {
return;
}
List<GamePlayer> viewers = new ArrayList<>();
for (HumanEntity humanViewer : event.getViewers()) {
if (humanViewer instanceof Player) {
GamePlayer viewer = this.game.getGame().getPlayer((Player) humanViewer);
if (viewer != null) {
viewers.add(viewer);
}
}
}
this.restoreWoolChest(event.getInventory().getHolder(), player, viewers);
}
}