Archiviert
13
0

Generic cleanup/reformat.

Dieser Commit ist enthalten in:
Erik Broes 2011-02-02 00:32:18 +01:00
Ursprung 001a45804e
Commit 04be2b9b31
32 geänderte Dateien mit 83 neuen und 99 gelöschten Zeilen

Datei anzeigen

@ -69,14 +69,14 @@ public class BlockDispenser extends BlockContainer {
CraftBlock block = (CraftBlock) craftWorld.getBlockAt(i, j, k);
LivingEntity who = (entityhuman == null)?null:(LivingEntity)entityhuman.getBukkitEntity();
BlockInteractEvent bie = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(bie);
BlockInteractEvent event = new BlockInteractEvent(eventType, block, who);
server.getPluginManager().callEvent(event);
if (bie.isCancelled()) {
if (event.isCancelled()) {
return true;
}
// CraftBukkit end
TileEntityDispenser tileentitydispenser = (TileEntityDispenser) world.getTileEntity(i, j, k);
entityhuman.a(tileentitydispenser);
@ -196,4 +196,4 @@ public class BlockDispenser extends BlockContainer {
world.c(i, j, k, 4);
}
}
}
}

Datei anzeigen

@ -113,7 +113,7 @@ public class BlockFire extends Block {
}
}
}
// Craftbukkit start - won't be needed next port hopefully
if(l == 15) {
this.a(world, i + 1, j, k, 1, random);
@ -131,13 +131,13 @@ public class BlockFire extends Block {
if (random.nextInt(l) < i1) {
boolean flag = world.getTypeId(i, j, k) == Block.TNT.id;
// CraftBukkit start: BlockBurnEvent
// CraftBukkit start
Server server = ((WorldServer)world).getServer();
CraftWorld cworld = ((WorldServer)world).getWorld();
org.bukkit.block.Block theBlock = (cworld.getBlockAt(i, j, k));
BlockBurnEvent burnEvent = new BlockBurnEvent(theBlock);
server.getPluginManager().callEvent(burnEvent);
if(!burnEvent.isCancelled()) {
BlockBurnEvent event = new BlockBurnEvent(theBlock);
server.getPluginManager().callEvent(event);
if(!event.isCancelled()) {
if (random.nextInt(2) == 0) {
world.e(i, j, k, this.id);
} else {
@ -148,7 +148,7 @@ public class BlockFire extends Block {
Block.TNT.a(world, i, j, k, 0);
}
}
// CraftBukkit end: BlockBurnEvent
// CraftBukkit end
}
}

Datei anzeigen

@ -79,7 +79,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void f(Entity entity) {
// Craftbukkit start
List<org.bukkit.inventory.ItemStack> loot = new ArrayList<org.bukkit.inventory.ItemStack>();
for (int i = 0; i < inventory.a.length; ++i) {
if (inventory.a[i] != null) {
loot.add(new CraftItemStack(inventory.a[i]));

Datei anzeigen

@ -65,7 +65,7 @@ public class ItemBlock extends Item {
return false;
} else {
// CraftBukkit start
/* We store the old data so we can undo it. Snow(78) and half-steps(44) are special in that they replace the block itself,
/* We store the old data so we can undo it. Snow(78) and half-steps(44) are special in that they replace the block itself,
* rather than the block touching the face we clicked on.
*/
org.bukkit.block.Block replacedBlock = (blockClicked.getTypeId() == Block.SNOW.id || blockClicked.getTypeId() == Block.STEP.id) ? blockClicked:blockClicked.getFace(faceClicked);

Datei anzeigen

@ -29,7 +29,7 @@ public class ItemSign extends Item {
CraftWorld craftWorld = ((WorldServer) world).getWorld();
CraftServer craftServer = ((WorldServer) world).getServer();
org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k);
//CraftBukkit end
// CraftBukkit end
if (l == 1) {
++j;

Datei anzeigen

@ -167,7 +167,7 @@ public class MinecraftServer implements ICommandListener, Runnable {
if(server != null) {
server.disablePlugins();
}
if (this.f != null) {
this.f.d();
}

Datei anzeigen

@ -427,7 +427,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
Player who = (this.e == null) ? null : (Player) this.e.getBukkitEntity();
org.bukkit.inventory.ItemStack itemInHand = new CraftItemStack(itemstack);
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
PlayerItemEvent event = new PlayerItemEvent(eventType, who, itemInHand, blockClicked, blockFace);
// CraftBukkit We still call this event even in spawn protection.
// Don't call this event if using Buckets / signs

Datei anzeigen

@ -2,9 +2,9 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
// CraftBukkit start
import org.bukkit.BlockChangeDelegate;
//CraftBukkit end
// CraftBukkit end
public class WorldGenBigTree extends WorldGenerator {
@ -346,7 +346,7 @@ public class WorldGenBigTree extends WorldGenerator {
// then allows plugins to catch manually-invoked generation events
return generate((BlockChangeDelegate)world, random, i, j, k);
}
public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) {
// CraftBukkit end
this.c = world;

Datei anzeigen

@ -2,9 +2,9 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
// CraftBukkit start
import org.bukkit.BlockChangeDelegate;
//CraftBukkit end
// CraftBukkit end
public class WorldGenForest extends WorldGenerator {
@ -18,7 +18,7 @@ public class WorldGenForest extends WorldGenerator {
// then allows plugins to catch manually-invoked generation events
return generate((BlockChangeDelegate)world, random, i, j, k);
}
public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) {
// CraftBukkit end
int l = random.nextInt(3) + 5;

Datei anzeigen

@ -2,9 +2,9 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
// CraftBukkit start
import org.bukkit.BlockChangeDelegate;
//CraftBukkit end
// CraftBukkit end
public class WorldGenTaiga1 extends WorldGenerator {
@ -18,7 +18,7 @@ public class WorldGenTaiga1 extends WorldGenerator {
// then allows plugins to catch manually-invoked generation events
return generate((BlockChangeDelegate)world, random, i, j, k);
}
public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) {
// CraftBukkit end
int l = random.nextInt(5) + 7;

Datei anzeigen

@ -2,9 +2,9 @@ package net.minecraft.server;
import java.util.Random;
//CraftBukkit start
// CraftBukkit start
import org.bukkit.BlockChangeDelegate;
//CraftBukkit end
// CraftBukkit end
public class WorldGenTaiga2 extends WorldGenerator {
@ -18,7 +18,7 @@ public class WorldGenTaiga2 extends WorldGenerator {
// then allows plugins to catch manually-invoked generation events
return generate((BlockChangeDelegate)world, random, i, j, k);
}
public boolean generate(BlockChangeDelegate world, Random random, int i, int j, int k) {
// CraftBukkit end
int l = random.nextInt(4) + 6;

Datei anzeigen

@ -24,7 +24,7 @@ import org.bukkit.World;
public class CraftWorld implements World {
private final WorldServer world;
private static final Random rand = new Random();
public CraftWorld(WorldServer world) {
@ -42,7 +42,7 @@ public class CraftWorld implements World {
public int getHighestBlockYAt(int x, int z) {
return world.d(x, z);
}
public Location getSpawnLocation() {
return new Location(this, world.spawnX, world.e(world.spawnX, world.spawnZ), world.spawnZ);
}
@ -89,7 +89,7 @@ public class CraftWorld implements World {
// However, this entity is not at the moment backed by a server entity class so it may be left.
return new CraftItemDrop(world.getServer(), entity);
}
public ItemDrop dropItemNaturally(Location loc, ItemStack item) {
double xs = world.l.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
double ys = world.l.nextFloat() * 0.7F + (1.0F - 0.7F) * 0.5D;
@ -108,7 +108,7 @@ public class CraftWorld implements World {
arrow.a(velocity.getX(), velocity.getY(), velocity.getZ(), speed, spread);
return (Arrow) arrow.getBukkitEntity();
}
public Minecart spawnMinecart(Location loc) {
EntityMinecart minecart = new EntityMinecart(
world,
@ -120,7 +120,7 @@ public class CraftWorld implements World {
world.a(minecart);
return (Minecart) minecart.getBukkitEntity();
}
public StorageMinecart spawnStorageMinecart(Location loc) {
EntityMinecart minecart = new EntityMinecart(
world,
@ -132,7 +132,7 @@ public class CraftWorld implements World {
world.a(minecart);
return (StorageMinecart) minecart.getBukkitEntity();
}
public PoweredMinecart spawnPoweredMinecart(Location loc) {
EntityMinecart minecart = new EntityMinecart(
world,
@ -144,13 +144,13 @@ public class CraftWorld implements World {
world.a(minecart);
return (PoweredMinecart) minecart.getBukkitEntity();
}
public Boat spawnBoat(Location loc) {
EntityBoat boat = new EntityBoat(world, loc.getX(), loc.getY(), loc.getZ());
world.a(boat);
return (Boat) boat.getBukkitEntity();
}
public boolean generateTree(Location loc, TreeType type) {
return generateTree(loc, type, world);
}
@ -158,29 +158,19 @@ public class CraftWorld implements World {
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
switch (type) {
case BIG_TREE:
return (new WorldGenBigTree())
.generate(delegate, rand,
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return new WorldGenBigTree().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case BIRCH:
return (new WorldGenForest())
.generate(delegate, rand,
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return new WorldGenForest().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
case REDWOOD:
return (new WorldGenTaiga2())
.generate(delegate, rand,
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return new WorldGenTaiga2().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
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:
default:
return (new WorldGenTrees())
.generate(delegate, rand,
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return new WorldGenTrees().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
}
public TileEntity getTileEntityAt(final int x, final int y, final int z) {
return world.getTileEntity(x, y, z);
}
@ -256,12 +246,10 @@ public class CraftWorld implements World {
public List<Entity> getEntities() {
List<Entity> list = new ArrayList<Entity>();
for (Object o : world.b) {
for (Object o: world.b) {
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
@ -270,27 +258,25 @@ public class CraftWorld implements World {
}
}
}
return list;
}
public List<LivingEntity> getLivingEntities() {
List<LivingEntity> list = new ArrayList<LivingEntity>();
for (Object o : world.b) {
for (Object o: world.b) {
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);
}
}
}
return list;
}
}

Datei anzeigen

@ -134,10 +134,10 @@ public class CraftBlock implements Block {
public int getTypeId() {
return chunk.getHandle().a(this.x & 0xF, this.y & 0x7F, this.z & 0xF);
}
/**
* Gets the light level between 0-15
*
*
* @return light level
*/
public byte getLightLevel() {
@ -170,8 +170,7 @@ public class CraftBlock implements Block {
* @return Block at the given face
*/
public Block getFace(final BlockFace face, final int distance) {
return getRelative(face.getModX() * distance, face.getModY() * distance,
face.getModZ() * distance);
return getRelative(face.getModX() * distance, face.getModY() * distance, face.getModZ() * distance);
}
/**
@ -232,11 +231,11 @@ public class CraftBlock implements Block {
public String toString() {
return "CraftBlock{" + "chunk=" + chunk + "x=" + x + "y=" + y + "z=" + z + '}';
}
/**
* Notch uses a 0-5 to mean DOWN, UP, EAST, WEST, NORTH, SOUTH
* in that order all over. This method is convenience to convert for us.
*
*
* @return BlockFace the BlockFace represented by this number
*/
public static BlockFace notchToBlockFace(int notch) {

Datei anzeigen

@ -125,7 +125,7 @@ public class CraftBlockState implements BlockState {
public void setTypeId(final int type) {
this.type = type;
world.getHandle().e(x, y, z, type);
createData((byte)0);
}

Datei anzeigen

@ -12,7 +12,7 @@ import org.bukkit.inventory.Inventory;
/**
* Represents a dispenser.
*
*
* @author sk89q
*/
public class CraftDispenser extends CraftBlockState implements Dispenser {

Datei anzeigen

@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftWorld;
/**
* Represents a note block.
*
*
* @author sk89q
*/
public class CraftNoteBlock extends CraftBlockState implements NoteBlock {

Datei anzeigen

@ -6,7 +6,7 @@ import org.bukkit.craftbukkit.CraftServer;
/**
* Represents an arrow.
*
*
* @author sk89q
*/
public class CraftArrow extends CraftEntity implements Arrow {

Datei anzeigen

@ -6,7 +6,7 @@ import org.bukkit.entity.Boat;
/**
* A minecart.
*
*
* @author sk89q
*/
public class CraftBoat extends CraftVehicle implements Boat {

Datei anzeigen

@ -6,7 +6,7 @@ import org.bukkit.entity.Egg;
/**
* An egg.
*
*
* @author sk89q
*/
public class CraftEgg extends CraftEntity implements Egg {

Datei anzeigen

@ -37,7 +37,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
// Monsters
else if (entity instanceof EntityMonster) {
if (entity instanceof EntityZombie) {
if (entity instanceof EntityZombie) {
if (entity instanceof EntityPigZombie) { return new CraftPigZombie( server, (EntityPigZombie) entity); }
else { return new CraftZombie( server, (EntityZombie) entity); }
}

Datei anzeigen

@ -7,7 +7,7 @@ import org.bukkit.entity.Fireball;
/**
* A Fireball.
*
*
* @author Cogito
*/
public class CraftFireball extends CraftEntity implements Fireball {

Datei anzeigen

@ -7,7 +7,7 @@ import org.bukkit.entity.Fish;
/**
* A Fish.
*
*
* @author Cogito
*/
public class CraftFish extends CraftEntity implements Fish {

Datei anzeigen

@ -4,7 +4,6 @@ package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityHuman;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.CraftServer;

Datei anzeigen

@ -8,12 +8,12 @@ import org.bukkit.craftbukkit.CraftServer;
/**
* Represents an item drop.
*
*
* @author sk89q
*/
public class CraftItemDrop extends CraftEntity implements ItemDrop {
private EntityItem item;
public CraftItemDrop(CraftServer server, EntityItem entity) {
super(server, entity);
this.item = entity;

Datei anzeigen

@ -79,7 +79,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
if (entity.vehicle == null) {
return false;
}
entity.setPassengerOf(null);
return true;
}
@ -88,12 +88,12 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
if (entity.vehicle == null) {
return null;
}
org.bukkit.entity.Entity vehicle = (entity.vehicle.getBukkitEntity());
if (vehicle instanceof Vehicle) {
return (Vehicle) vehicle;
}
return null;
}

Datei anzeigen

@ -7,7 +7,7 @@ import org.bukkit.entity.PoweredMinecart;
/**
* A powered minecart.
*
*
* @author sk89q
*/
public class CraftPoweredMinecart extends CraftMinecart

Datei anzeigen

@ -6,7 +6,7 @@ import org.bukkit.entity.Snowball;
/**
* A snowball.
*
*
* @author sk89q
*/
public class CraftSnowball extends CraftEntity implements Snowball {

Datei anzeigen

@ -9,12 +9,12 @@ import org.bukkit.entity.StorageMinecart;
/**
* A storage minecart.
*
*
* @author sk89q
*/
public class CraftStorageMinecart extends CraftMinecart implements StorageMinecart {
private CraftInventory inventory;
public CraftStorageMinecart(CraftServer server, EntityMinecart entity) {
super(server, entity);
inventory = new CraftInventory( entity );

Datei anzeigen

@ -6,7 +6,7 @@ import org.bukkit.entity.Vehicle;
/**
* A vehicle.
*
*
* @author sk89q
*/
public abstract class CraftVehicle extends CraftEntity implements Vehicle {
@ -17,7 +17,7 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
public Entity getPassenger() {
return isEmpty() ? null : (getHandle().passenger.getBukkitEntity());
}
public boolean setPassenger(Entity passenger) {
if(passenger instanceof CraftEntity){
((CraftEntity)passenger).getHandle().setPassengerOf(getHandle());
@ -30,12 +30,12 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle {
public boolean isEmpty() {
return getHandle().passenger == null;
}
public boolean eject() {
if (getHandle().passenger == null) {
return false;
}
getHandle().passenger.setPassengerOf(null);
return true;
}

Datei anzeigen

@ -159,7 +159,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
public int firstPartial(ItemStack item) {
return firstPartial(item.getTypeId());
}
public HashMap<Integer, ItemStack> addItem(ItemStack... items) {
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
@ -202,13 +202,13 @@ public class CraftInventory implements org.bukkit.inventory.Inventory {
int amount = item.getAmount();
int partialAmount = partialItem.getAmount();
int maxAmount = partialItem.getMaxStackSize();
// Check if it fully fits
if (amount + partialAmount <= maxAmount) {
partialItem.setAmount( amount + partialAmount );
break;
}
// It fits partially
partialItem.setAmount( maxAmount );
item.setAmount( amount + partialAmount - maxAmount );

Datei anzeigen

@ -9,7 +9,7 @@ public class CraftInventoryPlayer extends CraftInventory implements PlayerInvent
public CraftInventoryPlayer(net.minecraft.server.InventoryPlayer inventory) {
super(inventory);
}
public InventoryPlayer getInventory() {
return (InventoryPlayer) inventory;
}

Datei anzeigen

@ -106,7 +106,7 @@ public class CraftItemStack extends ItemStack {
if (item != null) {
super.setDurability(durability);
item.damage = durability;
}
}
}
@Override