@Override public void a(Packet108ButtonClick packet) { if (this.player.activeContainer instanceof ContainerEnchantTable) if (this.player.activeContainer.windowId == packet.a && this.player.activeContainer.c(this.player)) { // Store our pre-event values CraftPlayer player = (CraftPlayer) this.player.getBukkitEntity(); Inventory inventory = getActiveInventory(); ContainerEnchantTable table = (ContainerEnchantTable) this.player.activeContainer; ItemStack initial = table.a.getItem(0).cloneItemStack(); int level = this.player.expLevel; if (table.a(this.player, packet.b)) { ItemStack after = ((ContainerEnchantTable) this.player.activeContainer).a.getItem(0); int afterLevel = this.player.expLevel; SpoutCraftItemStack before = SpoutCraftItemStack.fromItemStack(initial); SpoutCraftItemStack result = SpoutCraftItemStack.fromItemStack(after); InventoryEnchantEvent event = new InventoryEnchantEvent(player, inventory, before, result, level, afterLevel); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { player.setLevel(level); table.a.setItem(0, initial); } else { player.setLevel(event.getLevelAfter()); table.a.setItem(0, SpoutCraftItemStack.createNMSItemStack(event.getResult())); } } this.player.activeContainer.a(); } else super.a(packet); }
@Override public void a(Packet101CloseWindow packet) { Inventory inventory = getActiveInventory(); InventoryCloseEvent event = new InventoryCloseEvent( (Player) this.player.getBukkitEntity(), inventory, getDefaultInventory(), activeLocation); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { IInventory inv = ((CraftInventory) event.getInventory()).getInventory(); if (inventory instanceof TileEntityFurnace) { this.player.a((TileEntityFurnace) inventory); } else if (inventory instanceof TileEntityDispenser) { this.player.a((TileEntityDispenser) inventory); } else if (inventory instanceof InventoryCraftResult && this.player.activeContainer instanceof ContainerWorkbench) { sendPacket(new Packet100OpenWindow(packet.a, 1, "Crafting", 9)); this.player.syncInventory(); } else if (inventory instanceof InventoryCraftResult) { // There is no way to force a player's own inventory back open. } else { this.player.a(inv); } } else { activeInventory = false; activeLocation = null; super.a(packet); } }
@Override public void a(Packet10Flying packet) { manageChunkQueue(true); SpoutPlayer player = SpoutManager.getPlayer(this.getPlayer()); boolean old = ((CraftServer) Bukkit.getServer()).getHandle().server.allowFlight; ((CraftServer) Bukkit.getServer()).getHandle().server.allowFlight = player.canFly(); super.a(packet); ((CraftServer) Bukkit.getServer()).getHandle().server.allowFlight = old; }
@Override public void a(Packet14BlockDig packet) { SpoutCraftPlayer player = (SpoutCraftPlayer) SpoutCraftPlayer.getPlayer(getPlayer()); boolean inAir = false; if (player.canFly() && !player.getHandle().onGround) { inAir = true; player.getHandle().onGround = true; } super.a(packet); if (inAir) { player.getHandle().onGround = false; } }
@Override public void a(Packet18ArmAnimation packet) { if (packet.a == -42) { SpoutCraftPlayer player = (SpoutCraftPlayer) SpoutCraftPlayer.getPlayer(getPlayer()); player.setBuildVersion(1); // Don't know yet, just set above zero try { Spout.getInstance().playerListener.manager.onSpoutcraftEnable((SpoutPlayer) getPlayer()); } catch (Exception e) { e.printStackTrace(); } } else { super.a(packet); } }
@Override public void a(Packet3Chat packet) { String chat = packet.message; if (chat.trim().isEmpty()) { return; } if (!allowReload && chat.equalsIgnoreCase("/reload")) { allowReload = true; SpoutCraftPlayer player = (SpoutCraftPlayer) SpoutCraftPlayer.getPlayer(getPlayer()); if (!player.isSpoutCraftEnabled()) { player.sendMessage(ChatColor.RED + "Spout does not support the /reload command."); player.sendMessage(ChatColor.RED + "Unexpected behavior may occur."); player.sendMessage(ChatColor.RED + "We recommend using /stop and restarting."); player.sendMessage(ChatColor.RED + "Or you can use /spout reload to reload the config."); player.sendMessage( ChatColor.RED + "If you want to use /reload anyway, use the command again."); } else { Label warning = new DecayingLabel( 200, ChatColor.RED + "Spout does not support the /reload command." + "\n" + ChatColor.RED + "Unexpected behavior may occur." + "\n" + ChatColor.RED + "We recommend using /stop and restarting." + " \n" + ChatColor.RED + "Or you can use /spout reload to reload the config." + "\n" + ChatColor.RED + "If you want to use /reload anyway, use the command again."); warning.setX(100).setY(100).setPriority(RenderPriority.Lowest); player.getMainScreen().attachWidget(Spout.getInstance(), warning); } return; } super.a(packet); }
@Override public void a() { syncFlushPacketQueue(); super.a(); }