Generic cleanup

This commit is contained in:
Erik Broes 2011-06-12 00:02:58 +02:00
parent 938db4de2d
commit 96b1b8a10c
37 changed files with 667 additions and 635 deletions

View File

@ -114,10 +114,8 @@ public class BlockDispenser extends BlockContainer {
if (itemstack == null) { if (itemstack == null) {
world.e(1001, i, j, k, 0); world.e(1001, i, j, k, 0);
} else { } else {
double d3;
// CraftBukkit start // CraftBukkit start
d3 = random.nextDouble() * 0.1D + 0.2D; double d3 = random.nextDouble() * 0.1D + 0.2D;
double motX = (double) b0 * d3; double motX = (double) b0 * d3;
double motY = 0.20000000298023224D; double motY = 0.20000000298023224D;
double motZ = (double) b1 * d3; double motZ = (double) b1 * d3;
@ -167,9 +165,9 @@ public class BlockDispenser extends BlockContainer {
world.e(1002, i, j, k, 0); world.e(1002, i, j, k, 0);
} else { } else {
EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack); EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack);
// CraftBukkit start // CraftBukkit start
d3 = random.nextDouble() * 0.1D + 0.2D; // double d3 = random.nextDouble() * 0.1D + 0.2D; // Moved up
entityitem.motX = motX; entityitem.motX = motX;
entityitem.motY = motY; entityitem.motY = motY;
entityitem.motZ = motZ; entityitem.motZ = motZ;

View File

@ -177,8 +177,8 @@ public class BlockDoor extends Block {
int power = block.getBlockPower(); int power = block.getBlockPower();
int powerTop = blockTop.getBlockPower(); int powerTop = blockTop.getBlockPower();
if (powerTop > power) power = powerTop; if (powerTop > power) power = powerTop;
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, (world.getData(i, j, k) & 4) > 0 ? 15 : 0, power); BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, (world.getData(i, j, k) & 4) > 0 ? 15 : 0, power);
server.getPluginManager().callEvent(eventRedstone); server.getPluginManager().callEvent(eventRedstone);
flag1 = eventRedstone.getNewCurrent() > 0; flag1 = eventRedstone.getNewCurrent() > 0;

View File

@ -128,6 +128,7 @@ public class BlockFlowing extends BlockFluids {
// CraftBukkit start - all four cardinal directions. Do not change the order! // CraftBukkit start - all four cardinal directions. Do not change the order!
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);

View File

@ -2,10 +2,12 @@ package net.minecraft.server;
import java.util.Random; import java.util.Random;
// CraftBukkit start
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.event.entity.EntityPortalEnterEvent; import org.bukkit.event.entity.EntityPortalEnterEvent;
// CraftBukkit end
public class BlockPortal extends BlockBreakable { public class BlockPortal extends BlockBreakable {
@ -144,6 +146,7 @@ public class BlockPortal extends BlockBreakable {
EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(craftWorld, i, j, k)); EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(craftWorld, i, j, k));
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
// CraftBukkit end // CraftBukkit end
entity.O(); entity.O();
} }
} }

View File

@ -108,14 +108,15 @@ public class BlockPressurePlate extends Block {
for (Object object: list) { for (Object object: list) {
if (object != null) { if (object != null) {
Cancellable cancellable; Cancellable cancellable;
if (object instanceof EntityHuman) { if (object instanceof EntityHuman) {
cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, Action.PHYSICAL, i, j, k, -1, null); cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, Action.PHYSICAL, i, j, k, -1, null);
} } else if (object instanceof Entity) {
else if (object instanceof Entity) {
cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), ((WorldServer) world).getWorld().getBlockAt(i, j, k)); cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), ((WorldServer) world).getWorld().getBlockAt(i, j, k));
((CraftServer) Bukkit.getServer()).getPluginManager().callEvent((EntityInteractEvent) cancellable); ((CraftServer) Bukkit.getServer()).getPluginManager().callEvent((EntityInteractEvent) cancellable);
} else {
continue;
} }
else continue;
if (cancellable.isCancelled()) { if (cancellable.isCancelled()) {
return; return;
} }

View File

@ -362,9 +362,9 @@ public class Chunk {
if (i != this.x || j != this.z) { if (i != this.x || j != this.z) {
System.out.println("Wrong location! " + entity); System.out.println("Wrong location! " + entity);
// Thread.dumpStack(); // CraftBukkit
// CraftBukkit // CraftBukkit
System.out.println("" + entity.locX + "," + entity.locZ + "(" + i + "," + j + ") vs " + this.x + "," + this.z); System.out.println("" + entity.locX + "," + entity.locZ + "(" + i + "," + j + ") vs " + this.x + "," + this.z);
// Thread.dumpStack(); // CraftBukkit
} }
int k = MathHelper.floor(entity.locY / 16.0D); int k = MathHelper.floor(entity.locY / 16.0D);

View File

@ -6,10 +6,10 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.Set; import java.util.Set;
// CraftBukkit start // CraftBukkit start
import java.util.Random;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.CraftChunk;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
@ -175,7 +175,7 @@ public class ChunkProviderServer implements IChunkProvider {
if (this.chunkProvider != null) { if (this.chunkProvider != null) {
this.chunkProvider.getChunkAt(ichunkprovider, i, j); this.chunkProvider.getChunkAt(ichunkprovider, i, j);
// Craftbukkit start // CraftBukkit start
BlockSand.a = true; BlockSand.a = true;
Random random = new Random(); Random random = new Random();
random.setSeed(world.getSeed()); random.setSeed(world.getSeed());
@ -186,7 +186,7 @@ public class ChunkProviderServer implements IChunkProvider {
populator.populate(world.getWorld(), random, chunk.bukkitChunk); populator.populate(world.getWorld(), random, chunk.bukkitChunk);
} }
BlockSand.a = false; BlockSand.a = false;
// Craftbukkit end // CraftBukkit end
chunk.f(); chunk.f();
} }

View File

@ -4,12 +4,12 @@ import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
// Craftbukkit start // CraftBukkit start
import java.util.List; import java.util.List;
import org.bukkit.craftbukkit.command.ServerCommandListener; import org.bukkit.craftbukkit.command.ServerCommandListener;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
// Craftbukkit end // CraftBukkit end
public class ConsoleCommandHandler { public class ConsoleCommandHandler {
@ -44,7 +44,7 @@ public class ConsoleCommandHandler {
serverconfigurationmanager.savePlayers(); serverconfigurationmanager.savePlayers();
} }
// Craftbukkit start // CraftBukkit start
for (i = 0; i < this.server.worlds.size(); ++i) { for (i = 0; i < this.server.worlds.size(); ++i) {
worldserver = this.server.worlds.get(i); worldserver = this.server.worlds.get(i);
boolean save = worldserver.E; boolean save = worldserver.E;
@ -58,15 +58,15 @@ public class ConsoleCommandHandler {
} else if (s.toLowerCase().startsWith("save-off")) { } else if (s.toLowerCase().startsWith("save-off")) {
this.print(s1, "Disabling level saving.."); this.print(s1, "Disabling level saving..");
for (i = 0; i < this.server.worlds.size(); ++i) { // Craftbukkit start for (i = 0; i < this.server.worlds.size(); ++i) { // CraftBukkit
worldserver = this.server.worlds.get(i); // Craftbukkit start worldserver = this.server.worlds.get(i); // CraftBukkit
worldserver.E = true; worldserver.E = true;
} }
} else if (s.toLowerCase().startsWith("save-on")) { } else if (s.toLowerCase().startsWith("save-on")) {
this.print(s1, "Enabling level saving.."); this.print(s1, "Enabling level saving..");
for (i = 0; i < this.server.worlds.size(); ++i) { // Craftbukkit start for (i = 0; i < this.server.worlds.size(); ++i) { // CraftBukkit
worldserver = this.server.worlds.get(i); // Craftbukkit start worldserver = this.server.worlds.get(i); // CraftBukkit
worldserver.E = false; worldserver.E = false;
} }
} else { } else {
@ -205,15 +205,15 @@ public class ConsoleCommandHandler {
WorldServer worldserver1; WorldServer worldserver1;
if ("add".equalsIgnoreCase(s3)) { if ("add".equalsIgnoreCase(s3)) {
for (k = 0; k < this.server.worlds.size(); ++k) { // Craftbukkit start for (k = 0; k < this.server.worlds.size(); ++k) { // CraftBukkit
worldserver1 = this.server.worlds.get(k); // Craftbukkit start worldserver1 = this.server.worlds.get(k); // CraftBukkit
worldserver1.setTime(worldserver1.getTime() + (long) j); worldserver1.setTime(worldserver1.getTime() + (long) j);
} }
this.print(s1, "Added " + j + " to time"); this.print(s1, "Added " + j + " to time");
} else if ("set".equalsIgnoreCase(s3)) { } else if ("set".equalsIgnoreCase(s3)) {
for (k = 0; k < this.server.worlds.size(); ++k) { // Craftbukkit start for (k = 0; k < this.server.worlds.size(); ++k) { // CraftBukkit
worldserver1 = this.server.worlds.get(k); // Craftbukkit start worldserver1 = this.server.worlds.get(k); // CraftBukkit
worldserver1.setTime((long) j); worldserver1.setTime((long) j);
} }

View File

@ -755,8 +755,9 @@ public abstract class Entity {
if (world == null) { if (world == null) {
this.die(); this.die();
this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
} else {
this.world = world;
} }
else this.world = world;
// CraftBukkit end // CraftBukkit end
} }
@ -909,9 +910,11 @@ public abstract class Entity {
nbttagcompound.a("Fire", (short) this.fireTicks); nbttagcompound.a("Fire", (short) this.fireTicks);
nbttagcompound.a("Air", (short) this.airTicks); nbttagcompound.a("Air", (short) this.airTicks);
nbttagcompound.a("OnGround", this.onGround); nbttagcompound.a("OnGround", this.onGround);
nbttagcompound.setString("World", world.worldData.name); // CraftBukkit // CraftBukkit start
nbttagcompound.a("UUIDLeast", this.uniqueId.getLeastSignificantBits()); // CraftBukkit nbttagcompound.setString("World", world.worldData.name);
nbttagcompound.a("UUIDMost", this.uniqueId.getMostSignificantBits()); // CraftBukkit nbttagcompound.a("UUIDLeast", this.uniqueId.getLeastSignificantBits());
nbttagcompound.a("UUIDMost", this.uniqueId.getMostSignificantBits());
// CraftBukkit end
this.b(nbttagcompound); this.b(nbttagcompound);
} }
@ -923,6 +926,19 @@ public abstract class Entity {
this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a; this.motX = ((NBTTagDouble) nbttaglist1.a(0)).a;
this.motY = ((NBTTagDouble) nbttaglist1.a(1)).a; this.motY = ((NBTTagDouble) nbttaglist1.a(1)).a;
this.motZ = ((NBTTagDouble) nbttaglist1.a(2)).a; this.motZ = ((NBTTagDouble) nbttaglist1.a(2)).a;
/* CraftBukkit start - moved section down
if (Math.abs(this.motX) > 10.0D) {
this.motX = 0.0D;
}
if (Math.abs(this.motY) > 10.0D) {
this.motY = 0.0D;
}
if (Math.abs(this.motZ) > 10.0D) {
this.motZ = 0.0D;
}
// CraftBukkit end */
this.lastX = this.bo = this.locX = ((NBTTagDouble) nbttaglist.a(0)).a; this.lastX = this.bo = this.locX = ((NBTTagDouble) nbttaglist.a(0)).a;
this.lastY = this.bp = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a; this.lastY = this.bp = this.locY = ((NBTTagDouble) nbttaglist.a(1)).a;

View File

@ -383,7 +383,7 @@ public class EntityBoat extends Entity {
} }
if (this.passenger != null && this.passenger.dead) { if (this.passenger != null && this.passenger.dead) {
this.passenger.vehicle = null; this.passenger.vehicle = null; // CraftBukkit
this.passenger = null; this.passenger = null;
} }
} }

View File

@ -152,6 +152,7 @@ public class EntityFireball extends Entity {
CraftServer server = ((WorldServer) this.world).getServer(); CraftServer server = ((WorldServer) this.world).getServer();
ExplosionPrimeEvent event = new ExplosionPrimeEvent(CraftEntity.getEntity(server, this), 1.0F, true); ExplosionPrimeEvent event = new ExplosionPrimeEvent(CraftEntity.getEntity(server, this), 1.0F, true);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
// give 'this' instead of (Entity) null so we know what causes the damage // give 'this' instead of (Entity) null so we know what causes the damage

View File

@ -602,6 +602,7 @@ public abstract class EntityHuman extends EntityLiving {
Player player = (Player) this.getBukkitEntity(); Player player = (Player) this.getBukkitEntity();
CraftServer server = ((WorldServer) world).getServer(); CraftServer server = ((WorldServer) world).getServer();
org.bukkit.block.Block bed = ((WorldServer) world).getWorld().getBlockAt(i, j, k); org.bukkit.block.Block bed = ((WorldServer) world).getWorld().getBlockAt(i, j, k);
PlayerBedEnterEvent event = new PlayerBedEnterEvent(player, bed); PlayerBedEnterEvent event = new PlayerBedEnterEvent(player, bed);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
@ -760,7 +761,7 @@ public abstract class EntityHuman extends EntityLiving {
public void a(ChunkCoordinates chunkcoordinates) { public void a(ChunkCoordinates chunkcoordinates) {
if (chunkcoordinates != null) { if (chunkcoordinates != null) {
this.b = new ChunkCoordinates(chunkcoordinates); this.b = new ChunkCoordinates(chunkcoordinates);
this.spawnWorld = world.worldData.name; this.spawnWorld = world.worldData.name; // CraftBukkit
} else { } else {
this.b = null; this.b = null;
} }

View File

@ -583,7 +583,7 @@ public class EntityMinecart extends Entity implements IInventory {
} }
if (this.passenger != null && this.passenger.dead) { if (this.passenger != null && this.passenger.dead) {
this.passenger.vehicle = null; this.passenger.vehicle = null; // CraftBukkit
this.passenger = null; this.passenger = null;
} }

View File

@ -315,6 +315,7 @@ public class EntityWolf extends EntityAnimal {
return false; return false;
} }
// CraftBukkit end // CraftBukkit end
this.d(true); this.d(true);
this.a((PathEntity) null); this.a((PathEntity) null);
this.setSitting(true); this.setSitting(true);

View File

@ -66,9 +66,9 @@ public class ItemFlintAndSteel extends Item {
itemstack.damage(1, entityhuman); itemstack.damage(1, entityhuman);
return false; return false;
} }
// CraftBukkit end
BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit BlockState blockState = CraftBlockState.getBlockState(world, i, j, k);
// CraftBukkit end
world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F); world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F);
world.setTypeId(i, j, k, Block.FIRE.id); world.setTypeId(i, j, k, Block.FIRE.id);

View File

@ -51,6 +51,7 @@ public class ItemInWorldManager {
} }
public void dig(int i, int j, int k, int l) { public void dig(int i, int j, int k, int l) {
// this.world.a((EntityHuman) null, i, j, k, l); // CraftBukkit - moved down
this.d = (int) (System.currentTimeMillis() / 50); // CraftBukkit this.d = (int) (System.currentTimeMillis() / 50); // CraftBukkit
int i1 = this.world.getTypeId(i, j, k); int i1 = this.world.getTypeId(i, j, k);

View File

@ -437,7 +437,7 @@ public class MinecraftServer implements Runnable, ICommandListener {
StatisticList.a(); StatisticList.a();
try { try {
MinecraftServer minecraftserver = new MinecraftServer(options); // CraftBukkit pass in the options MinecraftServer minecraftserver = new MinecraftServer(options); // CraftBukkit - pass in the options
// CraftBukkit - remove gui // CraftBukkit - remove gui

View File

@ -84,7 +84,7 @@ public class NetLoginHandler extends NetHandler {
if (entityplayer != null) { if (entityplayer != null) {
this.server.serverConfigurationManager.b(entityplayer); this.server.serverConfigurationManager.b(entityplayer);
// entityplayer.a((World) this.server.a(entityplayer.dimension)); // CraftBukkit - set by Entity // entityplayer.a((World) this.server.a(entityplayer.dimension)); // CraftBukkit - set by Entity
a.info(this.b() + " logged in with entity id " + entityplayer.id + " at ([ "+ entityplayer.world.worldData.name + "] " + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); a.info(this.b() + " logged in with entity id " + entityplayer.id + " at ([ " + entityplayer.world.worldData.name + "] " + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); // CraftBukkit
WorldServer worldserver = (WorldServer) entityplayer.world; // CraftBukkit WorldServer worldserver = (WorldServer) entityplayer.world; // CraftBukkit
ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer); NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer);

View File

@ -136,6 +136,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// Skip the first time we do this // Skip the first time we do this
if (lastPosX != Double.MAX_VALUE) { if (lastPosX != Double.MAX_VALUE) {
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
server.getPluginManager().callEvent(event); server.getPluginManager().callEvent(event);
from = event.getFrom(); from = event.getFrom();
@ -297,6 +298,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit start - make the movement speed check behave properly under tick degradation. // CraftBukkit start - make the movement speed check behave properly under tick degradation.
int elapsedTicks = MinecraftServer.currentTick - this.lastTick; int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
// Added this.m condition to solve this check being triggered by teleports // Added this.m condition to solve this check being triggered by teleports
if (d8 > 100.0D * (elapsedTicks <= 0 ? 1 : elapsedTicks) && this.m) { if (d8 > 100.0D * (elapsedTicks <= 0 ? 1 : elapsedTicks) && this.m) {
a.warning(this.player.name + " moved too quickly! Elapsed ticks: " + (elapsedTicks == 0 ? 1 : elapsedTicks) + ", Distance change: " + d8); a.warning(this.player.name + " moved too quickly! Elapsed ticks: " + (elapsedTicks == 0 ? 1 : elapsedTicks) + ", Distance change: " + d8);
@ -410,7 +412,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
if (packet14blockdig.e == 4) { if (packet14blockdig.e == 4) {
this.player.E(); this.player.E();
} else { } else {
boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit
boolean flag1 = false; boolean flag1 = false;
if (packet14blockdig.e == 0) { if (packet14blockdig.e == 0) {
@ -506,7 +508,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit end // CraftBukkit end
ItemStack itemstack = this.player.inventory.getItemInHand(); ItemStack itemstack = this.player.inventory.getItemInHand();
boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); boolean flag = worldserver.weirdIsOpCache = worldserver.dimension != 0 || this.minecraftServer.serverConfigurationManager.isOp(this.player.name); // CraftBukkit
if (packet15place.face == 255) { if (packet15place.face == 255) {
if (itemstack == null) { if (itemstack == null) {
@ -750,7 +752,7 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
s1 = s.substring(1); s1 = s.substring(1);
a.info(this.player.name + " tried command: " + s1); a.info(this.player.name + " tried command: " + s1);
} }
*/ // CraftBukkit end // CraftBukkit end */
} }
} }

View File

@ -5,13 +5,11 @@ import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.net.Socket; import java.net.Socket;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.io.IOException; // CraftBukkit - instead of SocketException import java.net.SocketException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.io.IOException; // CraftBukkit
// CraftBukkit
import java.net.SocketException;
public class NetworkManager { public class NetworkManager {
@ -49,8 +47,7 @@ public class NetworkManager {
// CraftBukkit start - IPv6 stack in Java on BSD/OSX doesn't support setTrafficClass // CraftBukkit start - IPv6 stack in Java on BSD/OSX doesn't support setTrafficClass
try { try {
socket.setTrafficClass(24); socket.setTrafficClass(24);
} catch (SocketException e) { } catch (SocketException e) {}
}
// CraftBukkit end // CraftBukkit end
try { try {

View File

@ -37,7 +37,7 @@ public class Packet51MapChunk extends Packet {
this.e = i1; this.e = i1;
this.f = j1; this.f = j1;
byte[] abyte = data; // CraftBukkit - uses data from above constructor byte[] abyte = data; // CraftBukkit - uses data from above constructor
Deflater deflater = new Deflater(1); Deflater deflater = new Deflater(-1);
try { try {
deflater.setInput(abyte); deflater.setInput(abyte);

View File

@ -271,7 +271,9 @@ public class PortalTravelAgent {
PortalCreateEvent event = new PortalCreateEvent(blocks, (org.bukkit.World) craftWorld); PortalCreateEvent event = new PortalCreateEvent(blocks, (org.bukkit.World) craftWorld);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if(event.isCancelled()) return true; if (event.isCancelled()) {
return true;
}
// CraftBukkit end // CraftBukkit end
if (d0 < 0.0D) { if (d0 < 0.0D) {

View File

@ -1,6 +1,6 @@
package net.minecraft.server; package net.minecraft.server;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator; // CraftBukkit
public class SecondaryWorldServer extends WorldServer { public class SecondaryWorldServer extends WorldServer {
// CraftBukkit start // CraftBukkit start

View File

@ -32,7 +32,7 @@ public class ServerConfigurationManager {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
public List players = new ArrayList(); public List players = new ArrayList();
public MinecraftServer server; // CraftBukkit - private -> public public MinecraftServer server; // CraftBukkit - private -> public
// private PlayerManager[] d = new PlayerManager[2]; // Craftbukkit - removed // private PlayerManager[] d = new PlayerManager[2]; // CraftBukkit - removed
public int maxPlayers; // CraftBukkit - private -> public public int maxPlayers; // CraftBukkit - private -> public
private Set banByName = new HashSet(); private Set banByName = new HashSet();
private Set banByIP = new HashSet(); private Set banByIP = new HashSet();
@ -61,7 +61,7 @@ public class ServerConfigurationManager {
this.m = minecraftserver.a("white-list.txt"); this.m = minecraftserver.a("white-list.txt");
int i = minecraftserver.propertyManager.getInt("view-distance", 10); int i = minecraftserver.propertyManager.getInt("view-distance", 10);
// Craftbukkit - removed playermanagers // CraftBukkit - removed playermanagers
this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20); this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20);
this.o = minecraftserver.propertyManager.getBoolean("white-list", false); this.o = minecraftserver.propertyManager.getBoolean("white-list", false);
this.g(); this.g();
@ -80,7 +80,7 @@ public class ServerConfigurationManager {
} }
public void a(EntityPlayer entityplayer) { public void a(EntityPlayer entityplayer) {
// Craftbukkit - removed playermanagers // CraftBukkit - removed playermanagers
for (WorldServer world : this.server.worlds) { for (WorldServer world : this.server.worlds) {
if (world.manager.a.contains(entityplayer)) { if (world.manager.a.contains(entityplayer)) {
world.manager.removePlayer(entityplayer); world.manager.removePlayer(entityplayer);
@ -94,17 +94,17 @@ public class ServerConfigurationManager {
} }
public int a() { public int a() {
// Craftbukkit start // CraftBukkit start
if (this.server.worlds.size() == 0) { if (this.server.worlds.size() == 0) {
return this.server.propertyManager.getInt("view-distance", 10) * 16 - 16; return this.server.propertyManager.getInt("view-distance", 10) * 16 - 16;
} else { } else {
return this.server.worlds.get(0).manager.c(); return this.server.worlds.get(0).manager.c();
} }
// Craftbukkit end // CraftBukkit end
} }
private PlayerManager a(int i) { private PlayerManager a(int i) {
return server.a(i).manager; // Craftbukkit return server.a(i).manager; // CraftBukkit
} }
public void b(EntityPlayer entityplayer) { public void b(EntityPlayer entityplayer) {
@ -226,14 +226,17 @@ public class ServerConfigurationManager {
entityplayer1.netServerHandler.sendPacket(new Packet70Bed(0)); entityplayer1.netServerHandler.sendPacket(new Packet70Bed(0));
} }
} }
if (location == null) { if (location == null) {
cw = (CraftWorld) this.server.server.getWorlds().get(0); cw = (CraftWorld) this.server.server.getWorlds().get(0);
chunkcoordinates = cw.getHandle().getSpawn(); chunkcoordinates = cw.getHandle().getSpawn();
location = new Location(cw, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z); location = new Location(cw, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z);
} }
Player respawnPlayer = cserver.getPlayer(entityplayer); Player respawnPlayer = cserver.getPlayer(entityplayer);
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location); PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location);
cserver.getPluginManager().callEvent(respawnEvent); cserver.getPluginManager().callEvent(respawnEvent);
location = respawnEvent.getRespawnLocation(); location = respawnEvent.getRespawnLocation();
entityplayer.health = 20; entityplayer.health = 20;
entityplayer.fireTicks = 0; entityplayer.fireTicks = 0;
@ -269,10 +272,9 @@ public class ServerConfigurationManager {
} }
public void f(EntityPlayer entityplayer) { public void f(EntityPlayer entityplayer) {
// CraftBukkit start
WorldServer worldserver = this.server.a(entityplayer.dimension); WorldServer worldserver = this.server.a(entityplayer.dimension);
boolean flag = false; // Unused boolean flag = false;
int b0; // byte -> int int b0; // CraftBukkit - byte -> int
if (entityplayer.dimension == -1) { if (entityplayer.dimension == -1) {
b0 = 0; b0 = 0;
@ -280,17 +282,19 @@ public class ServerConfigurationManager {
b0 = -1; b0 = -1;
} }
// entityplayer.dimension = b0; /* CraftBukkit start
// WorldServer worldserver1 = this.server.a(entityplayer.dimension); entityplayer.dimension = b0;
WorldServer worldserver1 = this.server.a(entityplayer.dimension);
// entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) entityplayer.dimension)); entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) entityplayer.dimension));
// worldserver.removeEntity(entityplayer); worldserver.removeEntity(entityplayer);
// entityplayer.dead = false; entityplayer.dead = false;
// CraftBukkit end */
double d0 = entityplayer.locX; double d0 = entityplayer.locX;
double d1 = entityplayer.locZ; double d1 = entityplayer.locZ;
double d2 = 8.0D; double d2 = 8.0D;
if (b0 == -1) { // entityplayer.dimension -> b0 if (b0 == -1) { // CraftBukkit - entityplayer.dimension -> b0
d0 /= d2; d0 /= d2;
d1 /= d2; d1 /= d2;
entityplayer.setPositionRotation(d0, entityplayer.locY, d1, entityplayer.yaw, entityplayer.pitch); entityplayer.setPositionRotation(d0, entityplayer.locY, d1, entityplayer.yaw, entityplayer.pitch);
@ -306,6 +310,7 @@ public class ServerConfigurationManager {
} }
} }
// CraftBukkit start
CraftWorld fromCraftWorld = worldserver.getWorld(); CraftWorld fromCraftWorld = worldserver.getWorld();
CraftWorld toCraftWorld = this.server.a(b0).getWorld(); CraftWorld toCraftWorld = this.server.a(b0).getWorld();
Location startLocation = new Location(fromCraftWorld, entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); Location startLocation = new Location(fromCraftWorld, entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
@ -336,21 +341,23 @@ public class ServerConfigurationManager {
} }
} }
// this.a(entityplayer); /* CraftBukkit -- not needed
// entityplayer.netServerHandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); this.a(entityplayer);
// entityplayer.a((World) worldserver1); entityplayer.netServerHandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
// this.a(entityplayer, worldserver1); entityplayer.a((World) worldserver1);
// this.g(entityplayer); this.a(entityplayer, worldserver1);
this.g(entityplayer);
// CraftBukkit */
this.a(entityplayer, b0, endLocation); this.a(entityplayer, b0, endLocation);
// CraftBukkit end // CraftBukkit end
} }
public void b() { public void b() {
// Craftbukkit start // CraftBukkit start
for (int i = 0; i < this.server.worlds.size(); ++i) { for (int i = 0; i < this.server.worlds.size(); ++i) {
this.server.worlds.get(i).manager.flush(); this.server.worlds.get(i).manager.flush();
} }
// Craftbukkit end // CraftBukkit end
} }
public void flagDirty(int i, int j, int k, int l) { public void flagDirty(int i, int j, int k, int l) {

View File

@ -50,7 +50,7 @@ public class World implements IBlockAccess {
public int spawnMonsters; public int spawnMonsters;
public Random random = new Random(); public Random random = new Random();
public boolean s = false; public boolean s = false;
public WorldProvider worldProvider; // Craftbukkit - remove final public WorldProvider worldProvider; // CraftBukkit - remove final
protected List u = new ArrayList(); protected List u = new ArrayList();
public IChunkProvider chunkProvider; // CraftBukkit - protected -> public public IChunkProvider chunkProvider; // CraftBukkit - protected -> public
protected final IDataManager w; protected final IDataManager w;
@ -62,22 +62,36 @@ public class World implements IBlockAccess {
private int K = 0; private int K = 0;
public boolean allowMonsters = true; // CraftBukkit - private -> public public boolean allowMonsters = true; // CraftBukkit - private -> public
public boolean allowAnimals = true; // CraftBukkit - private -> public public boolean allowAnimals = true; // CraftBukkit - private -> public
public boolean pvpMode; // CraftBukkit
static int A = 0; static int A = 0;
private Set N = new HashSet(); private Set N = new HashSet();
private int O; private int O;
private List P; private List P;
public boolean isStatic; public boolean isStatic;
public ChunkGenerator generator; // Craftbukkit
public WorldChunkManager getWorldChunkManager() { public WorldChunkManager getWorldChunkManager() {
return this.worldProvider.b; return this.worldProvider.b;
} }
// Craftbukkit start - changed signature // CraftBukkit start
public boolean pvpMode;
public ChunkGenerator generator;
Chunk lastChunkAccessed;
int lastXAccessed = Integer.MIN_VALUE;
int lastZAccessed = Integer.MIN_VALUE;
final Object chunkLock = new Object();
private boolean canSpawn(int x, int z) {
if (generator != null) {
return this.generator.canSpawn(((WorldServer) this).getWorld(), x, z);
} else {
return this.worldProvider.a(x, z);
}
}
// CraftBukkit - changed signature
public World(IDataManager idatamanager, String s, long i, WorldProvider worldprovider, ChunkGenerator gen) { public World(IDataManager idatamanager, String s, long i, WorldProvider worldprovider, ChunkGenerator gen) {
this.generator = gen; this.generator = gen;
// Craftbukkit end // CraftBukkit end
this.O = this.random.nextInt(12000); this.O = this.random.nextInt(12000);
this.P = new ArrayList(); this.P = new ArrayList();
@ -126,10 +140,11 @@ public class World implements IBlockAccess {
int j; int j;
// Craftbukkit start // CraftBukkit start
if (generator != null) { if (generator != null) {
Random rand = new Random(getSeed()); Random rand = new Random(getSeed());
Location spawn = generator.getFixedSpawnLocation(((WorldServer) this).getWorld(), rand); Location spawn = generator.getFixedSpawnLocation(((WorldServer) this).getWorld(), rand);
if (spawn != null) { if (spawn != null) {
if (spawn.getWorld() != ((WorldServer) this).getWorld()) { if (spawn.getWorld() != ((WorldServer) this).getWorld()) {
throw new IllegalStateException("Cannot set spawn point for " + worldData.name + " to be in another world (" + spawn.getWorld().getName() + ")"); throw new IllegalStateException("Cannot set spawn point for " + worldData.name + " to be in another world (" + spawn.getWorld().getName() + ")");
@ -144,22 +159,12 @@ public class World implements IBlockAccess {
for (j = 0; !canSpawn(i, j); j += this.random.nextInt(64) - this.random.nextInt(64)) { for (j = 0; !canSpawn(i, j); j += this.random.nextInt(64) - this.random.nextInt(64)) {
i += this.random.nextInt(64) - this.random.nextInt(64); i += this.random.nextInt(64) - this.random.nextInt(64);
} }
// Craftbukkit end // CraftBukkit end
this.worldData.setSpawn(i, b0, j); this.worldData.setSpawn(i, b0, j);
this.isLoading = false; this.isLoading = false;
} }
// Craftbukkit start
private boolean canSpawn(int x, int z) {
if (generator != null) {
return this.generator.canSpawn(((WorldServer)this).getWorld(), x, z);
} else {
return this.worldProvider.a(x, z);
}
}
// Craftbukkit end
public int a(int i, int j) { public int a(int i, int j) {
int k; int k;
@ -239,10 +244,6 @@ public class World implements IBlockAccess {
} }
// CraftBukkit start // CraftBukkit start
Chunk lastChunkAccessed;
int lastXAccessed = Integer.MIN_VALUE;
int lastZAccessed = Integer.MIN_VALUE;
final Object chunkLock = new Object();
public Chunk getChunkAt(int i, int j) { public Chunk getChunkAt(int i, int j) {
Chunk result = null; Chunk result = null;
synchronized (chunkLock) { synchronized (chunkLock) {
@ -818,6 +819,7 @@ public class World implements IBlockAccess {
// CraftBukkit start // CraftBukkit start
if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) { if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
CreatureSpawnEvent event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity); CreatureSpawnEvent event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity);
if (event.isCancelled()) { if (event.isCancelled()) {
return false; return false;
} }
@ -1815,8 +1817,8 @@ public class World implements IBlockAccess {
if (this.v() && i2 == 0 && Block.SNOW.canPlace(this, l + i, k1, j1 + j) && l1 != 0 && l1 != Block.ICE.id && Block.byId[l1].material.isSolid()) { if (this.v() && i2 == 0 && Block.SNOW.canPlace(this, l + i, k1, j1 + j) && l1 != 0 && l1 != Block.ICE.id && Block.byId[l1].material.isSolid()) {
// CraftBukkit start // CraftBukkit start
SnowFormEvent snow = new SnowFormEvent(((WorldServer) this).getWorld().getBlockAt(l + i, k1, j1 + j)); SnowFormEvent snow = new SnowFormEvent(((WorldServer) this).getWorld().getBlockAt(l + i, k1, j1 + j));
((WorldServer)this).getServer().getPluginManager().callEvent(snow);
((WorldServer) this).getServer().getPluginManager().callEvent(snow);
if (!snow.isCancelled()) { if (!snow.isCancelled()) {
this.setTypeId(l + i, k1, j1 + j, snow.getMaterial().getId()); this.setTypeId(l + i, k1, j1 + j, snow.getMaterial().getId());
this.setData(l + i, k1, j1 + j, snow.getData()); this.setData(l + i, k1, j1 + j, snow.getData());
@ -1946,7 +1948,6 @@ public class World implements IBlockAccess {
this.entityList.add(entity); this.entityList.add(entity);
// CraftBukkit end // CraftBukkit end
this.c((Entity) list.get(i)); this.c((Entity) list.get(i));
} }
} }
@ -1965,19 +1966,16 @@ public class World implements IBlockAccess {
axisalignedbb = null; axisalignedbb = null;
} }
// CraftBukkit - store the default action boolean defaultReturn; // CraftBukkit - store the default action
boolean defaultReturn;
if (axisalignedbb != null && !this.containsEntity(axisalignedbb)) { if (axisalignedbb != null && !this.containsEntity(axisalignedbb)) {
// CraftBukkit defaultReturn = false; // CraftBukkit
defaultReturn = false;
} else { } else {
if (block == Block.WATER || block == Block.STATIONARY_WATER || block == Block.LAVA || block == Block.STATIONARY_LAVA || block == Block.FIRE || block == Block.SNOW) { if (block == Block.WATER || block == Block.STATIONARY_WATER || block == Block.LAVA || block == Block.STATIONARY_LAVA || block == Block.FIRE || block == Block.SNOW) {
block = null; block = null;
} }
// CraftBukkit defaultReturn = i > 0 && block == null && block1.canPlace(this, j, k, l, i1); // CraftBukkit
defaultReturn = i > 0 && block == null && block1.canPlace(this, j, k, l, i1);
} }
// CraftBukkit start // CraftBukkit start

View File

@ -3,7 +3,7 @@ package net.minecraft.server;
public class WorldManager implements IWorldAccess { public class WorldManager implements IWorldAccess {
private MinecraftServer server; private MinecraftServer server;
public WorldServer world; // CraftBukkit private -> public public WorldServer world; // CraftBukkit - private -> public
public WorldManager(MinecraftServer minecraftserver, WorldServer worldserver) { public WorldManager(MinecraftServer minecraftserver, WorldServer worldserver) {
this.server = minecraftserver; this.server = minecraftserver;

View File

@ -95,6 +95,7 @@ public class WorldMap extends WorldMapBase {
byte b2 = 0; byte b2 = 0;
byte b3 = (byte) ((int) ((double) (f * 2.0F) + 0.5D)); byte b3 = (byte) ((int) ((double) (f * 2.0F) + 0.5D));
byte b4 = (byte) ((int) ((double) (f1 * 2.0F) + 0.5D)); byte b4 = (byte) ((int) ((double) (f1 * 2.0F) + 0.5D));
// CraftBukkit
byte b5 = (byte) ((int) ((double) (worldmaphumantracker1.a.yaw * 16.0F / 360.0F) + 0.5D)); byte b5 = (byte) ((int) ((double) (worldmaphumantracker1.a.yaw * 16.0F / 360.0F) + 0.5D));
if (this.d < 0) { if (this.d < 0) {

View File

@ -70,7 +70,7 @@ public class WorldServer extends World implements BlockChangeDelegate {
protected IChunkProvider b() { protected IChunkProvider b() {
IChunkLoader ichunkloader = this.w.a(this.worldProvider); IChunkLoader ichunkloader = this.w.a(this.worldProvider);
// Craftbukkit start // CraftBukkit start
InternalChunkGenerator gen; InternalChunkGenerator gen;
if (this.generator != null) { if (this.generator != null) {
@ -84,7 +84,7 @@ public class WorldServer extends World implements BlockChangeDelegate {
} }
this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, gen); this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, gen);
// Craftbukkit end // CraftBukkit end
return this.chunkProviderServer; return this.chunkProviderServer;
} }
@ -162,9 +162,11 @@ public class WorldServer extends World implements BlockChangeDelegate {
return explosion; return explosion;
} }
// explosion.a = flag; /* CraftBukkit
// explosion.a(); explosion.a = flag;
// explosion.a(false); explosion.a();
explosion.a(false);
// CraftBukkit */
this.server.serverConfigurationManager.a(d0, d1, d2, 64.0D, this.dimension, new Packet60Explosion(d0, d1, d2, f, explosion.g)); this.server.serverConfigurationManager.a(d0, d1, d2, 64.0D, this.dimension, new Packet60Explosion(d0, d1, d2, f, explosion.g));
// CraftBukkit end // CraftBukkit end
return explosion; return explosion;