diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-11-06 06:05:28 -0600 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2012-11-13 16:09:52 -0600 |
commit | 7f7192f8fd8357e664e7e2d6e7c5f65fd0fcd2f7 (patch) | |
tree | 843902ff94d82e86f40d7e0af1ac838fee859e75 /src/main/java/org/bukkit | |
parent | a0c3b4f9d1b403fa64230f22b5dd3222181ba646 (diff) | |
download | craftbukkit-7f7192f8fd8357e664e7e2d6e7c5f65fd0fcd2f7.tar craftbukkit-7f7192f8fd8357e664e7e2d6e7c5f65fd0fcd2f7.tar.gz craftbukkit-7f7192f8fd8357e664e7e2d6e7c5f65fd0fcd2f7.tar.lz craftbukkit-7f7192f8fd8357e664e7e2d6e7c5f65fd0fcd2f7.tar.xz craftbukkit-7f7192f8fd8357e664e7e2d6e7c5f65fd0fcd2f7.zip |
Update CraftBukkit to Minecraft 1.4.4.
Diffstat (limited to 'src/main/java/org/bukkit')
10 files changed, 22 insertions, 189 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/ChunkCompressionThread.java b/src/main/java/org/bukkit/craftbukkit/ChunkCompressionThread.java deleted file mode 100644 index cfd9715f..00000000 --- a/src/main/java/org/bukkit/craftbukkit/ChunkCompressionThread.java +++ /dev/null @@ -1,170 +0,0 @@ -package org.bukkit.craftbukkit; - -import java.util.HashMap; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.zip.Deflater; - -import net.minecraft.server.EntityPlayer; -import net.minecraft.server.Packet; -import net.minecraft.server.Packet51MapChunk; -import net.minecraft.server.Packet56MapChunkBulk; - -public final class ChunkCompressionThread implements Runnable { - - private static final ChunkCompressionThread instance = new ChunkCompressionThread(); - private static boolean isRunning = false; - - private final int QUEUE_CAPACITY = 1024 * 10; - private final HashMap<EntityPlayer, Integer> queueSizePerPlayer = new HashMap<EntityPlayer, Integer>(); - private final BlockingQueue<QueuedPacket> packetQueue = new LinkedBlockingQueue<QueuedPacket>(QUEUE_CAPACITY); - - private final int CHUNK_SIZE = 16 * 256 * 16 * 5 / 2; - private final int REDUCED_DEFLATE_THRESHOLD = CHUNK_SIZE / 4; - private final int DEFLATE_LEVEL_CHUNKS = 6; - private final int DEFLATE_LEVEL_PARTS = 1; - - private final Deflater deflater = new Deflater(); - private byte[] deflateBuffer = new byte[CHUNK_SIZE + 100]; - - public static void startThread() { - if (!isRunning) { - isRunning = true; - new Thread(instance).start(); - } - } - - public void run() { - while (true) { - try { - handleQueuedPacket(packetQueue.take()); - } catch (InterruptedException ie) { - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - private void handleQueuedPacket(QueuedPacket queuedPacket) { - addToPlayerQueueSize(queuedPacket.player, -1); - - // Compress the packet if necessary - if (queuedPacket.compress == 1) { - handleMapChunk((Packet51MapChunk) queuedPacket.packet); - } else if (queuedPacket.compress == 2) { - handleMapChunkBulk((Packet56MapChunkBulk) queuedPacket.packet); - } - - sendToNetworkQueue(queuedPacket); - } - - private void handleMapChunkBulk(Packet56MapChunkBulk packet) { - if (packet.buffer != null) { - return; - } - - int dataSize = packet.buildBuffer.length; - if (deflateBuffer.length < dataSize + 100) { - deflateBuffer = new byte[dataSize + 100]; - } - - deflater.reset(); - deflater.setLevel(dataSize < REDUCED_DEFLATE_THRESHOLD ? DEFLATE_LEVEL_PARTS : DEFLATE_LEVEL_CHUNKS); - deflater.setInput(packet.buildBuffer); - deflater.finish(); - int size = deflater.deflate(deflateBuffer); - if (size == 0) { - size = deflater.deflate(deflateBuffer); - } - - // copy compressed data to packet - packet.buffer = new byte[size]; - packet.size = size; - System.arraycopy(deflateBuffer, 0, packet.buffer, 0, size); - } - - private void handleMapChunk(Packet51MapChunk packet) { - // If 'packet.buffer' is set then this packet has already been compressed. - if (packet.buffer != null) { - return; - } - - int dataSize = packet.inflatedBuffer.length; - if (deflateBuffer.length < dataSize + 100) { - deflateBuffer = new byte[dataSize + 100]; - } - - deflater.reset(); - deflater.setLevel(dataSize < REDUCED_DEFLATE_THRESHOLD ? DEFLATE_LEVEL_PARTS : DEFLATE_LEVEL_CHUNKS); - deflater.setInput(packet.inflatedBuffer); - deflater.finish(); - int size = deflater.deflate(deflateBuffer); - if (size == 0) { - size = deflater.deflate(deflateBuffer); - } - - // copy compressed data to packet - packet.buffer = new byte[size]; - packet.size = size; - System.arraycopy(deflateBuffer, 0, packet.buffer, 0, size); - } - - private void sendToNetworkQueue(QueuedPacket queuedPacket) { - queuedPacket.player.netServerHandler.networkManager.queue(queuedPacket.packet); - } - - public static void sendPacket(EntityPlayer player, Packet packet) { - int compressType = 0; - - if (packet instanceof Packet51MapChunk) { - compressType = 1; - } else if (packet instanceof Packet56MapChunkBulk) { - compressType = 2; - } - - instance.addQueuedPacket(new QueuedPacket(player, packet, compressType)); - } - - private void addToPlayerQueueSize(EntityPlayer player, int amount) { - synchronized (queueSizePerPlayer) { - Integer count = queueSizePerPlayer.get(player); - amount += (count == null) ? 0 : count; - if (amount == 0) { - queueSizePerPlayer.remove(player); - } else { - queueSizePerPlayer.put(player, amount); - } - } - } - - public static int getPlayerQueueSize(EntityPlayer player) { - synchronized (instance.queueSizePerPlayer) { - Integer count = instance.queueSizePerPlayer.get(player); - return count == null ? 0 : count; - } - } - - private void addQueuedPacket(QueuedPacket task) { - addToPlayerQueueSize(task.player, +1); - - while (true) { - try { - packetQueue.put(task); - return; - } catch (InterruptedException e) { - } - } - } - - private static class QueuedPacket { - final EntityPlayer player; - final Packet packet; - final int compress; - - QueuedPacket(EntityPlayer player, Packet packet, int compress) { - this.player = player; - this.packet = packet; - this.compress = compress; - } - } -}
\ No newline at end of file diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 94b2c760..0cb25a61 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -204,8 +204,6 @@ public final class CraftServer implements Server { loadPlugins(); enablePlugins(PluginLoadOrder.STARTUP); - - ChunkCompressionThread.startThread(); } private File getConfigFile() { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index f4b19b85..88245a15 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -419,11 +419,11 @@ public class CraftWorld implements World { } public long getFullTime() { - return world.F(); + return world.getDayTime(); } public void setFullTime(long time) { - world.setTime(time); + world.setDayTime(time); // Forces the client to update to the new time immediately for (Player p : getPlayers()) { diff --git a/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java b/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java index e01e7366..82023716 100644 --- a/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java +++ b/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java @@ -93,7 +93,7 @@ public class PortalTravelAgent implements TravelAgent { for (int k1 = i1 - this.searchRadius; k1 <= i1 + this.searchRadius; ++k1) { double d3 = (double) k1 + 0.5D - location.getZ(); - for (int l1 = world.O() - 1; l1 >= 0; --l1) { + for (int l1 = world.P() - 1; l1 >= 0; --l1) { if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) { while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) { --l1; @@ -200,7 +200,7 @@ public class PortalTravelAgent implements TravelAgent { d2 = (double) j2 + 0.5D - location.getZ(); label271: - for (l2 = world.O() - 1; l2 >= 0; --l2) { + for (l2 = world.P() - 1; l2 >= 0; --l2) { if (world.isEmpty(i2, l2, j2)) { while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { --l2; @@ -251,7 +251,7 @@ public class PortalTravelAgent implements TravelAgent { d2 = (double) j2 + 0.5D - location.getZ(); label219: - for (l2 = world.O() - 1; l2 >= 0; --l2) { + for (l2 = world.P() - 1; l2 >= 0; --l2) { if (world.isEmpty(i2, l2, j2)) { while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) { --l2; @@ -312,8 +312,8 @@ public class PortalTravelAgent implements TravelAgent { i1 = 70; } - if (i1 > world.O() - 10) { - i1 = world.O() - 10; + if (i1 > world.P() - 10) { + i1 = world.P() - 10; } j5 = i1; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java b/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java index 43421818..e37734c3 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java @@ -1,5 +1,7 @@ package org.bukkit.craftbukkit.block; +import net.minecraft.server.Item; +import net.minecraft.server.ItemStack; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.Block; @@ -21,14 +23,14 @@ public class CraftJukebox extends CraftBlockState implements Jukebox { } public Material getPlaying() { - return Material.getMaterial(jukebox.record); + return Material.getMaterial(jukebox.record.id); } public void setPlaying(Material record) { if (record == null) { record = Material.AIR; } - jukebox.record = record.getId(); + jukebox.record = new ItemStack(Item.byId[record.getId()], 1); jukebox.update(); if (record == Material.AIR) { world.getHandle().setData(getX(), getY(), getZ(), 0); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 05f0abb9..190fe582 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -308,7 +308,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } public boolean isBlocking() { - return getHandle().be(); + return getHandle().bh(); } public boolean setWindowProperty(InventoryView.Property prop, int value) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index cff54eeb..096de373 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -301,6 +301,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } public boolean hasLineOfSight(Entity other) { - return getHandle().az().canSee(((CraftEntity) other).getHandle()); // az should be getEntitySenses + return getHandle().aA().canSee(((CraftEntity) other).getHandle()); // az should be getEntitySenses } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java index 7c79928b..cd5e5932 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java @@ -12,8 +12,8 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj } public LivingEntity getShooter() { - if (getHandle().shooter instanceof EntityLiving) { - return (LivingEntity) getHandle().shooter.getBukkitEntity(); + if (getHandle().getShooter() instanceof EntityLiving) { + return (LivingEntity) getHandle().getShooter().getBukkitEntity(); } return null; @@ -22,6 +22,9 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj public void setShooter(LivingEntity shooter) { if (shooter instanceof CraftLivingEntity) { getHandle().shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity; + if (shooter instanceof CraftHumanEntity) { + getHandle().shooterName = ((CraftHumanEntity) shooter).getName(); + } } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java index f12a7202..048451e1 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java @@ -64,7 +64,7 @@ public class CraftContainer extends Container { } @Override - public boolean b(EntityHuman entityhuman) { + public boolean c(EntityHuman entityhuman) { if (cachedType == view.getType() && cachedSize == getSize() && cachedTitle.equals(view.getTitle())) { return true; } @@ -79,8 +79,8 @@ public class CraftContainer extends Container { int type = getNotchInventoryType(cachedType); IInventory top = ((CraftInventory)view.getTopInventory()).getInventory(); IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory(); - this.a.clear(); this.b.clear(); + this.c.clear(); if (typeChanged) { setupSlots(top, bottom); } @@ -281,7 +281,7 @@ public class CraftContainer extends Container { // End copy from ContainerBrewingStand } - public boolean c(EntityHuman entity) { + public boolean a(EntityHuman entity) { return true; } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java index 7256e924..f54df7c4 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java @@ -108,7 +108,7 @@ public class CraftInventoryCustom extends CraftInventory { public void update() {} - public boolean a(EntityHuman entityhuman) { + public boolean a_(EntityHuman entityhuman) { return true; } |