From 309846d732849b68e382c53bf3a0d7a6dfd82579 Mon Sep 17 00:00:00 2001 From: Erik Broes Date: Sat, 14 May 2011 16:29:42 +0200 Subject: Whitespace + general cleanup --- .../java/net/minecraft/server/BlockBloodStone.java | 4 +- .../java/net/minecraft/server/BlockDispenser.java | 19 ++-- src/main/java/net/minecraft/server/BlockDoor.java | 4 +- src/main/java/net/minecraft/server/BlockFire.java | 16 +-- .../java/net/minecraft/server/BlockFlowing.java | 2 +- .../java/net/minecraft/server/BlockPumpkin.java | 6 +- .../net/minecraft/server/BlockRedstoneTorch.java | 2 + .../net/minecraft/server/BlockRedstoneWire.java | 4 +- src/main/java/net/minecraft/server/BlockSoil.java | 3 +- .../java/net/minecraft/server/BlockStationary.java | 4 +- src/main/java/net/minecraft/server/Chunk.java | 16 +-- .../net/minecraft/server/ChunkProviderServer.java | 10 +- .../minecraft/server/ConsoleCommandHandler.java | 2 +- .../net/minecraft/server/ConsoleLogManager.java | 2 +- .../java/net/minecraft/server/ContainerPlayer.java | 1 + .../net/minecraft/server/ContainerWorkbench.java | 1 + src/main/java/net/minecraft/server/Entity.java | 27 ++--- src/main/java/net/minecraft/server/EntityCow.java | 2 +- .../java/net/minecraft/server/EntityCreature.java | 3 +- src/main/java/net/minecraft/server/EntityEgg.java | 2 +- .../java/net/minecraft/server/EntityHuman.java | 6 +- .../java/net/minecraft/server/EntityLiving.java | 5 +- .../java/net/minecraft/server/EntityPainting.java | 4 +- src/main/java/net/minecraft/server/EntityPig.java | 16 +-- .../java/net/minecraft/server/EntityPlayer.java | 8 +- .../java/net/minecraft/server/EntitySpider.java | 2 +- .../java/net/minecraft/server/EntityTracker.java | 16 +-- .../net/minecraft/server/EntityWeatherStorm.java | 8 +- .../java/net/minecraft/server/InventoryPlayer.java | 2 +- src/main/java/net/minecraft/server/ItemBed.java | 2 +- src/main/java/net/minecraft/server/ItemBlock.java | 22 ++--- src/main/java/net/minecraft/server/ItemBucket.java | 16 +-- src/main/java/net/minecraft/server/ItemDoor.java | 2 +- .../net/minecraft/server/ItemFlintAndSteel.java | 2 +- src/main/java/net/minecraft/server/ItemHoe.java | 1 + .../net/minecraft/server/ItemInWorldManager.java | 6 +- .../java/net/minecraft/server/ItemPainting.java | 1 + .../java/net/minecraft/server/ItemRedstone.java | 70 ++++++------- src/main/java/net/minecraft/server/ItemReed.java | 6 +- src/main/java/net/minecraft/server/ItemSign.java | 2 +- src/main/java/net/minecraft/server/ItemStack.java | 2 +- .../java/net/minecraft/server/MinecraftServer.java | 14 +-- .../java/net/minecraft/server/NetLoginHandler.java | 3 +- .../net/minecraft/server/NetServerHandler.java | 109 +++++++++++---------- .../java/net/minecraft/server/NetworkManager.java | 6 +- src/main/java/net/minecraft/server/Packet.java | 6 +- .../java/net/minecraft/server/Packet3Chat.java | 12 +-- .../java/net/minecraft/server/PlayerInstance.java | 9 +- .../java/net/minecraft/server/PlayerManager.java | 4 +- .../server/ServerConfigurationManager.java | 32 +++--- src/main/java/net/minecraft/server/Slot.java | 4 +- .../java/net/minecraft/server/StatisticList.java | 4 +- .../net/minecraft/server/ThreadCommandReader.java | 14 +-- .../net/minecraft/server/ThreadLoginVerifier.java | 1 + .../net/minecraft/server/TileEntityDispenser.java | 10 +- .../net/minecraft/server/TileEntityFurnace.java | 8 +- .../net/minecraft/server/TileEntityMobSpawner.java | 2 +- src/main/java/net/minecraft/server/World.java | 48 +++++---- src/main/java/net/minecraft/server/WorldData.java | 2 +- .../java/net/minecraft/server/WorldGenBigTree.java | 3 +- .../java/net/minecraft/server/WorldGenForest.java | 3 +- .../java/net/minecraft/server/WorldGenTaiga1.java | 3 +- .../java/net/minecraft/server/WorldGenTaiga2.java | 3 +- .../java/net/minecraft/server/WorldGenTrees.java | 3 +- .../java/net/minecraft/server/WorldManager.java | 2 +- .../java/net/minecraft/server/WorldServer.java | 30 +++--- .../java/org/bukkit/craftbukkit/CraftChunk.java | 10 +- .../java/org/bukkit/craftbukkit/CraftServer.java | 6 +- .../java/org/bukkit/craftbukkit/CraftWorld.java | 14 +-- .../org/bukkit/craftbukkit/block/CraftBlock.java | 15 ++- .../bukkit/craftbukkit/block/CraftBlockState.java | 4 +- .../org/bukkit/craftbukkit/block/CraftChest.java | 2 +- .../org/bukkit/craftbukkit/block/CraftFurnace.java | 2 +- .../org/bukkit/craftbukkit/entity/CraftEntity.java | 66 ++++++------- .../craftbukkit/entity/CraftHumanEntity.java | 4 +- .../org/bukkit/craftbukkit/entity/CraftPlayer.java | 4 +- .../craftbukkit/entity/CraftStorageMinecart.java | 2 +- .../org/bukkit/craftbukkit/entity/CraftWolf.java | 6 +- .../craftbukkit/event/CraftEventFactory.java | 2 +- .../craftbukkit/inventory/CraftInventory.java | 30 +++--- .../inventory/CraftInventoryPlayer.java | 22 ++--- .../bukkit/craftbukkit/inventory/CraftSlot.java | 4 +- .../craftbukkit/scheduler/CraftScheduler.java | 2 +- .../bukkit/craftbukkit/scheduler/CraftTask.java | 2 +- .../bukkit/craftbukkit/scheduler/CraftWorker.java | 2 +- .../org/bukkit/craftbukkit/util/Java15Compat.java | 2 +- .../craftbukkit/util/ShortConsoleLogFormatter.java | 2 +- 87 files changed, 460 insertions(+), 407 deletions(-) (limited to 'src') diff --git a/src/main/java/net/minecraft/server/BlockBloodStone.java b/src/main/java/net/minecraft/server/BlockBloodStone.java index 5148d3f5..86db2c5c 100644 --- a/src/main/java/net/minecraft/server/BlockBloodStone.java +++ b/src/main/java/net/minecraft/server/BlockBloodStone.java @@ -12,7 +12,7 @@ public class BlockBloodStone extends Block { super(i, j, Material.STONE); } - // Craftbukkit start + // CraftBukkit start public void doPhysics(World world, int i, int j, int k, int l) { if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) { CraftWorld craftWorld = ((WorldServer) world).getWorld(); @@ -24,5 +24,5 @@ public class BlockBloodStone extends Block { server.getPluginManager().callEvent(eventRedstone); } } - // Craftbukkit end + // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/BlockDispenser.java b/src/main/java/net/minecraft/server/BlockDispenser.java index 3ad21479..8d6b82e0 100644 --- a/src/main/java/net/minecraft/server/BlockDispenser.java +++ b/src/main/java/net/minecraft/server/BlockDispenser.java @@ -1,6 +1,8 @@ package net.minecraft.server; import java.util.Random; + +// CraftBukkit start import org.bukkit.block.BlockState; import org.bukkit.block.Dispenser; import org.bukkit.craftbukkit.CraftServer; @@ -10,6 +12,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.util.Vector; +// CraftBukkit end public class BlockDispenser extends BlockContainer { @@ -74,7 +77,7 @@ public class BlockDispenser extends BlockContainer { } } - // CraftBukkit - private->public + // CraftBukkit - private -> public public void dispense(World world, int i, int j, int k, Random random) { int l = world.getData(i, j, k); float f = 0.0F; @@ -96,11 +99,12 @@ public class BlockDispenser extends BlockContainer { ItemStack itemstack = null; if (dispenseSlot > -1) { itemstack = tileentitydispenser.getContents()[dispenseSlot]; - + // Copy item stack, because we want it to have 1 item itemstack = new ItemStack(itemstack.id, 1, itemstack.damage); } // CraftBukkit end + double d0 = (double) i + (double) f * 0.5D + 0.5D; double d1 = (double) j + 0.5D; double d2 = (double) k + (double) f1 * 0.5D + 0.5D; @@ -109,7 +113,7 @@ public class BlockDispenser extends BlockContainer { world.makeSound((double) i, (double) j, (double) k, "random.click", 1.0F, 1.2F); } else { double d3; - + // CraftBukkit start d3 = random.nextDouble() * 0.1D + 0.2D; double motX = (double) f * d3; @@ -125,20 +129,19 @@ public class BlockDispenser extends BlockContainer { org.bukkit.inventory.ItemStack bukkitItem = (new CraftItemStack(itemstack)).clone(); BlockDispenseEvent event = new BlockDispenseEvent(block, bukkitItem, new Vector(motX, motY, motZ)); server.getPluginManager().callEvent(event); - + if (event.isCancelled()) { return; } - + // Actually remove the item tileentitydispenser.a(dispenseSlot, 1); motX = event.getVelocity().getX(); motY = event.getVelocity().getY(); motZ = event.getVelocity().getZ(); - - itemstack = new ItemStack(event.getItem().getTypeId(), - event.getItem().getAmount(), event.getItem().getDurability()); + + itemstack = new ItemStack(event.getItem().getTypeId(), event.getItem().getAmount(), event.getItem().getDurability()); // CraftBukkit end if (itemstack.id == Item.ARROW.id) { diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java index 89f8b01a..f39cbb80 100644 --- a/src/main/java/net/minecraft/server/BlockDoor.java +++ b/src/main/java/net/minecraft/server/BlockDoor.java @@ -174,7 +174,7 @@ public class BlockDoor extends Block { } else if (l > 0 && Block.byId[l].isPowerSource()) { boolean flag1 = world.isBlockIndirectlyPowered(i, j, k) || world.isBlockIndirectlyPowered(i, j + 1, k); - // Craftbukkit start + // CraftBukkit start CraftWorld craftWorld = ((WorldServer) world).getWorld(); CraftServer server = ((WorldServer) world).getServer(); org.bukkit.block.Block block = craftWorld.getBlockAt(i, j, k); @@ -187,7 +187,7 @@ public class BlockDoor extends Block { server.getPluginManager().callEvent(eventRedstone); flag1 = eventRedstone.getNewCurrent() > 0; - // Craftbukkit end + // CraftBukkit end this.setDoor(world, i, j, k, flag1); } diff --git a/src/main/java/net/minecraft/server/BlockFire.java b/src/main/java/net/minecraft/server/BlockFire.java index d4eae060..d1fef907 100644 --- a/src/main/java/net/minecraft/server/BlockFire.java +++ b/src/main/java/net/minecraft/server/BlockFire.java @@ -116,15 +116,15 @@ public class BlockFire extends Block { } } } - } - if (l == 15) { - this.a(world, i + 1, j, k, 1, random); - this.a(world, i - 1, j, k, 1, random); - this.a(world, i, j - 1, k, 1, random); - this.a(world, i, j + 1, k, 1, random); - this.a(world, i, j, k - 1, 1, random); - this.a(world, i, j, k + 1, 1, random); + if (l == 15) { + this.a(world, i + 1, j, k, 1, random); + this.a(world, i - 1, j, k, 1, random); + this.a(world, i, j - 1, k, 1, random); + this.a(world, i, j + 1, k, 1, random); + this.a(world, i, j, k - 1, 1, random); + this.a(world, i, j, k + 1, 1, random); + } } } } diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java index 9848abad..74f669d8 100644 --- a/src/main/java/net/minecraft/server/BlockFlowing.java +++ b/src/main/java/net/minecraft/server/BlockFlowing.java @@ -2,7 +2,7 @@ package net.minecraft.server; import java.util.Random; -// CraftBukkit Start +// CraftBukkit start import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; diff --git a/src/main/java/net/minecraft/server/BlockPumpkin.java b/src/main/java/net/minecraft/server/BlockPumpkin.java index 55b4b5ed..3837aaa1 100644 --- a/src/main/java/net/minecraft/server/BlockPumpkin.java +++ b/src/main/java/net/minecraft/server/BlockPumpkin.java @@ -1,8 +1,10 @@ package net.minecraft.server; +// CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.event.block.BlockRedstoneEvent; +// CraftBukkit end public class BlockPumpkin extends Block { @@ -51,7 +53,7 @@ public class BlockPumpkin extends Block { world.setData(i, j, k, l); } - // Craftbukkit start + // CraftBukkit start public void doPhysics(World world, int i, int j, int k, int l) { if (net.minecraft.server.Block.byId[l] != null && net.minecraft.server.Block.byId[l].isPowerSource()) { CraftWorld craftWorld = ((WorldServer) world).getWorld(); @@ -63,5 +65,5 @@ public class BlockPumpkin extends Block { server.getPluginManager().callEvent(eventRedstone); } } - // Craftbukkit end + // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java index dadad293..6cea9528 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java @@ -117,6 +117,7 @@ public class BlockRedstoneTorch extends BlockTorch { } } // CraftBukkit end + world.setTypeIdAndData(i, j, k, Block.REDSTONE_TORCH_OFF.id, world.getData(i, j, k)); if (this.a(world, i, j, k, true)) { world.makeSound((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k + 0.5F), "random.fizz", 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); @@ -140,6 +141,7 @@ public class BlockRedstoneTorch extends BlockTorch { } } // CraftBukkit end + world.setTypeIdAndData(i, j, k, Block.REDSTONE_TORCH_ON.id, world.getData(i, j, k)); } } diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java index bfd6434c..14c7d439 100644 --- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java +++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java @@ -262,7 +262,7 @@ public class BlockRedstoneWire extends Block { } } - // Craftbukkit private->public + // CraftBukkit - private -> public public int getPower(World world, int i, int j, int k, int l) { if (world.getTypeId(i, j, k) != this.id) { return l; @@ -282,7 +282,7 @@ public class BlockRedstoneWire extends Block { this.a_(world, i, j, k, i1); world.setTypeId(i, j, k, 0); } else { - // Craftbukkit + // CraftBukkit if ((Block.byId[l] != null && Block.byId[l].isPowerSource()) || Block.DIODE_OFF.id == l || Block.DIODE_ON.id == l) this.g(world, i, j, k); } diff --git a/src/main/java/net/minecraft/server/BlockSoil.java b/src/main/java/net/minecraft/server/BlockSoil.java index 286ab3c0..69b95c92 100644 --- a/src/main/java/net/minecraft/server/BlockSoil.java +++ b/src/main/java/net/minecraft/server/BlockSoil.java @@ -59,10 +59,11 @@ public class BlockSoil extends Block { cancellable = new EntityInteractEvent(entity.getBukkitEntity(), ((WorldServer) world).getWorld().getBlockAt(i, j, k)); ((CraftServer)Bukkit.getServer()).getPluginManager().callEvent((EntityInteractEvent) cancellable); } + if (cancellable.isCancelled()) { return; } - // Craftbukkit end + // CraftBukkit end world.setTypeId(i, j, k, Block.DIRT.id); } diff --git a/src/main/java/net/minecraft/server/BlockStationary.java b/src/main/java/net/minecraft/server/BlockStationary.java index 7a996584..1850b14c 100644 --- a/src/main/java/net/minecraft/server/BlockStationary.java +++ b/src/main/java/net/minecraft/server/BlockStationary.java @@ -41,7 +41,7 @@ public class BlockStationary extends BlockFluids { if (this.material == Material.LAVA) { int l = random.nextInt(3); - // CraftBukkit start: prevent lava putting something on fire. + // CraftBukkit start - prevent lava putting something on fire. Server server = ((WorldServer) world).getServer(); CraftWorld cworld = ((WorldServer) world).getWorld(); @@ -57,7 +57,7 @@ public class BlockStationary extends BlockFluids { if (j1 == 0) { if (this.j(world, i - 1, j, k) || this.j(world, i + 1, j, k) || this.j(world, i, j, k - 1) || this.j(world, i, j, k + 1) || this.j(world, i, j - 1, k) || this.j(world, i, j + 1, k)) { - // CraftBukkit start: prevent lava putting something on fire. + // CraftBukkit start - prevent lava putting something on fire. org.bukkit.block.Block theBlock = cworld.getBlockAt(i, j, k); if (theBlock.getTypeId() != Block.FIRE.id) { diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java index ebf7e95d..1ff640b1 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -51,9 +51,9 @@ public class Chunk { // CraftBukkit start CraftWorld cw = ((WorldServer) world).getWorld(); - bukkitChunk = (cw == null) ? null : cw.popPreservedChunk( i, j ); + bukkitChunk = (cw == null) ? null : cw.popPreservedChunk(i, j); if (bukkitChunk == null) { - bukkitChunk = new org.bukkit.craftbukkit.CraftChunk( this ); + bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); } } @@ -476,20 +476,20 @@ public class Chunk { this.world.c.removeAll(this.tileEntities.values()); for (int i = 0; i < this.entitySlices.length; ++i) { - // Craftbukkit start + // CraftBukkit start Iterator iter = this.entitySlices[i].iterator(); while (iter.hasNext()) { Entity entity = (Entity) iter.next(); int cx = Location.locToBlock(entity.locX) >> 4; int cz = Location.locToBlock(entity.locZ) >> 4; - if ((entity instanceof EntityPlayer) && ((cx != this.x) || (cz != this.z))) { - EntityPlayer player = (EntityPlayer) entity; - iter.remove(); // Do not pass along players, as doing so can get them stuck outside of time. - // (which for example disables inventory icon updates and prevents block breaking) + // Do not pass along players, as doing so can get them stuck outside of time. + // (which for example disables inventory icon updates and prevents block breaking) + if (entity instanceof EntityPlayer && (cx != this.x || cz != this.z)) { + iter.remove(); } } - // Craftbukkit end + // CraftBukkit end this.world.b(this.entitySlices[i]); } diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index f6f93d28..8dd30d80 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -124,7 +124,7 @@ public class ChunkProviderServer implements IChunkProvider { // CraftBukkit end } - public Chunk loadChunk(int i, int j) {// CraftBukkit - private->public + public Chunk loadChunk(int i, int j) { // CraftBukkit - private -> public if (this.d == null) { return null; } else { @@ -143,7 +143,7 @@ public class ChunkProviderServer implements IChunkProvider { } } - public void saveChunkNOP(Chunk chunk) { // CraftBukkit - private->public + public void saveChunkNOP(Chunk chunk) { // CraftBukkit - private -> public if (this.d != null) { try { this.d.b(this.world, chunk); @@ -153,7 +153,7 @@ public class ChunkProviderServer implements IChunkProvider { } } - public void saveChunk(Chunk chunk) { // CraftBukkit - private->public + public void saveChunk(Chunk chunk) { // CraftBukkit - private -> public if (this.d != null) { try { chunk.r = this.world.getTime(); @@ -219,12 +219,12 @@ public class ChunkProviderServer implements IChunkProvider { ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk); server.getPluginManager().callEvent(event); if (!event.isCancelled()) { - this.world.getWorld().preserveChunk( (CraftChunk) chunk.bukkitChunk ); + this.world.getWorld().preserveChunk((CraftChunk) chunk.bukkitChunk); chunk.removeEntities(); this.saveChunk(chunk); this.saveChunkNOP(chunk); - //this.unloadQueue.remove(integer); + // this.unloadQueue.remove(integer); this.chunks.remove(chunkcoordinates); // CraftBukkit this.chunkList.remove(chunk); } diff --git a/src/main/java/net/minecraft/server/ConsoleCommandHandler.java b/src/main/java/net/minecraft/server/ConsoleCommandHandler.java index c974a55f..48e16ac7 100644 --- a/src/main/java/net/minecraft/server/ConsoleCommandHandler.java +++ b/src/main/java/net/minecraft/server/ConsoleCommandHandler.java @@ -80,7 +80,7 @@ public class ConsoleCommandHandler { if (s.toLowerCase().startsWith("kick ")) { // CraftBukkit start - Add kick message compatibility String[] parts = s.split(" "); - s2 = ( parts.length >= 2 ) ? parts[1] : ""; + s2 = parts.length >= 2 ? parts[1] : ""; // CraftBukkit end entityplayer = null; diff --git a/src/main/java/net/minecraft/server/ConsoleLogManager.java b/src/main/java/net/minecraft/server/ConsoleLogManager.java index d7708b41..05de7c9f 100644 --- a/src/main/java/net/minecraft/server/ConsoleLogManager.java +++ b/src/main/java/net/minecraft/server/ConsoleLogManager.java @@ -19,7 +19,7 @@ public class ConsoleLogManager { public ConsoleLogManager() {} - // Craftbukkit - change of method signature! + // CraftBukkit - change of method signature! public static void init(MinecraftServer server) { ConsoleLogFormatter consolelogformatter = new ConsoleLogFormatter(); diff --git a/src/main/java/net/minecraft/server/ContainerPlayer.java b/src/main/java/net/minecraft/server/ContainerPlayer.java index 1b835087..2614a57d 100644 --- a/src/main/java/net/minecraft/server/ContainerPlayer.java +++ b/src/main/java/net/minecraft/server/ContainerPlayer.java @@ -53,6 +53,7 @@ public class ContainerPlayer extends Container { if (super.g.size() < 1) { return; } + EntityPlayer player = (EntityPlayer) super.g.get(0); // TODO: Is this _always_ correct? Seems like it. player.netServerHandler.sendPacket((Packet) (new Packet103SetSlot(player.activeContainer.f, 0, craftResult))); // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/ContainerWorkbench.java b/src/main/java/net/minecraft/server/ContainerWorkbench.java index d5d51dd4..6666353e 100644 --- a/src/main/java/net/minecraft/server/ContainerWorkbench.java +++ b/src/main/java/net/minecraft/server/ContainerWorkbench.java @@ -48,6 +48,7 @@ public class ContainerWorkbench extends Container { if (super.g.size() < 1) { return; } + EntityPlayer player = (EntityPlayer) super.g.get(0); // TODO: Is this _always_ correct? Seems like it. player.netServerHandler.sendPacket((Packet) (new Packet103SetSlot(player.activeContainer.f, 0, craftResult))); // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 53b237a9..540c1f70 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -56,7 +56,7 @@ public abstract class Entity { public float width; public float bh; public float bi; - public float fallDistance; // Craftbukkit made public + public float fallDistance; // CraftBukkit - private -> public private int b; public double bk; public double bl; @@ -69,7 +69,7 @@ public abstract class Entity { public int ticksLived; public int maxFireTicks; public int fireTicks; - public int maxAirTicks; // CraftBukkit -- protected->public + public int maxAirTicks; // CraftBukkit - protected - >public protected boolean bw; public int noDamageTicks; public int airTicks; @@ -146,9 +146,8 @@ public abstract class Entity { } protected void c(float f, float f1) { - // Craftbukkit start + // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0. if (Float.isNaN(f)) { - // CraftBukkit - yaw was sometimes set to NaN, so we need to set it back to 0. f = 0; } @@ -160,8 +159,8 @@ public abstract class Entity { f = 0; } + // pitch was sometimes set to NaN, so we need to set it back to 0. if (Float.isNaN(f1)) { - // CraftBukkit - pitch was sometimes set to NaN, so we need to set it back to 0. f1 = 0; } @@ -172,7 +171,7 @@ public abstract class Entity { } f1 = 0; } - // Craftbukkit end + // CraftBukkit end this.yaw = f % 360.0F; this.pitch = f1 % 360.0F; @@ -291,7 +290,7 @@ public abstract class Entity { protected void X() { if (!this.bz) { - // CraftBukkit start -- TODO: this event spams! + // CraftBukkit start - TODO: this event spams! if (this instanceof EntityLiving) { CraftServer server = ((WorldServer) this.world).getServer(); // TODO: shouldn't be sending null for the block. @@ -882,8 +881,8 @@ public abstract class Entity { this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a; this.motY = ((NBTTagDouble) nbttaglist1.a(1)).a; this.motZ = ((NBTTagDouble) nbttaglist1.a(2)).a; - // CraftBukkit Start - //Exempt Vehicles from notch's sanity check + + // CraftBukkit start - Exempt Vehicles from notch's sanity check if (!(this.getBukkitEntity() instanceof CraftVehicle)) { if (Math.abs(this.motX) > 10.0D) { this.motX = 0.0D; @@ -897,7 +896,7 @@ public abstract class Entity { this.motZ = 0.0D; } } - // CraftBukkit End + // CraftBukkit end this.lastX = this.bk = this.locX = ((NBTTagDouble) nbttaglist.a(0)).a; this.lastY = this.bl = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a; @@ -1168,17 +1167,19 @@ public abstract class Entity { } public void a(EntityWeatherStorm entityweatherstorm) { - // Craftbukkit start + // CraftBukkit start int damage = 5; EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(entityweatherstorm.getBukkitEntity(), getBukkitEntity(), DamageCause.LIGHTNING, damage); Bukkit.getServer().getPluginManager().callEvent(event); damage = event.getDamage(); + if (event.isCancelled()) { return; } - + this.a(damage); - // Craftbukkit end + // CraftBukkit end + ++this.fireTicks; if (this.fireTicks == 0) { this.fireTicks = 300; diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java index d1cd432a..3694ab7b 100644 --- a/src/main/java/net/minecraft/server/EntityCow.java +++ b/src/main/java/net/minecraft/server/EntityCow.java @@ -57,7 +57,7 @@ public class EntityCow extends EntityAnimal { CraftItemStack itemInHand = (CraftItemStack) event.getItemStack(); byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); - itemstack = new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data ); + itemstack = new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data); entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, itemstack); // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java index 25cb344b..b08d6b6a 100644 --- a/src/main/java/net/minecraft/server/EntityCreature.java +++ b/src/main/java/net/minecraft/server/EntityCreature.java @@ -43,6 +43,7 @@ public class EntityCreature extends EntityLiving { } } // CraftBukkit end + if (this.target != null) { this.pathEntity = this.world.findPath(this, this.target, f); } @@ -121,7 +122,7 @@ public class EntityCreature extends EntityLiving { double d1 = vec3d.a - this.locX; double d2 = vec3d.c - this.locZ; double d3 = vec3d.b - (double) l1; - // CraftBukkit -- Math -> TrigMath + // CraftBukkit - Math -> TrigMath float f4 = (float) (TrigMath.atan2(d2, d1) * 180.0D / 3.1415927410125732D) - 90.0F; float f5 = f4 - this.yaw; diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java index 3fdc78d2..97f61996 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -262,9 +262,9 @@ public class EntityEgg extends Entity { entity.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); this.world.addEntity(entity); } + // CraftBukkit end } } - // CraftBukkit end for (int l = 0; l < 8; ++l) { this.world.a("snowballpoof", this.locX, this.locY, this.locZ, 0.0D, 0.0D, 0.0D); diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 0ac7ff0b..7bcc0765 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -40,7 +40,7 @@ public abstract class EntityHuman extends EntityLiving { public boolean fauxSleeping; // CraftBukkit end private ChunkCoordinates a; - public int sleepTicks; // CraftBukkit (public) + public int sleepTicks; // CraftBukkit - private -> public public float A; public float B; private ChunkCoordinates c; @@ -176,7 +176,7 @@ public abstract class EntityHuman extends EntityLiving { this.n = this.o; super.u(); float f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ); - // CraftBukkit -- Math -> TrigMath + // CraftBukkit - Math -> TrigMath float f1 = (float) TrigMath.atan(-this.motY * 0.20000000298023224D) * 15.0F; if (f > 0.1F) { @@ -679,12 +679,14 @@ public abstract class EntityHuman extends EntityLiving { if (this.getBukkitEntity() instanceof Player) { Player player = (Player) this.getBukkitEntity(); CraftServer server = ((WorldServer) world).getServer(); + org.bukkit.block.Block bed; if (chunkcoordinates != null) { bed = ((WorldServer) world).getWorld().getBlockAt(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z); } else { bed = ((WorldServer) world).getWorld().getBlockAt(player.getLocation()); } + PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed); server.getPluginManager().callEvent(event); } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index c4e1c2e1..ba97a4c4 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -60,7 +60,7 @@ public abstract class EntityLiving extends Entity { protected double aq; protected double ar; float as = 0.0F; - public int lastDamage = 0; // CraftBukkit protected -> public + public int lastDamage = 0; // CraftBukkit - protected -> public protected int au = 0; protected float av; protected float aw; @@ -241,7 +241,7 @@ public abstract class EntityLiving extends Entity { if (f > 0.05F) { f3 = 1.0F; f2 = f * 3.0F; - // CraftBukkit -- Math -> TrigMath + // CraftBukkit - Math -> TrigMath f1 = (float) TrigMath.atan2(d1, d0) * 180.0F / 3.1415927F - 90.0F; } @@ -837,6 +837,7 @@ public abstract class EntityLiving extends Entity { if (event.isCancelled() || event.getDamage() == 0) { return; } + damageDone = event.getDamage(); this.damageEntity((Entity) null, damageDone); // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/EntityPainting.java b/src/main/java/net/minecraft/server/EntityPainting.java index b5406a71..517c58bf 100644 --- a/src/main/java/net/minecraft/server/EntityPainting.java +++ b/src/main/java/net/minecraft/server/EntityPainting.java @@ -123,11 +123,11 @@ public class EntityPainting extends Entity { if (this.f++ == 100 && !this.world.isStatic) { this.f = 0; if (!this.h()) { - // CraftBukkit start Painting painting = (Painting) getBukkitEntity(); PaintingBreakByWorldEvent event = new PaintingBreakByWorldEvent(painting); Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { return; } @@ -203,11 +203,11 @@ public class EntityPainting extends Entity { public boolean damageEntity(Entity entity, int i) { if (!this.dead && !this.world.isStatic) { - // CraftBukkit start Painting painting = (Painting) getBukkitEntity(); PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent(painting, entity == null ? null : entity.getBukkitEntity()); Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { return true; } diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java index 54d93869..7deabe94 100644 --- a/src/main/java/net/minecraft/server/EntityPig.java +++ b/src/main/java/net/minecraft/server/EntityPig.java @@ -1,6 +1,6 @@ package net.minecraft.server; -//CraftBukkit start +// CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.event.entity.EntityCombustEvent; @@ -42,8 +42,7 @@ public class EntityPig extends EntityAnimal { } public boolean a(EntityHuman entityhuman) { - if (this.x() && !this.world.isStatic - && (this.passenger == null || this.passenger == entityhuman)) { + if (this.x() && !this.world.isStatic && (this.passenger == null || this.passenger == entityhuman)) { entityhuman.mount(this); return true; } else { @@ -69,8 +68,6 @@ public class EntityPig extends EntityAnimal { public void a(EntityWeatherStorm entityweatherstorm) { EntityPigZombie entitypigzombie = new EntityPigZombie(this.world); - entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, - this.yaw, this.pitch); // CraftBukkit start CraftServer server = ((WorldServer) this.world).getServer(); @@ -79,11 +76,14 @@ public class EntityPig extends EntityAnimal { PigZapEvent event = new PigZapEvent(entity, entityweatherstorm.getBukkitEntity(), entitypigzombie.getBukkitEntity()); server.getPluginManager().callEvent(event); - if (!event.isCancelled()) { - this.world.addEntity(entitypigzombie); - this.die(); + if (event.isCancelled()) { + return; } // CraftBukkit end + + entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); + this.world.addEntity(entitypigzombie); + this.die(); } protected void a(float f) { diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index 53bc19be..7a03283a 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -131,7 +131,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { cworld.dropItemNaturally(craftEntity.getLocation(), stack); } - this.x(); + this.x(); // CraftBukkit end } @@ -139,7 +139,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { if (this.bG > 0) { return false; } else { - if (!this.world.pvpMode) { // CraftBukkit this.b.pvpMode -> this.world.pvpMode + if (!this.world.pvpMode) { // CraftBukkit if (entity instanceof EntityHuman) { return false; } @@ -371,10 +371,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } } - // Craftbukkit start + // CraftBukkit start @Override public String toString() { return super.toString() + "(" + name + " at " + locX + "," + locY + "," + locZ + ")"; } - // Craftbukkit end + // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/EntitySpider.java b/src/main/java/net/minecraft/server/EntitySpider.java index d3c717fc..6736efe1 100644 --- a/src/main/java/net/minecraft/server/EntitySpider.java +++ b/src/main/java/net/minecraft/server/EntitySpider.java @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent.TargetReason; -// CraftBukkit stop +// CraftBukkit end public class EntitySpider extends EntityMonster { diff --git a/src/main/java/net/minecraft/server/EntityTracker.java b/src/main/java/net/minecraft/server/EntityTracker.java index 4a7541dc..a1011b1b 100644 --- a/src/main/java/net/minecraft/server/EntityTracker.java +++ b/src/main/java/net/minecraft/server/EntityTracker.java @@ -17,7 +17,7 @@ public class EntityTracker { this.d = minecraftserver.serverConfigurationManager.a(); } - // CraftBukkit -- synchronized + // CraftBukkit - synchronized public synchronized void a(Entity entity) { if (entity instanceof EntityPlayer) { this.a(entity, 512, 2); @@ -62,7 +62,7 @@ public class EntityTracker { this.a(entity, i, j, false); } - // CraftBukkit -- synchronized + // CraftBukkit - synchronized public synchronized void a(Entity entity, int i, int j, boolean flag) { if (i > this.d) { i = this.d; @@ -70,7 +70,7 @@ public class EntityTracker { if (this.b.b(entity.id)) { // CraftBukkit - removed exception throw as tracking an already tracked entity theoretically shouldn't cause any issues. - //throw new IllegalStateException("Entity is already tracked!"); + // throw new IllegalStateException("Entity is already tracked!"); } else { EntityTrackerEntry entitytrackerentry = new EntityTrackerEntry(entity, i, j, flag); @@ -81,7 +81,7 @@ public class EntityTracker { } } - // CraftBukkit -- synchronized + // CraftBukkit - synchronized public synchronized void untrackEntity(Entity entity) { if (entity instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) entity; @@ -102,7 +102,7 @@ public class EntityTracker { } } - // CraftBukkit -- synchronized + // CraftBukkit - synchronized public synchronized void a() { ArrayList arraylist = new ArrayList(); Iterator iterator = this.a.iterator(); @@ -131,7 +131,7 @@ public class EntityTracker { } } - // CraftBukkit -- synchronized + // CraftBukkit - synchronized public synchronized void a(Entity entity, Packet packet) { EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) this.b.a(entity.id); @@ -140,7 +140,7 @@ public class EntityTracker { } } - // CraftBukkit -- synchronized + // CraftBukkit - synchronized public synchronized void b(Entity entity, Packet packet) { EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry) this.b.a(entity.id); @@ -149,7 +149,7 @@ public class EntityTracker { } } - // CraftBukkit -- synchronized + // CraftBukkit - synchronized public synchronized void trackPlayer(EntityPlayer entityplayer) { Iterator iterator = this.a.iterator(); diff --git a/src/main/java/net/minecraft/server/EntityWeatherStorm.java b/src/main/java/net/minecraft/server/EntityWeatherStorm.java index cacb06ea..b92fd4ac 100644 --- a/src/main/java/net/minecraft/server/EntityWeatherStorm.java +++ b/src/main/java/net/minecraft/server/EntityWeatherStorm.java @@ -39,9 +39,8 @@ public class EntityWeatherStorm extends EntityWeather { this.b = 2; this.a = this.random.nextLong(); this.c = this.random.nextInt(3) + 1; - // CraftBukkit start + // CraftBukkit if (!isEffect && world.spawnMonsters >= 2 && world.a(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2), 10)) { - // CraftBukkit end int i = MathHelper.floor(d0); int j = MathHelper.floor(d1); int k = MathHelper.floor(d2); @@ -51,6 +50,7 @@ public class EntityWeatherStorm extends EntityWeather { org.bukkit.block.Block theBlock = cworld.getBlockAt(i, j, k); BlockIgniteEvent event = new BlockIgniteEvent(theBlock, IgniteCause.LIGHTNING, null); ((WorldServer) world).getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { world.setTypeId(i, j, k, Block.FIRE.id); } @@ -112,9 +112,7 @@ public class EntityWeatherStorm extends EntityWeather { } } - // CraftBukkit start - if (!isEffect && this.b >= 0) { - // CraftBukkit end + if (this.b >= 0 && !isEffect) { // CraftBukkit double d0 = 3.0D; List list = this.world.b((Entity) this, AxisAlignedBB.b(this.locX - d0, this.locY - d0, this.locZ - d0, this.locX + d0, this.locY + 6.0D + d0, this.locZ + d0)); diff --git a/src/main/java/net/minecraft/server/InventoryPlayer.java b/src/main/java/net/minecraft/server/InventoryPlayer.java index 31c9e4f1..3ae8427c 100644 --- a/src/main/java/net/minecraft/server/InventoryPlayer.java +++ b/src/main/java/net/minecraft/server/InventoryPlayer.java @@ -5,7 +5,7 @@ public class InventoryPlayer implements IInventory { public ItemStack[] items = new ItemStack[36]; public ItemStack[] armor = new ItemStack[4]; public int itemInHandIndex = 0; - public EntityHuman d; // CraftBukkit - private->public + public EntityHuman d; // CraftBukkit - private -> public private ItemStack f; public boolean e = false; diff --git a/src/main/java/net/minecraft/server/ItemBed.java b/src/main/java/net/minecraft/server/ItemBed.java index 51b2a02f..4d7018f4 100644 --- a/src/main/java/net/minecraft/server/ItemBed.java +++ b/src/main/java/net/minecraft/server/ItemBed.java @@ -17,7 +17,7 @@ public class ItemBed extends Item { if (l != 1) { return false; } else { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit; + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit ++j; BlockBed blockbed = (BlockBed) Block.BED; diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java index d70a880d..72736720 100644 --- a/src/main/java/net/minecraft/server/ItemBlock.java +++ b/src/main/java/net/minecraft/server/ItemBlock.java @@ -18,7 +18,7 @@ public class ItemBlock extends Item { } public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit; + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (world.getTypeId(i, j, k) == Block.SNOW.id) { l = 0; @@ -61,21 +61,19 @@ public class ItemBlock extends Item { replacedBlockState = CraftBlockState.getBlockState(world, i, j - 1, k); } /** - * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1) - * - * This replaces world.setTypeIdAndData(IIIII), we're doing this because we need to - * hook between the 'placement' and the informing to 'world' so we can - * sanely undo this. - * - * Whenever the call to 'world.setTypeIdAndData' changes we need to figure out again what to - * replace this with. - */ + * @see net.minecraft.server.World#setTypeIdAndData(int i, int j, int k, int l, int i1) + * + * This replaces world.setTypeIdAndData(IIIII), we're doing this because we need to + * hook between the 'placement' and the informing to 'world' so we can + * sanely undo this. + * + * Whenever the call to 'world.setTypeIdAndData' changes we need to figure out again what to + * replace this with. + */ if (world.setRawTypeIdAndData(i, j, k, this.id, this.filterData(itemstack.getData()))) { // <-- world.setTypeIdAndData does this to place the block BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block); if (event.isCancelled() || !event.canBuild()) { - // CraftBukkit Undo! - if ((this.id == Block.STEP.id) && (world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) && (world.getTypeId(i, j, k) == 0)) { // Half steps automatically set the block below to a double world.setTypeId(i, j - 1, k, 44); diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java index 45aedd10..e1c2866a 100644 --- a/src/main/java/net/minecraft/server/ItemBucket.java +++ b/src/main/java/net/minecraft/server/ItemBucket.java @@ -78,7 +78,7 @@ public class ItemBucket extends Item { // CraftBukkit end world.setTypeId(i, j, k, 0); - return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data ); // CraftBukkit + return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data); // CraftBukkit } } else { if (this.a < 0) { @@ -91,10 +91,11 @@ public class ItemBucket extends Item { CraftItemStack itemInHand = (CraftItemStack) event.getItemStack(); byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); - return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data ); - // CraftBukkit end + return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data); } - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit + + int clickedX = i, clickedY = j, clickedZ = k; + // CraftBukkit end if (movingobjectposition.face == 0) { --j; @@ -142,12 +143,13 @@ public class ItemBucket extends Item { // CraftBukkit start CraftItemStack itemInHand = (CraftItemStack) event.getItemStack(); byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); - return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data ); + + return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data); // CraftBukkit end } } } else if (this.a == 0 && movingobjectposition.entity instanceof EntityCow) { - // CraftBukkit start -- This codepath seems to be *NEVER* called + // CraftBukkit start - This codepath seems to be *NEVER* called Location loc = movingobjectposition.entity.getBukkitEntity().getLocation(); PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Item.MILK_BUCKET); @@ -157,7 +159,7 @@ public class ItemBucket extends Item { CraftItemStack itemInHand = (CraftItemStack) event.getItemStack(); byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData(); - return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data ); + return new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data); // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/ItemDoor.java b/src/main/java/net/minecraft/server/ItemDoor.java index 860426f0..26ade7b8 100644 --- a/src/main/java/net/minecraft/server/ItemDoor.java +++ b/src/main/java/net/minecraft/server/ItemDoor.java @@ -21,7 +21,7 @@ public class ItemDoor extends Item { if (l != 1) { return false; } else { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit; + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit ++j; Block block; diff --git a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java index 845f647e..7bae873c 100644 --- a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java +++ b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java @@ -21,7 +21,7 @@ public class ItemFlintAndSteel extends Item { } public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit; + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (l == 0) { --j; diff --git a/src/main/java/net/minecraft/server/ItemHoe.java b/src/main/java/net/minecraft/server/ItemHoe.java index 7a51c31d..e05efd28 100644 --- a/src/main/java/net/minecraft/server/ItemHoe.java +++ b/src/main/java/net/minecraft/server/ItemHoe.java @@ -34,6 +34,7 @@ public class ItemHoe extends Item { // CraftBukkit start - Hoes - blockface -1 for 'SELF' BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, i, j, k, block); + if (event.isCancelled() || !event.canBuild()) { event.getBlockPlaced().setTypeId(blockState.getTypeId()); return false; diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java index f9fea29f..47c959d5 100644 --- a/src/main/java/net/minecraft/server/ItemInWorldManager.java +++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java @@ -50,7 +50,7 @@ public class ItemInWorldManager { } } - // CraftBukkit added face + // CraftBukkit - added face public void dig(int i, int j, int k, int face) { this.d = (int) (System.currentTimeMillis() / 50); // CraftBukkit int l = this.world.getTypeId(i, j, k); @@ -124,7 +124,7 @@ public class ItemInWorldManager { this.m = this.d; } } - // CraftBukkit start -- force blockreset to client + // CraftBukkit start - force blockreset to client } else { ((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world)); // CraftBukkit end @@ -224,6 +224,6 @@ public class ItemInWorldManager { } } return result; + // CraftBukkit end } - // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/ItemPainting.java b/src/main/java/net/minecraft/server/ItemPainting.java index 087880a9..6dd8d483 100644 --- a/src/main/java/net/minecraft/server/ItemPainting.java +++ b/src/main/java/net/minecraft/server/ItemPainting.java @@ -53,6 +53,7 @@ public class ItemPainting extends Item { PaintingPlaceEvent event = new PaintingPlaceEvent(painting, who, blockClicked, blockFace); Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { return false; } diff --git a/src/main/java/net/minecraft/server/ItemRedstone.java b/src/main/java/net/minecraft/server/ItemRedstone.java index ccb06bb7..631d93a7 100644 --- a/src/main/java/net/minecraft/server/ItemRedstone.java +++ b/src/main/java/net/minecraft/server/ItemRedstone.java @@ -14,53 +14,55 @@ public class ItemRedstone extends Item { } public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit; + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit - if (l == 0) { - --j; - } + if (world.getTypeId(i, j, k) != Block.SNOW.id) { + if (l == 0) { + --j; + } - if (l == 1) { - ++j; - } + if (l == 1) { + ++j; + } - if (l == 2) { - --k; - } + if (l == 2) { + --k; + } - if (l == 3) { - ++k; - } + if (l == 3) { + ++k; + } - if (l == 4) { - --i; - } + if (l == 4) { + --i; + } - if (l == 5) { - ++i; - } + if (l == 5) { + ++i; + } - if (!world.isEmpty(i, j, k)) { - return false; - } else { - if (Block.REDSTONE_WIRE.canPlace(world, i, j, k)) { - BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit + if (!world.isEmpty(i, j, k)) { + return false; + } + } - world.setTypeId(i, j, k, Block.REDSTONE_WIRE.id); + if (Block.REDSTONE_WIRE.canPlace(world, i, j, k)) { + BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit - // CraftBukkit start - redstone - BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.REDSTONE_WIRE); + world.setTypeId(i, j, k, Block.REDSTONE_WIRE.id); - if (event.isCancelled() || !event.canBuild()) { - event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); - return false; - } - // CraftBukkit end + // CraftBukkit start - redstone + BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.REDSTONE_WIRE); - --itemstack.count; // CraftBukkit -- ORDER MATTERS + if (event.isCancelled() || !event.canBuild()) { + event.getBlockPlaced().setTypeIdAndData(blockState.getTypeId(), blockState.getRawData(), false); + return false; } + // CraftBukkit end - return true; + --itemstack.count; // CraftBukkit - ORDER MATTERS } + + return true; } } diff --git a/src/main/java/net/minecraft/server/ItemReed.java b/src/main/java/net/minecraft/server/ItemReed.java index d4bb4be7..ec4ddb63 100644 --- a/src/main/java/net/minecraft/server/ItemReed.java +++ b/src/main/java/net/minecraft/server/ItemReed.java @@ -17,7 +17,7 @@ public class ItemReed extends Item { } public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit; + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (world.getTypeId(i, j, k) == Block.SNOW.id) { l = 0; @@ -57,7 +57,7 @@ public class ItemReed extends Item { BlockState replacedBlockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit /** * @see net.minecraft.server.World#setTypeId(int i, int j, int k, int l) - * + * * This replaces world.setTypeId(IIII), we're doing this because we need to * hook between the 'placement' and the informing to 'world' so we can * sanely undo this. @@ -69,7 +69,7 @@ public class ItemReed extends Item { BlockPlaceEvent event = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, replacedBlockState, clickedX, clickedY, clickedZ, block); if (event.isCancelled() || !event.canBuild()) { - // CraftBukkit Undo -- this only has reed, repeater and pie blocks + // CraftBukkit - undo; this only has reed, repeater and pie blocks world.setTypeIdAndData(i, j, k, replacedBlockState.getTypeId(), replacedBlockState.getRawData()); } else { world.update(i, j, k, this.id); // <-- world.setTypeId does this on success (tell the world) diff --git a/src/main/java/net/minecraft/server/ItemSign.java b/src/main/java/net/minecraft/server/ItemSign.java index 614e317a..7c8afbfd 100644 --- a/src/main/java/net/minecraft/server/ItemSign.java +++ b/src/main/java/net/minecraft/server/ItemSign.java @@ -20,7 +20,7 @@ public class ItemSign extends Item { } else if (!world.getMaterial(i, j, k).isBuildable()) { return false; } else { - int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit; + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit if (l == 1) { ++j; diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java index b7b7fd35..39f980c4 100644 --- a/src/main/java/net/minecraft/server/ItemStack.java +++ b/src/main/java/net/minecraft/server/ItemStack.java @@ -5,7 +5,7 @@ public final class ItemStack { public int count; public int b; public int id; - public int damage; // CraftBukkit - private->public + public int damage; // CraftBukkit - private -> public public ItemStack(Block block) { this(block, 1); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 2acd3f93..6b9e6e51 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -56,7 +56,7 @@ public class MinecraftServer implements Runnable, ICommandListener { public ColouredConsoleSender console; public ConsoleReader reader; public static int currentTick; - // Craftbukkit end + // CraftBukkit end public MinecraftServer(OptionSet options) { // CraftBukkit - adds argument OptionSet new ThreadSleepForever(this); @@ -78,7 +78,7 @@ public class MinecraftServer implements Runnable, ICommandListener { threadcommandreader.setDaemon(true); threadcommandreader.start(); - ConsoleLogManager.init(this); // Craftbukkit + ConsoleLogManager.init(this); // CraftBukkit // CraftBukkit start System.setOut(new PrintStream(new LoggerOutputStream(log, Level.INFO), true)); @@ -99,7 +99,7 @@ public class MinecraftServer implements Runnable, ICommandListener { this.spawnAnimals = this.propertyManager.getBoolean("spawn-animals", true); this.pvpMode = this.propertyManager.getBoolean("pvp", true); this.o = this.propertyManager.getBoolean("allow-flight", false); - this.spawnProtection = this.propertyManager.getInt("spawn-protection", 16); // CraftBukkit Configurable spawn protection start + this.spawnProtection = this.propertyManager.getInt("spawn-protection", 16); // CraftBukkit - Configurable spawn protection start InetAddress inetaddress = null; if (s.length() > 0) { @@ -146,7 +146,7 @@ public class MinecraftServer implements Runnable, ICommandListener { // CraftBukkit start long elapsed = System.nanoTime() - j; - String time = String.format( "%.3fs", elapsed / 10000000000.0D ); + String time = String.format("%.3fs", elapsed / 10000000000.0D); log.info("Done (" + time + ")! For help, type \"help\" or \"?\""); // CraftBukkit end @@ -226,15 +226,15 @@ public class MinecraftServer implements Runnable, ICommandListener { world.save(true, (IProgressUpdate) null); world.saveLevel(); - WorldSaveEvent event = new WorldSaveEvent( world.getWorld() ); - server.getPluginManager().callEvent( event ); + WorldSaveEvent event = new WorldSaveEvent(world.getWorld()); + server.getPluginManager().callEvent(event); } this.serverConfigurationManager.savePlayers(); // CraftBukkit - player data should be saved whenever a save happens. // CraftBukkit end } - public void stop() { // Craftbukkit: private -> public + public void stop() { // CraftBukkit - private -> public log.info("Stopping server"); // CraftBukkit start if (server != null) { diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java index db4ad260..2b5f86eb 100644 --- a/src/main/java/net/minecraft/server/NetLoginHandler.java +++ b/src/main/java/net/minecraft/server/NetLoginHandler.java @@ -82,7 +82,7 @@ public class NetLoginHandler extends NetHandler { EntityPlayer entityplayer = this.server.serverConfigurationManager.a(this, packet1login.name); if (entityplayer != null) { - a.info(this.b() + " logged in with entity id " + entityplayer.id); + a.info(this.b() + " logged in with entity id " + entityplayer.id + " at (" + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); ChunkCoordinates chunkcoordinates = entityplayer.world.getSpawn(); // CraftBukkit NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer); @@ -91,6 +91,7 @@ public class NetLoginHandler extends NetHandler { if (((WorldServer) entityplayer.world).v()) { // CraftBukkit netserverhandler.sendPacket(new Packet70Bed(1)); } + // this.server.serverConfigurationManager.sendAll(new Packet3Chat("\u00A7e" + entityplayer.name + " joined the game.")); // CraftBukkit - message moved to join event this.server.serverConfigurationManager.a(entityplayer); netserverhandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 21e6f15b..01d605dd 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -23,12 +23,11 @@ import org.bukkit.event.player.*; public class NetServerHandler extends NetHandler implements ICommandListener { - private static final int PLACE_DISTANCE_SQUARED = 6 * 6; // CraftBukkit here for now public static Logger a = Logger.getLogger("Minecraft"); public NetworkManager networkManager; public boolean disconnected = false; private MinecraftServer minecraftServer; - public EntityPlayer player; // CraftBukkit - private->public + public EntityPlayer player; // CraftBukkit - private -> public private int f; private int g; private int h; @@ -38,7 +37,6 @@ public class NetServerHandler extends NetHandler implements ICommandListener { private double z; private boolean m = true; private Map n = new HashMap(); - private int lastTick = MinecraftServer.currentTick; // CraftBukkit public NetServerHandler(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { this.minecraftServer = minecraftserver; @@ -51,6 +49,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener { server = minecraftserver.server; } private final CraftServer server; + private int lastTick = MinecraftServer.currentTick; + private static final int PLACE_DISTANCE_SQUARED = 6 * 6; // Get position of last block hit for BlockDamageLevel.STOPPED private double lastPosX = Double.MAX_VALUE; @@ -88,7 +88,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { return; } // Send the possibly modified leave message - this.sendPacket(new Packet255KickDisconnect( event.getReason() )); + this.sendPacket(new Packet255KickDisconnect(event.getReason())); this.networkManager.c(); leaveMessage = event.getLeaveMessage(); if (leaveMessage != null) { @@ -121,7 +121,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { Location to = player.getLocation(); // Prevent 40 event-calls for less than a single pixel of movement >.> - double delta = Math.pow( this.lastPosX - this.x, 2) + Math.pow( this.lastPosY - this.y, 2) + Math.pow( this.lastPosZ - this.z, 2); + double delta = Math.pow(this.lastPosX - this.x, 2) + Math.pow(this.lastPosY - this.y, 2) + Math.pow(this.lastPosZ - this.z, 2); float deltaAngle = Math.abs(this.lastYaw - this.player.yaw) + Math.abs(this.lastPitch - this.player.pitch); if (delta > 1f/256 || deltaAngle > 10f) { @@ -336,7 +336,6 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } this.player.onGround = packet10flying.g; - this.minecraftServer.serverConfigurationManager.b(this.player); this.player.b(this.player.locY - d0, packet10flying.g); // CraftBukkit end @@ -344,7 +343,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } public void a(double d0, double d1, double d2, float f, float f1) { - // CraftBukkit start -- Delegate to teleport(Location) + // CraftBukkit start - Delegate to teleport(Location) teleport(new Location(getPlayer().getWorld(), d0, d1, d2, f, f1)); } @@ -387,7 +386,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { this.player.setLocation(d0, d1, d2, f, f1); this.player.netServerHandler.sendPacket(new Packet13PlayerLookMove(d0, d1 + 1.6200000047683716D, d1, d2, f, f1, false)); - // CraftBukkit -- Returns TRUE if the teleport was successful + // CraftBukkit - Returns TRUE if the teleport was successful return !event.isCancelled(); } @@ -440,7 +439,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { if (packet14blockdig.e == 0) { // CraftBukkit if (i1 > this.minecraftServer.spawnProtection || flag) { - // CraftBukkit add face argument + // CraftBukkit - add face argument this.player.itemInWorldManager.dig(i, j, k, packet14blockdig.face); } } else if (packet14blockdig.e == 2) { @@ -486,7 +485,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { lastPacket = packet15place.timestamp; } - // CraftBukkit if rightclick decremented the item, always send the update packet. + // CraftBukkit - if rightclick decremented the item, always send the update packet. // this is not here for CraftBukkit's own functionality; rather it is to fix // a notch bug where the item doesn't update correctly. boolean always = false; @@ -508,7 +507,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { this.player.itemInWorldManager.useItem(this.player, this.player.world, itemstack); } - // CraftBukkit notch decrements the counter by 1 in the above method with food, + // CraftBukkit - notch decrements the counter by 1 in the above method with food, // snowballs and so forth, but he does it in a place that doesn't cause the // inventory update packet to get sent always = (itemstack.count != itemstackAmount); @@ -575,7 +574,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener { this.player.activeContainer.a(); this.player.h = false; - if (!ItemStack.equals(this.player.inventory.getItemInHand(), packet15place.itemstack) || always) { // CraftBukkit + // CraftBukkit + if (!ItemStack.equals(this.player.inventory.getItemInHand(), packet15place.itemstack) || always) { this.sendPacket(new Packet103SetSlot(this.player.activeContainer.f, slot.a, this.player.inventory.getItemInHand())); } @@ -584,7 +584,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } public void a(String s, Object[] aobject) { - if (this.disconnected) return; // CraftBukkit -- rarely it would send a disconnect line twice + if (this.disconnected) return; // CraftBukkit - rarely it would send a disconnect line twice a.info(this.player.name + " lost connection: " + s); // CraftBukkit start - we need to handle custom quit messages @@ -602,7 +602,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } public void sendPacket(Packet packet) { - // CraftBukkit + // CraftBukkit start if (packet instanceof Packet6SpawnPosition) { Packet6SpawnPosition packet6 = (Packet6SpawnPosition) packet; this.player.compassTarget = new Location(getPlayer().getWorld(), packet6.x, packet6.y, packet6.z); @@ -614,7 +614,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener { packet = null; } if (packet != null) this.networkManager.a(packet); - // CraftBukkit + // CraftBukkit end + this.g = this.f; } @@ -630,6 +631,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { PlayerItemHeldEvent event = new PlayerItemHeldEvent(getPlayer(), this.player.inventory.itemInHandIndex, packet16blockitemswitch.itemInHandIndex); server.getPluginManager().callEvent(event); // CraftBukkit end + this.player.inventory.itemInHandIndex = packet16blockitemswitch.itemInHandIndex; } else { a.warning(this.player.name + " tried to set an invalid carried item"); @@ -680,8 +682,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } return false; + // CraftBukkit end } - // CraftBukkit end private void handleCommand(String s) { // CraftBukkit start @@ -698,7 +700,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { try { targetPluginFound = server.dispatchCommand(player, s.substring(1)); } catch (CommandException ex) { - player.sendMessage(ChatColor.RED + "An internal error occured while attempting to perform this command"); + player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command"); Logger.getLogger(NetServerHandler.class.getName()).log(Level.SEVERE, null, ex); return; } @@ -706,8 +708,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { if (targetPluginFound) { return; } - - // CraftBukkit stop + // CraftBukkit end if (s.toLowerCase().startsWith("/me ")) { s = "* " + this.player.name + " " + s.substring(s.indexOf(" ")).trim(); @@ -749,7 +750,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { // CraftBukkit end if (packet18armanimation.b == 1) { - // CraftBukkit -- raytrace to look for 'rogue armswings' + // CraftBukkit start - raytrace to look for 'rogue armswings' float f = 1.0F; float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f; float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f; @@ -880,6 +881,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener { if (this.player.activeContainer.f == packet102windowclick.a && this.player.activeContainer.c(this.player)) { ItemStack itemstack = this.player.activeContainer.a(packet102windowclick.b, packet102windowclick.c, packet102windowclick.f, this.player); + if (ItemStack.equals(packet102windowclick.e, itemstack)) { this.player.netServerHandler.sendPacket(new Packet106Transaction(packet102windowclick.a, packet102windowclick.d, true)); this.player.h = true; @@ -923,59 +925,66 @@ public class NetServerHandler extends NetHandler implements ICommandListener { if (((WorldServer) this.player.world).isLoaded(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z)) { TileEntity tileentity = ((WorldServer) this.player.world).getTileEntity(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z); + // CraftBukkit end if (tileentity instanceof TileEntitySign) { TileEntitySign tileentitysign = (TileEntitySign) tileentity; if (!tileentitysign.a()) { this.minecraftServer.c("Player " + this.player.name + " just tried to change non-editable sign"); + // CraftBukkit this.sendPacket(new Packet130UpdateSign(packet130updatesign.x, packet130updatesign.y, packet130updatesign.z, tileentitysign.lines)); return; } + } - int i; - int j; + int i; + int j; - for (j = 0; j < 4; ++j) { - boolean flag = true; + for (j = 0; j < 4; ++j) { + boolean flag = true; - if (packet130updatesign.lines[j].length() > 15) { - flag = false; - } else { - for (i = 0; i < packet130updatesign.lines[j].length(); ++i) { - if (FontAllowedCharacters.a.indexOf(packet130updatesign.lines[j].charAt(i)) < 0) { - flag = false; - } + if (packet130updatesign.lines[j].length() > 15) { + flag = false; + } else { + for (i = 0; i < packet130updatesign.lines[j].length(); ++i) { + if (FontAllowedCharacters.a.indexOf(packet130updatesign.lines[j].charAt(i)) < 0) { + flag = false; } } + } - if (!flag) { - packet130updatesign.lines[j] = "!?"; - } + if (!flag) { + packet130updatesign.lines[j] = "!?"; } + } - if (tileentity instanceof TileEntitySign) { - j = packet130updatesign.x; - int k = packet130updatesign.y; - i = packet130updatesign.z; + if (tileentity instanceof TileEntitySign) { + j = packet130updatesign.x; + int k = packet130updatesign.y; - Player player = server.getPlayer(this.player); - SignChangeEvent event = new SignChangeEvent((CraftBlock) player.getWorld().getBlockAt(j, k, i), server.getPlayer(this.player), packet130updatesign.lines); - server.getPluginManager().callEvent(event); + i = packet130updatesign.z; + TileEntitySign tileentitysign1 = (TileEntitySign) tileentity; - if (!event.isCancelled()) { - for (int l = 0; l < 4; ++l) { - tileentitysign.lines[l] = event.getLine(l); - } - tileentitysign.setEditable(false); - } + // CraftBukkit start + Player player = server.getPlayer(this.player); + SignChangeEvent event = new SignChangeEvent((CraftBlock) player.getWorld().getBlockAt(j, k, i), server.getPlayer(this.player), packet130updatesign.lines); + server.getPluginManager().callEvent(event); - tileentitysign.update(); - ((WorldServer) this.player.world).notify(j, k, i); + if (!event.isCancelled()) { + for (int l = 0; l < 4; ++l) { + tileentitysign1.lines[l] = event.getLine(l); + } + tileentitysign1.setEditable(false); } + // CraftBukkit end + + tileentitysign1.update(); + + // CraftBukkit + ((WorldServer) this.player.world).notify(j, k, i); } } - // CraftBukkit end } public boolean c() { diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java index 2dc97649..0c3b1d20 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -6,7 +6,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.Socket; import java.net.SocketAddress; -import java.io.IOException; // CraftBukkit -- instead of SocketException +import java.io.IOException; // CraftBukkit - instead of SocketException import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -17,7 +17,7 @@ public class NetworkManager { public static int b; public static int c; private Object e = new Object(); - public Socket socket; // CraftBukkit -- private->public + public Socket socket; // CraftBukkit - private -> public private final SocketAddress g; private DataInputStream input; private DataOutputStream output; @@ -46,7 +46,7 @@ public class NetworkManager { socket.setSoTimeout(30000); socket.setTrafficClass(24); - // CraftBukkit start -- cant compile these outside the try + // CraftBukkit start - cant compile these outside the try this.input = new DataInputStream(socket.getInputStream()); this.output = new DataOutputStream(socket.getOutputStream()); // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/Packet.java b/src/main/java/net/minecraft/server/Packet.java index 116468a2..592d80d2 100644 --- a/src/main/java/net/minecraft/server/Packet.java +++ b/src/main/java/net/minecraft/server/Packet.java @@ -115,13 +115,13 @@ public abstract class Packet { return packet; } - // CraftBukkit - throws IOException + // CraftBukkit - throws IOException public static void a(Packet packet, DataOutputStream dataoutputstream) throws IOException { dataoutputstream.write(packet.b()); packet.a(dataoutputstream); } - // CraftBukkit - throws IOException + // CraftBukkit - throws IOException public static void a(String s, DataOutputStream dataoutputstream) throws IOException { if (s.length() > 32767) { throw new IOException("String too big"); @@ -131,7 +131,7 @@ public abstract class Packet { } } - // CraftBukkit - throws IOException + // CraftBukkit - throws IOException public static String a(DataInputStream datainputstream, int i) throws IOException { short short1 = datainputstream.readShort(); diff --git a/src/main/java/net/minecraft/server/Packet3Chat.java b/src/main/java/net/minecraft/server/Packet3Chat.java index 613cfcab..4fcc5788 100644 --- a/src/main/java/net/minecraft/server/Packet3Chat.java +++ b/src/main/java/net/minecraft/server/Packet3Chat.java @@ -2,7 +2,7 @@ package net.minecraft.server; import java.io.DataInputStream; import java.io.DataOutputStream; -import java.io.IOException; +import java.io.IOException; // CraftBukkit public class Packet3Chat extends Packet { @@ -11,11 +11,11 @@ public class Packet3Chat extends Packet { public Packet3Chat() {} public Packet3Chat(String s) { - // CraftBukkit start - handle this later - //if (s.length() > 119) { - // s = s.substring(0, 119); - //} - // CraftBukkit end + /* CraftBukkit start - handle this later + if (s.length() > 119) { + s = s.substring(0, 119); + } + // CraftBukkit end */ this.a = s; } diff --git a/src/main/java/net/minecraft/server/PlayerInstance.java b/src/main/java/net/minecraft/server/PlayerInstance.java index 60802ff9..1c980229 100644 --- a/src/main/java/net/minecraft/server/PlayerInstance.java +++ b/src/main/java/net/minecraft/server/PlayerInstance.java @@ -42,6 +42,7 @@ class PlayerInstance { entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.e.x, this.e.z, true)); } // CraftBukkit end + this.b.add(entityplayer); entityplayer.f.add(this.e); } @@ -50,7 +51,7 @@ class PlayerInstance { public void b(EntityPlayer entityplayer) { if (!this.b.contains(entityplayer)) { // CraftBukkit - reduce console spam under certain conditions - //(new IllegalStateException("Failed to remove player. " + entityplayer + " isn\'t in chunk " + this.chunkX + ", " + this.chunkZ)).printStackTrace(); + // (new IllegalStateException("Failed to remove player. " + entityplayer + " isn\'t in chunk " + this.chunkX + ", " + this.chunkZ)).printStackTrace(); } else { this.b.remove(entityplayer); if (this.b.size() == 0) { @@ -66,7 +67,8 @@ class PlayerInstance { } entityplayer.f.remove(this.e); - if (entityplayer.g.remove(this.e)) { // CraftBukkit - contains -> remove + // CraftBukkit - contains -> remove + if (entityplayer.g.remove(this.e)) { entityplayer.netServerHandler.sendPacket(new Packet50PreChunk(this.chunkX, this.chunkZ, false)); } } @@ -173,9 +175,10 @@ class PlayerInstance { j = this.chunkX * 16 + (this.dirtyCount >> 12 & 15); k = this.dirtyCount & 255; l = this.chunkZ * 16 + (this.dirtyCount >> 8 & 15); + // CraftBukkit start if (Block.isTileEntity[this.playerManager.world.getTypeId(j, k, l)]) { - //System.out.println("Sending!"); // CraftBukkit + // System.out.println("Sending!"); // CraftBukkit this.sendTileEntity(this.playerManager.world.getTileEntity(j, k, l)); } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/PlayerManager.java b/src/main/java/net/minecraft/server/PlayerManager.java index a1eda448..1195cedf 100644 --- a/src/main/java/net/minecraft/server/PlayerManager.java +++ b/src/main/java/net/minecraft/server/PlayerManager.java @@ -126,13 +126,13 @@ public class PlayerManager { int i1 = i - k; int j1 = j - l; - // Craftbukkit start + // CraftBukkit start if (i1 > 10 || i1 < -10 || j1 > 10 || j1 < -10) { this.removePlayer(entityplayer); this.addPlayer(entityplayer); return; } - // Craftbukkit end + // CraftBukkit end if (i1 != 0 || j1 != 0) { for (int k1 = i - 10; k1 <= i + 10; ++k1) { diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index f2906860..8cc67376 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -28,9 +28,9 @@ public class ServerConfigurationManager { public static Logger a = Logger.getLogger("Minecraft"); public List players = new ArrayList(); - public MinecraftServer server; // CraftBukkit - private->public + public MinecraftServer server; // CraftBukkit - private -> public // public PlayerManager d; // CraftBukkit - removed! - public int maxPlayers; // CraftBukkit - private->public + public int maxPlayers; // CraftBukkit - private -> public private Set banByName = new HashSet(); private Set banByIP = new HashSet(); private Set h = new HashSet(); @@ -39,7 +39,7 @@ public class ServerConfigurationManager { private File k; private File l; private File m; - public PlayerFileData playerFileData; // CraftBukkit private->public + public PlayerFileData playerFileData; // CraftBukkit - private - >public private boolean o; // CraftBukkit start @@ -120,7 +120,6 @@ public class ServerConfigurationManager { this.players.remove(entityplayer); return playerQuitEvent.getQuitMessage(); // CraftBukkit - // CraftBukkit end } public EntityPlayer a(NetLoginHandler netloginhandler, String s) { @@ -139,6 +138,7 @@ public class ServerConfigurationManager { if (this.banByName.contains(s.trim().toLowerCase())) { event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You are banned from this server!"); + // return null // CraftBukkit } else if (!this.isWhitelisted(s)) { event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!"); } else if (this.banByIP.contains(s2)) { @@ -168,22 +168,28 @@ public class ServerConfigurationManager { } public EntityPlayer d(EntityPlayer entityplayer) { - // CraftBukkit start - every reference to this.minecraftServer.worldServer should be entityplayer.world this.server.tracker.trackPlayer(entityplayer); this.server.tracker.untrackEntity(entityplayer); + // CraftBukkit ((WorldServer) entityplayer.world).manager.removePlayer(entityplayer); this.players.remove(entityplayer); + // CraftBukkit entityplayer.world.removeEntity(entityplayer); ChunkCoordinates chunkcoordinates = entityplayer.K(); + // CraftBukkit EntityPlayer entityplayer1 = new EntityPlayer(this.server, entityplayer.world, entityplayer.name, new ItemInWorldManager(entityplayer.world)); entityplayer1.id = entityplayer.id; entityplayer1.netServerHandler = entityplayer.netServerHandler; - entityplayer1.displayName = entityplayer.displayName; // CraftBukkit - entityplayer1.compassTarget = entityplayer.compassTarget; // CraftBukkit - entityplayer1.fauxSleeping = entityplayer.fauxSleeping; // CraftBukkit + + // CraftBukkit start - transfer internal variables + entityplayer1.displayName = entityplayer.displayName; + entityplayer1.compassTarget = entityplayer.compassTarget; + entityplayer1.fauxSleeping = entityplayer.fauxSleeping; + // CraftBukkit end if (chunkcoordinates != null) { + // CraftBukkit ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(entityplayer.world, chunkcoordinates); if (chunkcoordinates1 != null) { @@ -194,8 +200,10 @@ public class ServerConfigurationManager { } } + // CraftBukkit ((WorldServer) entityplayer.world).chunkProviderServer.getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4); + // CraftBukkit while (entityplayer.world.getEntities(entityplayer1, entityplayer1.boundingBox).size() != 0) { entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ); } @@ -204,7 +212,7 @@ public class ServerConfigurationManager { Player respawnPlayer = cserver.getPlayer(entityplayer); Location respawnLocation = new Location(respawnPlayer.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); - PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, respawnLocation ); + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, respawnLocation); cserver.getPluginManager().callEvent(respawnEvent); entityplayer1.world = ((CraftWorld) respawnEvent.getRespawnLocation().getWorld()).getHandle(); @@ -374,7 +382,8 @@ public class ServerConfigurationManager { bufferedreader.close(); } catch (Exception exception) { - a.warning("Failed to load ops: " + exception); // CraftBukkit corrected text + // CraftBukkit - corrected text + a.warning("Failed to load ops: " + exception); } } @@ -391,7 +400,8 @@ public class ServerConfigurationManager { printwriter.close(); } catch (Exception exception) { - a.warning("Failed to save ops: " + exception); // CraftBukkit corrected text + // CraftBukkit - corrected text + a.warning("Failed to save ops: " + exception); } } diff --git a/src/main/java/net/minecraft/server/Slot.java b/src/main/java/net/minecraft/server/Slot.java index 2b7fde25..94dba7b5 100644 --- a/src/main/java/net/minecraft/server/Slot.java +++ b/src/main/java/net/minecraft/server/Slot.java @@ -2,8 +2,8 @@ package net.minecraft.server; public class Slot { - public final int index; // CraftBukkit: private -> public - public final IInventory inventory; // CraftBukkit: private -> public + public final int index; // CraftBukkit - private -> public + public final IInventory inventory; // CraftBukkit - private -> public public int a; public int b; public int c; diff --git a/src/main/java/net/minecraft/server/StatisticList.java b/src/main/java/net/minecraft/server/StatisticList.java index 837a3acd..939f08f0 100644 --- a/src/main/java/net/minecraft/server/StatisticList.java +++ b/src/main/java/net/minecraft/server/StatisticList.java @@ -53,7 +53,7 @@ public class StatisticList { F = b(F, "stat.breakItem", 16973824, 0, Block.byId.length); G = true; d(); - //System.out.println(E); // CraftBukkit + // System.out.println(E); // CraftBukkit } public static void c() { @@ -61,7 +61,7 @@ public class StatisticList { F = b(F, "stat.breakItem", 16973824, Block.byId.length, 32000); H = true; d(); - //System.out.println(E); // CraftBukkit + // System.out.println(E); // CraftBukkit } public static void d() { diff --git a/src/main/java/net/minecraft/server/ThreadCommandReader.java b/src/main/java/net/minecraft/server/ThreadCommandReader.java index 4ab2c930..f3d36e65 100644 --- a/src/main/java/net/minecraft/server/ThreadCommandReader.java +++ b/src/main/java/net/minecraft/server/ThreadCommandReader.java @@ -5,7 +5,6 @@ import java.io.IOException; import java.io.InputStreamReader; // CraftBukkit start -import java.io.PrintStream; import java.util.logging.Level; import java.util.logging.Logger; import jline.ConsoleReader; @@ -20,17 +19,18 @@ public class ThreadCommandReader extends Thread { } public void run() { - // Craftbukkit start - whole method, nuked to oblivion! :o + // CraftBukkit + ConsoleReader bufferedreader = this.server.reader; + String s = null; try { - ConsoleReader reader = this.server.reader; - String line = null; - while ((!this.server.isStopped) && (MinecraftServer.isRunning(this.server)) && ((line = reader.readLine(">", null)) != null)) { - this.server.issueCommand(line, (ICommandListener) this.server); + // CraftBukkit + while (!this.server.isStopped && MinecraftServer.isRunning(this.server) && ((s = bufferedreader.readLine(">", null)) != null)) { + this.server.issueCommand(s, this.server); } } catch (IOException ioexception) { + // CraftBukkit Logger.getLogger(ThreadCommandReader.class.getName()).log(Level.SEVERE, null, ioexception); } - // Craftbukkit end } } diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java index b781583c..16641aef 100644 --- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java +++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java @@ -22,6 +22,7 @@ class ThreadLoginVerifier extends Thread { ThreadLoginVerifier(NetLoginHandler netloginhandler, Packet1Login packet1login, CraftServer server) { this.server = server; // CraftBukkit end + this.netLoginHandler = netloginhandler; this.loginPacket = packet1login; } diff --git a/src/main/java/net/minecraft/server/TileEntityDispenser.java b/src/main/java/net/minecraft/server/TileEntityDispenser.java index 842702f5..855e411d 100644 --- a/src/main/java/net/minecraft/server/TileEntityDispenser.java +++ b/src/main/java/net/minecraft/server/TileEntityDispenser.java @@ -46,24 +46,26 @@ public class TileEntityDispenser extends TileEntity implements IInventory { } } - // CraftBukkit start + // CraftBukkit - change signature public int findDispenseSlot() { int i = -1; int j = 1; for (int k = 0; k < this.items.length; ++k) { - if (this.items[k] != null && this.items[k].count != 0 && this.b.nextInt(j) == 0) { + if (this.items[k] != null && this.b.nextInt(j) == 0) { + if (this.items[k].count != 0) continue; // CraftBukkit i = k; ++j; } } - + + // CraftBukkit start return i; } public ItemStack b() { int i = findDispenseSlot(); - // CraftBukkit end + // CraftBukkit end if (i >= 0) { return this.a(i, 1); diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java index 03c4d050..22cb5adc 100644 --- a/src/main/java/net/minecraft/server/TileEntityFurnace.java +++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java @@ -163,8 +163,12 @@ public class TileEntityFurnace extends TileEntity implements IInventory { if (this.items[2] == null) { this.items[2] = itemstack.j(); - } else if (this.items[2].id == itemstack.id && this.items[2].damage == itemstack.damage) { // CraftBukkit - compare damage too - this.items[2].count += itemstack.count; // CraftBukkit - increment by count instead of 1 + } else if (this.items[2].id == itemstack.id) { + // CraftBukkit start - compare damage too + if (this.items[2].damage == itemstack.damage) { + this.items[2].count += itemstack.count; + } + // CraftBukkit end } --this.items[0].count; diff --git a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java index ee36b470..af1d650a 100644 --- a/src/main/java/net/minecraft/server/TileEntityMobSpawner.java +++ b/src/main/java/net/minecraft/server/TileEntityMobSpawner.java @@ -3,7 +3,7 @@ package net.minecraft.server; public class TileEntityMobSpawner extends TileEntity { public int spawnDelay = -1; - public String mobName = "Pig"; // CraftBukkit private -> public + public String mobName = "Pig"; // CraftBukkit - private -> public public double b; public double c = 0.0D; diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index f8178e9e..777b1f52 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -49,15 +49,15 @@ public class World implements IBlockAccess { public boolean n = false; public final WorldProvider worldProvider; protected List p = new ArrayList(); - public IChunkProvider chunkProvider; // CraftBukkit protected->public + public IChunkProvider chunkProvider; // CraftBukkit - protected -> public protected final IDataManager r; - public WorldData worldData; // CraftBukkit protected->public + public WorldData worldData; // CraftBukkit - protected -> public public boolean isLoading; private boolean H; private ArrayList I = new ArrayList(); private int J = 0; - public boolean allowMonsters = true; // CraftBukkit private->public - public boolean allowAnimals = true; // CraftBukkit private->public + public boolean allowMonsters = true; // CraftBukkit - private -> public + public boolean allowAnimals = true; // CraftBukkit - private -> public public boolean pvpMode; // CraftBukkit static int u = 0; private Set M = new HashSet(); @@ -302,7 +302,7 @@ public class World implements IBlockAccess { } public boolean setTypeId(int i, int j, int k, int l) { - // Craftbukkit start + // CraftBukkit start int old = this.getTypeId(i, j, k); if (this.setRawTypeId(i, j, k, l)) { this.update(i, j, k, l == 0 ? old : l); @@ -310,11 +310,11 @@ public class World implements IBlockAccess { } else { return false; } - // Craftbukkit end + // CraftBukkit end } public boolean setTypeIdAndData(int i, int j, int k, int l, int i1) { - // Craftbukkit start + // CraftBukkit start int old = this.getTypeId(i, j, k); if (this.setRawTypeIdAndData(i, j, k, l, i1)) { this.update(i, j, k, l == 0 ? old : l); @@ -322,7 +322,7 @@ public class World implements IBlockAccess { } else { return false; } - // Craftbukkit end + // CraftBukkit end } public void notify(int i, int j, int k) { @@ -383,7 +383,7 @@ public class World implements IBlockAccess { return; } } - // CraftBukkit stop + // CraftBukkit end block.doPhysics(this, i, j, k, l); } @@ -1441,7 +1441,7 @@ public class World implements IBlockAccess { } } - // CraftBukkit start -- Only call spawner if we have players online and the world allows for mobs or animals + // CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals if ((this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && ((WorldServer) this).getServer().getHandle().players.size() > 0)) { SpawnerCreature.spawnEntities(this, this.allowMonsters, this.allowAnimals); } @@ -1580,7 +1580,7 @@ public class World implements IBlockAccess { this.worldData.b(0); this.worldData.a(false); } - //CraftBukkit end + // CraftBukkit end } protected void j() { @@ -1667,6 +1667,7 @@ public class World implements IBlockAccess { // CraftBukkit start SnowFormEvent snow = new SnowFormEvent(((WorldServer)this).getWorld().getBlockAt(l + i, k1, j1 + j)); ((WorldServer)this).getServer().getPluginManager().callEvent(snow); + if (!snow.isCancelled()) { this.setTypeId(l + i, k1, j1 + j, snow.getMaterial().getId()); this.setData(l + i, k1, j1 + j, snow.getData()); @@ -1793,7 +1794,7 @@ public class World implements IBlockAccess { Entity entity = null; for (int i = 0; i < list.size(); ++i) { entity = (Entity) list.get(i); - // CraftBukkit start + if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) { CreatureSpawnEvent event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity); if (event.isCancelled()) { @@ -1803,6 +1804,7 @@ public class World implements IBlockAccess { this.entityList.add(entity); // CraftBukkit end + this.c((Entity) list.get(i)); } } @@ -1821,13 +1823,22 @@ public class World implements IBlockAccess { axisalignedbb = null; } - // CraftBukkit start - We dont want to allow the user to override the bounding box check - boolean defaultReturn = axisalignedbb != null && !this.containsEntity(axisalignedbb) ? false : (block != Block.WATER && block != Block.STATIONARY_WATER && block != Block.LAVA && block != Block.STATIONARY_LAVA && block != Block.FIRE && block != Block.SNOW ? i > 0 && block == null && block1.canPlace(this, j, k, l) : true); + // CraftBukkit - store the default action + boolean defaultReturn; if (axisalignedbb != null && !this.containsEntity(axisalignedbb)) { - return false; + // CraftBukkit + defaultReturn = false; + } else { + if (block == Block.WATER || block == Block.STATIONARY_WATER || block == Block.LAVA || block == Block.STATIONARY_LAVA || block == Block.FIRE || block == Block.SNOW) { + block = null; + } + + // CraftBukkit + defaultReturn = i > 0 && block == null && block1.canPlace(this, j, k, l); } + // CraftBukkit start BlockCanBuildEvent event = new BlockCanBuildEvent(((WorldServer) this).getWorld().getBlockAt(j, k, l), i, defaultReturn); ((WorldServer) this).getServer().getPluginManager().callEvent(event); @@ -2061,20 +2072,19 @@ public class World implements IBlockAccess { if (this.H && !this.isStatic) { Iterator iterator = this.players.iterator(); - // CraftBukkit start + // CraftBukkit - This allows us to assume that some people are in bed but not really, allowing time to pass in spite of AFKers boolean foundActualSleepers = false; - // This allows us to assume that some people are in bed - // but not really, allowing time to pass in spite of AFKers - EntityHuman entityhuman; do { if (!iterator.hasNext()) { + // CraftBukkit return foundActualSleepers; } entityhuman = (EntityHuman) iterator.next(); + // CraftBukkit start if (entityhuman.isDeeplySleeping()) { foundActualSleepers = true; } diff --git a/src/main/java/net/minecraft/server/WorldData.java b/src/main/java/net/minecraft/server/WorldData.java index a07969db..bde44e06 100644 --- a/src/main/java/net/minecraft/server/WorldData.java +++ b/src/main/java/net/minecraft/server/WorldData.java @@ -13,7 +13,7 @@ public class WorldData { private long g; private NBTTagCompound h; private int i; - public String name; // CraftBukkit private->public + public String name; // CraftBukkit - private -> public private int k; private boolean l; private int m; diff --git a/src/main/java/net/minecraft/server/WorldGenBigTree.java b/src/main/java/net/minecraft/server/WorldGenBigTree.java index 5ef40e15..c93785ab 100644 --- a/src/main/java/net/minecraft/server/WorldGenBigTree.java +++ b/src/main/java/net/minecraft/server/WorldGenBigTree.java @@ -2,8 +2,7 @@ package net.minecraft.server; import java.util.Random; -// CraftBukkit -import org.bukkit.BlockChangeDelegate; +import org.bukkit.BlockChangeDelegate; // CraftBukkit public class WorldGenBigTree extends WorldGenerator { diff --git a/src/main/java/net/minecraft/server/WorldGenForest.java b/src/main/java/net/minecraft/server/WorldGenForest.java index 288aaefd..5db08bd3 100644 --- a/src/main/java/net/minecraft/server/WorldGenForest.java +++ b/src/main/java/net/minecraft/server/WorldGenForest.java @@ -2,8 +2,7 @@ package net.minecraft.server; import java.util.Random; -// CraftBukkit -import org.bukkit.BlockChangeDelegate; +import org.bukkit.BlockChangeDelegate; // CraftBukkit public class WorldGenForest extends WorldGenerator { diff --git a/src/main/java/net/minecraft/server/WorldGenTaiga1.java b/src/main/java/net/minecraft/server/WorldGenTaiga1.java index 972f806d..bab2b45f 100644 --- a/src/main/java/net/minecraft/server/WorldGenTaiga1.java +++ b/src/main/java/net/minecraft/server/WorldGenTaiga1.java @@ -2,8 +2,7 @@ package net.minecraft.server; import java.util.Random; -// CraftBukkit -import org.bukkit.BlockChangeDelegate; +import org.bukkit.BlockChangeDelegate; // CraftBukkit public class WorldGenTaiga1 extends WorldGenerator { diff --git a/src/main/java/net/minecraft/server/WorldGenTaiga2.java b/src/main/java/net/minecraft/server/WorldGenTaiga2.java index 6bee4ce4..d23c2019 100644 --- a/src/main/java/net/minecraft/server/WorldGenTaiga2.java +++ b/src/main/java/net/minecraft/server/WorldGenTaiga2.java @@ -2,8 +2,7 @@ package net.minecraft.server; import java.util.Random; -// CraftBukkit -import org.bukkit.BlockChangeDelegate; +import org.bukkit.BlockChangeDelegate; // CraftBukkit public class WorldGenTaiga2 extends WorldGenerator { diff --git a/src/main/java/net/minecraft/server/WorldGenTrees.java b/src/main/java/net/minecraft/server/WorldGenTrees.java index c5baf5c2..6c2fe975 100644 --- a/src/main/java/net/minecraft/server/WorldGenTrees.java +++ b/src/main/java/net/minecraft/server/WorldGenTrees.java @@ -2,8 +2,7 @@ package net.minecraft.server; import java.util.Random; -// CraftBukkit -import org.bukkit.BlockChangeDelegate; +import org.bukkit.BlockChangeDelegate; // CraftBukkit public class WorldGenTrees extends WorldGenerator { diff --git a/src/main/java/net/minecraft/server/WorldManager.java b/src/main/java/net/minecraft/server/WorldManager.java index f565a9f9..218a5ade 100644 --- a/src/main/java/net/minecraft/server/WorldManager.java +++ b/src/main/java/net/minecraft/server/WorldManager.java @@ -28,7 +28,7 @@ public class WorldManager implements IWorldAccess { public void a() {} public void a(int i, int j, int k) { - // CraftBukkit -- add world argument + // CraftBukkit - add world argument this.server.serverConfigurationManager.flagDirty(i, j, k, world); } diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 34ee124a..66e3e047 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -43,11 +43,11 @@ public class WorldServer extends World implements BlockChangeDelegate { // CraftBukkit end public void entityJoinedWorld(Entity entity, boolean flag) { - // CraftBukkit start -- We prevent spawning in general, so this butchering is not needed - //if (!this.server.spawnAnimals && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { - // entity.die(); - //} - // CraftBukkit end + /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed + if (!this.server.spawnAnimals && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { + entity.die(); + } + // CraftBukkit end */ if (entity.passenger == null || !(entity.passenger instanceof EntityHuman)) { super.entityJoinedWorld(entity, flag); @@ -87,7 +87,7 @@ public class WorldServer extends World implements BlockChangeDelegate { i1 = l; } - // CraftBukkit -- Configurable spawn protection + // CraftBukkit - Configurable spawn protection return i1 > this.server.spawnProtection || this.server.serverConfigurationManager.isOp(entityhuman.name); } @@ -107,15 +107,17 @@ public class WorldServer extends World implements BlockChangeDelegate { public boolean a(Entity entity) { if (super.a(entity)) { - CraftServer server = cserver; - + // CraftBukkit start LightningStrikeEvent lightning = new LightningStrikeEvent((org.bukkit.World) world, (org.bukkit.entity.LightningStrike) entity.getBukkitEntity()); - server.getPluginManager().callEvent(lightning); - if (!lightning.isCancelled()) { - this.server.serverConfigurationManager.a(entity.locX, entity.locY, entity.locZ, 512.0D, new Packet71Weather(entity)); - return true; + this.cserver.getPluginManager().callEvent(lightning); + + if (lightning.isCancelled()) { + return false; } - return false; + // CraftBukkit end + + this.server.serverConfigurationManager.a(entity.locX, entity.locY, entity.locZ, 512.0D, new Packet71Weather(entity)); + return true; } else { return false; } @@ -128,9 +130,9 @@ public class WorldServer extends World implements BlockChangeDelegate { } public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag) { + // CraftBukkit start Explosion explosion = super.createExplosion(entity, d0, d1, d2, f, flag); - // CraftBukkit start if (explosion.wasCanceled) { return explosion; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index 06df2b14..ca4be8ce 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -43,7 +43,7 @@ public class CraftChunk implements Chunk { void breakLink() { weakChunk.clear(); - } + } public int getX() { return x; @@ -60,15 +60,15 @@ public class CraftChunk implements Chunk { public Block getBlock(int x, int y, int z) { int pos = (x & 0xF) << 11 | (z & 0xF) << 7 | (y & 0x7F); - Block block = this.cache.get( pos ); + Block block = this.cache.get(pos); if (block == null) { - Block newBlock = new CraftBlock( this, (getX() << 4) | (x & 0xF), y & 0x7F, (getZ() << 4) | (z & 0xF) ); - Block oldBlock = this.cache.put( pos, newBlock ); + Block newBlock = new CraftBlock(this, (getX() << 4) | (x & 0xF), y & 0x7F, (getZ() << 4) | (z & 0xF)); + Block oldBlock = this.cache.put(pos, newBlock); if(oldBlock == null) { block = newBlock; } else { block = oldBlock; - } + } } return block; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 9ac65d54..04246e2f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -267,7 +267,7 @@ public final class CraftServer implements Server { // NOTE: Should only be called from MinecraftServer.b() public boolean dispatchCommand(CommandSender sender, ServerCommand serverCommand) { - if ( commandMap.dispatch(sender, serverCommand.command) ) { + if (commandMap.dispatch(sender, serverCommand.command)) { return true; } return console.consoleCommandHandler.handle(serverCommand); @@ -279,7 +279,7 @@ public final class CraftServer implements Server { return true; } - if ( ! sender.isOp() ) { + if (!sender.isOp()) { return false; } @@ -457,7 +457,7 @@ public final class CraftServer implements Server { private final String prefix; CommandListener(CommandSender commandSender) { this.commandSender = commandSender; - String[] parts = commandSender.getClass().getName().split( "\\." ); + String[] parts = commandSender.getClass().getName().split("\\."); this.prefix = parts[parts.length-1]; } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index c31d62ed..2b38b2bb 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -47,13 +47,13 @@ public class CraftWorld implements World { server.addWorld(this); } - public void preserveChunk( CraftChunk chunk ) { + public void preserveChunk(CraftChunk chunk) { chunk.breakLink(); - unloadedChunks.put( (chunk.getX() << 16) + chunk.getZ(), chunk ); + unloadedChunks.put((chunk.getX() << 16) + chunk.getZ(), chunk); } - public Chunk popPreservedChunk( int x, int z ) { - return unloadedChunks.remove( (x << 16) + z ); + public Chunk popPreservedChunk(int x, int z) { + return unloadedChunks.remove((x << 16) + z); } public Block getBlockAt(int x, int y, int z) { @@ -97,7 +97,7 @@ public class CraftWorld implements World { } public boolean isChunkLoaded(int x, int z) { - return provider.isChunkLoaded( x, z ); + return provider.isChunkLoaded(x, z); } public Chunk[] getLoadedChunks() { @@ -285,7 +285,7 @@ public class CraftWorld implements World { EntityItem entity = new EntityItem(world, loc.getX(), loc.getY(), loc.getZ(), stack); entity.pickupDelay = 10; world.addEntity(entity); - //TODO this is inconsistent with how Entity.getBukkitEntity() works. + // TODO this is inconsistent with how Entity.getBukkitEntity() works. // However, this entity is not at the moment backed by a server entity class so it may be left. return new CraftItem(world.getServer(), entity); } @@ -433,7 +433,7 @@ public class CraftWorld implements World { public void setFullTime(long time) { world.setTime(time); - //Forces the client to update to the new time immediately + // Forces the client to update to the new time immediately for (Player p: getPlayers()) { CraftPlayer cp = (CraftPlayer) p; cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(time)); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 68249b59..ce1c7974 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -245,11 +245,10 @@ public class CraftBlock implements Block { BlockFace[] values = BlockFace.values(); for (BlockFace face : values) { - if ( - (this.getX() + face.getModX() == block.getX()) && - (this.getY() + face.getModY() == block.getY()) && - (this.getZ() + face.getModZ() == block.getZ()) - ) { + if ((this.getX() + face.getModX() == block.getX()) && + (this.getY() + face.getModY() == block.getY()) && + (this.getZ() + face.getModZ() == block.getZ()) + ) { return face; } } @@ -286,7 +285,7 @@ public class CraftBlock implements Block { return BlockFace.SELF; } } - + public static int blockFaceToNotch(BlockFace face) { switch(face) { case DOWN: @@ -302,7 +301,7 @@ public class CraftBlock implements Block { case SOUTH: return 5; default: - return 7; //Good as anything here, but technically invalid + return 7; // Good as anything here, but technically invalid } } @@ -371,7 +370,7 @@ public class CraftBlock implements Block { } @Override - public boolean equals( Object o ) { + public boolean equals(Object o) { return this == o; } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index ad5bc042..1678bbf8 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -34,8 +34,8 @@ public class CraftBlockState implements BlockState { createData(block.getData()); } - public static BlockState getBlockState( net.minecraft.server.World world, int x, int y, int z) { - return new CraftBlockState( ((WorldServer) world).getWorld().getBlockAt(x, y, z) ); + public static BlockState getBlockState(net.minecraft.server.World world, int x, int y, int z) { + return new CraftBlockState(((WorldServer) world).getWorld().getBlockAt(x, y, z)); } /** diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java index 5d1c963e..42c2d6e1 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java @@ -9,7 +9,7 @@ import org.bukkit.inventory.Inventory; /** * Represents a chest. - * + * * @author sk89q */ public class CraftChest extends CraftBlockState implements Chest { diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java index f266ece4..5b1fe8aa 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftFurnace.java @@ -9,7 +9,7 @@ import org.bukkit.inventory.Inventory; /** * Represents a furnace. - * + * * @author sk89q */ public class CraftFurnace extends CraftBlockState implements Furnace { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 841e4c19..34ec97b7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -20,62 +20,62 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { this.entity = entity; } - public static CraftEntity getEntity( CraftServer server, Entity entity) { + public static CraftEntity getEntity(CraftServer server, Entity entity) { /** * Order is *EXTREMELY* important -- keep it right! =D */ if (entity instanceof EntityLiving) { // Players if (entity instanceof EntityHuman) { - if (entity instanceof EntityPlayer) { return new CraftPlayer( server, (EntityPlayer) entity); } - else { return new CraftHumanEntity( server, (EntityHuman) entity); } + if (entity instanceof EntityPlayer) { return new CraftPlayer(server, (EntityPlayer) entity); } + else { return new CraftHumanEntity(server, (EntityHuman) entity); } } else if (entity instanceof EntityCreature) { // Animals if (entity instanceof EntityAnimal) { - if (entity instanceof EntityChicken) { return new CraftChicken( server, (EntityChicken) entity); } - else if (entity instanceof EntityCow) { return new CraftCow( server, (EntityCow) entity); } - else if (entity instanceof EntityPig) { return new CraftPig( server, (EntityPig) entity); } - else if (entity instanceof EntityWolf) { return new CraftWolf( server, (EntityWolf) entity); } - else if (entity instanceof EntitySheep) { return new CraftSheep( server, (EntitySheep) entity); } - else { return new CraftAnimals( server, (EntityAnimal) entity); } + if (entity instanceof EntityChicken) { return new CraftChicken(server, (EntityChicken) entity); } + else if (entity instanceof EntityCow) { return new CraftCow(server, (EntityCow) entity); } + else if (entity instanceof EntityPig) { return new CraftPig(server, (EntityPig) entity); } + else if (entity instanceof EntityWolf) { return new CraftWolf(server, (EntityWolf) entity); } + else if (entity instanceof EntitySheep) { return new CraftSheep(server, (EntitySheep) entity); } + else { return new CraftAnimals(server, (EntityAnimal) entity); } } // Monsters else if (entity instanceof EntityMonster) { if (entity instanceof EntityZombie) { - if (entity instanceof EntityPigZombie) { return new CraftPigZombie( server, (EntityPigZombie) entity); } - else { return new CraftZombie( server, (EntityZombie) entity); } + if (entity instanceof EntityPigZombie) { return new CraftPigZombie(server, (EntityPigZombie) entity); } + else { return new CraftZombie(server, (EntityZombie) entity); } } - else if (entity instanceof EntityCreeper) { return new CraftCreeper( server, (EntityCreeper) entity); } - else if (entity instanceof EntityGiantZombie) { return new CraftGiant( server, (EntityGiantZombie) entity); } - else if (entity instanceof EntitySkeleton) { return new CraftSkeleton( server, (EntitySkeleton) entity); } - else if (entity instanceof EntitySpider) { return new CraftSpider( server, (EntitySpider) entity); } + else if (entity instanceof EntityCreeper) { return new CraftCreeper(server, (EntityCreeper) entity); } + else if (entity instanceof EntityGiantZombie) { return new CraftGiant(server, (EntityGiantZombie) entity); } + else if (entity instanceof EntitySkeleton) { return new CraftSkeleton(server, (EntitySkeleton) entity); } + else if (entity instanceof EntitySpider) { return new CraftSpider(server, (EntitySpider) entity); } - else { return new CraftMonster( server, (EntityMonster) entity); } + else { return new CraftMonster(server, (EntityMonster) entity); } } // Water Animals else if (entity instanceof EntityWaterAnimal) { - if (entity instanceof EntitySquid) { return new CraftSquid( server, (EntitySquid) entity); } - else { return new CraftWaterMob( server, (EntityWaterAnimal) entity); } + if (entity instanceof EntitySquid) { return new CraftSquid(server, (EntitySquid) entity); } + else { return new CraftWaterMob(server, (EntityWaterAnimal) entity); } } - else { return new CraftCreature( server, (EntityCreature) entity); } + else { return new CraftCreature(server, (EntityCreature) entity); } } // Slimes are a special (and broken) case - else if (entity instanceof EntitySlime) { return new CraftSlime( server, (EntitySlime) entity); } + else if (entity instanceof EntitySlime) { return new CraftSlime(server, (EntitySlime) entity); } // Flying else if (entity instanceof EntityFlying) { - if (entity instanceof EntityGhast) { return new CraftGhast( server, (EntityGhast) entity); } - else { return new CraftFlying( server, (EntityFlying) entity); } + if (entity instanceof EntityGhast) { return new CraftGhast(server, (EntityGhast) entity); } + else { return new CraftFlying(server, (EntityFlying) entity); } } else { return new CraftLivingEntity(server, (EntityLiving) entity); } } - else if (entity instanceof EntityArrow) { return new CraftArrow( server, (EntityArrow) entity); } - else if (entity instanceof EntityBoat) { return new CraftBoat( server, (EntityBoat) entity); } - else if (entity instanceof EntityEgg) { return new CraftEgg( server, (EntityEgg) entity); } - else if (entity instanceof EntityFallingSand) { return new CraftFallingSand( server, (EntityFallingSand) entity); } - else if (entity instanceof EntityFireball) { return new CraftFireball( server, (EntityFireball) entity); } - else if (entity instanceof EntityFish) { return new CraftFish( server, (EntityFish) entity); } - else if (entity instanceof EntityItem) { return new CraftItem( server, (EntityItem) entity); } + else if (entity instanceof EntityArrow) { return new CraftArrow(server, (EntityArrow) entity); } + else if (entity instanceof EntityBoat) { return new CraftBoat(server, (EntityBoat) entity); } + else if (entity instanceof EntityEgg) { return new CraftEgg(server, (EntityEgg) entity); } + else if (entity instanceof EntityFallingSand) { return new CraftFallingSand(server, (EntityFallingSand) entity); } + else if (entity instanceof EntityFireball) { return new CraftFireball(server, (EntityFireball) entity); } + else if (entity instanceof EntityFish) { return new CraftFish(server, (EntityFish) entity); } + else if (entity instanceof EntityItem) { return new CraftItem(server, (EntityItem) entity); } else if (entity instanceof EntityWeather) { if (entity instanceof EntityWeatherStorm) { return new CraftLightningStrike(server, (EntityWeatherStorm)entity); @@ -93,10 +93,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return new CraftMinecart(server, mc); } } - else if (entity instanceof EntityPainting) { return new CraftPainting( server, (EntityPainting) entity); } - else if (entity instanceof EntitySnowball) { return new CraftSnowball( server, (EntitySnowball) entity); } - else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed( server, (EntityTNTPrimed) entity); } - else throw new IllegalArgumentException( "Unknown entity" ); + else if (entity instanceof EntityPainting) { return new CraftPainting(server, (EntityPainting) entity); } + else if (entity instanceof EntitySnowball) { return new CraftSnowball(server, (EntitySnowball) entity); } + else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed(server, (EntityTNTPrimed) entity); } + else throw new IllegalArgumentException("Unknown entity"); } public Location getLocation() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index b7b2d63e..27b7aee3 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -13,7 +13,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public CraftHumanEntity(final CraftServer server, final EntityHuman entity) { super(server, entity); - this.inventory = new CraftInventoryPlayer( entity.inventory ); + this.inventory = new CraftInventoryPlayer(entity.inventory); } public String getName() { @@ -28,7 +28,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public void setHandle(final EntityHuman entity) { super.setHandle((EntityHuman)entity); this.entity = entity; - this.inventory = new CraftInventoryPlayer( entity.inventory ); + this.inventory = new CraftInventoryPlayer(entity.inventory); } public PlayerInventory getInventory() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 55d80dde..0ae97517 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -197,8 +197,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { manager.server.tracker.untrackEntity(entity); int cx = (int) location.getBlockX() >> 4; int cz = (int) location.getBlockZ() >> 4; - for (int x = -10 ; x <= 10 ; x++ ) { - for (int z = -10 ; z <= 10 ; z++ ) { + for (int x = -10 ; x <= 10 ; x++) { + for (int z = -10 ; z <= 10 ; z++) { ChunkCoordIntPair chunkPosition = new ChunkCoordIntPair(cx + x, cz + z); if (entity.g.remove(chunkPosition)) { newEntity.g.add(chunkPosition); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java index 4f32bbdf..86d7f050 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftStorageMinecart.java @@ -17,7 +17,7 @@ public class CraftStorageMinecart extends CraftMinecart implements StorageMineca public CraftStorageMinecart(CraftServer server, EntityMinecart entity) { super(server, entity); - inventory = new CraftInventory( entity ); + inventory = new CraftInventory(entity); } public Inventory getInventory() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java index ffd46dc6..9e69da70 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -30,7 +30,7 @@ public class CraftWolf extends CraftAnimals implements Wolf { public void setSitting(boolean sitting) { getHandle().setSitting(sitting); // TODO determine what the following would do - it is affected every time a player makes their wolf sit or stand - //getHandle().ay = false; + // getHandle().ay = false; setPath((PathEntity) null); } @@ -59,9 +59,9 @@ public class CraftWolf extends CraftAnimals implements Wolf { /* Set owner */ // TODO persist owner to the persistence store if (owner instanceof Player) { - setOwnerName(((Player) owner).getName()); + setOwnerName(((Player) owner).getName()); } else { - setOwnerName(""); + setOwnerName(""); } } else { setTamed(false); /* Make him not tame */ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 736896f6..4f879b98 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -125,7 +125,7 @@ public class CraftEventFactory { /** * Player Interact event */ - + public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) { if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) { throw new IllegalArgumentException(); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index bba47de7..9cc8d436 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -34,7 +34,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { ItemStack[] items = new ItemStack[getSize()]; net.minecraft.server.ItemStack[] mcItems = getInventory().getContents(); - for (int i = 0; i < mcItems.length; i++ ) { + for (int i = 0; i < mcItems.length; i++) { items[i] = mcItems[i] == null ? null : new CraftItemStack(mcItems[i]); } @@ -48,18 +48,18 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { net.minecraft.server.ItemStack[] mcItems = getInventory().getContents(); - for (int i = 0; i < items.length; i++ ) { + for (int i = 0; i < items.length; i++) { ItemStack item = items[i]; if (item == null || item.getTypeId() <= 0) { mcItems[i] = null; } else { - mcItems[i] = new net.minecraft.server.ItemStack( item.getTypeId(), item.getAmount(), item.getDurability()); + mcItems[i] = new net.minecraft.server.ItemStack(item.getTypeId(), item.getAmount(), item.getDurability()); } } } public void setItem(int index, ItemStack item) { - getInventory().setItem(index, (item == null ? null : new net.minecraft.server.ItemStack( item.getTypeId(), item.getAmount(), item.getDurability()))); + getInventory().setItem(index, (item == null ? null : new net.minecraft.server.ItemStack(item.getTypeId(), item.getAmount(), item.getDurability()))); } public boolean contains(int materialId) { @@ -121,7 +121,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { for (int i = 0; i < inventory.length; i++) { ItemStack item = inventory[i]; if (item != null && item.getTypeId() == materialId) { - slots.put( i, item ); + slots.put(i, item); } } return slots; @@ -137,7 +137,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { ItemStack[] inventory = getContents(); for (int i = 0; i < inventory.length; i++) { if (item.equals(inventory[i])) { - slots.put( i, inventory[i] ); + slots.put(i, inventory[i]); } } } @@ -238,11 +238,11 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { } else { // More than a single stack! if (item.getAmount() > getMaxItemStack()) { - setItem( firstFree, new CraftItemStack(item.getTypeId(), getMaxItemStack(), item.getDurability())); + setItem(firstFree, new CraftItemStack(item.getTypeId(), getMaxItemStack(), item.getDurability())); item.setAmount(item.getAmount() - getMaxItemStack()); } else { // Just store it - setItem( firstFree, item ); + setItem(firstFree, item); break; } } @@ -256,13 +256,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { // Check if it fully fits if (amount + partialAmount <= maxAmount) { - partialItem.setAmount( amount + partialAmount ); + partialItem.setAmount(amount + partialAmount); break; } // It fits partially - partialItem.setAmount( maxAmount ); - item.setAmount( amount + partialAmount - maxAmount ); + partialItem.setAmount(maxAmount); + item.setAmount(amount + partialAmount - maxAmount); } } } @@ -283,7 +283,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { // Drat! we don't have this type in the inventory if (first == -1) { - item.setAmount( toDelete ); + item.setAmount(toDelete); leftover.put(i, item); break; } else { @@ -293,11 +293,11 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { if (amount <= toDelete) { toDelete -= amount; // clear the slot, all used up - clear( first ); + clear(first); } else { // split the stack and store - itemStack.setAmount( amount - toDelete ); - setItem( first, itemStack ); + itemStack.setAmount(amount - toDelete); + setItem(first, itemStack); toDelete = 0; } } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java index 72c6a478..ee51f9d2 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryPlayer.java @@ -19,11 +19,11 @@ public class CraftInventoryPlayer extends CraftInventory implements PlayerInvent } public ItemStack getItemInHand() { - return new CraftItemStack( getInventory().getItemInHand() ); + return new CraftItemStack(getInventory().getItemInHand()); } public void setItemInHand(ItemStack stack) { - setItem( getHeldItemSlot(), stack ); + setItem(getHeldItemSlot(), stack); } public int getHeldItemSlot() { @@ -31,42 +31,42 @@ public class CraftInventoryPlayer extends CraftInventory implements PlayerInvent } public ItemStack getHelmet() { - return getItem( getSize() + 3 ); + return getItem(getSize() + 3); } public ItemStack getChestplate() { - return getItem( getSize() + 2 ); + return getItem(getSize() + 2); } public ItemStack getLeggings() { - return getItem( getSize() + 1 ); + return getItem(getSize() + 1); } public ItemStack getBoots() { - return getItem( getSize() + 0 ); + return getItem(getSize() + 0); } public void setHelmet(ItemStack helmet) { - setItem( getSize() + 3, helmet ); + setItem(getSize() + 3, helmet); } public void setChestplate(ItemStack chestplate) { - setItem( getSize() + 2, chestplate ); + setItem(getSize() + 2, chestplate); } public void setLeggings(ItemStack leggings) { - setItem( getSize() + 1, leggings ); + setItem(getSize() + 1, leggings); } public void setBoots(ItemStack boots) { - setItem( getSize() + 0, boots ); + setItem(getSize() + 0, boots); } public CraftItemStack[] getArmorContents() { net.minecraft.server.ItemStack[] mcItems = getInventory().getArmorContents(); CraftItemStack[] ret = new CraftItemStack[mcItems.length]; - for (int i = 0; i < mcItems.length; i++ ) { + for (int i = 0; i < mcItems.length; i++) { ret[i] = new CraftItemStack(mcItems[i]); } return ret; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSlot.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSlot.java index a44c1b90..3899eb75 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSlot.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSlot.java @@ -12,7 +12,7 @@ public class CraftSlot implements org.bukkit.inventory.Slot { } public Inventory getInventory() { - return new CraftInventory( slot.inventory ); + return new CraftInventory(slot.inventory); } public int getIndex() { @@ -20,6 +20,6 @@ public class CraftSlot implements org.bukkit.inventory.Slot { } public ItemStack getItem() { - return new CraftItemStack( slot.getItem() ); + return new CraftItemStack(slot.getItem()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java index 222a3158..707de087 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -59,7 +59,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable { firstTick = first.getExecutionTick(); - if (currentTick >= firstTick ) { + if (currentTick >= firstTick) { schedulerQueue.remove(first); processTask(first); if (first.getPeriod()>=0) { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java index d5cc4f4e..4227dbc9 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java @@ -91,7 +91,7 @@ public class CraftTask implements Comparable, BukkitTask { } @Override - public boolean equals( Object other ) { + public boolean equals(Object other) { if (other == null) { return false; diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftWorker.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftWorker.java index 42f9bb9b..94aa411c 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftWorker.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftWorker.java @@ -74,7 +74,7 @@ public class CraftWorker implements Runnable, BukkitWorker { } @Override - public boolean equals( Object other ) { + public boolean equals(Object other) { if (other == null) { return false; } diff --git a/src/main/java/org/bukkit/craftbukkit/util/Java15Compat.java b/src/main/java/org/bukkit/craftbukkit/util/Java15Compat.java index a9ccc70b..c9c5f284 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Java15Compat.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Java15Compat.java @@ -21,7 +21,7 @@ public class Java15Compat { if (original.length >= start && 0 <= start) { if (start <= end) { int length = end - start; - int copyLength = Math.min( length, original.length - start); + int copyLength = Math.min(length, original.length - start); long[] copy = (long[]) Array.newInstance(original.getClass().getComponentType(), length); System.arraycopy(original, start, copy, 0, copyLength); return copy; diff --git a/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java b/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java index d8282580..8d8b4e73 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java +++ b/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java @@ -55,5 +55,5 @@ public class ShortConsoleLogFormatter extends Formatter { return builder.toString(); } - + } -- cgit v1.2.3