summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorAndrew Ardill <andrew.ardill@gmail.com>2011-01-23 23:23:13 +1100
committerAndrew Ardill <andrew.ardill@gmail.com>2011-01-23 23:23:13 +1100
commita809e4e6e32e194c288723ceb2e1534bbddea174 (patch)
treeceebf1bdff232e048d8d9b669e267a6598d2af13 /src/main
parent9cd81ddd6d78d625bab88ee0ab0bc6080447fc96 (diff)
downloadcraftbukkit-a809e4e6e32e194c288723ceb2e1534bbddea174.tar
craftbukkit-a809e4e6e32e194c288723ceb2e1534bbddea174.tar.gz
craftbukkit-a809e4e6e32e194c288723ceb2e1534bbddea174.tar.lz
craftbukkit-a809e4e6e32e194c288723ceb2e1534bbddea174.tar.xz
craftbukkit-a809e4e6e32e194c288723ceb2e1534bbddea174.zip
removed all instances of new CraftEntity* where appropriate.
Entity.getBukkitEntity() is now used instead.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/net/minecraft/server/BlockButton.java18
-rw-r--r--src/main/java/net/minecraft/server/BlockChest.java16
-rw-r--r--src/main/java/net/minecraft/server/BlockDoor.java20
-rw-r--r--src/main/java/net/minecraft/server/BlockFurnace.java22
-rw-r--r--src/main/java/net/minecraft/server/BlockJukeBox.java20
-rw-r--r--src/main/java/net/minecraft/server/BlockLever.java26
-rw-r--r--src/main/java/net/minecraft/server/BlockPressurePlate.java24
-rw-r--r--src/main/java/net/minecraft/server/BlockWorkbench.java23
-rw-r--r--src/main/java/net/minecraft/server/ItemBlock.java16
-rw-r--r--src/main/java/net/minecraft/server/ItemBoat.java26
-rw-r--r--src/main/java/net/minecraft/server/ItemBucket.java27
-rw-r--r--src/main/java/net/minecraft/server/ItemHoe.java28
-rw-r--r--src/main/java/net/minecraft/server/ItemMinecart.java28
-rw-r--r--src/main/java/net/minecraft/server/ItemRedstone.java29
-rw-r--r--src/main/java/net/minecraft/server/ItemSeeds.java23
-rw-r--r--src/main/java/net/minecraft/server/ItemSign.java28
-rw-r--r--src/main/java/net/minecraft/server/NetServerHandler.java34
-rw-r--r--src/main/java/net/minecraft/server/ServerConfigurationManager.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftMappable.java1
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java9
22 files changed, 279 insertions, 149 deletions
diff --git a/src/main/java/net/minecraft/server/BlockButton.java b/src/main/java/net/minecraft/server/BlockButton.java
index 625acdd9..3a82ea91 100644
--- a/src/main/java/net/minecraft/server/BlockButton.java
+++ b/src/main/java/net/minecraft/server/BlockButton.java
@@ -4,8 +4,11 @@ import java.util.Random;
// CraftBukkit start
import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
@@ -139,11 +142,14 @@ public class BlockButton extends Block {
public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
// CraftBukkit start - Interact Button
- CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player);
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(bie);
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
+
+ BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) {
return true;
@@ -166,7 +172,7 @@ public class BlockButton extends Block {
int old = (j1 != 8) ? 1 : 0;
int current = (j1 == 8) ? 1 : 0;
BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, old, current);
- ((WorldServer) world).getServer().getPluginManager().callEvent(bre);
+ server.getPluginManager().callEvent(bre);
if ((bre.getNewCurrent() > 0) == (j1 == 8)) {
world.c(i, j, k, i1 + j1);
world.b(i, j, k, i, j, k);
diff --git a/src/main/java/net/minecraft/server/BlockChest.java b/src/main/java/net/minecraft/server/BlockChest.java
index 78be0927..607990df 100644
--- a/src/main/java/net/minecraft/server/BlockChest.java
+++ b/src/main/java/net/minecraft/server/BlockChest.java
@@ -3,8 +3,11 @@ package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end
@@ -150,11 +153,14 @@ public class BlockChest extends BlockContainer {
return true;
} else {
// CraftBukkit start - Interact Chest
- CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player);
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(bie);
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
+
+ BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) return true;
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/BlockDoor.java b/src/main/java/net/minecraft/server/BlockDoor.java
index c9c92fee..33c577e1 100644
--- a/src/main/java/net/minecraft/server/BlockDoor.java
+++ b/src/main/java/net/minecraft/server/BlockDoor.java
@@ -3,8 +3,11 @@ package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end
@@ -72,13 +75,16 @@ public class BlockDoor extends Block {
}
// CraftBukkit start - Interact Door
- CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player);
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(bie);
-
- // Craftbukkit the client updates the doors before the server does it's thing.
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
+
+ BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(bie);
+
+ // CraftBukkit the client updates the doors before the server does it's thing.
// Forcibly send correct data.
if (bie.isCancelled()) {
((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
diff --git a/src/main/java/net/minecraft/server/BlockFurnace.java b/src/main/java/net/minecraft/server/BlockFurnace.java
index d9302f7d..34a13f81 100644
--- a/src/main/java/net/minecraft/server/BlockFurnace.java
+++ b/src/main/java/net/minecraft/server/BlockFurnace.java
@@ -3,8 +3,11 @@ package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end
@@ -69,13 +72,18 @@ public class BlockFurnace extends BlockContainer {
return true;
} else {
// CraftBukkit start - Interact Furnace
- CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player);
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(bie);
-
- if (bie.isCancelled()) return true;
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
+
+ BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(bie);
+
+ if (bie.isCancelled()) {
+ return true;
+ }
// CraftBukkit end
TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.m(i, j, k);
diff --git a/src/main/java/net/minecraft/server/BlockJukeBox.java b/src/main/java/net/minecraft/server/BlockJukeBox.java
index 5e4ee71e..2ed220e6 100644
--- a/src/main/java/net/minecraft/server/BlockJukeBox.java
+++ b/src/main/java/net/minecraft/server/BlockJukeBox.java
@@ -1,8 +1,11 @@
package net.minecraft.server;
// CraftBukkit start
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end
@@ -22,13 +25,18 @@ public class BlockJukeBox extends Block {
if (l > 0) {
// CraftBukkit start - Interact Jukebox
- CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player);
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
+
+ BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(bie);
- ((WorldServer) world).getServer().getPluginManager().callEvent(bie);
-
- if (bie.isCancelled()) return true;
+ if (bie.isCancelled()) {
+ return true;
+ }
// CraftBukkit end
f(world, i, j, k, l);
diff --git a/src/main/java/net/minecraft/server/BlockLever.java b/src/main/java/net/minecraft/server/BlockLever.java
index 41ca010b..bcd2846d 100644
--- a/src/main/java/net/minecraft/server/BlockLever.java
+++ b/src/main/java/net/minecraft/server/BlockLever.java
@@ -2,8 +2,11 @@ package net.minecraft.server;
// CraftBukkit start
import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
@@ -143,13 +146,16 @@ public class BlockLever extends Block {
}
// CraftBukkit start - Interact Lever
- CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player);
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(bie);
-
- // Craftbukkit the client updates the doors before the server does it's thing.
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
+
+ BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(bie);
+
+ // CraftBukkit the client updates the doors before the server does it's thing.
// Forcibly send correct data.
if (bie.isCancelled()) {
((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));
@@ -161,12 +167,12 @@ public class BlockLever extends Block {
int i1 = l & 7;
int j1 = 8 - (l & 8);
- // Craftbukkit start
+ // CraftBukkit start
int old = (j1 != 8) ? 1 : 0;
int current = (j1 == 8) ? 1 : 0;
BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, old, current);
- ((WorldServer) world).getServer().getPluginManager().callEvent(bre);
- // Craftbukkit end
+ server.getPluginManager().callEvent(bre);
+ // CraftBukkit end
if ((bre.getNewCurrent() > 0) == (j1 == 8)) {
world.c(i, j, k, i1 + j1);
diff --git a/src/main/java/net/minecraft/server/BlockPressurePlate.java b/src/main/java/net/minecraft/server/BlockPressurePlate.java
index 211099f4..fcb48af8 100644
--- a/src/main/java/net/minecraft/server/BlockPressurePlate.java
+++ b/src/main/java/net/minecraft/server/BlockPressurePlate.java
@@ -4,9 +4,12 @@ import java.util.List;
import java.util.Random;
// CraftBukkit start
-import org.bukkit.block.BlockFace;import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.block.BlockFace;import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
@@ -76,17 +79,14 @@ public class BlockPressurePlate extends Block {
} else {
// CraftBukkit start - Interact Pressure Plate
if (entity instanceof EntityLiving) {
- CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftLivingEntity craftEntity = null;
-
- if (entity instanceof EntityPlayerMP) {
- craftEntity = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entity);
- } else {
- craftEntity = new CraftLivingEntity(((WorldServer) world).getServer(), (EntityLiving) entity);
- }
- BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, craftEntity);
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(bie);
+ CraftServer server = ((WorldServer) world).getServer();
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ org.bukkit.entity.LivingEntity who = (entity == null)?null:(LivingEntity) entity.getBukkitEntity();
+
+ BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) {
return;
diff --git a/src/main/java/net/minecraft/server/BlockWorkbench.java b/src/main/java/net/minecraft/server/BlockWorkbench.java
index 3639ec73..33bcf7b3 100644
--- a/src/main/java/net/minecraft/server/BlockWorkbench.java
+++ b/src/main/java/net/minecraft/server/BlockWorkbench.java
@@ -1,8 +1,10 @@
package net.minecraft.server;
// CraftBukkit start
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
-import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end
@@ -33,13 +35,18 @@ public class BlockWorkbench extends Block {
return true;
} else {
// CraftBukkit start - Interact Workbench
- CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player);
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(bie);
-
- if (bie.isCancelled()) return true;
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_INTERACT;
+ CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
+ LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
+
+ BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
+ server.getPluginManager().callEvent(bie);
+
+ if (bie.isCancelled()) {
+ return true;
+ }
// CraftBukkit end
entityplayer.a(i, j, k);
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
index edf628cb..f6a7dac2 100644
--- a/src/main/java/net/minecraft/server/ItemBlock.java
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
@@ -2,9 +2,10 @@ package net.minecraft.server;
// CraftBukkit start
import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
-import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockPlaceEvent;
// CraftBukkit end
@@ -75,17 +76,20 @@ public class ItemBlock extends Item {
* replace this with.
*/
if (world.a(i, j, k, a, a(itemstack.h()))) { // <-- world.b does this to place the block
- CraftBlock placedBlock = (CraftBlock) blockClicked.getFace(faceClicked) ;
- CraftItemStack itemInHand = new CraftItemStack(itemstack);
- CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
+ org.bukkit.Server server = ((WorldServer) world).getServer();
+ Type eventType = Type.BLOCK_PLACED;
+ org.bukkit.block.Block placedBlock = blockClicked.getFace(faceClicked) ;
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ Player thePlayer = (entityplayer ==null)?null:(Player)entityplayer.getBukkitEntity();
int distanceFromSpawn = (int) Math.max(Math.abs(i - world.m), Math.abs(k - world.o));
// CraftBukkit hardcoded Spawn distance for now
+ // TODO make spawn size configurable
boolean canBuild = distanceFromSpawn > 16 || thePlayer.isOp();
- BlockPlaceEvent bpe = new BlockPlaceEvent(Type.BLOCK_PLACED, placedBlock, blockClicked, itemInHand, thePlayer, canBuild);
- ((WorldServer) world).getServer().getPluginManager().callEvent(bpe);
+ BlockPlaceEvent bpe = new BlockPlaceEvent(eventType, placedBlock, blockClicked, itemInHand, thePlayer, canBuild);
+ server.getPluginManager().callEvent(bpe);
if (bpe.isCancelled() || !bpe.canBuild()) {
// CraftBukkit Undo!
diff --git a/src/main/java/net/minecraft/server/ItemBoat.java b/src/main/java/net/minecraft/server/ItemBoat.java
index df51f991..ade7bf24 100644
--- a/src/main/java/net/minecraft/server/ItemBoat.java
+++ b/src/main/java/net/minecraft/server/ItemBoat.java
@@ -1,9 +1,12 @@
package net.minecraft.server;
// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
-import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end
@@ -44,14 +47,21 @@ public class ItemBoat extends Item {
if (!world.z) {
// CraftBukkit start - Boat placement
- CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftItemStack itemInHand = new CraftItemStack(itemstack);
- CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(movingobjectposition.e));
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
+
+ PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(pie);
- ((WorldServer) world).getServer().getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) return itemstack;
+ if (pie.isCancelled()) {
+ return itemstack;
+ }
// CraftBukkit end
world.a(((Entity) (new EntityBoat(world, (float) i + 0.5F, (float) j + 1.5F, (float) k + 0.5F))));
diff --git a/src/main/java/net/minecraft/server/ItemBucket.java b/src/main/java/net/minecraft/server/ItemBucket.java
index b38992e9..017fd0d4 100644
--- a/src/main/java/net/minecraft/server/ItemBucket.java
+++ b/src/main/java/net/minecraft/server/ItemBucket.java
@@ -7,7 +7,9 @@ import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end
@@ -55,18 +57,21 @@ public class ItemBucket extends Item {
}
// CraftBukkit start - Click == placed when handling an empty bucket!
- CraftWorld theWorld = ((WorldServer) world).getWorld();
- CraftBlock blockClicked = (CraftBlock) theWorld.getBlockAt(i, j, k);
- BlockFace direction = CraftBlock.notchToBlockFace(movingobjectposition.e);
- CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- CraftItemStack itemInHand = new CraftItemStack(itemstack);
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockFace = CraftBlock.notchToBlockFace(movingobjectposition.e);
// CraftBukkit end
if (a == 0) {
if (world.c(i, j, k) == Material.f && world.b(i, j, k) == 0) {
// CraftBukkit start
- PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, direction);
- ((WorldServer) world).getServer().getPluginManager().callEvent(pie);
+ PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return itemstack;
@@ -77,8 +82,8 @@ public class ItemBucket extends Item {
}
if (world.c(i, j, k) == Material.g && world.b(i, j, k) == 0) {
// CraftBukkit start
- PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, direction);
- ((WorldServer) world).getServer().getPluginManager().callEvent(pie);
+ PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return itemstack;
@@ -117,8 +122,8 @@ public class ItemBucket extends Item {
}
} else {
// CraftBukkit start - bucket empty.
- PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, direction);
- ((WorldServer) world).getServer().getPluginManager().callEvent(pie);
+ PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return itemstack;
diff --git a/src/main/java/net/minecraft/server/ItemHoe.java b/src/main/java/net/minecraft/server/ItemHoe.java
index 033fc7c8..d60829a7 100644
--- a/src/main/java/net/minecraft/server/ItemHoe.java
+++ b/src/main/java/net/minecraft/server/ItemHoe.java
@@ -3,9 +3,12 @@ package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
-import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end
@@ -24,14 +27,21 @@ public class ItemHoe extends Item {
if (!material.a() && i1 == Block.u.bi || i1 == Block.v.bi) {
// CraftBukkit start - Hoes
- CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftItemStack itemInHand = new CraftItemStack(itemstack);
- CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) return false;
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockFace = CraftBlock.notchToBlockFace(1);
+
+ PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(pie);
+
+ if (pie.isCancelled()) {
+ return false;
+ }
// CraftBukkit end
Block block = Block.aA;
diff --git a/src/main/java/net/minecraft/server/ItemMinecart.java b/src/main/java/net/minecraft/server/ItemMinecart.java
index 35bbe4ee..7d97e6fc 100644
--- a/src/main/java/net/minecraft/server/ItemMinecart.java
+++ b/src/main/java/net/minecraft/server/ItemMinecart.java
@@ -1,9 +1,12 @@
package net.minecraft.server;
// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
-import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end
@@ -23,14 +26,21 @@ public class ItemMinecart extends Item {
if (i1 == Block.aG.bi) {
// CraftBukkit start - Minecarts
- CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftItemStack itemInHand = new CraftItemStack(itemstack);
- CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) return false;
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockFace = CraftBlock.notchToBlockFace(1);
+
+ PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
+ craftServer.getPluginManager().callEvent(pie);
+
+ if (pie.isCancelled()) {
+ return false;
+ }
// CraftBukkit end
if (!world.z) {
diff --git a/src/main/java/net/minecraft/server/ItemRedstone.java b/src/main/java/net/minecraft/server/ItemRedstone.java
index c5630faa..2119012d 100644
--- a/src/main/java/net/minecraft/server/ItemRedstone.java
+++ b/src/main/java/net/minecraft/server/ItemRedstone.java
@@ -1,9 +1,13 @@
package net.minecraft.server;
// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end
@@ -15,9 +19,6 @@ public class ItemRedstone extends Item {
}
public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
- // CraftBukkit - get the clicked block
- CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
-
if (l == 0) {
j--;
}
@@ -41,13 +42,21 @@ public class ItemRedstone extends Item {
}
if (Block.av.a(world, i, j, k)) {
// CraftBukkit start - Redstone
- CraftItemStack itemInHand = new CraftItemStack(itemstack);
- CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) return false;
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockface = CraftBlock.notchToBlockFace(1);
+
+ PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
+ craftServer.getPluginManager().callEvent(pie);
+
+ if (pie.isCancelled()) {
+ return false;
+ }
// CraftBukkit end
itemstack.a--;
diff --git a/src/main/java/net/minecraft/server/ItemSeeds.java b/src/main/java/net/minecraft/server/ItemSeeds.java
index 50694506..cab36fde 100644
--- a/src/main/java/net/minecraft/server/ItemSeeds.java
+++ b/src/main/java/net/minecraft/server/ItemSeeds.java
@@ -1,9 +1,13 @@
package net.minecraft.server;
// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end
@@ -25,13 +29,18 @@ public class ItemSeeds extends Item {
if (i1 == Block.aA.bi && world.e(i, j + 1, k)) {
// CraftBukkit start - Seeds
- CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
- CraftItemStack itemInHand = new CraftItemStack(itemstack);
- CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(pie);
-
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockface = CraftBlock.notchToBlockFace(1);
+
+ PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
+ craftServer.getPluginManager().callEvent(pie);
+
if (pie.isCancelled()) {
return false;
}
diff --git a/src/main/java/net/minecraft/server/ItemSign.java b/src/main/java/net/minecraft/server/ItemSign.java
index 09a01186..5950f526 100644
--- a/src/main/java/net/minecraft/server/ItemSign.java
+++ b/src/main/java/net/minecraft/server/ItemSign.java
@@ -1,9 +1,12 @@
package net.minecraft.server;
// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
-import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end
@@ -25,7 +28,6 @@ public class ItemSign extends Item {
}
// CraftBukkit - store the clicked block
- CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
if (l == 1) {
j++;
@@ -48,13 +50,21 @@ public class ItemSign extends Item {
// CraftBukkit start
// Signs
- CraftItemStack itemInHand = new CraftItemStack(itemstack);
- CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
- PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
-
- ((WorldServer) world).getServer().getPluginManager().callEvent(pie);
-
- if (pie.isCancelled()) return false;
+ CraftWorld craftWorld = ((WorldServer) world).getWorld();
+ CraftServer craftServer = ((WorldServer) world).getServer();
+
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+ org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
+ BlockFace blockface = CraftBlock.notchToBlockFace(1);
+
+ PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
+ craftServer.getPluginManager().callEvent(pie);
+
+ if (pie.isCancelled()) {
+ return false;
+ }
// CraftBukkit end
if (l == 1) {
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java
index 13ef4a7f..1d53f57f 100644
--- a/src/main/java/net/minecraft/server/NetServerHandler.java
+++ b/src/main/java/net/minecraft/server/NetServerHandler.java
@@ -12,6 +12,8 @@ import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockRightClickEvent;
@@ -38,10 +40,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit start - next 2 lines
private final CraftServer server;
- private final CraftPlayer player;
public CraftPlayer getPlayer() {
- return player;
+ return (e == null)?null:(CraftPlayer)e.getBukkitEntity();
}
// CraftBukkit end
@@ -58,7 +59,6 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit - next 2 lines
server = minecraftserver.server;
- player = new CraftPlayer(server, e);
}
public void a() {
@@ -86,6 +86,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
// CraftBukkit start
+ Player player = getPlayer();
Location from = new Location(player.getWorld(), g, h, i, e.v, e.w);
Location to = player.getLocation();
if (!from.equals(to)) {
@@ -212,6 +213,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
public void a(double d1, double d2, double d3, float f1, float f2) {
// CraftBukkit start
+ Player player = getPlayer();
Location from = player.getLocation();
Location to = new Location(player.getWorld(), d1, d2, d3, f1, f2);
PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_TELEPORT, player, from, to);
@@ -283,6 +285,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
// CraftBukkit start
+ CraftPlayer player = getPlayer();
CraftBlock block = (CraftBlock) player.getWorld().getBlockAt(l, i1, j1);
int blockId = block.getTypeId();
float damage = 0;
@@ -402,13 +405,15 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
// CraftBukkit start
- CraftItemStack craftItem = new CraftItemStack(itemstack);
- CraftPlayer player = new CraftPlayer(server, e);
- PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, player, craftItem, blockClicked, blockFace);
+ Type eventType = Type.PLAYER_ITEM;
+ Player who = (e == null)?null:(Player)e.getBukkitEntity();
+ org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
+
+ PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
// CraftBukkit We still call this event even in spawn protection.
// Don't call this event if using Buckets / signs
- switch (craftItem.getType()) {
+ switch (itemInHand.getType()) {
case SIGN:
case BUCKET:
case WATER_BUCKET:
@@ -440,7 +445,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
// CraftBukkit start - spawn proection moved to ItemBlock!!!
CraftItemStack craftItem = new CraftItemStack(itemstack);
- CraftPlayer player = new CraftPlayer(server, e);
+ Player player = getPlayer();
BlockRightClickEvent brce = new BlockRightClickEvent(Type.BLOCK_RIGHTCLICKED, blockClicked, blockFace, craftItem, player);
server.getPluginManager().callEvent(brce);
@@ -523,6 +528,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
c(s);
} else {
// CraftBukkit start
+ Player player = getPlayer();
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_CHAT, player, s);
server.getPluginManager().callEvent(event);
s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
@@ -538,7 +544,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
private void c(String s) {
// CraftBukkit start
- boolean targetPluginFound = server.dispatchCommand(player, s);
+ CraftPlayer player = getPlayer();
+ boolean targetPluginFound = server.dispatchCommand(player , s);
if (targetPluginFound) {
return;
}
@@ -549,7 +556,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
return;
}
s = event.getMessage();
- CraftPlayer player = (CraftPlayer) event.getPlayer();
+ player = (CraftPlayer) event.getPlayer();
EntityPlayerMP e = player.getHandle();
// CraftBukkit stop
@@ -585,9 +592,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
public void a(Packet18ArmAnimation packet18armanimation) {
if (packet18armanimation.b == 1) {
-
- // Craftbukkit: Arm swing animation
- PlayerAnimationEvent event = new PlayerAnimationEvent(Type.PLAYER_ANIMATION, player);
+ Player player = getPlayer();
+ // CraftBukkit: Arm swing animation
+ PlayerAnimationEvent event = new PlayerAnimationEvent(Type.PLAYER_ANIMATION, player);
server.getPluginManager().callEvent(event);
e.K();
@@ -635,6 +642,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
return;
} else {
e = d.f.d(e);
+ CraftPlayer player = getPlayer();
player.setHandle(e); // CraftBukkit
return;
}
diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java
index 670bcef5..0cd6b62c 100644
--- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java
+++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java
@@ -7,6 +7,7 @@ import java.util.logging.Logger;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerLoginEvent;
@@ -94,7 +95,8 @@ public class ServerConfigurationManager {
// in the event, check with plugins to see if it's ok, and THEN kick
// depending on the outcome.
EntityPlayerMP entity = new EntityPlayerMP(c, ((World) (c.e)), s, new ItemInWorldManager(((World) (c.e))));
- PlayerLoginEvent event = new PlayerLoginEvent(Type.PLAYER_LOGIN, new CraftPlayer(server, entity));
+ Player player = (entity == null)?null:(Player)entity.getBukkitEntity();
+ PlayerLoginEvent event = new PlayerLoginEvent(Type.PLAYER_LOGIN, player);
// CraftBukkit end
String s2 = ((netloginhandler.b.b())).toString();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftMappable.java b/src/main/java/org/bukkit/craftbukkit/CraftMappable.java
index 8a0de5e2..da0c2bce 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftMappable.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftMappable.java
@@ -8,6 +8,7 @@ import org.bukkit.craftbukkit.entity.CraftEntity;
*
* @author sk89q
*/
+/**@deprecated*/
public interface CraftMappable {
/**
* Gets the CraftEntity version.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index ea89b7b1..a03d26db 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -151,7 +151,7 @@ public class CraftWorld implements World {
CraftMinecart.Type.Minecart.getId()
);
world.a(minecart);
- return new CraftMinecart(world.getServer(), minecart);
+ return (Minecart) minecart.getBukkitEntity();
}
public StorageMinecart spawnStorageMinecart(Location loc) {
@@ -163,7 +163,7 @@ public class CraftWorld implements World {
CraftMinecart.Type.StorageMinecart.getId()
);
world.a(minecart);
- return new CraftStorageMinecart(world.getServer(), minecart);
+ return (StorageMinecart) minecart.getBukkitEntity();
}
public PoweredMinecart spawnPoweredMinecart(Location loc) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
index 0463bfd8..b0912c31 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
@@ -52,6 +52,8 @@ public class CraftMinecart extends CraftVehicle implements Minecart {
* @param server
* @param minecart
* @return
+ *
+ * @deprecated
*/
public static CraftMinecart getCraftMinecart(CraftServer server,
EntityMinecart minecart) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java
index 3fbd7c00..e1cca613 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java
@@ -1,7 +1,6 @@
package org.bukkit.craftbukkit.entity;
import org.bukkit.craftbukkit.CraftServer;
-import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Vehicle;
@@ -20,8 +19,12 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
}
public boolean setPassenger(Entity passenger) {
- ((CraftEntity)passenger).getHandle().setPassengerOf(getHandle());
- return true;
+ if(passenger instanceof CraftEntity){
+ ((CraftEntity)passenger).getHandle().setPassengerOf(getHandle());
+ return true;
+ } else {
+ return false;
+ }
}
public boolean isEmpty() {