/** * Gets the list of players viewing the primary (upper) inventory involved * in this event * * @return A list of people viewing. */ public List<HumanEntity> getViewers() { return transaction.getTopInventory().getViewers(); }
@Override public List<HumanEntity> getViewers() { return base.getViewers(); }
@Override public List<HumanEntity> getViewers() { return base.getViewers(); }
@Override public List<MCHumanEntity> getViewers() { List<MCHumanEntity> retn = new ArrayList<>(); for(HumanEntity human : i.getViewers()) { retn.add(new BukkitMCHumanEntity((human))); } return retn; }
@Override public List<HumanEntity> getViewers() { if (minecraftInventory == null) { return Collections.emptyList(); } return minecraftInventory.getBukkitInventory().getViewers(); }
public void closeAll() { for (HumanEntity entity : ImmutableList.copyOf(inventory.getViewers())) { entity.closeInventory(); } }
/** * Gets the list of players viewing the primary (upper) inventory involved * in this event * * @return A list of people viewing. */ public List<HumanEntity> getViewers() { return transaction.getTopInventory().getViewers(); }
@Override public void updateViewers() { for(HumanEntity human : i.getViewers()) { if(human instanceof Player) { ((Player) human).updateInventory(); } } }
public static void replaceInventory(Inventory oldInv, Inventory newInv) { // getViewers() is updated as we remove players, so we need to make a copy for (HumanEntity entity : ImmutableList.copyOf(oldInv.getViewers())) { entity.openInventory(newInv); } }
public void close() { for(HumanEntity human: new ArrayList<>(toInventory().getViewers())) { human.closeInventory(); } }
public void close() { for(HumanEntity human: new ArrayList<>(toInventory().getViewers())) { human.closeInventory(); } }
public static void scheduleUpdate(Inventory inventory) { for (HumanEntity humanEntity : inventory.getViewers()) { if (humanEntity instanceof Player) { new PlayerUpdateInventoryTask((Player) humanEntity).runTask(mcMMO.p); } } } }
public void clearInventory(Location l) { BlockMenu menu = getInventory(l); for (HumanEntity human: new ArrayList<>(menu.toInventory().getViewers())) { human.closeInventory(); } inventories.get(l).delete(l); inventories.remove(l); }
@Override public double[] getShape(final BlockCache blockCache, final World world, final int x, final int y, final int z) { final Block block = world.getBlockAt(x, y, z); final BlockState state = block.getState(); //final BlockData blockData = state.getBlockData(); if (state instanceof Container) { if (!((Container) state).getInventory().getViewers().isEmpty()) { return new double[] {0.0, 0.0, 0.0, 1.0, 1.5, 1.0}; } } return new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0}; }
public void saveVault(Player player, Inventory inventory) { if (plugin.getInVault().containsKey(player.getUniqueId().toString())) { Inventory inv = Bukkit.createInventory(null, 6 * 9); inv.setContents(inventory.getContents().clone()); if (inventory.getViewers().size() == 1) { VaultViewInfo info = plugin.getInVault().get(player.getUniqueId().toString()); vaultManager.saveVault(inv, info.getVaultName(), info.getNumber()); plugin.getOpenInventories().remove(info.toString()); } plugin.getInVault().remove(player.getUniqueId().toString()); } }
@Override public void onDisable() { for (Player player : Bukkit.getOnlinePlayers()) { if (this.inVault.containsKey(player.getUniqueId().toString())) { Inventory inventory = player.getOpenInventory().getTopInventory(); if (inventory.getViewers().size() == 1) { VaultViewInfo info = this.inVault.get(player.getUniqueId().toString()); VaultManager.getInstance().saveVault(inventory, player.getUniqueId().toString(), info.getNumber()); this.openInventories.remove(info.toString()); // try this to make sure that they can't make further edits if the process hangs. player.closeInventory(); } this.inVault.remove(player.getUniqueId().toString()); debug("Closing vault for " + player.getName()); player.closeInventory(); } } if (getConfig().getBoolean("cleanup.enable", false)) { saveSignsFile(); } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent e) { if (!cm.isAntiChestViewerDupe) { return; } if (e.getBlock() != null && e.getBlock().getState() instanceof InventoryHolder) { InventoryHolder inventory = (InventoryHolder) e.getBlock().getState(); // 如果容器正在使用则不允许被破坏,以防止利用漏洞刷物品 if (!inventory.getInventory().getViewers().isEmpty()) { e.setCancelled(true); e.getPlayer().sendMessage(i18n.tr("antiChestViewerDupeMessage")); } } } }