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
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);
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();
((WorldServer) world).getServer().getPluginManager().callEvent(bie);
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);

View File

@ -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);
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();
((WorldServer) world).getServer().getPluginManager().callEvent(bie);
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) return true;
// CraftBukkit end

View File

@ -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);
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();
((WorldServer) world).getServer().getPluginManager().callEvent(bie);
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.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.
if (bie.isCancelled()) {
((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;
// 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);
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();
((WorldServer) world).getServer().getPluginManager().callEvent(bie);
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) return true;
if (bie.isCancelled()) {
return true;
}
// CraftBukkit end
TileEntityFurnace tileentityfurnace = (TileEntityFurnace) world.m(i, j, k);

View File

@ -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();
((WorldServer) world).getServer().getPluginManager().callEvent(bie);
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) return true;
if (bie.isCancelled()) {
return true;
}
// CraftBukkit end
f(world, i, j, k, l);

View File

@ -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);
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();
((WorldServer) world).getServer().getPluginManager().callEvent(bie);
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.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.
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);

View File

@ -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;
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();
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);
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) {
return;

View File

@ -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);
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();
((WorldServer) world).getServer().getPluginManager().callEvent(bie);
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
if (bie.isCancelled()) return true;
if (bie.isCancelled()) {
return true;
}
// CraftBukkit end
entityplayer.a(i, j, k);

View File

@ -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!

View File

@ -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();
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
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);
if (pie.isCancelled()) return itemstack;
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(pie);
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))));

View File

@ -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;

View File

@ -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));
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
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);
if (pie.isCancelled()) return false;
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return false;
}
// CraftBukkit end
Block block = Block.aA;

View File

@ -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));
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
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);
if (pie.isCancelled()) return false;
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return false;
}
// CraftBukkit end
if (!world.z) {

View File

@ -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));
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
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);
if (pie.isCancelled()) return false;
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return false;
}
// CraftBukkit end
itemstack.a--;

View File

@ -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,12 +29,17 @@ 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));
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
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;

View File

@ -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));
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
((WorldServer) world).getServer().getPluginManager().callEvent(pie);
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);
if (pie.isCancelled()) return false;
PlayerItemEvent pie = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockface);
craftServer.getPluginManager().callEvent(pie);
if (pie.isCancelled()) {
return false;
}
// CraftBukkit end
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.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,6 +544,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
private void c(String s) {
// CraftBukkit start
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,8 +592,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
public void a(Packet18ArmAnimation packet18armanimation) {
if (packet18armanimation.b == 1) {
// Craftbukkit: Arm swing animation
Player player = getPlayer();
// CraftBukkit: Arm swing animation
PlayerAnimationEvent event = new PlayerAnimationEvent(Type.PLAYER_ANIMATION, player);
server.getPluginManager().callEvent(event);
@ -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;
}

View File

@ -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();

View File

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

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {
if(passenger instanceof CraftEntity){
((CraftEntity)passenger).getHandle().setPassengerOf(getHandle());
return true;
} else {
return false;
}
}
public boolean isEmpty() {