removed all instances of new CraftEntity* where appropriate.

Entity.getBukkitEntity() is now used instead.
This commit is contained in:
Andrew Ardill 2011-01-23 23:23:13 +11:00
parent 9cd81ddd6d
commit a809e4e6e3
22 changed files with 275 additions and 145 deletions

View File

@ -4,8 +4,11 @@ import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.block.BlockFace; 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.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent; import org.bukkit.event.block.BlockInteractEvent;
import org.bukkit.event.block.BlockRedstoneEvent; 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) { public boolean a(World world, int i, int j, int k, EntityPlayer entityplayer) {
// CraftBukkit start - Interact Button // CraftBukkit start - Interact Button
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); CraftServer server = ((WorldServer) world).getServer();
BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
((WorldServer) world).getServer().getPluginManager().callEvent(bie); LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) { if (bie.isCancelled()) {
return true; return true;
@ -166,7 +172,7 @@ public class BlockButton extends Block {
int old = (j1 != 8) ? 1 : 0; int old = (j1 != 8) ? 1 : 0;
int current = (j1 == 8) ? 1 : 0; int current = (j1 == 8) ? 1 : 0;
BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, old, current); 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)) { if ((bre.getNewCurrent() > 0) == (j1 == 8)) {
world.c(i, j, k, i1 + j1); world.c(i, j, k, i1 + j1);
world.b(i, j, k, i, j, k); world.b(i, j, k, i, j, k);

View File

@ -3,8 +3,11 @@ package net.minecraft.server;
import java.util.Random; import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent; import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end // CraftBukkit end
@ -150,11 +153,14 @@ public class BlockChest extends BlockContainer {
return true; return true;
} else { } else {
// CraftBukkit start - Interact Chest // CraftBukkit start - Interact Chest
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); CraftServer server = ((WorldServer) world).getServer();
BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); Type eventType = Type.BLOCK_INTERACT;
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
((WorldServer) world).getServer().getPluginManager().callEvent(bie); LivingEntity who = (entityplayer == null)?null:(LivingEntity)entityplayer.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) return true; if (bie.isCancelled()) return true;
// CraftBukkit end // CraftBukkit end

View File

