Generic cleanup of the org.bukkit.craftbukkit classes.
Dieser Commit ist enthalten in:
Ursprung
b042f48b24
Commit
9adc03abab
@ -35,7 +35,7 @@ public class CraftChunk implements Chunk {
|
||||
public net.minecraft.server.Chunk getHandle() {
|
||||
net.minecraft.server.Chunk c = weakChunk.get();
|
||||
if (c == null) {
|
||||
c = worldServer.getChunkAt(x,z);
|
||||
c = worldServer.getChunkAt(x, z);
|
||||
weakChunk = new WeakReference<net.minecraft.server.Chunk>(c);
|
||||
}
|
||||
return c;
|
||||
@ -64,7 +64,7 @@ public class CraftChunk implements Chunk {
|
||||
if (block == null) {
|
||||
Block newBlock = new CraftBlock(this, (getX() << 4) | (x & 0xF), y & 0x7F, (getZ() << 4) | (z & 0xF));
|
||||
Block oldBlock = this.cache.put(pos, newBlock);
|
||||
if(oldBlock == null) {
|
||||
if (oldBlock == null) {
|
||||
block = newBlock;
|
||||
} else {
|
||||
block = oldBlock;
|
||||
|
@ -68,7 +68,7 @@ public final class CraftServer implements Server {
|
||||
private final String protocolVersion = "1.6.6";
|
||||
private final PluginManager pluginManager = new SimplePluginManager(this);
|
||||
private final ServicesManager servicesManager = new SimpleServicesManager();
|
||||
private final BukkitScheduler scheduler = new CraftScheduler(this);
|
||||
private final BukkitScheduler scheduler = new CraftScheduler(this);
|
||||
private final CommandMap commandMap = new SimpleCommandMap(this);
|
||||
protected final MinecraftServer console;
|
||||
protected final ServerConfigurationManager server;
|
||||
@ -84,7 +84,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
Logger.getLogger("Minecraft").log(Level.INFO, "This server is running " + getName() + " version " + getVersion());
|
||||
|
||||
configuration = new Configuration((File)console.options.valueOf("bukkit-settings"));
|
||||
configuration = new Configuration((File) console.options.valueOf("bukkit-settings"));
|
||||
configuration.load();
|
||||
loadConfigDefaults();
|
||||
configuration.save();
|
||||
@ -102,7 +102,7 @@ public final class CraftServer implements Server {
|
||||
public void loadPlugins() {
|
||||
pluginManager.registerInterface(JavaPluginLoader.class);
|
||||
|
||||
File pluginFolder = (File)console.options.valueOf("plugins");
|
||||
File pluginFolder = (File) console.options.valueOf("plugins");
|
||||
|
||||
if (pluginFolder.exists()) {
|
||||
try {
|
||||
@ -293,7 +293,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
// See if the server can process this command
|
||||
return console.consoleCommandHandler.handle(new ServerCommand(commandLine, (ICommandListener)new ServerCommandListener(sender)));
|
||||
return console.consoleCommandHandler.handle(new ServerCommand(commandLine, (ICommandListener) new ServerCommandListener(sender)));
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
@ -320,16 +320,15 @@ public final class CraftServer implements Server {
|
||||
int pollCount = 0;
|
||||
|
||||
// Wait for at most 2.5 seconds for plugins to close their threads
|
||||
while(pollCount < 50 && getScheduler().getActiveWorkers().size() > 0) {
|
||||
while (pollCount < 50 && getScheduler().getActiveWorkers().size() > 0) {
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
} catch (InterruptedException e) {}
|
||||
pollCount++;
|
||||
}
|
||||
|
||||
List<BukkitWorker> overdueWorkers = getScheduler().getActiveWorkers();
|
||||
for(BukkitWorker worker : overdueWorkers) {
|
||||
for (BukkitWorker worker : overdueWorkers) {
|
||||
Plugin plugin = worker.getOwner();
|
||||
String author = "<NoAuthorGiven>";
|
||||
if (plugin.getDescription().getAuthors().size() > 0) {
|
||||
@ -385,7 +384,7 @@ public final class CraftServer implements Server {
|
||||
internal.z = console.worlds.get(0).z;
|
||||
|
||||
internal.tracker = new EntityTracker(console, dimension);
|
||||
internal.addIWorldAccess((IWorldAccess)new WorldManager(console, internal));
|
||||
internal.addIWorldAccess((IWorldAccess) new WorldManager(console, internal));
|
||||
internal.spawnMonsters = 1;
|
||||
internal.setSpawnFlags(true, true);
|
||||
console.worlds.add(internal);
|
||||
@ -492,7 +491,7 @@ public final class CraftServer implements Server {
|
||||
Command command = commandMap.getCommand(name);
|
||||
|
||||
if (command instanceof PluginCommand) {
|
||||
return (PluginCommand)command;
|
||||
return (PluginCommand) command;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -520,7 +519,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
public boolean addRecipe(Recipe recipe) {
|
||||
CraftRecipe toAdd;
|
||||
if(recipe instanceof CraftRecipe) {
|
||||
if (recipe instanceof CraftRecipe) {
|
||||
toAdd = (CraftRecipe) recipe;
|
||||
} else {
|
||||
if (recipe instanceof ShapedRecipe) {
|
||||
|
@ -32,7 +32,7 @@ public class CraftWorld implements World {
|
||||
private Environment environment;
|
||||
private final CraftServer server;
|
||||
private final ChunkProviderServer provider;
|
||||
private HashMap<Integer,CraftChunk> unloadedChunks = new HashMap<Integer, CraftChunk>();
|
||||
private HashMap<Integer, CraftChunk> unloadedChunks = new HashMap<Integer, CraftChunk>();
|
||||
private final ChunkGenerator generator;
|
||||
private final List<BlockPopulator> populators = new ArrayList<BlockPopulator>();
|
||||
|
||||
@ -91,7 +91,7 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public Chunk getChunkAt(int x, int z) {
|
||||
return this.provider.getChunkAt(x,z).bukkitChunk;
|
||||
return this.provider.getChunkAt(x, z).bukkitChunk;
|
||||
}
|
||||
|
||||
public Chunk getChunkAt(Block block) {
|
||||
@ -107,7 +107,7 @@ public class CraftWorld implements World {
|
||||
org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length];
|
||||
|
||||
for (int i = 0; i < chunks.length; i++) {
|
||||
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk)chunks[i];
|
||||
net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) chunks[i];
|
||||
craftChunks[i] = chunk.bukkitChunk;
|
||||
}
|
||||
|
||||
@ -186,18 +186,18 @@ public class CraftWorld implements World {
|
||||
return false;
|
||||
}
|
||||
|
||||
int px = x<<4;
|
||||
int pz = z<<4;
|
||||
int px = x << 4;
|
||||
int pz = z << 4;
|
||||
|
||||
// If there are more than 10 updates to a chunk at once, it carries out the update as a cuboid
|
||||
// This flags 16 blocks in a line along the bottom for update and then flags a block at the opposite corner at the top
|
||||
// The cuboid that contains these 17 blocks covers the entire chunk
|
||||
// The server will compress the chunk and send it to all clients
|
||||
|
||||
for(int xx = px; xx < (px + 16); xx++) {
|
||||
for (int xx = px; xx < (px + 16); xx++) {
|
||||
world.notify(xx, 0, pz);
|
||||
}
|
||||
world.notify(px, 127, pz+15);
|
||||
world.notify(px, 127, pz + 15);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -526,7 +526,7 @@ public class CraftWorld implements World {
|
||||
|
||||
for (Object o: world.entityList) {
|
||||
if (o instanceof net.minecraft.server.Entity) {
|
||||
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
|
||||
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
|
||||
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
||||
|
||||
// Assuming that bukkitEntity isn't null
|
||||
@ -544,12 +544,12 @@ public class CraftWorld implements World {
|
||||
|
||||
for (Object o: world.entityList) {
|
||||
if (o instanceof net.minecraft.server.Entity) {
|
||||
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
|
||||
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
|
||||
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
||||
|
||||
// Assuming that bukkitEntity isn't null
|
||||
if (bukkitEntity != null && bukkitEntity instanceof LivingEntity) {
|
||||
list.add((LivingEntity)bukkitEntity);
|
||||
list.add((LivingEntity) bukkitEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -562,11 +562,11 @@ public class CraftWorld implements World {
|
||||
|
||||
for (Object o : world.entityList) {
|
||||
if (o instanceof net.minecraft.server.Entity) {
|
||||
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity)o;
|
||||
net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o;
|
||||
Entity bukkitEntity = mcEnt.getBukkitEntity();
|
||||
|
||||
if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) {
|
||||
list.add((Player)bukkitEntity);
|
||||
list.add((Player) bukkitEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,9 @@ public class TrigMath {
|
||||
|
||||
private static double mxatan(double arg) {
|
||||
double argsq = arg * arg, value;
|
||||
|
||||
value = ((((p4 * argsq + p3) * argsq + p2) * argsq + p1) * argsq + p0);
|
||||
value = value / (((((argsq+q4)*argsq+q3)*argsq+q2)*argsq+q1)*argsq+q0);
|
||||
value = value / (((((argsq + q4) * argsq + q3) * argsq + q2) * argsq + q1) * argsq + q0);
|
||||
return value * arg;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class CraftBlock implements Block {
|
||||
* @return Location of the block
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return new Location(getWorld(), x, y, z);
|
||||
return new Location(getWorld(), x, y, z);
|
||||
}
|
||||
|
||||
public BlockVector getVector() {
|
||||
|
@ -23,13 +23,13 @@ public class CraftBlockState implements BlockState {
|
||||
protected byte light;
|
||||
|
||||
public CraftBlockState(final Block block) {
|
||||
this.world = (CraftWorld)block.getWorld();
|
||||
this.world = (CraftWorld) block.getWorld();
|
||||
this.x = block.getX();
|
||||
this.y = block.getY();
|
||||
this.z = block.getZ();
|
||||
this.type = block.getTypeId();
|
||||
this.light = block.getLightLevel();
|
||||
this.chunk = (CraftChunk)block.getChunk();
|
||||
this.chunk = (CraftChunk) block.getChunk();
|
||||
|
||||
createData(block.getData());
|
||||
}
|
||||
@ -129,7 +129,7 @@ public class CraftBlockState implements BlockState {
|
||||
public boolean setTypeId(final int type) {
|
||||
this.type = type;
|
||||
|
||||
createData((byte)0);
|
||||
createData((byte) 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ public class CraftChest extends CraftBlockState implements Chest {
|
||||
public CraftChest(final Block block) {
|
||||
super(block);
|
||||
|
||||
world = (CraftWorld)block.getWorld();
|
||||
chest = (TileEntityChest)world.getTileEntityAt(getX(), getY(), getZ());
|
||||
world = (CraftWorld) block.getWorld();
|
||||
chest = (TileEntityChest) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public Inventory getInventory() {
|
||||
|
@ -13,8 +13,8 @@ public class CraftCreatureSpawner extends CraftBlockState implements CreatureSpa
|
||||
public CraftCreatureSpawner(final Block block) {
|
||||
super(block);
|
||||
|
||||
world = (CraftWorld)block.getWorld();
|
||||
spawner = (TileEntityMobSpawner)world.getTileEntityAt(getX(), getY(), getZ());
|
||||
world = (CraftWorld) block.getWorld();
|
||||
spawner = (TileEntityMobSpawner) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public CreatureType getCreatureType() {
|
||||
|
@ -22,8 +22,8 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
|
||||
public CraftDispenser(final Block block) {
|
||||
super(block);
|
||||
|
||||
world = (CraftWorld)block.getWorld();
|
||||
dispenser = (TileEntityDispenser)world.getTileEntityAt(getX(), getY(), getZ());
|
||||
world = (CraftWorld) block.getWorld();
|
||||
dispenser = (TileEntityDispenser) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public Inventory getInventory() {
|
||||
@ -35,7 +35,8 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
|
||||
|
||||
synchronized (block) {
|
||||
if (block.getType() == Material.DISPENSER) {
|
||||
BlockDispenser dispense = (BlockDispenser)net.minecraft.server.Block.DISPENSER;
|
||||
BlockDispenser dispense = (BlockDispenser) net.minecraft.server.Block.DISPENSER;
|
||||
|
||||
dispense.dispense(world.getHandle(), getX(), getY(), getZ(), new Random());
|
||||
return true;
|
||||
} else {
|
||||
|
@ -19,8 +19,8 @@ public class CraftFurnace extends CraftBlockState implements Furnace {
|
||||
public CraftFurnace(final Block block) {
|
||||
super(block);
|
||||
|
||||
world = (CraftWorld)block.getWorld();
|
||||
furnace = (TileEntityFurnace)world.getTileEntityAt(getX(), getY(), getZ());
|
||||
world = (CraftWorld) block.getWorld();
|
||||
furnace = (TileEntityFurnace) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public Inventory getInventory() {
|
||||
@ -39,7 +39,7 @@ public class CraftFurnace extends CraftBlockState implements Furnace {
|
||||
}
|
||||
|
||||
public short getBurnTime() {
|
||||
return (short)furnace.burnTime;
|
||||
return (short) furnace.burnTime;
|
||||
}
|
||||
|
||||
public void setBurnTime(short burnTime) {
|
||||
@ -47,7 +47,7 @@ public class CraftFurnace extends CraftBlockState implements Furnace {
|
||||
}
|
||||
|
||||
public short getCookTime() {
|
||||
return (short)furnace.cookTime;
|
||||
return (short) furnace.cookTime;
|
||||
}
|
||||
|
||||
public void setCookTime(short cookTime) {
|
||||
|
@ -18,8 +18,8 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
|
||||
public CraftNoteBlock(final Block block) {
|
||||
super(block);
|
||||
|
||||
world = (CraftWorld)block.getWorld();
|
||||
note = (TileEntityNote)world.getTileEntityAt(getX(), getY(), getZ());
|
||||
world = (CraftWorld) block.getWorld();
|
||||
note = (TileEntityNote) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public byte getNote() {
|
||||
|
@ -12,8 +12,8 @@ public class CraftSign extends CraftBlockState implements Sign {
|
||||
public CraftSign(final Block block) {
|
||||
super(block);
|
||||
|
||||
world = (CraftWorld)block.getWorld();
|
||||
sign = (TileEntitySign)world.getTileEntityAt(getX(), getY(), getZ());
|
||||
world = (CraftWorld) block.getWorld();
|
||||
sign = (TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
public String[] getLines() {
|
||||
|
@ -26,10 +26,10 @@ public class ServerCommandListener implements ICommandListener {
|
||||
|
||||
public String getName() {
|
||||
try {
|
||||
Method getName = commandSender.getClass().getMethod( "getName" );
|
||||
Method getName = commandSender.getClass().getMethod("getName");
|
||||
|
||||
return (String) getName.invoke(commandSender);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
|
||||
return this.prefix;
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ import net.minecraft.server.EntityChicken;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Chicken;
|
||||
|
||||
public class CraftChicken extends CraftAnimals implements Chicken{
|
||||
|
||||
public class CraftChicken extends CraftAnimals implements Chicken {
|
||||
|
||||
public CraftChicken(CraftServer server, EntityChicken entity) {
|
||||
super(server, entity);
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public class CraftCreature extends CraftLivingEntity implements Creature{
|
||||
public class CraftCreature extends CraftLivingEntity implements Creature {
|
||||
public CraftCreature(CraftServer server, EntityCreature entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
@ -32,14 +32,14 @@ public class CraftCreeper extends CraftMonster implements Creeper {
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
getHandle().Z().b(17, (byte)1);
|
||||
getHandle().Z().b(17, (byte) 1);
|
||||
}
|
||||
} else {
|
||||
CreeperPowerEvent event = new CreeperPowerEvent(entity, CreeperPowerEvent.PowerCause.SET_OFF);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
getHandle().Z().b(17, (byte)0);
|
||||
getHandle().Z().b(17, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,11 +118,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return ((WorldServer)entity.world).getWorld();
|
||||
return ((WorldServer) entity.world).getWorld();
|
||||
}
|
||||
|
||||
public boolean teleport(Location location) {
|
||||
entity.world = ((CraftWorld)location.getWorld()).getHandle();
|
||||
entity.world = ((CraftWorld) location.getWorld()).getHandle();
|
||||
entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
// entity.setLocation() throws no event, and so cannot be cancelled
|
||||
return true;
|
||||
@ -140,10 +140,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
teleport(destination);
|
||||
}
|
||||
|
||||
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z){
|
||||
List<Entity> notchEntityList = entity.world.b(entity, entity.boundingBox.b(x,y,z));
|
||||
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z) {
|
||||
List<Entity> notchEntityList = entity.world.b(entity, entity.boundingBox.b(x, y, z));
|
||||
List<org.bukkit.entity.Entity> bukkitEntityList = new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size());
|
||||
for (Entity e: notchEntityList){
|
||||
|
||||
for (Entity e: notchEntityList) {
|
||||
bukkitEntityList.add(e.getBukkitEntity());
|
||||
}
|
||||
return bukkitEntityList;
|
||||
@ -229,7 +230,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
|
||||
public boolean setPassenger(org.bukkit.entity.Entity passenger) {
|
||||
if (passenger instanceof CraftEntity){
|
||||
if (passenger instanceof CraftEntity) {
|
||||
((CraftEntity) passenger).getHandle().setPassengerOf(getHandle());
|
||||
return true;
|
||||
} else {
|
||||
|
@ -26,7 +26,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
}
|
||||
|
||||
public void setHandle(final EntityHuman entity) {
|
||||
super.setHandle((EntityHuman)entity);
|
||||
super.setHandle((EntityHuman) entity);
|
||||
this.entity = entity;
|
||||
this.inventory = new CraftInventoryPlayer(entity.inventory);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike
|
||||
|
||||
@Override
|
||||
public EntityWeatherStorm getHandle() {
|
||||
return (EntityWeatherStorm)super.getHandle();
|
||||
return (EntityWeatherStorm) super.getHandle();
|
||||
}
|
||||
|
||||
public boolean isEffect() {
|
||||
|
@ -40,7 +40,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
if (entity instanceof EntityPlayer && health == 0) {
|
||||
((EntityPlayer)entity).a((Entity)null);
|
||||
((EntityPlayer) entity).a((Entity) null);
|
||||
}
|
||||
|
||||
getHandle().health = health;
|
||||
@ -52,7 +52,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public void setHandle(final EntityLiving entity) {
|
||||
super.setHandle((Entity)entity);
|
||||
super.setHandle((Entity) entity);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@ -62,15 +62,17 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public Egg throwEgg() {
|
||||
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
|
||||
net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle();
|
||||
EntityEgg egg = new EntityEgg(world, getHandle());
|
||||
|
||||
world.addEntity(egg);
|
||||
return (Egg) egg.getBukkitEntity();
|
||||
}
|
||||
|
||||
public Snowball throwSnowball() {
|
||||
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
|
||||
net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle();
|
||||
EntitySnowball snowball = new EntitySnowball(world, getHandle());
|
||||
|
||||
world.addEntity(snowball);
|
||||
return (Snowball) snowball.getBukkitEntity();
|
||||
}
|
||||
@ -101,7 +103,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (!transparent.contains((byte)id)) {
|
||||
if (!transparent.contains((byte) id)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -123,8 +125,9 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public Arrow shootArrow() {
|
||||
net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle();
|
||||
net.minecraft.server.World world = ((CraftWorld) getWorld()).getHandle();
|
||||
EntityArrow arrow = new EntityArrow(world, getHandle());
|
||||
|
||||
world.addEntity(arrow);
|
||||
return (Arrow) arrow.getBukkitEntity();
|
||||
}
|
||||
|
@ -147,8 +147,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
public void playNote(Location loc, byte instrument, byte note) {
|
||||
getHandle().netServerHandler.sendPacket(
|
||||
new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), instrument, note));
|
||||
getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), instrument, note));
|
||||
}
|
||||
|
||||
public void playEffect(Location loc, Effect effect, int data) {
|
||||
@ -162,9 +161,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
public void sendBlockChange(Location loc, int material, byte data) {
|
||||
Packet53BlockChange packet = new Packet53BlockChange(
|
||||
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(),
|
||||
((CraftWorld) loc.getWorld()).getHandle());
|
||||
Packet53BlockChange packet = new Packet53BlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());
|
||||
|
||||
packet.d = material;
|
||||
packet.e = data;
|
||||
getHandle().netServerHandler.sendPacket(packet);
|
||||
@ -219,8 +217,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle();
|
||||
// Grab the EntityPlayer
|
||||
EntityPlayer entity = getHandle();
|
||||
|
||||
// Check if the fromWorld and toWorld are the same.
|
||||
if (fromWorld == toWorld){
|
||||
if (fromWorld == toWorld) {
|
||||
entity.netServerHandler.teleport(to);
|
||||
} else {
|
||||
server.getHandle().a(entity, toWorld.dimension, to);
|
||||
|
@ -12,6 +12,6 @@ public class CraftWeather extends CraftEntity implements Weather {
|
||||
|
||||
@Override
|
||||
public EntityWeather getHandle() {
|
||||
return (EntityWeather)super.getHandle();
|
||||
return (EntityWeather) super.getHandle();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ import net.minecraft.server.EntityZombie;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Zombie;
|
||||
|
||||
public class CraftZombie extends CraftMonster implements Zombie{
|
||||
|
||||
public class CraftZombie extends CraftMonster implements Zombie {
|
||||
|
||||
public CraftZombie(CraftServer server, EntityZombie entity) {
|
||||
super(server, entity);
|
||||
|
@ -116,7 +116,7 @@ public class CraftEventFactory {
|
||||
if (type == Type.PLAYER_BUCKET_EMPTY) {
|
||||
event = new PlayerBucketEmptyEvent(player, blockClicked, blockFace, bucket, itemInHand);
|
||||
((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
|
||||
} else if(type == Type.PLAYER_BUCKET_FILL) {
|
||||
} else if (type == Type.PLAYER_BUCKET_FILL) {
|
||||
event = new PlayerBucketFillEvent(player, blockClicked, blockFace, bucket, itemInHand);
|
||||
((PlayerBucketFillEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
private final Random random;
|
||||
|
||||
public CustomChunkGenerator(World world, long seed, ChunkGenerator generator) {
|
||||
this.world = (WorldServer)world;
|
||||
this.world = (WorldServer) world;
|
||||
this.seed = seed;
|
||||
this.generator = generator;
|
||||
|
||||
@ -29,7 +29,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
}
|
||||
|
||||
public Chunk getOrCreateChunk(int x, int z) {
|
||||
random.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
|
||||
random.setSeed((long) x * 341873128712L + (long) z * 132897987541L);
|
||||
byte[] types = generator.generate(world.getWorld(), random, x, z);
|
||||
|
||||
Chunk chunk = new Chunk(world, types, x, z);
|
||||
|
@ -22,7 +22,7 @@ public class NormalChunkGenerator extends InternalChunkGenerator {
|
||||
}
|
||||
|
||||
public boolean canSpawn(org.bukkit.World world, int x, int z) {
|
||||
return ((CraftWorld)world).getHandle().worldProvider.a(x, z);
|
||||
return ((CraftWorld) world).getHandle().worldProvider.a(x, z);
|
||||
}
|
||||
|
||||
public List<BlockPopulator> getDefaultPopulators(org.bukkit.World world) {
|
||||
|
@ -270,7 +270,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
|
||||
}
|
||||
|
||||
public HashMap<Integer, ItemStack> removeItem(ItemStack... items) {
|
||||
HashMap<Integer,ItemStack> leftover = new HashMap<Integer,ItemStack>();
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
// TODO: optimization
|
||||
|
||||
|
@ -73,16 +73,17 @@ public class CraftInventoryPlayer extends CraftInventory implements PlayerInvent
|
||||
}
|
||||
|
||||
public void setArmorContents(ItemStack[] items) {
|
||||
int cnt = getSize();
|
||||
if (items == null) {
|
||||
items = new ItemStack[4];
|
||||
}
|
||||
for (ItemStack item : items) {
|
||||
if (item == null || item.getTypeId() == 0) {
|
||||
clear(cnt++);
|
||||
} else {
|
||||
setItem(cnt++, item);
|
||||
}
|
||||
}
|
||||
int cnt = getSize();
|
||||
|
||||
if (items == null) {
|
||||
items = new ItemStack[4];
|
||||
}
|
||||
for (ItemStack item : items) {
|
||||
if (item == null || item.getTypeId() == 0) {
|
||||
clear(cnt++);
|
||||
} else {
|
||||
setItem(cnt++, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class CraftFuture<T> implements Runnable, Future<T> {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
@ -35,7 +35,7 @@ public class CraftFuture<T> implements Runnable, Future<T> {
|
||||
} catch (Exception e) {
|
||||
this.e = e;
|
||||
}
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
running = false;
|
||||
done = true;
|
||||
this.notify();
|
||||
@ -50,7 +50,7 @@ public class CraftFuture<T> implements Runnable, Future<T> {
|
||||
}
|
||||
|
||||
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
if (isDone()) {
|
||||
return getResult();
|
||||
}
|
||||
@ -63,31 +63,31 @@ public class CraftFuture<T> implements Runnable, Future<T> {
|
||||
if (cancelled) {
|
||||
throw new CancellationException();
|
||||
}
|
||||
if (e!=null) {
|
||||
if (e != null) {
|
||||
throw new ExecutionException(e);
|
||||
}
|
||||
return returnStore.getObject();
|
||||
}
|
||||
|
||||
public boolean isDone() {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
return done;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
return cancelled;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean cancel(boolean mayInterruptIfRunning) {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
if (cancelled) {
|
||||
return false;
|
||||
}
|
||||
cancelled = true;
|
||||
if (taskId!=-1) {
|
||||
if (taskId != -1) {
|
||||
craftScheduler.cancelTask(taskId);
|
||||
}
|
||||
if (!running && !done) {
|
||||
@ -99,7 +99,7 @@ public class CraftFuture<T> implements Runnable, Future<T> {
|
||||
}
|
||||
|
||||
public void setTaskId(int taskId) {
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
private final LinkedList<CraftTask> mainThreadQueue = new LinkedList<CraftTask>();
|
||||
private final LinkedList<CraftTask> syncedTasks = new LinkedList<CraftTask>();
|
||||
|
||||
private final TreeMap<CraftTask,Boolean> schedulerQueue = new TreeMap<CraftTask,Boolean>();
|
||||
private final TreeMap<CraftTask, Boolean> schedulerQueue = new TreeMap<CraftTask, Boolean>();
|
||||
|
||||
private final Object currentTickSync = new Object();
|
||||
private Long currentTick = 0L;
|
||||
@ -54,7 +54,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
first = null;
|
||||
if (!schedulerQueue.isEmpty()) {
|
||||
first = schedulerQueue.firstKey();
|
||||
if (first!=null) {
|
||||
if (first != null) {
|
||||
currentTick = getCurrentTick();
|
||||
|
||||
firstTick = first.getExecutionTick();
|
||||
@ -62,7 +62,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
if (currentTick >= firstTick) {
|
||||
schedulerQueue.remove(first);
|
||||
processTask(first);
|
||||
if (first.getPeriod()>=0) {
|
||||
if (first.getPeriod() >= 0) {
|
||||
first.updateExecution();
|
||||
schedulerQueue.put(first, first.isSync());
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
sleepTime = 60000L;
|
||||
} else {
|
||||
currentTick = getCurrentTick();
|
||||
sleepTime = (firstTick-currentTick)*50 + 25;
|
||||
sleepTime = (firstTick - currentTick) * 50 + 25;
|
||||
}
|
||||
|
||||
if (sleepTime < 50L) {
|
||||
@ -95,8 +95,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
synchronized (schedulerQueue) {
|
||||
try {
|
||||
schedulerQueue.wait(sleepTime);
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
} catch (InterruptedException ie) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -207,7 +206,8 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
throw new IllegalArgumentException("Delay cannot be less than 0");
|
||||
}
|
||||
|
||||
CraftTask newTask = new CraftTask(plugin, task, true, getCurrentTick()+delay, period);
|
||||
CraftTask newTask = new CraftTask(plugin, task, true, getCurrentTick() + delay, period);
|
||||
|
||||
synchronized (schedulerQueue) {
|
||||
schedulerQueue.put(newTask, true);
|
||||
schedulerQueue.notify();
|
||||
@ -234,7 +234,8 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
throw new IllegalArgumentException("Delay cannot be less than 0");
|
||||
}
|
||||
|
||||
CraftTask newTask = new CraftTask(plugin, task, false, getCurrentTick()+delay, period);
|
||||
CraftTask newTask = new CraftTask(plugin, task, false, getCurrentTick() + delay, period);
|
||||
|
||||
synchronized (schedulerQueue) {
|
||||
schedulerQueue.put(newTask, false);
|
||||
schedulerQueue.notify();
|
||||
@ -267,7 +268,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
public void cancelTasks(Plugin plugin) {
|
||||
syncedTasksLock.lock();
|
||||
try {
|
||||
synchronized(schedulerQueue) {
|
||||
synchronized (schedulerQueue) {
|
||||
mainThreadLock.lock();
|
||||
try {
|
||||
Iterator<CraftTask> itr = schedulerQueue.keySet().iterator();
|
||||
@ -312,7 +313,7 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
craftThreadManager.interruptAllTasks();
|
||||
}
|
||||
|
||||
public boolean isCurrentlyRunning(int taskId){
|
||||
public boolean isCurrentlyRunning(int taskId) {
|
||||
return craftThreadManager.isAlive(taskId);
|
||||
}
|
||||
|
||||
@ -333,8 +334,9 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
synchronized (craftThreadManager.workers) {
|
||||
List<BukkitWorker> workerList = new ArrayList<BukkitWorker>(craftThreadManager.workers.size());
|
||||
Iterator<CraftWorker> itr = craftThreadManager.workers.iterator();
|
||||
|
||||
while (itr.hasNext()) {
|
||||
workerList.add((BukkitWorker)itr.next());
|
||||
workerList.add((BukkitWorker) itr.next());
|
||||
}
|
||||
return workerList;
|
||||
}
|
||||
@ -359,8 +361,9 @@ public class CraftScheduler implements BukkitScheduler, Runnable {
|
||||
syncedTasksLock.unlock();
|
||||
}
|
||||
List<BukkitTask> newTaskList = new ArrayList<BukkitTask>(taskList.size());
|
||||
|
||||
for (CraftTask craftTask : taskList) {
|
||||
newTaskList.add((BukkitTask)craftTask);
|
||||
newTaskList.add((BukkitTask) craftTask);
|
||||
}
|
||||
return newTaskList;
|
||||
}
|
||||
|
@ -79,9 +79,9 @@ public class CraftTask implements Comparable<Object>, BukkitTask {
|
||||
} else {
|
||||
CraftTask o = (CraftTask) other;
|
||||
long timeDiff = executionTick - o.getExecutionTick();
|
||||
if (timeDiff>0) {
|
||||
if (timeDiff > 0) {
|
||||
return 1;
|
||||
} else if (timeDiff<0) {
|
||||
} else if (timeDiff < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
CraftTask otherCraftTask = (CraftTask) other;
|
||||
|
@ -27,9 +27,9 @@ import java.lang.ref.SoftReference;
|
||||
* @author raphfrk
|
||||
*/
|
||||
|
||||
public class ConcurrentSoftMap<K,V> {
|
||||
public class ConcurrentSoftMap<K, V> {
|
||||
|
||||
private final ConcurrentHashMap<K,SoftMapReference<K,V>> map = new ConcurrentHashMap<K,SoftMapReference<K,V>>();
|
||||
private final ConcurrentHashMap<K, SoftMapReference<K, V>> map = new ConcurrentHashMap<K, SoftMapReference<K, V>>();
|
||||
private final ReferenceQueue<SoftMapReference> queue = new ReferenceQueue<SoftMapReference>();
|
||||
private final LinkedList<V> strongReferenceQueue = new LinkedList<V>();
|
||||
private final int strongReferenceSize;
|
||||
@ -51,17 +51,18 @@ public class ConcurrentSoftMap<K,V> {
|
||||
|
||||
private void emptyQueue() {
|
||||
SoftMapReference ref;
|
||||
while ((ref=(SoftMapReference) queue.poll()) != null) {
|
||||
|
||||
while ((ref = (SoftMapReference) queue.poll()) != null) {
|
||||
map.remove(ref.key);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
synchronized(strongReferenceQueue) {
|
||||
strongReferenceQueue.clear();
|
||||
}
|
||||
map.clear();
|
||||
emptyQueue();
|
||||
synchronized (strongReferenceQueue) {
|
||||
strongReferenceQueue.clear();
|
||||
}
|
||||
map.clear();
|
||||
emptyQueue();
|
||||
}
|
||||
|
||||
// Shouldn't support this, since the garbage collection is async
|
||||
@ -88,8 +89,8 @@ public class ConcurrentSoftMap<K,V> {
|
||||
// Doesn't support these either
|
||||
|
||||
public boolean equals(Object o) {
|
||||
emptyQueue();
|
||||
throw new UnsupportedOperationException("SoftMap doesn't support equals checks");
|
||||
emptyQueue();
|
||||
throw new UnsupportedOperationException("SoftMap doesn't support equals checks");
|
||||
}
|
||||
|
||||
// This operation returns null if the entry is not in the map
|
||||
@ -100,13 +101,15 @@ public class ConcurrentSoftMap<K,V> {
|
||||
}
|
||||
|
||||
private V fastGet(K key) {
|
||||
SoftMapReference<K,V> ref = map.get(key);
|
||||
if (ref==null) {
|
||||
SoftMapReference<K, V> ref = map.get(key);
|
||||
|
||||
if (ref == null) {
|
||||
return null;
|
||||
}
|
||||
V value = ref.get();
|
||||
if (value!=null) {
|
||||
synchronized(strongReferenceQueue) {
|
||||
|
||||
if (value != null) {
|
||||
synchronized (strongReferenceQueue) {
|
||||
strongReferenceQueue.addFirst(value);
|
||||
if (strongReferenceQueue.size() > strongReferenceSize) {
|
||||
strongReferenceQueue.removeLast();
|
||||
@ -119,8 +122,8 @@ public class ConcurrentSoftMap<K,V> {
|
||||
// Doesn't support this either
|
||||
|
||||
public int hashCode() {
|
||||
emptyQueue();
|
||||
throw new UnsupportedOperationException("SoftMap doesn't support hashCode");
|
||||
emptyQueue();
|
||||
throw new UnsupportedOperationException("SoftMap doesn't support hashCode");
|
||||
}
|
||||
|
||||
// This is another risky method, since again, garbage collection is async
|
||||
@ -147,8 +150,8 @@ public class ConcurrentSoftMap<K,V> {
|
||||
}
|
||||
|
||||
private void fastPut(K key, V value) {
|
||||
map.put(key, new SoftMapReference<K,V>(key, value, queue));
|
||||
synchronized(strongReferenceQueue) {
|
||||
map.put(key, new SoftMapReference<K, V>(key, value, queue));
|
||||
synchronized (strongReferenceQueue) {
|
||||
strongReferenceQueue.addFirst(value);
|
||||
if (strongReferenceQueue.size() > strongReferenceSize) {
|
||||
strongReferenceQueue.removeLast();
|
||||
@ -161,21 +164,23 @@ public class ConcurrentSoftMap<K,V> {
|
||||
return fastPutIfAbsent(key, value);
|
||||
}
|
||||
|
||||
private V fastPutIfAbsent(K key, V value) {
|
||||
private V fastPutIfAbsent(K key, V value) {
|
||||
V ret = null;
|
||||
|
||||
if (map.containsKey(key)) {
|
||||
SoftMapReference<K,V> current = map.get(key);
|
||||
if (current != null) {
|
||||
ret = current.get();
|
||||
}
|
||||
SoftMapReference<K, V> current = map.get(key);
|
||||
|
||||
if (current != null) {
|
||||
ret = current.get();
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == null) {
|
||||
SoftMapReference<K,V> newValue = new SoftMapReference<K,V>(key, value, queue);
|
||||
SoftMapReference<K, V> newValue = new SoftMapReference<K, V>(key, value, queue);
|
||||
boolean success = false;
|
||||
|
||||
while (!success) {
|
||||
SoftMapReference<K,V> oldValue = map.putIfAbsent(key, newValue);
|
||||
SoftMapReference<K, V> oldValue = map.putIfAbsent(key, newValue);
|
||||
|
||||
if (oldValue == null) { // put was successful (key didn't exist)
|
||||
ret = null;
|
||||
@ -192,7 +197,7 @@ public class ConcurrentSoftMap<K,V> {
|
||||
}
|
||||
|
||||
if (ret == null) {
|
||||
synchronized(strongReferenceQueue) {
|
||||
synchronized (strongReferenceQueue) {
|
||||
strongReferenceQueue.addFirst(value);
|
||||
if (strongReferenceQueue.size() > strongReferenceSize) {
|
||||
strongReferenceQueue.removeLast();
|
||||
@ -218,7 +223,8 @@ public class ConcurrentSoftMap<K,V> {
|
||||
|
||||
public V remove(K key) {
|
||||
emptyQueue();
|
||||
SoftMapReference<K,V> ref = map.remove(key);
|
||||
SoftMapReference<K, V> ref = map.remove(key);
|
||||
|
||||
if (ref != null) {
|
||||
return ref.get();
|
||||
}
|
||||
@ -239,8 +245,7 @@ public class ConcurrentSoftMap<K,V> {
|
||||
throw new UnsupportedOperationException("SoftMap does not support this operation, since it creates potentially stong references");
|
||||
}
|
||||
|
||||
|
||||
private static class SoftMapReference<K,V> extends SoftReference<V> {
|
||||
private static class SoftMapReference<K, V> extends SoftReference<V> {
|
||||
K key;
|
||||
|
||||
SoftMapReference(K key, V value, ReferenceQueue queue) {
|
||||
|
@ -14,7 +14,7 @@ public class LongHashtable<V> extends LongHash {
|
||||
if (value instanceof Chunk) {
|
||||
Chunk c = (Chunk) value;
|
||||
if (msw != c.x || lsw != c.z) {
|
||||
MinecraftServer.log.info("Chunk (" + c.x + ", " + c.z +") stored at (" + msw + ", " + lsw + ")");
|
||||
MinecraftServer.log.info("Chunk (" + c.x + ", " + c.z + ") stored at (" + msw + ", " + lsw + ")");
|
||||
Throwable x = new Throwable();
|
||||
x.fillInStackTrace();
|
||||
x.printStackTrace();
|
||||
@ -27,7 +27,7 @@ public class LongHashtable<V> extends LongHash {
|
||||
if (value instanceof Chunk) {
|
||||
Chunk c = (Chunk) value;
|
||||
if (msw != c.x || lsw != c.z) {
|
||||
MinecraftServer.log.info("Chunk (" + c.x + ", " + c.z +") stored at (" + msw + ", " + lsw + ")");
|
||||
MinecraftServer.log.info("Chunk (" + c.x + ", " + c.z + ") stored at (" + msw + ", " + lsw + ")");
|
||||
Throwable x = new Throwable();
|
||||
x.fillInStackTrace();
|
||||
x.printStackTrace();
|
||||
|
@ -21,7 +21,7 @@ public class ShortConsoleLogFormatter extends Formatter {
|
||||
Object object = options.valueOf("date-format");
|
||||
|
||||
if ((object != null) && (object instanceof SimpleDateFormat)) {
|
||||
date = (SimpleDateFormat)object;
|
||||
date = (SimpleDateFormat) object;
|
||||
}
|
||||
} catch (OptionException ex) {
|
||||
System.err.println("Given date format is not valid. Falling back to default.");
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren