Archiviert
13
0

Fix formatting.

Dieser Commit ist enthalten in:
Erik Broes 2012-01-14 23:02:10 +01:00
Ursprung 61ec751ca1
Commit a4ce846d07
68 geänderte Dateien mit 322 neuen und 465 gelöschten Zeilen

Datei anzeigen

@ -132,7 +132,7 @@ public class BlockFlowing extends BlockFluids {
BlockFace[] faces = new BlockFace[] { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST }; BlockFace[] faces = new BlockFace[] { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST };
int index = 0; int index = 0;
for (BlockFace currentFace: faces) { for (BlockFace currentFace : faces) {
if (aboolean[index]) { if (aboolean[index]) {
BlockFromToEvent event = new BlockFromToEvent(source, currentFace); BlockFromToEvent event = new BlockFromToEvent(source, currentFace);

Datei anzeigen

@ -101,7 +101,7 @@ public class BlockPressurePlate extends Block {
if (flag != flag1) { if (flag != flag1) {
if (flag1) { if (flag1) {
for (Object object: list) { for (Object object : list) {
if (object != null) { if (object != null) {
org.bukkit.event.Cancellable cancellable; org.bukkit.event.Cancellable cancellable;

Datei anzeigen

@ -9,6 +9,7 @@ import java.util.logging.Logger;
import java.util.logging.Handler; import java.util.logging.Handler;
import org.bukkit.craftbukkit.util.ShortConsoleLogFormatter; import org.bukkit.craftbukkit.util.ShortConsoleLogFormatter;
import org.bukkit.craftbukkit.util.TerminalConsoleHandler; import org.bukkit.craftbukkit.util.TerminalConsoleHandler;
// CraftBukkit end // CraftBukkit end
public class ConsoleLogManager { public class ConsoleLogManager {
@ -16,7 +17,8 @@ public class ConsoleLogManager {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
public static Logger global = Logger.getLogger(""); // CraftBukkit public static Logger global = Logger.getLogger(""); // CraftBukkit
public ConsoleLogManager() {} public ConsoleLogManager() {
}
// CraftBukkit - change of method signature! // CraftBukkit - change of method signature!
public static void init(MinecraftServer server) { public static void init(MinecraftServer server) {
@ -26,7 +28,7 @@ public class ConsoleLogManager {
// CraftBukkit start // CraftBukkit start
ConsoleHandler consolehandler = new TerminalConsoleHandler(server.reader); ConsoleHandler consolehandler = new TerminalConsoleHandler(server.reader);
for (Handler handler: global.getHandlers()) { for (Handler handler : global.getHandlers()) {
global.removeHandler(handler); global.removeHandler(handler);
} }
@ -38,10 +40,10 @@ public class ConsoleLogManager {
try { try {
// CraftBukkit start // CraftBukkit start
String pattern = (String)server.options.valueOf("log-pattern"); String pattern = (String) server.options.valueOf("log-pattern");
int limit = ((Integer)server.options.valueOf("log-limit")).intValue(); int limit = ((Integer) server.options.valueOf("log-limit")).intValue();
int count = ((Integer)server.options.valueOf("log-count")).intValue(); int count = ((Integer) server.options.valueOf("log-count")).intValue();
boolean append = ((Boolean)server.options.valueOf("log-append")).booleanValue(); boolean append = ((Boolean) server.options.valueOf("log-append")).booleanValue();
FileHandler filehandler = new FileHandler(pattern, limit, count, append); FileHandler filehandler = new FileHandler(pattern, limit, count, append);
// CraftBukkit end // CraftBukkit end

Datei anzeigen

@ -3,7 +3,7 @@ package net.minecraft.server;
import org.bukkit.craftbukkit.enchantments.CraftEnchantment; import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
public abstract class Enchantment { public abstract class Enchantment {
// CraftBukkit - update CraftEnchant.getName(i) if this changes. // CraftBukkit - update CraftEnchant.getName(i) if this changes.
public static final Enchantment[] byId = new Enchantment[256]; public static final Enchantment[] byId = new Enchantment[256];
public static final Enchantment PROTECTION_ENVIRONMENTAL = new EnchantmentProtection(0, 10, 0); public static final Enchantment PROTECTION_ENVIRONMENTAL = new EnchantmentProtection(0, 10, 0);
public static final Enchantment PROTECTION_FIRE = new EnchantmentProtection(1, 5, 1); public static final Enchantment PROTECTION_FIRE = new EnchantmentProtection(1, 5, 1);

Datei anzeigen

@ -75,7 +75,7 @@ public class EntityEgg extends EntityProjectile {
org.bukkit.entity.Entity entity = world.getWorld().spawn(new Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass(), SpawnReason.EGG); org.bukkit.entity.Entity entity = world.getWorld().spawn(new Location(world.getWorld(), this.locX, this.locY, this.locZ, this.yaw, 0.0F), hatchingType.getEntityClass(), SpawnReason.EGG);
if (entity instanceof Animals) { if (entity instanceof Animals) {
((Animals)entity).setAge(-24000); ((Animals) entity).setAge(-24000);
} }
} }
} }

Datei anzeigen

@ -491,8 +491,8 @@ public class EntityEnderDragon extends EntityComplex {
EntityExplodeEvent event = new EntityExplodeEvent(bukkitEntity, bukkitEntity.getLocation(), destroyedBlocks, 0F); EntityExplodeEvent event = new EntityExplodeEvent(bukkitEntity, bukkitEntity.getLocation(), destroyedBlocks, 0F);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
// this flag literally means 'Dragon hit something hard' (Obsidian, White Stone or Bedrock) and will cause the dragon to slow down. // this flag literally means 'Dragon hit something hard' (Obsidian, White Stone or Bedrock) and will cause the dragon to slow down.
// We should consider adding an event extension for it, or perhaps returning true if the event is cancelled. // We should consider adding an event extension for it, or perhaps returning true if the event is cancelled.
return flag; return flag;
} else { } else {
for (org.bukkit.block.Block block : event.blockList()) { for (org.bukkit.block.Block block : event.blockList()) {

Datei anzeigen

@ -35,7 +35,7 @@ public class EntityEnderPearl extends EntityProjectile {
if (this.shooter != null) { if (this.shooter != null) {
if (this.shooter instanceof EntityPlayer) { if (this.shooter instanceof EntityPlayer) {
CraftPlayer player = (CraftPlayer)this.shooter.bukkitEntity; CraftPlayer player = (CraftPlayer) this.shooter.bukkitEntity;
teleport = player.isOnline(); teleport = player.isOnline();
if (teleport) { if (teleport) {
@ -50,7 +50,7 @@ public class EntityEnderPearl extends EntityProjectile {
if (teleport) { if (teleport) {
if (this.shooter instanceof EntityPlayer) { if (this.shooter instanceof EntityPlayer) {
((EntityPlayer)this.shooter).netServerHandler.teleport(teleEvent.getTo()); ((EntityPlayer) this.shooter).netServerHandler.teleport(teleEvent.getTo());
} else { } else {
this.shooter.enderTeleportTo(this.locX, this.locY, this.locZ); this.shooter.enderTeleportTo(this.locX, this.locY, this.locZ);
} }

Datei anzeigen

@ -843,7 +843,7 @@ public abstract class EntityHuman extends EntityLiving {
if (l > 0) { if (l > 0) {
// CraftBukkit start - raise a combust event when somebody hits with a fire enchanted item // CraftBukkit start - raise a combust event when somebody hits with a fire enchanted item
EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), l*4); EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), l * 4);
Bukkit.getPluginManager().callEvent(combustEvent); Bukkit.getPluginManager().callEvent(combustEvent);
if (!combustEvent.isCancelled()) { if (!combustEvent.isCancelled()) {

Datei anzeigen

@ -3,7 +3,7 @@ package net.minecraft.server;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
// CraftBukkit End // CraftBukkit end
public class EntityItem extends Entity { public class EntityItem extends Entity {

Datei anzeigen

@ -125,7 +125,7 @@ public class EntityPainting extends Entity {
this.f = 0; this.f = 0;
if (!this.survives()) { if (!this.survives()) {
// CraftBukkit start // CraftBukkit start
Material material = this.world.getMaterial((int)this.locX, (int)this.locY, (int)this.locZ); Material material = this.world.getMaterial((int) this.locX, (int) this.locY, (int) this.locZ);
RemoveCause cause; RemoveCause cause;
if (material.equals(Material.WATER)) { if (material.equals(Material.WATER)) {
cause = RemoveCause.WATER; cause = RemoveCause.WATER;
@ -142,7 +142,7 @@ public class EntityPainting extends Entity {
return; return;
} }
if(!dead) { if (!dead) {
this.die(); this.die();
this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING))); this.world.addEntity(new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.PAINTING)));
} }

Datei anzeigen

@ -85,7 +85,7 @@ public class EntityPig extends EntityAnimal {
// CraftBukkit end // CraftBukkit end
entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
// CraftBukkit - added a reason for spawning this creature // CraftBukkit - added a reason for spawning this creature
this.world.addEntity(entitypigzombie, SpawnReason.LIGHTNING); this.world.addEntity(entitypigzombie, SpawnReason.LIGHTNING);
this.die(); this.die();
} }

Datei anzeigen

@ -633,7 +633,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void reset() { public void reset() {
float exp = 0; float exp = 0;
if(this.keepLevel) { if (this.keepLevel) {
exp = this.exp; exp = this.exp;
this.newTotalExp = this.expTotal; this.newTotalExp = this.expTotal;
this.newLevel = this.expLevel; this.newLevel = this.expLevel;
@ -650,7 +650,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
effects.clear(); effects.clear();
this.activeContainer = this.defaultContainer; this.activeContainer = this.defaultContainer;
this.lastSentExp = -1; this.lastSentExp = -1;
if(this.keepLevel) { if (this.keepLevel) {
this.exp = exp; this.exp = exp;
} else { } else {
this.giveExp(this.newExp); this.giveExp(this.newExp);
@ -659,7 +659,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
} }
public CraftPlayer getPlayer() { public CraftPlayer getPlayer() {
return (CraftPlayer)getBukkitEntity(); return (CraftPlayer) getBukkitEntity();
} }
// CraftBukkit end // CraftBukkit end
} }

Datei anzeigen

@ -119,15 +119,15 @@ public class EntitySpider extends EntityMonster {
// CraftBukkit start - whole method; adapted from super.dropDeathLoot. // CraftBukkit start - whole method; adapted from super.dropDeathLoot.
List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(); List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int k = this.random.nextInt(3); int k = this.random.nextInt(3);
if (i > 0) { if (i > 0) {
k += this.random.nextInt(i + 1); k += this.random.nextInt(i + 1);
} }
if (k > 0) { if (k > 0) {
loot.add(new org.bukkit.inventory.ItemStack(Item.STRING.id, k)); loot.add(new org.bukkit.inventory.ItemStack(Item.STRING.id, k));
} }
if (flag && (this.random.nextInt(3) == 0 || this.random.nextInt(1 + i) > 0)) { if (flag && (this.random.nextInt(3) == 0 || this.random.nextInt(1 + i) > 0)) {
loot.add(new org.bukkit.inventory.ItemStack(Item.SPIDER_EYE.id, 1)); loot.add(new org.bukkit.inventory.ItemStack(Item.SPIDER_EYE.id, 1));

Datei anzeigen

@ -117,7 +117,7 @@ public class EntityWolf extends EntityAnimal {
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.RANDOM_TARGET); EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.RANDOM_TARGET);
this.world.getServer().getPluginManager().callEvent(event); this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled() || event.getTarget() != null ) { if (!event.isCancelled() || event.getTarget() != null) {
this.setTarget(entity); this.setTarget(entity);
} }
// CraftBukkit end // CraftBukkit end

Datei anzeigen

@ -71,8 +71,7 @@ public class ItemBlock extends Item {
CraftBlockState blockStateBelow = null; CraftBlockState blockStateBelow = null;
// Toggles whether the normal or the block below is used for the place event // Toggles whether the normal or the block below is used for the place event
boolean eventUseBlockBelow = false; boolean eventUseBlockBelow = false;
if ((world.getTypeId(i, j - 1, k) == Block.STEP.id || world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) if ((world.getTypeId(i, j - 1, k) == Block.STEP.id || world.getTypeId(i, j - 1, k) == Block.DOUBLE_STEP.id) && (itemstack.id == Block.DOUBLE_STEP.id || itemstack.id == Block.STEP.id)) {
&& (itemstack.id == Block.DOUBLE_STEP.id || itemstack.id == Block.STEP.id)) {
blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k); blockStateBelow = CraftBlockState.getBlockState(world, i, j - 1, k);
// Step is placed on step, forms a doublestep replacing the original step, so we need the lower block // Step is placed on step, forms a doublestep replacing the original step, so we need the lower block
eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id; eventUseBlockBelow = itemstack.id == Block.STEP.id && blockStateBelow.getTypeId() == Block.STEP.id;

Datei anzeigen

@ -29,7 +29,7 @@ public class ItemDye extends Item {
if (i1 == Block.SAPLING.id) { if (i1 == Block.SAPLING.id) {
if (!world.isStatic) { if (!world.isStatic) {
// CraftBukkit start // CraftBukkit start
Player player = (entityhuman instanceof EntityPlayer) ? (Player)entityhuman.getBukkitEntity() : null; Player player = (entityhuman instanceof EntityPlayer) ? (Player) entityhuman.getBukkitEntity() : null;
((BlockSapling) Block.SAPLING).grow(world, i, j, k, world.random, true, player, itemstack); ((BlockSapling) Block.SAPLING).grow(world, i, j, k, world.random, true, player, itemstack);
//--itemstack.count; - called later if the bonemeal attempt was succesful //--itemstack.count; - called later if the bonemeal attempt was succesful
// CraftBukkit end // CraftBukkit end
@ -41,7 +41,7 @@ public class ItemDye extends Item {
if (i1 == Block.BROWN_MUSHROOM.id || i1 == Block.RED_MUSHROOM.id) { if (i1 == Block.BROWN_MUSHROOM.id || i1 == Block.RED_MUSHROOM.id) {
// CraftBukkit start // CraftBukkit start
if (!world.isStatic) { if (!world.isStatic) {
Player player = (entityhuman instanceof EntityPlayer) ? (Player)entityhuman.getBukkitEntity() : null; Player player = (entityhuman instanceof EntityPlayer) ? (Player) entityhuman.getBukkitEntity() : null;
((BlockMushroom) Block.byId[i1]).grow(world, i, j, k, world.random, true, player, itemstack); ((BlockMushroom) Block.byId[i1]).grow(world, i, j, k, world.random, true, player, itemstack);
//--itemstack.count; - called later if the bonemeal attempt was succesful //--itemstack.count; - called later if the bonemeal attempt was succesful
// CraftBukkit end // CraftBukkit end

Datei anzeigen

@ -18,7 +18,7 @@ public class ItemFishingRod extends Item {
entityhuman.s_(); entityhuman.s_();
} else { } else {
// CraftBukkit start // CraftBukkit start
PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null,PlayerFishEvent.State.FISHING); PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, PlayerFishEvent.State.FISHING);
world.getServer().getPluginManager().callEvent(playerFishEvent); world.getServer().getPluginManager().callEvent(playerFishEvent);
if (playerFishEvent.isCancelled()) { if (playerFishEvent.isCancelled()) {

Datei anzeigen

@ -61,7 +61,7 @@ public class ItemRedstone extends Item {
return false; return false;
} }
world.update( i, j, k, Block.REDSTONE_WIRE.id); // Must take place after BlockPlaceEvent, we need to update all other blocks. world.update(i, j, k, Block.REDSTONE_WIRE.id); // Must take place after BlockPlaceEvent, we need to update all other blocks.
// CraftBukkit end // CraftBukkit end
--itemstack.count; // CraftBukkit - ORDER MATTERS --itemstack.count; // CraftBukkit - ORDER MATTERS

Datei anzeigen

@ -502,7 +502,7 @@ public class MinecraftServer implements Runnable, ICommandListener, IMinecraftSe
// Send timeupdates to everyone, it will get the right time from the world the player is in. // Send timeupdates to everyone, it will get the right time from the world the player is in.
if (this.ticks % 20 == 0) { if (this.ticks % 20 == 0) {
for ( k = 0; k < this.serverConfigurationManager.players.size(); ++k) { for (k = 0; k < this.serverConfigurationManager.players.size(); ++k) {
EntityPlayer entityplayer = (EntityPlayer) this.serverConfigurationManager.players.get(k); EntityPlayer entityplayer = (EntityPlayer) this.serverConfigurationManager.players.get(k);
entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(entityplayer.getPlayerTime())); // Add support for per player time entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(entityplayer.getPlayerTime())); // Add support for per player time
} }

Datei anzeigen

@ -110,7 +110,7 @@ public class NetLoginHandler extends NetHandler {
netserverhandler.sendPacket(new Packet6SpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z)); netserverhandler.sendPacket(new Packet6SpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z));
this.server.serverConfigurationManager.a(entityplayer, worldserver); this.server.serverConfigurationManager.a(entityplayer, worldserver);
// this.server.serverConfigurationManager.sendAll(new Packet3Chat("\u00A7e" + entityplayer.name + " joined the game.")); // CraftBukkit - message moved to join event // this.server.serverConfigurationManager.sendAll(new Packet3Chat("\u00A7e" + entityplayer.name + " joined the game.")); // CraftBukkit - message moved to join event
this.server.serverConfigurationManager.c(entityplayer); this.server.serverConfigurationManager.c(entityplayer);
netserverhandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); netserverhandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
this.server.networkListenThread.a(netserverhandler); this.server.networkListenThread.a(netserverhandler);

Datei anzeigen

@ -65,6 +65,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit start // CraftBukkit start
this.server = minecraftserver.server; this.server = minecraftserver.server;
} }
private final CraftServer server; private final CraftServer server;
private int lastTick = MinecraftServer.currentTick; private int lastTick = MinecraftServer.currentTick;
private int lastDropTick = MinecraftServer.currentTick; private int lastDropTick = MinecraftServer.currentTick;
@ -674,7 +675,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.x, packet6.y, packet6.z); this.player.compassTarget = new Location(this.getPlayer().getWorld(), packet6.x, packet6.y, packet6.z);
} else if (packet instanceof Packet3Chat) { } else if (packet instanceof Packet3Chat) {
String message = ((Packet3Chat) packet).message; String message = ((Packet3Chat) packet).message;
for (final String line: TextWrapper.wrapText(message)) { for (final String line : TextWrapper.wrapText(message)) {
this.networkManager.queue(new Packet3Chat(line)); this.networkManager.queue(new Packet3Chat(line));
} }
packet = null; packet = null;

Datei anzeigen

@ -103,7 +103,7 @@ public abstract class Packet {
} }
// CraftBukkit - throws IOException // CraftBukkit - throws IOException
public static void a(String s, DataOutputStream dataoutputstream) throws IOException { public static void a(String s, DataOutputStream dataoutputstream) throws IOException {
if (s.length() > 32767) { if (s.length() > 32767) {
throw new IOException("String too big"); throw new IOException("String too big");
} else { } else {
@ -113,7 +113,7 @@ public abstract class Packet {
} }
// CraftBukkit - throws IOException // CraftBukkit - throws IOException
public static String a(DataInputStream datainputstream, int i) throws IOException { public static String a(DataInputStream datainputstream, int i) throws IOException {
short short1 = datainputstream.readShort(); short short1 = datainputstream.readShort();
if (short1 > i) { if (short1 > i) {

Datei anzeigen

@ -18,13 +18,16 @@ public final class SpawnerCreature {
// private static HashMap b = new HashMap(); // CraftBukkit - moved local to spawnEntities // private static HashMap b = new HashMap(); // CraftBukkit - moved local to spawnEntities
static private class ChunkEntry extends EntryBase { static private class ChunkEntry extends EntryBase {
public boolean spawn; public boolean spawn;
public ChunkEntry (int x, int z, boolean spawn) {
public ChunkEntry(int x, int z, boolean spawn) {
super(LongHash.toLong(x, z)); super(LongHash.toLong(x, z));
this.spawn = spawn; this.spawn = spawn;
} }
int getX() { int getX() {
return LongHash.msw(key); return LongHash.msw(key);
} }
int getZ() { int getZ() {
return LongHash.lsw(key); return LongHash.lsw(key);
} }

Datei anzeigen

@ -159,7 +159,7 @@ public class TileEntityChest extends TileEntity implements IInventory {
TileEntity entity = this.world.getTileEntity(x, y, z); TileEntity entity = this.world.getTileEntity(x, y, z);
if (entity instanceof TileEntityChest) { if (entity instanceof TileEntityChest) {
return (TileEntityChest)entity; return (TileEntityChest) entity;
} else { } else {
String name = "null"; String name = "null";
if (entity != null) { if (entity != null) {

Datei anzeigen

@ -15,6 +15,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
// CraftBukkit start // CraftBukkit start
private int lastTick = (int) (System.currentTimeMillis() / 50); private int lastTick = (int) (System.currentTimeMillis() / 50);
public ItemStack[] getContents() { public ItemStack[] getContents() {
return this.items; return this.items;
} }

Datei anzeigen

@ -864,9 +864,8 @@ public class World implements IBlockAccess {
return this.addEntity(entity, SpawnReason.CUSTOM); // Set reason as Custom by default return this.addEntity(entity, SpawnReason.CUSTOM); // Set reason as Custom by default
} }
public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason public boolean addEntity(Entity entity, SpawnReason spawnReason) { // Changed signature, added SpawnReason
// CraftBukkit end // CraftBukkit end
int i = MathHelper.floor(entity.locX / 16.0D); int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D); int j = MathHelper.floor(entity.locZ / 16.0D);
boolean flag = false; boolean flag = false;
@ -2307,7 +2306,7 @@ public class World implements IBlockAccess {
} else { } else {
if (i > 1000) { if (i > 1000) {
// CraftBukkit start - if the server has too much to process over time, try to alleviate that // CraftBukkit start - if the server has too much to process over time, try to alleviate that
if(i > 20 * 1000) { if (i > 20 * 1000) {
i = i / 20; i = i / 20;
} else { } else {
i = 1000; i = 1000;

Datei anzeigen

@ -217,7 +217,7 @@ public class WorldGenBigTree extends WorldGenerator {
aint3[b3] = MathHelper.floor((double) aint[b3] + (double) j * d1 + 0.5D); aint3[b3] = MathHelper.floor((double) aint[b3] + (double) j * d1 + 0.5D);
// CraftBukkit start // CraftBukkit start
if (event == null) { if (event == null) {
this.setTypeAndData(this.world, aint3[0], aint3[1], aint3[2], i, 0); this.setTypeAndData(this.world, aint3[0], aint3[1], aint3[2], i, 0);
} else { } else {
BlockState state = bukkitWorld.getBlockAt(aint3[0], aint3[1], aint3[2]).getState(); BlockState state = bukkitWorld.getBlockAt(aint3[0], aint3[1], aint3[2]).getState();
state.setTypeId(i); state.setTypeId(i);

Datei anzeigen

@ -205,7 +205,7 @@ public class WorldNBTStorage implements PlayerFileData, IDataManager {
if (nbttagcompound != null) { if (nbttagcompound != null) {
// CraftBukkit start // CraftBukkit start
if (entityhuman instanceof EntityPlayer) { if (entityhuman instanceof EntityPlayer) {
CraftPlayer player = (CraftPlayer)entityhuman.bukkitEntity; CraftPlayer player = (CraftPlayer) entityhuman.bukkitEntity;
player.setFirstPlayed(new File(playerDir, entityhuman.name + ".dat").lastModified()); player.setFirstPlayed(new File(playerDir, entityhuman.name + ".dat").lastModified());
} }
// CraftBukkit end // CraftBukkit end

Datei anzeigen

@ -82,7 +82,7 @@ public class WorldServer extends World implements BlockChangeDelegate {
+ "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover."); + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.");
if (Block.byId[type] instanceof BlockContainer) { if (Block.byId[type] instanceof BlockContainer) {
TileEntity replacement = ((BlockContainer)Block.byId[type]).a_(); TileEntity replacement = ((BlockContainer) Block.byId[type]).a_();
setTileEntity(x, y, z, replacement); setTileEntity(x, y, z, replacement);
return replacement; return replacement;
} else { } else {

Datei anzeigen

@ -23,7 +23,7 @@ public class CraftChunk implements Chunk {
private int z; private int z;
public CraftChunk(net.minecraft.server.Chunk chunk) { public CraftChunk(net.minecraft.server.Chunk chunk) {
if(!(chunk instanceof EmptyChunk)) { if (!(chunk instanceof EmptyChunk)) {
this.weakChunk = new WeakReference<net.minecraft.server.Chunk>(chunk); this.weakChunk = new WeakReference<net.minecraft.server.Chunk>(chunk);
} }
worldServer = (WorldServer) getHandle().world; worldServer = (WorldServer) getHandle().world;
@ -39,7 +39,7 @@ public class CraftChunk implements Chunk {
net.minecraft.server.Chunk c = weakChunk.get(); net.minecraft.server.Chunk c = weakChunk.get();
if (c == null) { if (c == null) {
c = worldServer.getChunkAt(x, z); c = worldServer.getChunkAt(x, z);
if(!(c instanceof EmptyChunk)) { if (!(c instanceof EmptyChunk)) {
weakChunk = new WeakReference<net.minecraft.server.Chunk>(c); weakChunk = new WeakReference<net.minecraft.server.Chunk>(c);
} }
} }
@ -76,7 +76,7 @@ public class CraftChunk implements Chunk {
Entity[] entities = new Entity[count]; Entity[] entities = new Entity[count];
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
for (Object obj: chunk.entitySlices[i].toArray()) { for (Object obj : chunk.entitySlices[i].toArray()) {
if (!(obj instanceof net.minecraft.server.Entity)) { if (!(obj instanceof net.minecraft.server.Entity)) {
continue; continue;
} }
@ -155,10 +155,10 @@ public class CraftChunk implements Chunk {
biomeTemp = new double[256]; biomeTemp = new double[256];
biomeRain = new double[256]; biomeRain = new double[256];
float[] dat = wcm.getTemperatures((float[]) null, getX() << 4, getZ() << 4, 16, 16); float[] dat = wcm.getTemperatures((float[]) null, getX() << 4, getZ() << 4, 16, 16);
for(int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
biomeTemp[i] = dat[i]; biomeTemp[i] = dat[i];
dat = wcm.getWetness((float[]) null, getX() << 4, getZ() << 4, 16, 16); dat = wcm.getWetness((float[]) null, getX() << 4, getZ() << 4, 16, 16);
for(int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
biomeRain[i] = dat[i]; biomeRain[i] = dat[i];
} }
} }
@ -212,10 +212,10 @@ public class CraftChunk implements Chunk {
biomeTemp = new double[256]; biomeTemp = new double[256];
biomeRain = new double[256]; biomeRain = new double[256];
float[] dat = wcm.getTemperatures((float[]) null, x << 4, z << 4, 16, 16); float[] dat = wcm.getTemperatures((float[]) null, x << 4, z << 4, 16, 16);
for(int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
biomeTemp[i] = dat[i]; biomeTemp[i] = dat[i];
dat = wcm.getWetness((float[]) null, x << 4, z << 4, 16, 16); dat = wcm.getWetness((float[]) null, x << 4, z << 4, 16, 16);
for(int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
biomeRain[i] = dat[i]; biomeRain[i] = dat[i];
} }
} }

Datei anzeigen

@ -5,6 +5,7 @@ import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import net.minecraft.server.BiomeBase; import net.minecraft.server.BiomeBase;
/** /**
* Represents a static, thread-safe snapshot of chunk of blocks * Represents a static, thread-safe snapshot of chunk of blocks
* Purpose is to allow clean, efficient copy of a chunk data to be made, and then handed off for processing in another thread (e.g. map rendering) * Purpose is to allow clean, efficient copy of a chunk data to be made, and then handed off for processing in another thread (e.g. map rendering)
@ -23,9 +24,6 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
private static final int BLOCKLIGHT_OFF = BLOCKDATA_OFF + 16384; private static final int BLOCKLIGHT_OFF = BLOCKDATA_OFF + 16384;
private static final int SKYLIGHT_OFF = BLOCKLIGHT_OFF + 16384; private static final int SKYLIGHT_OFF = BLOCKLIGHT_OFF + 16384;
/**
* Constructor
*/
CraftChunkSnapshot(int x, int z, String wname, long wtime, byte[] buf, byte[] hmap, BiomeBase[] biome, double[] biomeTemp, double[] biomeRain) { CraftChunkSnapshot(int x, int z, String wname, long wtime, byte[] buf, byte[] hmap, BiomeBase[] biome, double[] biomeTemp, double[] biomeRain) {
this.x = x; this.x = x;
this.z = z; this.z = z;
@ -38,135 +36,56 @@ public class CraftChunkSnapshot implements ChunkSnapshot {
this.biomeRain = biomeRain; this.biomeRain = biomeRain;
} }
/**
* Gets the X-coordinate of this chunk
*
* @return X-coordinate
*/
public int getX() { public int getX() {
return x; return x;
} }
/**
* Gets the Z-coordinate of this chunk
*
* @return Z-coordinate
*/
public int getZ() { public int getZ() {
return z; return z;
} }
/**
* Gets name of the world containing this chunk
*
* @return Parent World Name
*/
public String getWorldName() { public String getWorldName() {
return worldname; return worldname;
} }
/**
* Get block type for block at corresponding coordinate in the chunk
*
* @param x 0-15
* @param y 0-127
* @param z 0-15
* @return 0-255
*/
public int getBlockTypeId(int x, int y, int z) { public int getBlockTypeId(int x, int y, int z) {
return buf[x << 11 | z << 7 | y] & 255; return buf[x << 11 | z << 7 | y] & 255;
} }
/**
* Get block data for block at corresponding coordinate in the chunk
*
* @param x 0-15
* @param y 0-127
* @param z 0-15
* @return 0-15
*/
public int getBlockData(int x, int y, int z) { public int getBlockData(int x, int y, int z) {
int off = ((x << 10) | (z << 6) | (y >> 1)) + BLOCKDATA_OFF; int off = ((x << 10) | (z << 6) | (y >> 1)) + BLOCKDATA_OFF;
return ((y & 1) == 0) ? (buf[off] & 0xF) : ((buf[off] >> 4) & 0xF); return ((y & 1) == 0) ? (buf[off] & 0xF) : ((buf[off] >> 4) & 0xF);
} }
/**
* Get sky light level for block at corresponding coordinate in the chunk
*
* @param x 0-15
* @param y 0-127
* @param z 0-15
* @return 0-15
*/
public int getBlockSkyLight(int x, int y, int z) { public int getBlockSkyLight(int x, int y, int z) {
int off = ((x << 10) | (z << 6) | (y >> 1)) + SKYLIGHT_OFF; int off = ((x << 10) | (z << 6) | (y >> 1)) + SKYLIGHT_OFF;
return ((y & 1) == 0) ? (buf[off] & 0xF) : ((buf[off] >> 4) & 0xF); return ((y & 1) == 0) ? (buf[off] & 0xF) : ((buf[off] >> 4) & 0xF);
} }
/**
* Get light level emitted by block at corresponding coordinate in the chunk
*
* @param x 0-15
* @param y 0-127
* @param z 0-15
* @return 0-15
*/
public int getBlockEmittedLight(int x, int y, int z) { public int getBlockEmittedLight(int x, int y, int z) {
int off = ((x << 10) | (z << 6) | (y >> 1)) + BLOCKLIGHT_OFF; int off = ((x << 10) | (z << 6) | (y >> 1)) + BLOCKLIGHT_OFF;
return ((y & 1) == 0) ? (buf[off] & 0xF) : ((buf[off] >> 4) & 0xF); return ((y & 1) == 0) ? (buf[off] & 0xF) : ((buf[off] >> 4) & 0xF);
} }
/**
* Gets the highest non-air coordinate at the given coordinates
*
* @param x X-coordinate of the blocks
* @param z Z-coordinate of the blocks
* @return Y-coordinate of the highest non-air block
*/
public int getHighestBlockYAt(int x, int z) { public int getHighestBlockYAt(int x, int z) {
return hmap[z << 4 | x] & 255; return hmap[z << 4 | x] & 255;
} }
/**
* Get biome at given coordinates
*
* @param x X-coordinate
* @param z Z-coordinate
* @return Biome at given coordinate
*/
public Biome getBiome(int x, int z) { public Biome getBiome(int x, int z) {
return CraftBlock.biomeBaseToBiome(biome[z << 4 | x]); return CraftBlock.biomeBaseToBiome(biome[z << 4 | x]);
} }
/**
* Get raw biome temperature (0.0-1.0) at given coordinate
*
* @param x X-coordinate
* @param z Z-coordinate
* @return temperature at given coordinate
*/
public double getRawBiomeTemperature(int x, int z) { public double getRawBiomeTemperature(int x, int z) {
return biomeTemp[z << 4 | x]; return biomeTemp[z << 4 | x];
} }
/**
* Get raw biome rainfall (0.0-1.0) at given coordinate
*
* @param x X-coordinate
* @param z Z-coordinate
* @return rainfall at given coordinate
*/
public double getRawBiomeRainfall(int x, int z) { public double getRawBiomeRainfall(int x, int z) {
return biomeRain[z << 4 | x]; return biomeRain[z << 4 | x];
} }
/**
* Get world full time when chunk snapshot was captured
* @return time in ticks
*/
public long getCaptureFullTime() { public long getCaptureFullTime() {
return captureFulltime; return captureFulltime;
} }

Datei anzeigen

@ -22,7 +22,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
protected CraftOfflinePlayer(CraftServer server, String name) { protected CraftOfflinePlayer(CraftServer server, String name) {
this.server = server; this.server = server;
this.name = name; this.name = name;
this.storage = (WorldNBTStorage)(server.console.worlds.get(0).getDataManager()); this.storage = (WorldNBTStorage) (server.console.worlds.get(0).getDataManager());
} }
public boolean isOnline() { public boolean isOnline() {
@ -84,7 +84,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
} }
public static OfflinePlayer deserialize(Map<String, Object> args) { public static OfflinePlayer deserialize(Map<String, Object> args) {
return Bukkit.getServer().getOfflinePlayer((String)args.get("name")); return Bukkit.getServer().getOfflinePlayer((String) args.get("name"));
} }
@Override @Override
@ -93,8 +93,8 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
} }
public Player getPlayer() { public Player getPlayer() {
for (Object obj: server.getHandle().players) { for (Object obj : server.getHandle().players) {
EntityPlayer player = (EntityPlayer)obj; EntityPlayer player = (EntityPlayer) obj;
if (player.name.equalsIgnoreCase(getName())) { if (player.name.equalsIgnoreCase(getName())) {
return (player.netServerHandler != null) ? player.netServerHandler.getPlayer() : null; return (player.netServerHandler != null) ? player.netServerHandler.getPlayer() : null;
} }
@ -111,7 +111,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
if (!(obj instanceof OfflinePlayer)) { if (!(obj instanceof OfflinePlayer)) {
return false; return false;
} }
OfflinePlayer other = (OfflinePlayer)obj; OfflinePlayer other = (OfflinePlayer) obj;
if ((this.getName() == null) || (other.getName() == null)) { if ((this.getName() == null) || (other.getName() == null)) {
return false; return false;
} }

Datei anzeigen

@ -135,7 +135,7 @@ public final class CraftServer implements Server {
} }
private File getConfigFile() { private File getConfigFile() {
return (File)console.options.valueOf("bukkit-settings"); return (File) console.options.valueOf("bukkit-settings");
} }
private void saveConfig() { private void saveConfig() {
@ -372,7 +372,6 @@ public final class CraftServer implements Server {
return server; return server;
} }
// NOTE: Should only be called from MinecraftServer.b() // NOTE: Should only be called from MinecraftServer.b()
public boolean dispatchCommand(CommandSender sender, ServerCommand serverCommand) { public boolean dispatchCommand(CommandSender sender, ServerCommand serverCommand) {
return dispatchCommand(sender, serverCommand.command); return dispatchCommand(sender, serverCommand.command);
@ -457,7 +456,7 @@ public final class CraftServer implements Server {
Map<String, Map<String, Object>> perms; Map<String, Map<String, Object>> perms;
try { try {
perms = (Map<String, Map<String, Object>>)yaml.load(stream); perms = (Map<String, Map<String, Object>>) yaml.load(stream);
} catch (MarkedYAMLException ex) { } catch (MarkedYAMLException ex) {
getLogger().log(Level.WARNING, "Server permissions file " + file + " is not valid YAML: " + ex.toString()); getLogger().log(Level.WARNING, "Server permissions file " + file + " is not valid YAML: " + ex.toString());
return; return;
@ -557,7 +556,7 @@ public final class CraftServer implements Server {
} }
pluginManager.callEvent(new WorldInitEvent(internal.getWorld())); pluginManager.callEvent(new WorldInitEvent(internal.getWorld()));
System.out.print("Preparing start region for level " + (console.worlds.size() -1) + " (Seed: " + internal.getSeed() + ")"); System.out.print("Preparing start region for level " + (console.worlds.size() - 1) + " (Seed: " + internal.getSeed() + ")");
if (internal.getWorld().getKeepSpawnInMemory()) { if (internal.getWorld().getKeepSpawnInMemory()) {
short short1 = 196; short short1 = 196;
@ -811,7 +810,7 @@ public final class CraftServer implements Server {
for (Permissible permissible : permissibles) { for (Permissible permissible : permissibles) {
if (permissible instanceof CommandSender) { if (permissible instanceof CommandSender) {
CommandSender user = (CommandSender)permissible; CommandSender user = (CommandSender) permissible;
user.sendMessage(message); user.sendMessage(message);
count++; count++;
} }
@ -854,7 +853,7 @@ public final class CraftServer implements Server {
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>(); Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
for (Object name : server.banByName) { for (Object name : server.banByName) {
result.add(getOfflinePlayer((String)name)); result.add(getOfflinePlayer((String) name));
} }
return result; return result;
@ -869,7 +868,7 @@ public final class CraftServer implements Server {
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>(); Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
for (Object name : server.getWhitelisted()) { for (Object name : server.getWhitelisted()) {
result.add(getOfflinePlayer((String)name)); result.add(getOfflinePlayer((String) name));
} }
return result; return result;
@ -879,7 +878,7 @@ public final class CraftServer implements Server {
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>(); Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
for (Object name : server.operators) { for (Object name : server.operators) {
result.add(getOfflinePlayer((String)name)); result.add(getOfflinePlayer((String) name));
} }
return result; return result;
@ -899,7 +898,7 @@ public final class CraftServer implements Server {
} }
for (World world : getWorlds()) { for (World world : getWorlds()) {
((CraftWorld)world).getHandle().worldData.setGameType(mode.getValue()); ((CraftWorld) world).getHandle().worldData.setGameType(mode.getValue());
} }
} }
@ -910,16 +909,15 @@ public final class CraftServer implements Server {
public void detectListNameConflict(EntityPlayer entityPlayer) { public void detectListNameConflict(EntityPlayer entityPlayer) {
// Collisions will make for invisible people // Collisions will make for invisible people
for (int i = 0; i < getHandle().players.size(); ++i) { for (int i = 0; i < getHandle().players.size(); ++i) {
EntityPlayer testEntityPlayer = (EntityPlayer)getHandle().players.get(i); EntityPlayer testEntityPlayer = (EntityPlayer) getHandle().players.get(i);
// We have a problem! // We have a problem!
if (testEntityPlayer != entityPlayer && testEntityPlayer.listName.equals(entityPlayer.listName)) { if (testEntityPlayer != entityPlayer && testEntityPlayer.listName.equals(entityPlayer.listName)) {
String oldName = entityPlayer.listName; String oldName = entityPlayer.listName;
int spaceLeft = 16 - oldName.length(); int spaceLeft = 16 - oldName.length();
if (spaceLeft <= 1) { // We also hit the list name length limit! if (spaceLeft <= 1) { // We also hit the list name length limit!
entityPlayer.listName = oldName.subSequence(0, oldName.length() - 2 - spaceLeft) entityPlayer.listName = oldName.subSequence(0, oldName.length() - 2 - spaceLeft) + String.valueOf(System.currentTimeMillis() % 99);
+ String.valueOf(System.currentTimeMillis() % 99);
} else { } else {
entityPlayer.listName = oldName + String.valueOf(System.currentTimeMillis() % 99); entityPlayer.listName = oldName + String.valueOf(System.currentTimeMillis() % 99);
} }

Datei anzeigen

@ -46,7 +46,7 @@ import org.bukkit.plugin.messaging.StandardMessenger;
public class CraftWorld implements World { public class CraftWorld implements World {
private final WorldServer world; private final WorldServer world;
private Environment environment; private Environment environment;
private final CraftServer server = (CraftServer)Bukkit.getServer(); private final CraftServer server = (CraftServer) Bukkit.getServer();
private ConcurrentMap<Integer, CraftChunk> unloadedChunks = new MapMaker().weakValues().makeMap(); private ConcurrentMap<Integer, CraftChunk> unloadedChunks = new MapMaker().weakValues().makeMap();
private final ChunkGenerator generator; private final ChunkGenerator generator;
private final List<BlockPopulator> populators = new ArrayList<BlockPopulator>(); private final List<BlockPopulator> populators = new ArrayList<BlockPopulator>();
@ -78,7 +78,7 @@ public class CraftWorld implements World {
} }
public int getHighestBlockYAt(int x, int z) { public int getHighestBlockYAt(int x, int z) {
if (!isChunkLoaded(x >> 4, z >> 4)){ if (!isChunkLoaded(x >> 4, z >> 4)) {
loadChunk(x >> 4, z >> 4); loadChunk(x >> 4, z >> 4);
} }
@ -221,7 +221,6 @@ public class CraftWorld implements World {
return true; return true;
} }
public boolean isChunkInUse(int x, int z) { public boolean isChunkInUse(int x, int z) {
Player[] players = server.getOnlinePlayers(); Player[] players = server.getOnlinePlayers();
@ -334,7 +333,7 @@ public class CraftWorld implements World {
return null; return null;
} }
return (LivingEntity)result; return (LivingEntity) result;
} }
public LightningStrike strikeLightning(Location loc) { public LightningStrike strikeLightning(Location loc) {
@ -355,17 +354,17 @@ public class CraftWorld implements World {
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
switch (type) { switch (type) {
case BIG_TREE: case BIG_TREE:
return new WorldGenBigTree(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); return new WorldGenBigTree(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null);
case BIRCH: case BIRCH:
return new WorldGenForest(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); return new WorldGenForest(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null);
case REDWOOD: case REDWOOD:
return new WorldGenTaiga2(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); return new WorldGenTaiga2(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null);
case TALL_REDWOOD: case TALL_REDWOOD:
return new WorldGenTaiga1().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); return new WorldGenTaiga1().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case TREE: case TREE:
default: default:
return new WorldGenTrees(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); return new WorldGenTrees(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null);
} }
} }
@ -411,7 +410,7 @@ public class CraftWorld implements World {
world.setTime(time); world.setTime(time);
// Forces the client to update to the new time immediately // Forces the client to update to the new time immediately
for (Player p: getPlayers()) { for (Player p : getPlayers()) {
CraftPlayer cp = (CraftPlayer) p; CraftPlayer cp = (CraftPlayer) p;
cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().getPlayerTime())); cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().getPlayerTime()));
} }
@ -493,7 +492,7 @@ public class CraftWorld implements World {
public List<Entity> getEntities() { public List<Entity> getEntities() {
List<Entity> list = new ArrayList<Entity>(); List<Entity> list = new ArrayList<Entity>();
for (Object o: world.entityList) { for (Object o : world.entityList) {
if (o instanceof net.minecraft.server.Entity) { 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(); Entity bukkitEntity = mcEnt.getBukkitEntity();
@ -511,7 +510,7 @@ public class CraftWorld implements World {
public List<LivingEntity> getLivingEntities() { public List<LivingEntity> getLivingEntities() {
List<LivingEntity> list = new ArrayList<LivingEntity>(); List<LivingEntity> list = new ArrayList<LivingEntity>();
for (Object o: world.entityList) { for (Object o : world.entityList) {
if (o instanceof net.minecraft.server.Entity) { 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(); Entity bukkitEntity = mcEnt.getBukkitEntity();
@ -790,20 +789,21 @@ public class CraftWorld implements World {
face = BlockFace.SOUTH; face = BlockFace.SOUTH;
} }
int dir; int dir;
switch(face) { switch (face) {
case EAST: case EAST:
default: default:
dir = 0; dir = 0;
break; break;
case NORTH: case NORTH:
dir = 1; dir = 1;
break; break;
case WEST: case WEST:
dir = 2; dir = 2;
break; break;
case SOUTH: case SOUTH:
dir = 3;; dir = 3;
break; ;
break;
} }
entity = new EntityPainting(world, (int) x, (int) y, (int) z, dir); entity = new EntityPainting(world, (int) x, (int) y, (int) z, dir);
if (!((EntityPainting) entity).survives()) { if (!((EntityPainting) entity).survives()) {
@ -866,7 +866,7 @@ public class CraftWorld implements World {
ChunkCoordinates chunkcoordinates = this.world.getSpawn(); ChunkCoordinates chunkcoordinates = this.world.getSpawn();
int chunkCoordX = chunkcoordinates.x >> 4; int chunkCoordX = chunkcoordinates.x >> 4;
int chunkCoordZ = chunkcoordinates.z >> 4; int chunkCoordZ = chunkcoordinates.z >> 4;
// Cycle through the 25x25 Chunks around it to load/unload the chunks. // Cycle through the 25x25 Chunks around it to load/unload the chunks.
for (int x = -12; x <= 12; x++) { for (int x = -12; x <= 12; x++) {
for (int z = -12; z <= 12; z++) { for (int z = -12; z <= 12; z++) {
if (keepLoaded) { if (keepLoaded) {
@ -904,7 +904,7 @@ public class CraftWorld implements World {
} }
public File getWorldFolder() { public File getWorldFolder() {
return ((WorldNBTStorage)world.getDataManager()).getDirectory(); return ((WorldNBTStorage) world.getDataManager()).getDirectory();
} }
public void explodeBlock(Block block, float yield) { public void explodeBlock(Block block, float yield) {

Datei anzeigen

@ -1,4 +1,3 @@
package org.bukkit.craftbukkit; package org.bukkit.craftbukkit;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;

Datei anzeigen

@ -137,7 +137,6 @@ public class PortalTravelAgent implements TravelAgent {
public boolean createPortal(Location location) { public boolean createPortal(Location location) {
net.minecraft.server.World world = ((CraftWorld) location.getWorld()).getHandle(); net.minecraft.server.World world = ((CraftWorld) location.getWorld()).getHandle();
if (location.getWorld().getEnvironment() == Environment.THE_END) { if (location.getWorld().getEnvironment() == Environment.THE_END) {
int i = MathHelper.floor(location.getBlockX()); int i = MathHelper.floor(location.getBlockX());
int j = MathHelper.floor(location.getBlockY()) - 1; int j = MathHelper.floor(location.getBlockY()) - 1;
@ -401,9 +400,6 @@ public class PortalTravelAgent implements TravelAgent {
return true; return true;
} }
public TravelAgent setSearchRadius(int radius) { public TravelAgent setSearchRadius(int radius) {
this.searchRadius = radius; this.searchRadius = radius;
return this; return this;

Datei anzeigen

@ -1,8 +1,8 @@
package org.bukkit.craftbukkit; package org.bukkit.craftbukkit;
/** /**
* Credits for this class goes to user aioobe on stackoverflow.com * Credits for this class goes to user aioobe on stackoverflow.com
* Source: http://stackoverflow.com/questions/4454630/j2me-calculate-the-the-distance-between-2-latitude-and-longitude * Source: http://stackoverflow.com/questions/4454630/j2me-calculate-the-the-distance-between-2-latitude-and-longitude
*
*/ */
public class TrigMath { public class TrigMath {

Datei anzeigen

@ -175,21 +175,21 @@ public class CraftBlock implements Block {
} }
public static int blockFaceToNotch(BlockFace face) { public static int blockFaceToNotch(BlockFace face) {
switch(face) { switch (face) {
case DOWN: case DOWN:
return 0; return 0;
case UP: case UP:
return 1; return 1;
case EAST: case EAST:
return 2; return 2;
case WEST: case WEST:
return 3; return 3;
case NORTH: case NORTH:
return 4; return 4;
case SOUTH: case SOUTH:
return 5; return 5;
default: default:
return 7; // Good as anything here, but technically invalid return 7; // Good as anything here, but technically invalid
} }
} }
@ -197,25 +197,25 @@ public class CraftBlock implements Block {
Material material = getType(); Material material = getType();
switch (material) { switch (material) {
case SIGN: case SIGN:
case SIGN_POST: case SIGN_POST:
case WALL_SIGN: case WALL_SIGN:
return new CraftSign(this); return new CraftSign(this);
case CHEST: case CHEST:
return new CraftChest(this); return new CraftChest(this);
case BURNING_FURNACE: case BURNING_FURNACE:
case FURNACE: case FURNACE:
return new CraftFurnace(this); return new CraftFurnace(this);
case DISPENSER: case DISPENSER:
return new CraftDispenser(this); return new CraftDispenser(this);
case MOB_SPAWNER: case MOB_SPAWNER:
return new CraftCreatureSpawner(this); return new CraftCreatureSpawner(this);
case NOTE_BLOCK: case NOTE_BLOCK:
return new CraftNoteBlock(this); return new CraftNoteBlock(this);
case JUKEBOX: case JUKEBOX:
return new CraftJukebox(this); return new CraftJukebox(this);
default: default:
return new CraftBlockState(this); return new CraftBlockState(this);
} }
} }
@ -245,27 +245,27 @@ public class CraftBlock implements Block {
} else if (base == BiomeBase.OCEAN) { } else if (base == BiomeBase.OCEAN) {
return Biome.OCEAN; return Biome.OCEAN;
} else if (base == BiomeBase.FROZEN_OCEAN) { } else if (base == BiomeBase.FROZEN_OCEAN) {
return Biome.FROZEN_OCEAN; return Biome.FROZEN_OCEAN;
} else if (base == BiomeBase.FROZEN_RIVER) { } else if (base == BiomeBase.FROZEN_RIVER) {
return Biome.FROZEN_RIVER; return Biome.FROZEN_RIVER;
} else if (base == BiomeBase.ICE_PLAINS) { } else if (base == BiomeBase.ICE_PLAINS) {
return Biome.ICE_PLAINS; return Biome.ICE_PLAINS;
} else if (base == BiomeBase.ICE_MOUNTAINS) { } else if (base == BiomeBase.ICE_MOUNTAINS) {
return Biome.ICE_MOUNTAINS; return Biome.ICE_MOUNTAINS;
} else if (base == BiomeBase.MUSHROOM_ISLAND) { } else if (base == BiomeBase.MUSHROOM_ISLAND) {
return Biome.MUSHROOM_ISLAND; return Biome.MUSHROOM_ISLAND;
} else if (base == BiomeBase.MUSHROOM_SHORE) { } else if (base == BiomeBase.MUSHROOM_SHORE) {
return Biome.MUSHROOM_SHORE; return Biome.MUSHROOM_SHORE;
} else if (base == BiomeBase.BEACH) { } else if (base == BiomeBase.BEACH) {
return Biome.BEACH; return Biome.BEACH;
} else if (base == BiomeBase.DESERT_HILLS) { } else if (base == BiomeBase.DESERT_HILLS) {
return Biome.DESERT_HILLS; return Biome.DESERT_HILLS;
} else if (base == BiomeBase.FOREST_HILLS) { } else if (base == BiomeBase.FOREST_HILLS) {
return Biome.FOREST_HILLS; return Biome.FOREST_HILLS;
} else if (base == BiomeBase.TAIGA_HILLS) { } else if (base == BiomeBase.TAIGA_HILLS) {
return Biome.TAIGA_HILLS; return Biome.TAIGA_HILLS;
} else if (base == BiomeBase.SMALL_MOUNTAINS) { } else if (base == BiomeBase.SMALL_MOUNTAINS) {
return Biome.SMALL_MOUNTAINS; return Biome.SMALL_MOUNTAINS;
} }
return null; return null;

Datei anzeigen

@ -36,56 +36,26 @@ public class CraftBlockState implements BlockState {
return new CraftBlockState(world.getWorld().getBlockAt(x, y, z)); return new CraftBlockState(world.getWorld().getBlockAt(x, y, z));
} }
/**
* Gets the world which contains this Block
*
* @return World containing this block
*/
public World getWorld() { public World getWorld() {
return world; return world;
} }
/**
* Gets the x-coordinate of this block
*
* @return x-coordinate
*/
public int getX() { public int getX() {
return x; return x;
} }
/**
* Gets the y-coordinate of this block
*
* @return y-coordinate
*/
public int getY() { public int getY() {
return y; return y;
} }
/**
* Gets the z-coordinate of this block
*
* @return z-coordinate
*/
public int getZ() { public int getZ() {
return z; return z;
} }
/**
* Gets the chunk which contains this block
*
* @return Containing Chunk
*/
public Chunk getChunk() { public Chunk getChunk() {
return chunk; return chunk;
} }
/**
* Sets the metadata for this block
*
* @param data New block specific metadata
*/
public void setData(final MaterialData data) { public void setData(final MaterialData data) {
Material mat = getType(); Material mat = getType();
@ -101,29 +71,14 @@ public class CraftBlockState implements BlockState {
} }
} }
/**
* Gets the metadata for this block
*
* @return block specific metadata
*/
public MaterialData getData() { public MaterialData getData() {
return data; return data;
} }
/**
* Sets the type of this block
*
* @param type Material to change this block to
*/
public void setType(final Material type) { public void setType(final Material type) {
setTypeId(type.getId()); setTypeId(type.getId());
} }
/**
* Sets the type-id of this block
*
* @param type Type-Id to change this block to
*/
public boolean setTypeId(final int type) { public boolean setTypeId(final int type) {
this.type = type; this.type = type;
@ -131,29 +86,14 @@ public class CraftBlockState implements BlockState {
return true; return true;
} }
/**
* Gets the type of this block
*
* @return block type
*/
public Material getType() { public Material getType() {
return Material.getMaterial(getTypeId()); return Material.getMaterial(getTypeId());
} }
/**
* Gets the type-id of this block
*
* @return block type-id
*/
public int getTypeId() { public int getTypeId() {
return type; return type;
} }
/**
* Gets the light level between 0-15
*
* @return light level
*/
public byte getLightLevel() { public byte getLightLevel() {
return light; return light;
} }

Datei anzeigen

@ -44,7 +44,7 @@ public class CraftJukebox extends CraftBlockState implements Jukebox {
public boolean eject() { public boolean eject() {
boolean result = isPlaying(); boolean result = isPlaying();
((BlockJukeBox)net.minecraft.server.Block.JUKEBOX).dropRecord(world.getHandle(), getX(), getY(), getZ()); ((BlockJukeBox) net.minecraft.server.Block.JUKEBOX).dropRecord(world.getHandle(), getX(), getY(), getZ());
return result; return result;
} }
} }

Datei anzeigen

@ -13,7 +13,7 @@ public class ServerCommandListener implements ICommandListener {
public ServerCommandListener(CommandSender commandSender) { public ServerCommandListener(CommandSender commandSender) {
this.commandSender = commandSender; this.commandSender = commandSender;
String[] parts = commandSender.getClass().getName().split("\\."); String[] parts = commandSender.getClass().getName().split("\\.");
this.prefix = parts[parts.length-1]; this.prefix = parts[parts.length - 1];
} }
public void sendMessage(String msg) { public void sendMessage(String msg) {

Datei anzeigen

@ -27,26 +27,26 @@ public class CraftEnchantment extends Enchantment {
@Override @Override
public EnchantmentTarget getItemTarget() { public EnchantmentTarget getItemTarget() {
switch (target.slot) { switch (target.slot) {
case ALL: case ALL:
return EnchantmentTarget.ALL; return EnchantmentTarget.ALL;
case ARMOR: case ARMOR:
return EnchantmentTarget.ARMOR; return EnchantmentTarget.ARMOR;
case ARMOR_FEET: case ARMOR_FEET:
return EnchantmentTarget.ARMOR_FEET; return EnchantmentTarget.ARMOR_FEET;
case ARMOR_HEAD: case ARMOR_HEAD:
return EnchantmentTarget.ARMOR_HEAD; return EnchantmentTarget.ARMOR_HEAD;
case ARMOR_LEGS: case ARMOR_LEGS:
return EnchantmentTarget.ARMOR_LEGS; return EnchantmentTarget.ARMOR_LEGS;
case ARMOR_TORSO: case ARMOR_TORSO:
return EnchantmentTarget.ARMOR_TORSO; return EnchantmentTarget.ARMOR_TORSO;
case DIGGER: case DIGGER:
return EnchantmentTarget.TOOL; return EnchantmentTarget.TOOL;
case WEAPON: case WEAPON:
return EnchantmentTarget.WEAPON; return EnchantmentTarget.WEAPON;
case BOW: case BOW:
return EnchantmentTarget.BOW; return EnchantmentTarget.BOW;
default: default:
return null; return null;
} }
} }
@ -58,60 +58,60 @@ public class CraftEnchantment extends Enchantment {
@Override @Override
public String getName() { public String getName() {
switch (target.id) { switch (target.id) {
case 0: case 0:
return "PROTECTION_ENVIRONMENTAL"; return "PROTECTION_ENVIRONMENTAL";
case 1: case 1:
return "PROTECTION_FIRE"; return "PROTECTION_FIRE";
case 2: case 2:
return "PROTECTION_FALL"; return "PROTECTION_FALL";
case 3: case 3:
return "PROTECTION_EXPLOSIONS"; return "PROTECTION_EXPLOSIONS";
case 4: case 4:
return "PROTECTION_PROJECTILE"; return "PROTECTION_PROJECTILE";
case 5: case 5:
return "OXYGEN"; return "OXYGEN";
case 6: case 6:
return "WATER_WORKER"; return "WATER_WORKER";
case 16: case 16:
return "DAMAGE_ALL"; return "DAMAGE_ALL";
case 17: case 17:
return "DAMAGE_UNDEAD"; return "DAMAGE_UNDEAD";
case 18: case 18:
return "DAMAGE_ARTHROPODS"; return "DAMAGE_ARTHROPODS";
case 19: case 19:
return "KNOCKBACK"; return "KNOCKBACK";
case 20: case 20:
return "FIRE_ASPECT"; return "FIRE_ASPECT";
case 21: case 21:
return "LOOT_BONUS_MOBS"; return "LOOT_BONUS_MOBS";
case 32: case 32:
return "DIG_SPEED"; return "DIG_SPEED";
case 33: case 33:
return "SILK_TOUCH"; return "SILK_TOUCH";
case 34: case 34:
return "DURABILITY"; return "DURABILITY";
case 35: case 35:
return "LOOT_BONUS_BLOCKS"; return "LOOT_BONUS_BLOCKS";
case 48: case 48:
return "ARROW_DAMAGE"; return "ARROW_DAMAGE";
case 49: case 49:
return "ARROW_KNOCKBACK"; return "ARROW_KNOCKBACK";
case 50: case 50:
return "ARROW_FIRE"; return "ARROW_FIRE";
case 51: case 51:
return "ARROW_INFINITE"; return "ARROW_INFINITE";
default: default:
return "UNKNOWN_ENCHANT_" + target.id; return "UNKNOWN_ENCHANT_" + target.id;
} }
} }
public static net.minecraft.server.Enchantment getRaw(Enchantment enchantment) { public static net.minecraft.server.Enchantment getRaw(Enchantment enchantment) {
if (enchantment instanceof EnchantmentWrapper) { if (enchantment instanceof EnchantmentWrapper) {
enchantment = ((EnchantmentWrapper)enchantment).getEnchantment(); enchantment = ((EnchantmentWrapper) enchantment).getEnchantment();
} }
if (enchantment instanceof CraftEnchantment) { if (enchantment instanceof CraftEnchantment) {
return ((CraftEnchantment)enchantment).target; return ((CraftEnchantment) enchantment).target;
} }
return null; return null;

Datei anzeigen

@ -30,7 +30,7 @@ public class CraftArrow extends AbstractProjectile implements Arrow {
} }
@Override @Override
public EntityArrow getHandle(){ public EntityArrow getHandle() {
return (EntityArrow) entity; return (EntityArrow) entity;
} }

Datei anzeigen

@ -177,7 +177,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
List<Entity> notchEntityList = entity.world.getEntities(entity, entity.boundingBox.grow(x, y, z)); List<Entity> notchEntityList = entity.world.getEntities(entity, entity.boundingBox.grow(x, y, z));
List<org.bukkit.entity.Entity> bukkitEntityList = new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size()); 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()); bukkitEntityList.add(e.getBukkitEntity());
} }
return bukkitEntityList; return bukkitEntityList;
@ -269,7 +269,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
CraftPlayer result = players.get(entity.name); CraftPlayer result = players.get(entity.name);
if (result == null) { if (result == null) {
result = new CraftPlayer((CraftServer)Bukkit.getServer(), entity); result = new CraftPlayer((CraftServer) Bukkit.getServer(), entity);
players.put(entity.name, result); players.put(entity.name, result);
} else { } else {
result.setHandle(entity); result.setHandle(entity);

Datei anzeigen

@ -1,4 +1,3 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityExperienceOrb; import net.minecraft.server.EntityExperienceOrb;

Datei anzeigen

@ -1,4 +1,3 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import java.util.Set; import java.util.Set;

Datei anzeigen

@ -173,9 +173,9 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
DamageSource reason = DamageSource.GENERIC; DamageSource reason = DamageSource.GENERIC;
if (source instanceof HumanEntity) { if (source instanceof HumanEntity) {
reason = DamageSource.playerAttack(((CraftHumanEntity)source).getHandle()); reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
} else if (source instanceof LivingEntity) { } else if (source instanceof LivingEntity) {
reason = DamageSource.mobAttack(((CraftLivingEntity)source).getHandle()); reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
} }
entity.damageEntity(reason, amount); entity.damageEntity(reason, amount);
@ -226,6 +226,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} }
public Player getKiller() { public Player getKiller() {
return getHandle().killer == null ? null : (Player)getHandle().killer.getBukkitEntity(); return getHandle().killer == null ? null : (Player) getHandle().killer.getBukkitEntity();
} }
} }

Datei anzeigen

@ -1,6 +1,5 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityMagmaCube; import net.minecraft.server.EntityMagmaCube;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.MagmaCube; import org.bukkit.entity.MagmaCube;

Datei anzeigen

@ -102,7 +102,7 @@ public class CraftPainting extends CraftEntity implements Painting {
} }
private void update() { private void update() {
WorldServer world = ((CraftWorld)getWorld()).getHandle(); WorldServer world = ((CraftWorld) getWorld()).getHandle();
EntityPainting painting = new EntityPainting(world); EntityPainting painting = new EntityPainting(world);
painting.x = getHandle().x; painting.x = getHandle().x;
painting.y = getHandle().y; painting.y = getHandle().y;

Datei anzeigen

@ -76,7 +76,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
public boolean isOnline() { public boolean isOnline() {
for (Object obj: server.getHandle().players) { for (Object obj : server.getHandle().players) {
EntityPlayer player = (EntityPlayer) obj; EntityPlayer player = (EntityPlayer) obj;
if (player.name.equalsIgnoreCase(getName())) { if (player.name.equalsIgnoreCase(getName())) {
return true; return true;
@ -173,7 +173,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (!(obj instanceof OfflinePlayer)) { if (!(obj instanceof OfflinePlayer)) {
return false; return false;
} }
OfflinePlayer other = (OfflinePlayer)obj; OfflinePlayer other = (OfflinePlayer) obj;
if ((this.getName() == null) || (other.getName() == null)) { if ((this.getName() == null) || (other.getName() == null)) {
return false; return false;
} }
@ -485,7 +485,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
public int getExperience() { public int getExperience() {
return (int)(getExp() * 100); return (int) (getExp() * 100);
} }
public void setExperience(int exp) { public void setExperience(int exp) {
@ -493,7 +493,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
public int getLevel() { public int getLevel() {
return (int)getHandle().expLevel; return (int) getHandle().expLevel;
} }
public void setLevel(int level) { public void setLevel(int level) {
@ -655,7 +655,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
for (String channel : listening) { for (String channel : listening) {
try { try {
stream.write(channel.getBytes("UTF8")); stream.write(channel.getBytes("UTF8"));
stream.write((byte)0); stream.write((byte) 0);
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(CraftPlayer.class.getName()).log(Level.SEVERE, "Could not send Plugin Channel REGISTER to " + getName(), ex); Logger.getLogger(CraftPlayer.class.getName()).log(Level.SEVERE, "Could not send Plugin Channel REGISTER to " + getName(), ex);
} }

Datei anzeigen

@ -13,7 +13,7 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj
public LivingEntity getShooter() { public LivingEntity getShooter() {
if (getHandle().shooter instanceof EntityLiving) { if (getHandle().shooter instanceof EntityLiving) {
return (LivingEntity)getHandle().shooter.getBukkitEntity(); return (LivingEntity) getHandle().shooter.getBukkitEntity();
} }
return null; return null;
@ -21,7 +21,7 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj
public void setShooter(LivingEntity shooter) { public void setShooter(LivingEntity shooter) {
if (shooter instanceof CraftLivingEntity) { if (shooter instanceof CraftLivingEntity) {
getHandle().shooter = (EntityLiving)((CraftLivingEntity)shooter).entity; getHandle().shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity;
} }
} }

Datei anzeigen

@ -1,4 +1,3 @@
package org.bukkit.craftbukkit.entity; package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityWeather; import net.minecraft.server.EntityWeather;

Datei anzeigen

@ -74,6 +74,7 @@ public class CraftWolf extends CraftAnimals implements Wolf {
/** /**
* The owner's name is how MC knows and persists the Wolf's owner. Since we choose to instead use an AnimalTamer, this functionality * The owner's name is how MC knows and persists the Wolf's owner. Since we choose to instead use an AnimalTamer, this functionality
* is used only as a backup. If the animal tamer is a player, we will store their name, otherwise we store an empty string. * is used only as a backup. If the animal tamer is a player, we will store their name, otherwise we store an empty string.
*
* @return the owner's name, if they are a player; otherwise, the empty string or null. * @return the owner's name, if they are a player; otherwise, the empty string or null.
*/ */
String getOwnerName() { String getOwnerName() {
@ -87,6 +88,7 @@ public class CraftWolf extends CraftAnimals implements Wolf {
/** /**
* Only used internally at the moment, and there to set the path to null (that is stop the thing from running around) * Only used internally at the moment, and there to set the path to null (that is stop the thing from running around)
* TODO use this later to extend the API, when we have Path classes in Bukkit * TODO use this later to extend the API, when we have Path classes in Bukkit
*
* @param pathentity currently the MC defined PathEntity class. Should be replaced with an API interface at some point. * @param pathentity currently the MC defined PathEntity class. Should be replaced with an API interface at some point.
*/ */
private void setPath(PathEntity pathentity) { private void setPath(PathEntity pathentity) {
@ -99,12 +101,10 @@ public class CraftWolf extends CraftAnimals implements Wolf {
private void playTamingAnimation(boolean successful){ private void playTamingAnimation(boolean successful){
getHandle().a(successful); getHandle().a(successful);
} }
*/ */
@Override @Override
public EntityWolf getHandle() { public EntityWolf getHandle() {
// It's somewhat easier to override this here, as many internal methods rely on EntityWolf specific methods.
// Doing this has no impact on anything outside this class.
return (EntityWolf) entity; return (EntityWolf) entity;
} }

Datei anzeigen

@ -147,6 +147,7 @@ public class CraftEventFactory {
} }
return callPlayerInteractEvent(who, action, 0, 255, 0, 0, itemstack); return callPlayerInteractEvent(who, action, 0, 255, 0, 0, itemstack);
} }
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) { public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) {
Player player = (who == null) ? null : (Player) who.getBukkitEntity(); Player player = (who == null) ? null : (Player) who.getBukkitEntity();
CraftItemStack itemInHand = new CraftItemStack(itemstack); CraftItemStack itemInHand = new CraftItemStack(itemstack);
@ -160,12 +161,12 @@ public class CraftEventFactory {
if (clickedY == 255) { if (clickedY == 255) {
blockClicked = null; blockClicked = null;
switch (action) { switch (action) {
case LEFT_CLICK_BLOCK: case LEFT_CLICK_BLOCK:
action = Action.LEFT_CLICK_AIR; action = Action.LEFT_CLICK_AIR;
break; break;
case RIGHT_CLICK_BLOCK: case RIGHT_CLICK_BLOCK:
action = Action.RIGHT_CLICK_AIR; action = Action.RIGHT_CLICK_AIR;
break; break;
} }
} }
@ -317,7 +318,7 @@ public class CraftEventFactory {
victim.expToDrop = event.getDroppedExp(); victim.expToDrop = event.getDroppedExp();
for (org.bukkit.inventory.ItemStack stack: event.getDrops()) { for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
world.dropItemNaturally(entity.getLocation(), stack); world.dropItemNaturally(entity.getLocation(), stack);
} }
@ -325,7 +326,7 @@ public class CraftEventFactory {
} }
public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) { public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) {
CraftPlayer entity = (CraftPlayer)victim.getBukkitEntity(); CraftPlayer entity = (CraftPlayer) victim.getBukkitEntity();
PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage); PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage);
org.bukkit.World world = entity.getWorld(); org.bukkit.World world = entity.getWorld();
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
@ -337,7 +338,7 @@ public class CraftEventFactory {
victim.expToDrop = event.getDroppedExp(); victim.expToDrop = event.getDroppedExp();
victim.newExp = event.getNewExp(); victim.newExp = event.getNewExp();
for (org.bukkit.inventory.ItemStack stack: event.getDrops()) { for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
world.dropItemNaturally(entity.getLocation(), stack); world.dropItemNaturally(entity.getLocation(), stack);
} }

Datei anzeigen

@ -1,4 +1,3 @@
package org.bukkit.craftbukkit.generator; package org.bukkit.craftbukkit.generator;
import net.minecraft.server.IChunkProvider; import net.minecraft.server.IChunkProvider;

Datei anzeigen

@ -63,7 +63,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
} }
public boolean contains(int materialId) { public boolean contains(int materialId) {
for (ItemStack item: getContents()) { for (ItemStack item : getContents()) {
if (item != null && item.getTypeId() == materialId) { if (item != null && item.getTypeId() == materialId) {
return true; return true;
} }
@ -79,7 +79,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
if (item == null) { if (item == null) {
return false; return false;
} }
for (ItemStack i: getContents()) { for (ItemStack i : getContents()) {
if (item.equals(i)) { if (item.equals(i)) {
return true; return true;
} }
@ -89,7 +89,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
public boolean contains(int materialId, int amount) { public boolean contains(int materialId, int amount) {
int amt = 0; int amt = 0;
for (ItemStack item: getContents()) { for (ItemStack item : getContents()) {
if (item != null && item.getTypeId() == materialId) { if (item != null && item.getTypeId() == materialId) {
amt += item.getAmount(); amt += item.getAmount();
} }
@ -106,7 +106,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
return false; return false;
} }
int amt = 0; int amt = 0;
for (ItemStack i: getContents()) { for (ItemStack i : getContents()) {
if (item.equals(i)) { if (item.equals(i)) {
amt += item.getAmount(); amt += item.getAmount();
} }

Datei anzeigen

@ -175,10 +175,10 @@ public class CraftItemStack extends ItemStack {
} }
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
short id = ((NBTTagCompound)list.get(i)).getShort("id"); short id = ((NBTTagCompound) list.get(i)).getShort("id");
short level = ((NBTTagCompound)list.get(i)).getShort("lvl"); short level = ((NBTTagCompound) list.get(i)).getShort("lvl");
result.put(Enchantment.getById(id), (int)level); result.put(Enchantment.getById(id), (int) level);
} }
return result; return result;
@ -197,8 +197,8 @@ public class CraftItemStack extends ItemStack {
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) { for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
NBTTagCompound subtag = new NBTTagCompound(); NBTTagCompound subtag = new NBTTagCompound();
subtag.setShort("id", (short)entry.getKey().getId()); subtag.setShort("id", (short) entry.getKey().getId());
subtag.setShort("lvl", (short)(int)entry.getValue()); subtag.setShort("lvl", (short) (int) entry.getValue());
list.add(subtag); list.add(subtag);
} }

Datei anzeigen

@ -33,7 +33,8 @@ public class CraftMapCanvas implements MapCanvas {
} }
public void setPixel(int x, int y, byte color) { public void setPixel(int x, int y, byte color) {
if (x < 0 || y < 0 || x >= 128 || y >= 128) return; if (x < 0 || y < 0 || x >= 128 || y >= 128)
return;
if (buffer[y * 128 + x] != color) { if (buffer[y * 128 + x] != color) {
buffer[y * 128 + x] = color; buffer[y * 128 + x] = color;
mapView.worldMap.flagDirty(x, y, y); mapView.worldMap.flagDirty(x, y, y);
@ -41,12 +42,14 @@ public class CraftMapCanvas implements MapCanvas {
} }
public byte getPixel(int x, int y) { public byte getPixel(int x, int y) {
if (x < 0 || y < 0 || x >= 128 || y >= 128) return 0; if (x < 0 || y < 0 || x >= 128 || y >= 128)
return 0;
return buffer[y * 128 + x]; return buffer[y * 128 + x];
} }
public byte getBasePixel(int x, int y) { public byte getBasePixel(int x, int y) {
if (x < 0 || y < 0 || x >= 128 || y >= 128) return 0; if (x < 0 || y < 0 || x >= 128 || y >= 128)
return 0;
return base[y * 128 + x]; return base[y * 128 + x];
} }

Datei anzeigen

@ -36,7 +36,7 @@ public class CraftMapRenderer extends MapRenderer {
} }
for (int i = 0; i < worldMap.decorations.size(); ++i) { for (int i = 0; i < worldMap.decorations.size(); ++i) {
WorldMapDecoration decoration = (WorldMapDecoration) worldMap.decorations.get(i); WorldMapDecoration decoration = (WorldMapDecoration) worldMap.decorations.get(i);
cursors.addCursor(decoration.locX, decoration.locY, (byte)(decoration.rotation & 15), (byte)(decoration.type)); cursors.addCursor(decoration.locX, decoration.locY, (byte) (decoration.rotation & 15), (byte) (decoration.type));
} }
} }

Datei anzeigen

@ -1,7 +1,8 @@
package org.bukkit.craftbukkit.util; package org.bukkit.craftbukkit.util;
public class EntryBase { public class EntryBase {
protected long key; protected long key;
public EntryBase(long key) { public EntryBase(long key) {
this.key = key; this.key = key;
} }

Datei anzeigen

@ -84,7 +84,7 @@ public class LongBaseHashtable extends LongHash {
if (inner[i].key == key) { if (inner[i].key == key) {
for (i++; i < inner.length; i++) { for (i++; i < inner.length; i++) {
if (inner[i] == null) break; if (inner[i] == null) break;
inner[i-1] = inner[i]; inner[i - 1] = inner[i];
} }
inner[i-1] = null; inner[i-1] = null;
@ -97,13 +97,13 @@ public class LongBaseHashtable extends LongHash {
public synchronized ArrayList<EntryBase> entries() { public synchronized ArrayList<EntryBase> entries() {
ArrayList<EntryBase> ret = new ArrayList<EntryBase>(); ArrayList<EntryBase> ret = new ArrayList<EntryBase>();
for (EntryBase[][] outer: this.values) { for (EntryBase[][] outer : this.values) {
if (outer == null) continue; if (outer == null) continue;
for (EntryBase[] inner: outer) { for (EntryBase[] inner : outer) {
if (inner == null) continue; if (inner == null) continue;
for (EntryBase entry: inner) { for (EntryBase entry : inner) {
if (entry == null) break; if (entry == null) break;
ret.add(entry); ret.add(entry);

Datei anzeigen

@ -71,7 +71,7 @@ public class LongHashset extends LongHash {
long[] inner = outer[(int) ((key >> 32) & 255)]; long[] inner = outer[(int) ((key >> 32) & 255)];
if (inner == null) return false; if (inner == null) return false;
for (long entry: inner) { for (long entry : inner) {
if (entry == key) return true; if (entry == key) return true;
} }
return false; return false;
@ -134,7 +134,7 @@ public class LongHashset extends LongHash {
rl.lock(); rl.lock();
try { try {
long[] ret = new long[this.count]; long[] ret = new long[this.count];
for (long[][] outer: this.values) { for (long[][] outer : this.values) {
if (outer == null) continue; if (outer == null) continue;
for (int oIdx = outer.length - 1; oIdx >= 0; oIdx--) { for (int oIdx = outer.length - 1; oIdx >= 0; oIdx--) {
@ -159,13 +159,13 @@ public class LongHashset extends LongHash {
rl.lock(); rl.lock();
try { try {
long[] ret = new long[this.count]; long[] ret = new long[this.count];
for (long[][] outer: this.values) { for (long[][] outer : this.values) {
if (outer == null) continue; if (outer == null) continue;
for (long[] inner: outer) { for (long[] inner : outer) {
if (inner == null) continue; if (inner == null) continue;
for (long entry: inner) { for (long entry : inner) {
ret[index++] = entry; ret[index++] = entry;
} }
} }

Datei anzeigen

@ -28,7 +28,7 @@ public class LongHashtable<V> extends LongBaseHashtable {
ArrayList<EntryBase> entries = entries(); ArrayList<EntryBase> entries = entries();
for(EntryBase entry : entries) { for (EntryBase entry : entries) {
ret.add(((Entry) entry).value); ret.add(((Entry) entry).value);
} }
return ret; return ret;
@ -36,6 +36,7 @@ public class LongHashtable<V> extends LongBaseHashtable {
private class Entry extends EntryBase { private class Entry extends EntryBase {
V value; V value;
Entry(long k, V v) { Entry(long k, V v) {
super(k); super(k);
this.value = v; this.value = v;

Datei anzeigen

@ -1,4 +1,3 @@
package org.bukkit.craftbukkit.util; package org.bukkit.craftbukkit.util;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;