@ -3,8 +3,11 @@ package net.minecraft.server;
import java.util.Random; import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent; import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end // CraftBukkit end
@ -72,13 +75,16 @@ public class BlockDoor extends Block {
} }
// CraftBukkit start - Interact Door // CraftBukkit start - Interact Door
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); CraftServer server = ((WorldServer) world).getServer();
BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); 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); // CraftBukkit the client updates the doors before the server does it's thing.
// Craftbukkit the client updates the doors before the server does it's thing.
// Forcibly send correct data. // Forcibly send correct data.
if (bie.isCancelled()) { if (bie.isCancelled()) {
((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world)); ((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world));

View File

@ -3,8 +3,11 @@ package net.minecraft.server;
import java.util.Random; import java.util.Random;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent; import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end // CraftBukkit end
@ -69,13 +72,18 @@ public class BlockFurnace extends BlockContainer {
return true; return true;
} else { } else {
// CraftBukkit start - Interact Furnace // CraftBukkit start - Interact Furnace
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); CraftServer server = ((WorldServer) world).getServer();
BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); 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 // CraftBukkit end
TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.m(i, j, k); TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.m(i, j, k);

View File

@ -1,8 +1,11 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent; import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end // CraftBukkit end
@ -22,13 +25,18 @@ public class BlockJukeBox extends Block {
if (l > 0) { if (l > 0) {
// CraftBukkit start - Interact Jukebox // CraftBukkit start - Interact Jukebox
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); CraftServer server = ((WorldServer) world).getServer();
BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); 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 // CraftBukkit end
f(world, i, j, k, l); f(world, i, j, k, l);

View File

@ -2,8 +2,11 @@ package net.minecraft.server;
// CraftBukkit start // CraftBukkit start
import org.bukkit.block.BlockFace; 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.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent; import org.bukkit.event.block.BlockInteractEvent;
import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockRedstoneEvent;
@ -143,13 +146,16 @@ public class BlockLever extends Block {
} }
// CraftBukkit start - Interact Lever // CraftBukkit start - Interact Lever
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); CraftServer server = ((WorldServer) world).getServer();
BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); 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); // CraftBukkit the client updates the doors before the server does it's thing.
// Craftbukkit the client updates the doors before the server does it's thing.
// Forcibly send correct data. // Forcibly send correct data.
if (bie.isCancelled()) { if (bie.isCancelled()) {
((EntityPlayerMP) entityplayer).a.b(new Packet53BlockChange(i, j, k, (WorldServer) world)); ((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 i1 = l & 7;
int j1 = 8 - (l & 8); int j1 = 8 - (l & 8);
// Craftbukkit start // CraftBukkit start
int old = (j1 != 8) ? 1 : 0; int old = (j1 != 8) ? 1 : 0;
int current = (j1 == 8) ? 1 : 0; int current = (j1 == 8) ? 1 : 0;
BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, old, current); BlockRedstoneEvent bre = new BlockRedstoneEvent(block, BlockFace.SELF, old, current);
((WorldServer) world).getServer().getPluginManager().callEvent(bre); server.getPluginManager().callEvent(bre);
// Craftbukkit end // CraftBukkit end
if ((bre.getNewCurrent() > 0) == (j1 == 8)) { if ((bre.getNewCurrent() > 0) == (j1 == 8)) {
world.c(i, j, k, i1 + j1); world.c(i, j, k, i1 + j1);

View File

@ -4,9 +4,12 @@ import java.util.List;
import java.util.Random; import java.util.Random;
// CraftBukkit start // 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.CraftLivingEntity;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.block.BlockInteractEvent; import org.bukkit.event.block.BlockInteractEvent;
import org.bukkit.event.block.BlockRedstoneEvent; import org.bukkit.event.block.BlockRedstoneEvent;
@ -76,17 +79,14 @@ public class BlockPressurePlate extends Block {
} else { } else {
// CraftBukkit start - Interact Pressure Plate // CraftBukkit start - Interact Pressure Plate
if (entity instanceof EntityLiving) { if (entity instanceof EntityLiving) {
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftServer server = ((WorldServer) world).getServer();
CraftLivingEntity craftEntity = null; CraftWorld craftWorld = ((WorldServer) world).getWorld();
Type eventType = Type.BLOCK_INTERACT;
if (entity instanceof EntityPlayerMP) { CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
craftEntity = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entity); org.bukkit.entity.LivingEntity who = (entity == null)?null:(LivingEntity) entity.getBukkitEntity();
} else {
craftEntity = new CraftLivingEntity(((WorldServer) world).getServer(), (EntityLiving) entity); BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
} server.getPluginManager().callEvent(bie);
BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, craftEntity);
((WorldServer) world).getServer().getPluginManager().callEvent(bie);
if (bie.isCancelled()) { if (bie.isCancelled()) {
return; return;

View File

@ -1,8 +1,10 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock; 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.Event.Type;
import org.bukkit.event.block.BlockInteractEvent; import org.bukkit.event.block.BlockInteractEvent;
// CraftBukkit end // CraftBukkit end
@ -33,13 +35,18 @@ public class BlockWorkbench extends Block {
return true; return true;
} else { } else {
// CraftBukkit start - Interact Workbench // CraftBukkit start - Interact Workbench
CraftBlock block = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftPlayer player = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); CraftServer server = ((WorldServer) world).getServer();
BlockInteractEvent bie = new BlockInteractEvent(Type.BLOCK_INTERACT, block, player); 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 // CraftBukkit end
entityplayer.a(i, j, k); entityplayer.a(i, j, k);

View File

@ -2,9 +2,10 @@ package net.minecraft.server;
// CraftBukkit start // CraftBukkit start
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; 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.Event.Type;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
// CraftBukkit end // CraftBukkit end
@ -75,17 +76,20 @@ public class ItemBlock extends Item {
* replace this with. * replace this with.
*/ */
if (world.a(i, j, k, a, a(itemstack.h()))) { // <-- world.b does this to place the block if (world.a(i, j, k, a, a(itemstack.h()))) { // <-- world.b does this to place the block
CraftBlock placedBlock = (CraftBlock) blockClicked.getFace(faceClicked) ; org.bukkit.Server server = ((WorldServer) world).getServer();
CraftItemStack itemInHand = new CraftItemStack(itemstack); Type eventType = Type.BLOCK_PLACED;
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); 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)); int distanceFromSpawn = (int) Math.max(Math.abs(i - world.m), Math.abs(k - world.o));
// CraftBukkit hardcoded Spawn distance for now // CraftBukkit hardcoded Spawn distance for now
// TODO make spawn size configurable
boolean canBuild = distanceFromSpawn > 16 || thePlayer.isOp(); boolean canBuild = distanceFromSpawn > 16 || thePlayer.isOp();
BlockPlaceEvent bpe = new BlockPlaceEvent(Type.BLOCK_PLACED, placedBlock, blockClicked, itemInHand, thePlayer, canBuild); BlockPlaceEvent bpe = new BlockPlaceEvent(eventType, placedBlock, blockClicked, itemInHand, thePlayer, canBuild);
((WorldServer) world).getServer().getPluginManager().callEvent(bpe); server.getPluginManager().callEvent(bpe);
if (bpe.isCancelled() || !bpe.canBuild()) { if (bpe.isCancelled() || !bpe.canBuild()) {
// CraftBukkit Undo! // CraftBukkit Undo!

View File

@ -1,9 +1,12 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // 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.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; 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.Event.Type;
import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end // CraftBukkit end
@ -44,14 +47,21 @@ public class ItemBoat extends Item {
if (!world.z) { if (!world.z) {
// CraftBukkit start - Boat placement // CraftBukkit start - Boat placement
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftItemStack itemInHand = new CraftItemStack(itemstack); CraftServer craftServer = ((WorldServer) world).getServer();
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(movingobjectposition.e)); 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 // CraftBukkit end
world.a(((Entity) (new EntityBoat(world, (float) i + 0.5F, (float) j + 1.5F, (float) k + 0.5F)))); world.a(((Entity) (new EntityBoat(world, (float) i + 0.5F, (float) j + 1.5F, (float) k + 0.5F))));

View File

@ -7,7 +7,9 @@ import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end // CraftBukkit end
@ -55,18 +57,21 @@ public class ItemBucket extends Item {
} }
// CraftBukkit start - Click == placed when handling an empty bucket! // CraftBukkit start - Click == placed when handling an empty bucket!
CraftWorld theWorld = ((WorldServer) world).getWorld(); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftBlock blockClicked = (CraftBlock) theWorld.getBlockAt(i, j, k); CraftServer craftServer = ((WorldServer) world).getServer();
BlockFace direction = CraftBlock.notchToBlockFace(movingobjectposition.e);
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); Type eventType = Type.PLAYER_ITEM;
CraftItemStack itemInHand = new CraftItemStack(itemstack); 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 // CraftBukkit end
if (a == 0) { if (a == 0) {
if (world.c(i, j, k) == Material.f && world.b(i, j, k) == 0) { if (world.c(i, j, k) == Material.f && world.b(i, j, k) == 0) {
// CraftBukkit start // CraftBukkit start
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, direction); PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
((WorldServer) world).getServer().getPluginManager().callEvent(pie); craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) { if (pie.isCancelled()) {
return itemstack; 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) { if (world.c(i, j, k) == Material.g && world.b(i, j, k) == 0) {
// CraftBukkit start // CraftBukkit start
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, direction); PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
((WorldServer) world).getServer().getPluginManager().callEvent(pie); craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) { if (pie.isCancelled()) {
return itemstack; return itemstack;
@ -117,8 +122,8 @@ public class ItemBucket extends Item {
} }
} else { } else {
// CraftBukkit start - bucket empty. // CraftBukkit start - bucket empty.
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, direction); PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
((WorldServer) world).getServer().getPluginManager().callEvent(pie); craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) { if (pie.isCancelled()) {
return itemstack; return itemstack;

View File

@ -3,9 +3,12 @@ package net.minecraft.server;
import java.util.Random; import java.util.Random;
// CraftBukkit start // 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.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; 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.Event.Type;
import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end // CraftBukkit end
@ -24,14 +27,21 @@ public class ItemHoe extends Item {
if (!material.a() && i1 == Block.u.bi || i1 == Block.v.bi) { if (!material.a() && i1 == Block.u.bi || i1 == Block.v.bi) {
// CraftBukkit start - Hoes // CraftBukkit start - Hoes
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftItemStack itemInHand = new CraftItemStack(itemstack); CraftServer craftServer = ((WorldServer) world).getServer();
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l)); Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
((WorldServer) world).getServer().getPluginManager().callEvent(pie); org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
if (pie.isCancelled()) return false; 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 // CraftBukkit end
Block block = Block.aA; Block block = Block.aA;

View File

@ -1,9 +1,12 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // 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.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; 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.Event.Type;
import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end // CraftBukkit end
@ -23,14 +26,21 @@ public class ItemMinecart extends Item {
if (i1 == Block.aG.bi) { if (i1 == Block.aG.bi) {
// CraftBukkit start - Minecarts // CraftBukkit start - Minecarts
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftItemStack itemInHand = new CraftItemStack(itemstack); CraftServer craftServer = ((WorldServer) world).getServer();
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l)); Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
((WorldServer) world).getServer().getPluginManager().callEvent(pie); org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
if (pie.isCancelled()) return false; 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 // CraftBukkit end
if (!world.z) { if (!world.z) {

View File

@ -1,9 +1,13 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // 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.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end // 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) { 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) { if (l == 0) {
j--; j--;
} }
@ -41,13 +42,21 @@ public class ItemRedstone extends Item {
} }
if (Block.av.a(world, i, j, k)) { if (Block.av.a(world, i, j, k)) {
// CraftBukkit start - Redstone // CraftBukkit start - Redstone
CraftItemStack itemInHand = new CraftItemStack(itemstack); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); CraftServer craftServer = ((WorldServer) world).getServer();
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
Type eventType = Type.PLAYER_ITEM;
((WorldServer) world).getServer().getPluginManager().callEvent(pie); Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
if (pie.isCancelled()) return false; 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 // CraftBukkit end
itemstack.a--; itemstack.a--;

View File

@ -1,9 +1,13 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // 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.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end // CraftBukkit end
@ -25,13 +29,18 @@ public class ItemSeeds extends Item {
if (i1 == Block.aA.bi && world.e(i, j + 1, k)) { if (i1 == Block.aA.bi && world.e(i, j + 1, k)) {
// CraftBukkit start - Seeds // CraftBukkit start - Seeds
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftItemStack itemInHand = new CraftItemStack(itemstack); CraftServer craftServer = ((WorldServer) world).getServer();
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer);
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l)); Type eventType = Type.PLAYER_ITEM;
Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
((WorldServer) world).getServer().getPluginManager().callEvent(pie); 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()) { if (pie.isCancelled()) {
return false; return false;
} }

View File

@ -1,9 +1,12 @@
package net.minecraft.server; package net.minecraft.server;
// CraftBukkit start // 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.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; 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.Event.Type;
import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerItemEvent;
// CraftBukkit end // CraftBukkit end
@ -25,7 +28,6 @@ public class ItemSign extends Item {
} }
// CraftBukkit - store the clicked block // CraftBukkit - store the clicked block
CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k);
if (l == 1) { if (l == 1) {
j++; j++;
@ -48,13 +50,21 @@ public class ItemSign extends Item {
// CraftBukkit start // CraftBukkit start
// Signs // Signs
CraftItemStack itemInHand = new CraftItemStack(itemstack); CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); CraftServer craftServer = ((WorldServer) world).getServer();
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l));
Type eventType = Type.PLAYER_ITEM;
((WorldServer) world).getServer().getPluginManager().callEvent(pie); Player who = (entityplayer == null)?null:(Player)entityplayer.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
if (pie.isCancelled()) return false; 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 // CraftBukkit end
if (l == 1) { if (l == 1) {

View File

@ -12,6 +12,8 @@ import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer; 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.Event.Type;
import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockRightClickEvent; import org.bukkit.event.block.BlockRightClickEvent;
@ -38,10 +40,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit start - next 2 lines // CraftBukkit start - next 2 lines
private final CraftServer server; private final CraftServer server;
private final CraftPlayer player;
public CraftPlayer getPlayer() { public CraftPlayer getPlayer() {
return player; return (e == null)?null:(CraftPlayer)e.getBukkitEntity();
} }
// CraftBukkit end // CraftBukkit end
@ -58,7 +59,6 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit - next 2 lines // CraftBukkit - next 2 lines
server = minecraftserver.server; server = minecraftserver.server;
player = new CraftPlayer(server, e);
} }
public void a() { public void a() {
@ -86,6 +86,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
} }
// CraftBukkit start // CraftBukkit start
Player player = getPlayer();
Location from = new Location(player.getWorld(), g, h, i, e.v, e.w); Location from = new Location(player.getWorld(), g, h, i, e.v, e.w);
Location to = player.getLocation(); Location to = player.getLocation();
if (!from.equals(to)) { 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) { public void a(double d1, double d2, double d3, float f1, float f2) {
// CraftBukkit start // CraftBukkit start
Player player = getPlayer();
Location from = player.getLocation(); Location from = player.getLocation();
Location to = new Location(player.getWorld(), d1, d2, d3, f1, f2); Location to = new Location(player.getWorld(), d1, d2, d3, f1, f2);
PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_TELEPORT, player, from, to); PlayerMoveEvent event = new PlayerMoveEvent(Type.PLAYER_TELEPORT, player, from, to);
@ -283,6 +285,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
} }
// CraftBukkit start // CraftBukkit start
CraftPlayer player = getPlayer();
CraftBlock block = (CraftBlock) player.getWorld().getBlockAt(l, i1, j1); CraftBlock block = (CraftBlock) player.getWorld().getBlockAt(l, i1, j1);
int blockId = block.getTypeId(); int blockId = block.getTypeId();
float damage = 0; float damage = 0;
@ -402,13 +405,15 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
} }
// CraftBukkit start // CraftBukkit start
CraftItemStack craftItem = new CraftItemStack(itemstack); Type eventType = Type.PLAYER_ITEM;
CraftPlayer player = new CraftPlayer(server, e); Player who = (e == null)?null:(Player)e.getBukkitEntity();
PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, player, craftItem, blockClicked, blockFace); 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. // CraftBukkit We still call this event even in spawn protection.
// Don't call this event if using Buckets / signs // Don't call this event if using Buckets / signs
switch (craftItem.getType()) { switch (itemInHand.getType()) {
case SIGN: case SIGN:
case BUCKET: case BUCKET:
case WATER_BUCKET: case WATER_BUCKET:
@ -440,7 +445,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
} }
// CraftBukkit start - spawn proection moved to ItemBlock!!! // CraftBukkit start - spawn proection moved to ItemBlock!!!
CraftItemStack craftItem = new CraftItemStack(itemstack); 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); BlockRightClickEvent brce = new BlockRightClickEvent(Type.BLOCK_RIGHTCLICKED, blockClicked, blockFace, craftItem, player);
server.getPluginManager().callEvent(brce); server.getPluginManager().callEvent(brce);
@ -523,6 +528,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
c(s); c(s);
} else { } else {
// CraftBukkit start // CraftBukkit start
Player player = getPlayer();
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_CHAT, player, s); PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_CHAT, player, s);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); 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) { private void c(String s) {
// CraftBukkit start // CraftBukkit start
boolean targetPluginFound = server.dispatchCommand(player, s); CraftPlayer player = getPlayer();
boolean targetPluginFound = server.dispatchCommand(player , s);
if (targetPluginFound) { if (targetPluginFound) {
return; return;
} }
@ -549,7 +556,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
return; return;
} }
s = event.getMessage(); s = event.getMessage();
CraftPlayer player = (CraftPlayer) event.getPlayer(); player = (CraftPlayer) event.getPlayer();
EntityPlayerMP e = player.getHandle(); EntityPlayerMP e = player.getHandle();
// CraftBukkit stop // CraftBukkit stop
@ -585,9 +592,9 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
public void a(Packet18ArmAnimation packet18armanimation) { public void a(Packet18ArmAnimation packet18armanimation) {
if (packet18armanimation.b == 1) { if (packet18armanimation.b == 1) {
Player player = getPlayer();
// Craftbukkit: Arm swing animation // CraftBukkit: Arm swing animation
PlayerAnimationEvent event = new PlayerAnimationEvent(Type.PLAYER_ANIMATION, player); PlayerAnimationEvent event = new PlayerAnimationEvent(Type.PLAYER_ANIMATION, player);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
e.K(); e.K();
@ -635,6 +642,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
return; return;
} else { } else {
e = d.f.d(e); e = d.f.d(e);
CraftPlayer player = getPlayer();
player.setHandle(e); // CraftBukkit player.setHandle(e); // CraftBukkit
return; return;
} }

View File

@ -7,6 +7,7 @@ import java.util.logging.Logger;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Type; import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerLoginEvent; 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 // in the event, check with plugins to see if it's ok, and THEN kick
// depending on the outcome. // depending on the outcome.
EntityPlayerMP entity = new EntityPlayerMP(c, ((World) (c.e)), s, new ItemInWorldManager(((World) (c.e)))); 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 // CraftBukkit end
String s2 = ((netloginhandler.b.b())).toString(); String s2 = ((netloginhandler.b.b())).toString();

View File

@ -8,6 +8,7 @@ import org.bukkit.craftbukkit.entity.CraftEntity;
* *
* @author sk89q * @author sk89q
*/ */
/**@deprecated*/
public interface CraftMappable { public interface CraftMappable {
/** /**
* Gets the CraftEntity version. * Gets the CraftEntity version.

View File

@ -151,7 +151,7 @@ public class CraftWorld implements World {
CraftMinecart.Type.Minecart.getId() CraftMinecart.Type.Minecart.getId()
); );
world.a(minecart); world.a(minecart);
return new CraftMinecart(world.getServer(), minecart); return (Minecart) minecart.getBukkitEntity();
} }
public StorageMinecart spawnStorageMinecart(Location loc) { public StorageMinecart spawnStorageMinecart(Location loc) {
@ -163,7 +163,7 @@ public class CraftWorld implements World {
CraftMinecart.Type.StorageMinecart.getId() CraftMinecart.Type.StorageMinecart.getId()
); );
world.a(minecart); world.a(minecart);
return new CraftStorageMinecart(world.getServer(), minecart); return (StorageMinecart) minecart.getBukkitEntity();
} }
public PoweredMinecart spawnPoweredMinecart(Location loc) { public PoweredMinecart spawnPoweredMinecart(Location loc) {

View File

@ -52,6 +52,8 @@ public class CraftMinecart extends CraftVehicle implements Minecart {
* @param server * @param server
* @param minecart * @param minecart
* @return * @return
*
* @deprecated
*/ */
public static CraftMinecart getCraftMinecart(CraftServer server, public static CraftMinecart getCraftMinecart(CraftServer server,
EntityMinecart minecart) { EntityMinecart minecart) {

View File

@ -1,7 +1,6 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;
@ -20,8 +19,12 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
} }
public boolean setPassenger(Entity passenger) { public boolean setPassenger(Entity passenger) {
((CraftEntity)passenger).getHandle().setPassengerOf(getHandle()); if(passenger instanceof CraftEntity){
return true; ((CraftEntity)passenger).getHandle().setPassengerOf(getHandle());
return true;
} else {
return false;
}
} }
public boolean isEmpty() { public boolean isEmpty() {