/** @unimplemented FIXME */ public static Container callInventoryOpenEvent(EntityPlayer player, Container container) { // if (player.craftingInventory != player.inventory) { // fire INVENTORY_CLOSE if one already // open // player.netServerHandler.handleContainerClose(new // Packet101CloseWindow(player.activeContainer.windowId)); // } BukkitServer server = (BukkitServer) Bukkit.getServer(); BukkitPlayer craftPlayer = (BukkitPlayer) getBukkitEntity(player); // player.craftingInventory.(container, craftPlayer); int i = 0; InventoryBasic inv = new InventoryBasic("", container.getInventory().size()); for (Object j : container.inventoryItemStacks) { net.minecraft.src.ItemStack v = (net.minecraft.src.ItemStack) j; inv.setInventorySlotContents(i, v); i++; } InventoryOpenEvent event = new InventoryOpenEvent( new BukkitInventoryView( (HumanEntity) getBukkitEntity(player), new BukkitInventory(inv), container)); server.getPluginManager().callEvent(event); if (event.isCancelled()) { container.setPlayerIsPresent(craftPlayer.getHandle(), false); return null; } return container; }
public static PlayerDeathEvent callPlayerDeathEvent( EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) { BukkitPlayer entity = (BukkitPlayer) getBukkitEntity(victim); PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.experienceValue, 0, deathMessage); org.bukkit.World world = entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); /*victim.keepLevel = event.getKeepLevel(); victim.newLevel = event.getNewLevel(); victim.newTotalExp = event.getNewTotalExp(); victim.expToDrop = event.getDroppedExp(); victim.newExp = event.getNewExp();*/ for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { if (stack == null || stack.getType() == Material.AIR) continue; if (stack instanceof BukkitItemStack) { // Use the internal item to preserve possible data. victim.dropItemWithOffset(stack.getTypeId(), stack.getAmount(), 0.0F); } else { world.dropItemNaturally(entity.getLocation(), stack); } } return event; }
@Override public boolean isOp() { if (isConsole) return true; return realPlayer.isOp(); }
@Override public void recalculatePermissions() { if (isConsole) cons.recalculatePermissions(); else realPlayer.recalculatePermissions(); }
@Override public Set<PermissionAttachmentInfo> getEffectivePermissions() { if (isConsole) return cons.getEffectivePermissions(); else return realPlayer.getEffectivePermissions(); }
@Override public PermissionAttachment addAttachment(Plugin plugin, int ticks) { return isConsole ? cons.addAttachment(plugin, ticks) : realPlayer.addAttachment(plugin, ticks); }
@Override public void removeAttachment(PermissionAttachment attachment) { if (isConsole) cons.removeAttachment(attachment); else realPlayer.removeAttachment(attachment); }
@Override public boolean hasPermission(Permission perm) { return isConsole ? cons.hasPermission(perm) : realPlayer.hasPermission(perm); }
@Override public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) { return isConsole ? cons.addAttachment(plugin, name, value, ticks) : realPlayer.addAttachment(plugin, name, value, ticks); }
@Override public boolean isPermissionSet(Permission perm) { return isConsole ? cons.isPermissionSet(perm) : realPlayer.isPermissionSet(perm); }
@Override public boolean hasPermission(String name) { return isConsole ? cons.hasPermission(name) : realPlayer.hasPermission(name); }
@Override public boolean isPermissionSet(String name) { return isConsole ? cons.isPermissionSet(name) : realPlayer.isPermissionSet(name); }
@Override public String getName() { if (isConsole) return cons.getName(); return realPlayer.getName(); }
@Override public Server getServer() { if (isConsole) return cons.getServer(); return realPlayer.getServer(); }
@Override public void sendMessage(String[] messages) { if (isConsole) cons.sendMessage(messages); else realPlayer.sendMessage(messages); }
@Override public void setOp(boolean value) { if (isConsole) throw new IllegalArgumentException("Can't change op status of console!"); realPlayer.setOp(value); }