Update CraftBukkit to Minecraft 1.3.1

By: feildmaster <admin@feildmaster.com>
This commit is contained in:
CraftBukkit/Spigot 2012-07-29 02:33:13 -05:00
parent a45bcca987
commit 6e2987bb35
27 changed files with 253 additions and 126 deletions

View file

@ -4,7 +4,7 @@
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<packaging>jar</packaging>
<version>1.2.5-R5.1-SNAPSHOT</version>
<version>1.3.1-R0.1-SNAPSHOT</version>
<name>CraftBukkit</name>
<url>http://www.bukkit.org</url>
@ -51,14 +51,14 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.2.5-R5.1-SNAPSHOT</version>
<version>1.3.1-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>minecraft-server</artifactId>
<version>1.2.5</version>
<version>1.3.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

View file

@ -8,6 +8,7 @@ import java.util.zip.Deflater;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.Packet;
import net.minecraft.server.Packet51MapChunk;
import net.minecraft.server.Packet56MapChunkBulk;
public final class ChunkCompressionThread implements Runnable {
@ -46,29 +47,56 @@ public final class ChunkCompressionThread implements Runnable {
private void handleQueuedPacket(QueuedPacket queuedPacket) {
addToPlayerQueueSize(queuedPacket.player, -1);
// Compress the packet if necessary.
if (queuedPacket.compress) {
handleMapChunk(queuedPacket);
// Compress the packet if necessary
if (queuedPacket.compress == 1) {
handleMapChunk((Packet51MapChunk) queuedPacket.packet);
} else if (queuedPacket.compress == 2) {
handleMapChunkBulk((Packet56MapChunkBulk) queuedPacket.packet);
}
sendToNetworkQueue(queuedPacket);
}
private void handleMapChunk(QueuedPacket queuedPacket) {
Packet51MapChunk packet = (Packet51MapChunk) queuedPacket.packet;
// If 'packet.g' is set then this packet has already been compressed.
private void handleMapChunkBulk(Packet56MapChunkBulk packet) {
if (packet.buffer != null) {
return;
}
int dataSize = packet.rawData.length;
int dataSize = packet.buildBuffer.length;
if (deflateBuffer.length < dataSize + 100) {
deflateBuffer = new byte[dataSize + 100];
}
deflater.reset();
deflater.setLevel(dataSize < REDUCED_DEFLATE_THRESHOLD ? DEFLATE_LEVEL_PARTS : DEFLATE_LEVEL_CHUNKS);
deflater.setInput(packet.rawData);
deflater.setInput(packet.buildBuffer);
deflater.finish();
int size = deflater.deflate(deflateBuffer);
if (size == 0) {
size = deflater.deflate(deflateBuffer);
}
// copy compressed data to packet
packet.buffer = new byte[size];
packet.size = size;
System.arraycopy(deflateBuffer, 0, packet.buffer, 0, size);
}
private void handleMapChunk(Packet51MapChunk packet) {
// If 'packet.buffer' is set then this packet has already been compressed.
if (packet.buffer != null) {
return;
}
int dataSize = packet.inflatedBuffer.length;
if (deflateBuffer.length < dataSize + 100) {
deflateBuffer = new byte[dataSize + 100];
}
deflater.reset();
deflater.setLevel(dataSize < REDUCED_DEFLATE_THRESHOLD ? DEFLATE_LEVEL_PARTS : DEFLATE_LEVEL_CHUNKS);
deflater.setInput(packet.inflatedBuffer);
deflater.finish();
int size = deflater.deflate(deflateBuffer);
if (size == 0) {
@ -86,13 +114,15 @@ public final class ChunkCompressionThread implements Runnable {
}
public static void sendPacket(EntityPlayer player, Packet packet) {
int compressType = 0;
if (packet instanceof Packet51MapChunk) {
// MapChunk Packets need compressing.
instance.addQueuedPacket(new QueuedPacket(player, packet, true));
} else {
// Other Packets don't.
instance.addQueuedPacket(new QueuedPacket(player, packet, false));
compressType = 1;
} else if (packet instanceof Packet56MapChunkBulk) {
compressType = 2;
}
instance.addQueuedPacket(new QueuedPacket(player, packet, compressType));
}
private void addToPlayerQueueSize(EntityPlayer player, int amount) {
@ -129,9 +159,9 @@ public final class ChunkCompressionThread implements Runnable {
private static class QueuedPacket {
final EntityPlayer player;
final Packet packet;
final boolean compress;
final int compress;
QueuedPacket(EntityPlayer player, Packet packet, boolean compress) {
QueuedPacket(EntityPlayer player, Packet packet, int compress) {
this.player = player;
this.packet = packet;
this.compress = compress;

View file

@ -150,7 +150,7 @@ public class CraftChunk implements Chunk {
public ChunkSnapshot getChunkSnapshot(boolean includeMaxBlockY, boolean includeBiome, boolean includeBiomeTempRain) {
net.minecraft.server.Chunk chunk = getHandle();
ChunkSection[] cs = chunk.h(); /* Get sections */
ChunkSection[] cs = chunk.i(); /* Get sections */
short[][] sectionBlockIDs = new short[cs.length][];
byte[][] sectionBlockData = new byte[cs.length][];
byte[][] sectionSkyLights = new byte[cs.length][];
@ -173,8 +173,8 @@ public class CraftChunk implements Chunk {
blockids[j] = (short) (baseids[j] & 0xFF);
}
if (cs[i].h() != null) { /* If we've got extended IDs */
byte[] extids = cs[i].h().a;
if (cs[i].i() != null) { /* If we've got extended IDs */
byte[] extids = cs[i].i().a;
for (int j = 0; j < 2048; j++) {
short b = (short) (extids[j] & 0xFF);

View file

@ -4,9 +4,12 @@ import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.server.BanEntry;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.WorldNBTStorage;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
@ -56,15 +59,18 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
}
public boolean isBanned() {
return server.getHandle().banByName.contains(name.toLowerCase());
return server.getHandle().getNameBans().isBanned(name.toLowerCase());
}
public void setBanned(boolean value) {
if (value) {
server.getHandle().addUserBan(name.toLowerCase());
BanEntry entry = new BanEntry(name.toLowerCase());
server.getHandle().getNameBans().add(entry);
} else {
server.getHandle().removeUserBan(name.toLowerCase());
server.getHandle().getNameBans().remove(name.toLowerCase());
}
server.getHandle().getNameBans().save();
}
public boolean isWhitelisted() {

View file

@ -17,14 +17,18 @@ import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.BanEntry;
import net.minecraft.server.ChunkCoordinates;
import net.minecraft.server.ConvertProgressUpdater;
import net.minecraft.server.Convertable;
import net.minecraft.server.ConvertProgressUpdater;
import net.minecraft.server.CraftingManager;
import net.minecraft.server.DedicatedServer;
import net.minecraft.server.Enchantment;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityTracker;
import net.minecraft.server.FurnaceRecipes;
import net.minecraft.server.EnumGamemode;
import net.minecraft.server.ExceptionWorldConflict;
import net.minecraft.server.RecipesFurnace;
import net.minecraft.server.IProgressUpdate;
import net.minecraft.server.IWorldAccess;
import net.minecraft.server.Item;
@ -33,6 +37,7 @@ import net.minecraft.server.MobEffectList;
import net.minecraft.server.PropertyManager;
import net.minecraft.server.ServerCommand;
import net.minecraft.server.ServerConfigurationManager;
import net.minecraft.server.ServerConfigurationManagerAbstract;
import net.minecraft.server.ServerNBTManager;
import net.minecraft.server.WorldLoaderServer;
import net.minecraft.server.WorldManager;
@ -128,7 +133,7 @@ public final class CraftServer implements Server {
private final String serverVersion;
private final String bukkitVersion = Versioning.getBukkitVersion();
private final ServicesManager servicesManager = new SimpleServicesManager();
private final BukkitScheduler scheduler = new CraftScheduler();
private final CraftScheduler scheduler = new CraftScheduler();
private final SimpleCommandMap commandMap = new SimpleCommandMap(this);
private final SimpleHelpMap helpMap = new SimpleHelpMap(this);
private final StandardMessenger messenger = new StandardMessenger();
@ -146,14 +151,15 @@ public final class CraftServer implements Server {
private int monsterSpawn = -1;
private int animalSpawn = -1;
private int waterAnimalSpawn = -1;
private File container;
static {
ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
}
public CraftServer(MinecraftServer console, ServerConfigurationManager server) {
public CraftServer(MinecraftServer console, ServerConfigurationManagerAbstract server) {
this.console = console;
this.server = server;
this.server = (ServerConfigurationManager) server;
this.serverVersion = CraftServer.class.getPackage().getImplementationVersion();
Bukkit.setServer(this);
@ -355,7 +361,7 @@ public final class CraftServer implements Server {
}
public int getMaxPlayers() {
return server.maxPlayers;
return server.getMaxPlayers();
}
// NOTE: These are dependent on the corrisponding call in MinecraftServer
@ -410,15 +416,15 @@ public final class CraftServer implements Server {
// NOTE: Temporary calls through to server.properies until its replaced
private String getConfigString(String variable, String defaultValue) {
return this.console.propertyManager.getString(variable, defaultValue);
return this.console.getPropertyManager().getString(variable, defaultValue);
}
private int getConfigInt(String variable, int defaultValue) {
return this.console.propertyManager.getInt(variable, defaultValue);
return this.console.getPropertyManager().getInt(variable, defaultValue);
}
private boolean getConfigBoolean(String variable, boolean defaultValue) {
return this.console.propertyManager.getBoolean(variable, defaultValue);
return this.console.getPropertyManager().getBoolean(variable, defaultValue);
}
// End Temporary calls
@ -451,7 +457,7 @@ public final class CraftServer implements Server {
return pluginManager;
}
public BukkitScheduler getScheduler() {
public CraftScheduler getScheduler() {
return scheduler;
}
@ -467,7 +473,7 @@ public final class CraftServer implements Server {
return server;
}
// NOTE: Should only be called from MinecraftServer.b()
// NOTE: Should only be called from DedicatedServer.ah()
public boolean dispatchServerCommand(CommandSender sender, ServerCommand serverCommand) {
if (sender instanceof Conversable) {
Conversable conversable = (Conversable)sender;
@ -494,17 +500,17 @@ public final class CraftServer implements Server {
configuration = YamlConfiguration.loadConfiguration(getConfigFile());
PropertyManager config = new PropertyManager(console.options);
console.propertyManager = config;
((DedicatedServer) console).propertyManager = config;
boolean animals = config.getBoolean("spawn-animals", console.spawnAnimals);
boolean animals = config.getBoolean("spawn-animals", console.getSpawnAnimals());
boolean monsters = config.getBoolean("spawn-monsters", console.worlds.get(0).difficulty > 0);
int difficulty = config.getInt("difficulty", console.worlds.get(0).difficulty);
console.onlineMode = config.getBoolean("online-mode", console.onlineMode);
console.spawnAnimals = config.getBoolean("spawn-animals", console.spawnAnimals);
console.pvpMode = config.getBoolean("pvp", console.pvpMode);
console.allowFlight = config.getBoolean("allow-flight", console.allowFlight);
console.motd = config.getString("motd", console.motd);
console.setOnlineMode(config.getBoolean("online-mode", console.getOnlineMode()));
console.setSpawnAnimals(config.getBoolean("spawn-animals", console.getSpawnAnimals()));
console.setPvP(config.getBoolean("pvp", console.getPvP()));
console.setAllowFlight(config.getBoolean("allow-flight", console.getAllowFlight()));
console.setMotd(config.getString("motd", console.getMotd()));
monsterSpawn = configuration.getInt("spawn-limits.monsters");
animalSpawn = configuration.getInt("spawn-limits.animals");
waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
@ -669,7 +675,7 @@ public final class CraftServer implements Server {
} while(used);
boolean hardcore = false;
WorldServer internal = new WorldServer(console, new ServerNBTManager(getWorldContainer(), name, true), name, dimension, new WorldSettings(creator.seed(), getDefaultGameMode().getValue(), generateStructures, hardcore, type), creator.environment(), generator);
WorldServer internal = new WorldServer(console, new ServerNBTManager(getWorldContainer(), name, true), name, dimension, new WorldSettings(creator.seed(), EnumGamemode.a(getDefaultGameMode().getValue()), generateStructures, hardcore, type), console.methodProfiler, creator.environment(), generator);
if (!(worlds.containsKey(name.toLowerCase()))) {
return null;
@ -677,7 +683,7 @@ public final class CraftServer implements Server {
internal.worldMaps = console.worlds.get(0).worldMaps;
internal.tracker = new EntityTracker(console, internal); // CraftBukkit
internal.tracker = new EntityTracker(internal); // CraftBukkit
internal.addIWorldAccess((IWorldAccess) new WorldManager(console, internal));
internal.difficulty = 1;
internal.setSpawnFlags(true, true);
@ -753,10 +759,14 @@ public final class CraftServer implements Server {
}
if (save) {
handle.save(true, (IProgressUpdate) null);
handle.saveLevel();
WorldSaveEvent event = new WorldSaveEvent(handle.getWorld());
getPluginManager().callEvent(event);
try {
handle.save(true, (IProgressUpdate) null);
handle.saveLevel();
WorldSaveEvent event = new WorldSaveEvent(handle.getWorld());
getPluginManager().callEvent(event);
} catch (ExceptionWorldConflict ex) {
getLogger().log(Level.SEVERE, null, ex);
}
}
worlds.remove(world.getName().toLowerCase());
@ -870,13 +880,13 @@ public final class CraftServer implements Server {
}
public void clearRecipes() {
CraftingManager.getInstance().recipies.clear();
FurnaceRecipes.getInstance().recipies.clear();
CraftingManager.getInstance().recipes.clear();
RecipesFurnace.getInstance().recipes.clear();
}
public void resetRecipes() {
CraftingManager.getInstance().recipies = new CraftingManager().recipies;
FurnaceRecipes.getInstance().recipies = new FurnaceRecipes().recipies;
CraftingManager.getInstance().recipes = new CraftingManager().recipes;
RecipesFurnace.getInstance().recipes = new RecipesFurnace().recipes;
}
public Map<String, String[]> getCommandAliases() {
@ -910,11 +920,11 @@ public final class CraftServer implements Server {
}
public boolean getOnlineMode() {
return this.console.onlineMode;
return console.getOnlineMode();
}
public boolean getAllowFlight() {
return this.console.allowFlight;
return console.getAllowFlight();
}
public boolean useExactLoginLocation() {
@ -1004,21 +1014,24 @@ public final class CraftServer implements Server {
@SuppressWarnings("unchecked")
public Set<String> getIPBans() {
return new HashSet<String>(server.banByIP);
return server.getIPBans().getEntries().keySet();
}
public void banIP(String address) {
server.addIpBan(address);
BanEntry entry = new BanEntry(address);
server.getIPBans().add(entry);
server.getIPBans().save();
}
public void unbanIP(String address) {
server.removeIpBan(address);
server.getIPBans().remove(address);
server.getIPBans().save();
}
public Set<OfflinePlayer> getBannedPlayers() {
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
for (Object name : server.banByName) {
for (Object name : server.getNameBans().getEntries().keySet()) {
result.add(getOfflinePlayer((String) name));
}
@ -1027,7 +1040,7 @@ public final class CraftServer implements Server {
public void setWhitelist(boolean value) {
server.hasWhitelist = value;
console.propertyManager.setBoolean("white-list", value);
console.getPropertyManager().a("white-list", value);
}
public Set<OfflinePlayer> getWhitelistedPlayers() {
@ -1046,7 +1059,7 @@ public final class CraftServer implements Server {
public Set<OfflinePlayer> getOperators() {
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
for (Object name : server.operators) {
for (Object name : server.getOPs()) {
result.add(getOfflinePlayer((String) name));
}
@ -1058,7 +1071,7 @@ public final class CraftServer implements Server {
}
public GameMode getDefaultGameMode() {
return GameMode.getByValue(console.worlds.get(0).worldData.getGameType());
return GameMode.getByValue(console.worlds.get(0).getWorldData().getGameType().a());
}
public void setDefaultGameMode(GameMode mode) {
@ -1067,7 +1080,7 @@ public final class CraftServer implements Server {
}
for (World world : getWorlds()) {
((CraftWorld) world).getHandle().worldData.setGameType(mode.getValue());
((CraftWorld) world).getHandle().worldData.setGameType(EnumGamemode.a(mode.getValue()));
}
}
@ -1109,7 +1122,15 @@ public final class CraftServer implements Server {
}
public File getWorldContainer() {
return new File(configuration.getString("settings.world-container", "."));
if (this.getServer().universe != null) {
return this.getServer().universe;
}
if (container == null) {
container = new File(configuration.getString("settings.world-container", "."));
}
return container;
}
public OfflinePlayer[] getOfflinePlayers() {
@ -1197,6 +1218,6 @@ public final class CraftServer implements Server {
}
public String getMotd() {
return console.motd;
return console.getMotd();
}
}

View file

@ -257,7 +257,6 @@ public class CraftWorld implements World {
world.chunkProviderServer.chunks.put(x, z, chunk);
world.chunkProviderServer.chunkList.add(chunk);
chunk.loadNOP();
chunk.addEntities();
if (!chunk.done && world.chunkProviderServer.isChunkLoaded(x + 1, z + 1) && world.chunkProviderServer.isChunkLoaded(x, z + 1) && world.chunkProviderServer.isChunkLoaded(x + 1, z)) {
@ -338,13 +337,13 @@ public class CraftWorld implements World {
}
public LightningStrike strikeLightning(Location loc) {
EntityWeatherLighting lightning = new EntityWeatherLighting(world, loc.getX(), loc.getY(), loc.getZ());
EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ());
world.strikeLightning(lightning);
return new CraftLightningStrike(server, lightning);
}
public LightningStrike strikeLightningEffect(Location loc) {
EntityWeatherLighting lightning = new EntityWeatherLighting(world, loc.getX(), loc.getY(), loc.getZ(), true);
EntityLightning lightning = new EntityLightning(world, loc.getX(), loc.getY(), loc.getZ(), true);
world.strikeLightning(lightning);
return new CraftLightningStrike(server, lightning);
}
@ -400,7 +399,7 @@ public class CraftWorld implements World {
}
public String getName() {
return world.worldData.name;
return world.worldData.getName();
}
@Deprecated
@ -409,7 +408,7 @@ public class CraftWorld implements World {
}
public UUID getUID() {
return world.getUUID();
return world.getDataManager().getUUID();
}
@Override
@ -514,18 +513,18 @@ public class CraftWorld implements World {
net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(x, z);
if (chunk != null) {
byte[] biomevals = chunk.l();
byte[] biomevals = chunk.m();
biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.id;
}
}
}
public double getTemperature(int x, int z) {
return this.world.getBiome(x, z).F;
return this.world.getBiome(x, z).temperature;
}
public double getHumidity(int x, int z) {
return this.world.getBiome(x, z).G;
return this.world.getBiome(x, z).humidity;
}
public List<Entity> getEntities() {
@ -636,12 +635,16 @@ public class CraftWorld implements World {
}
public void save() {
boolean oldSave = world.savingDisabled;
try {
boolean oldSave = world.savingDisabled;
world.savingDisabled = false;
world.save(true, null);
world.savingDisabled = false;
world.save(true, null);
world.savingDisabled = oldSave;
world.savingDisabled = oldSave;
} catch (ExceptionWorldConflict ex) {
ex.printStackTrace();
}
}
public boolean isAutoSave() {
@ -806,8 +809,6 @@ public class CraftWorld implements World {
entity = new EntitySnowball(world, x, y, z);
} else if (Egg.class.isAssignableFrom(clazz)) {
entity = new EntityEgg(world, x, y, z);
} else if (EnderPearl.class.isAssignableFrom(clazz)) {
entity = new EntityEnderPearl(world, x, y, z);
} else if (Arrow.class.isAssignableFrom(clazz)) {
entity = new EntityArrow(world);
entity.setPositionRotation(x, y, z, 0, 0);
@ -946,7 +947,7 @@ public class CraftWorld implements World {
entity = new EntityExperienceOrb(world, x, y, z, 0);
} else if (Weather.class.isAssignableFrom(clazz)) {
// not sure what this can do
entity = new EntityWeatherLighting(world, x, y, z);
entity = new EntityLightning(world, x, y, z);
} else if (LightningStrike.class.isAssignableFrom(clazz)) {
// what is this, I don't even
} else if (Fish.class.isAssignableFrom(clazz)) {

View file

@ -38,10 +38,15 @@ public class Main {
.ofType(String.class)
.describedAs("Hostname or IP");
acceptsAll(asList("w", "world", "level-name"), "World directory")
acceptsAll(asList("W", "world-dir", "universe", "world-container"), "World container")
.withRequiredArg()
.ofType(File.class)
.describedAs("Directory containing worlds");
acceptsAll(asList("w", "world", "level-name"), "World name")
.withRequiredArg()
.ofType(String.class)
.describedAs("World dir");
.describedAs("World name");
acceptsAll(asList("p", "port", "server-port"), "Port to listen on")
.withRequiredArg()
@ -100,6 +105,8 @@ public class Main {
acceptsAll(asList("noconsole"), "Disables the console");
acceptsAll(asList("v", "version"), "Show the CraftBukkit Version");
acceptsAll(asList("demo"), "Demo mode");
}
};

View file

@ -87,7 +87,7 @@ public class PortalTravelAgent implements TravelAgent {
for (int k1 = i1 - this.searchRadius; k1 <= i1 + this.searchRadius; ++k1) {
double d3 = (double) k1 + 0.5D - location.getZ();
for (int l1 = 127; l1 >= 0; --l1) {
for (int l1 = world.L() - 1; l1 >= 0; --l1) {
if (world.getTypeId(j1, l1, k1) == Block.PORTAL.id) {
while (world.getTypeId(j1, l1 - 1, k1) == Block.PORTAL.id) {
--l1;
@ -194,7 +194,7 @@ public class PortalTravelAgent implements TravelAgent {
d2 = (double) j2 + 0.5D - location.getZ();
label271:
for (l2 = 127; l2 >= 0; --l2) {
for (l2 = world.L() - 1; l2 >= 0; --l2) {
if (world.isEmpty(i2, l2, j2)) {
while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) {
--l2;
@ -245,7 +245,7 @@ public class PortalTravelAgent implements TravelAgent {
d2 = (double) j2 + 0.5D - location.getZ();
label219:
for (l2 = 127; l2 >= 0; --l2) {
for (l2 = world.L() - 1; l2 >= 0; --l2) {
if (world.isEmpty(i2, l2, j2)) {
while (l2 > 0 && world.isEmpty(i2, l2 - 1, j2)) {
--l2;
@ -306,8 +306,8 @@ public class PortalTravelAgent implements TravelAgent {
i1 = 70;
}
if (i1 > 118) {
i1 = 118;
if (i1 > world.L() - 10) {
i1 = world.L() - 10;
}
j5 = i1;

View file

@ -54,7 +54,7 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
synchronized (block) {
if (block.getType() == Material.NOTE_BLOCK) {
world.getHandle().playNote(getX(), getY(), getZ(), instrument, note);
world.getHandle().playNote(getX(), getY(), getZ(), block.getTypeId(), instrument, note);
return true;
} else {
return false;
@ -67,7 +67,7 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
synchronized (block) {
if (block.getType() == Material.NOTE_BLOCK) {
world.getHandle().playNote(getX(), getY(), getZ(), instrument.getType(), note.getId());
world.getHandle().playNote(getX(), getY(), getZ(), block.getTypeId(), instrument.getType(), note.getId());
return true;
} else {
return false;

View file

@ -3,6 +3,7 @@ package org.bukkit.craftbukkit.command;
import java.lang.reflect.Method;
import net.minecraft.server.ICommandListener;
import net.minecraft.server.LocaleLanguage;
import org.bukkit.command.CommandSender;
@ -33,4 +34,12 @@ public class ServerCommandListener implements ICommandListener {
return this.prefix;
}
public String a(String s, Object... aobject) {
return LocaleLanguage.a().a(s, aobject);
}
public boolean b(String s) {
return true;
}
}

View file

@ -124,7 +124,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else if (entity instanceof EntityFishingHook) { return new CraftFish(server, (EntityFishingHook) entity); }
else if (entity instanceof EntityItem) { return new CraftItem(server, (EntityItem) entity); }
else if (entity instanceof EntityWeather) {
if (entity instanceof EntityWeatherLighting) { return new CraftLightningStrike(server, (EntityWeatherLighting) entity); }
if (entity instanceof EntityLightning) { return new CraftLightningStrike(server, (EntityLightning) entity); }
else { return new CraftWeather(server, (EntityWeather) entity); }
}
else if (entity instanceof EntityMinecart) {

View file

@ -301,7 +301,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
}
public boolean isBlocking() {
return getHandle().P();
return getHandle().aY();
}
public boolean setWindowProperty(InventoryView.Property prop, int value) {

View file

@ -21,11 +21,11 @@ public class CraftIronGolem extends CraftGolem implements IronGolem {
}
public boolean isPlayerCreated() {
return getHandle().n_();
return getHandle().q();
}
public void setPlayerCreated(boolean playerCreated) {
getHandle().b(playerCreated);
getHandle().f(playerCreated);
}
@Override

View file

@ -1,22 +1,22 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityWeatherLighting;
import net.minecraft.server.EntityLightning;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LightningStrike;
public class CraftLightningStrike extends CraftEntity implements LightningStrike {
public CraftLightningStrike(final CraftServer server, final EntityWeatherLighting entity) {
public CraftLightningStrike(final CraftServer server, final EntityLightning entity) {
super(server, entity);
}
public boolean isEffect() {
return ((EntityWeatherLighting) super.getHandle()).isEffect;
return ((EntityLightning) super.getHandle()).isEffect;
}
@Override
public EntityWeatherLighting getHandle() {
return (EntityWeatherLighting) entity;
public EntityLightning getHandle() {
return (EntityLightning) entity;
}
@Override

View file

@ -244,7 +244,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public void removePotionEffect(PotionEffectType type) {
getHandle().effects.remove(type.getId());
getHandle().e = true; // Should be called updateEffects
getHandle().updateEffects = true;
if (getHandle() instanceof EntityPlayer) {
if (((EntityPlayer) getHandle()).netServerHandler == null) return;
((EntityPlayer) getHandle()).netServerHandler.sendPacket(new Packet42RemoveMobEffect(getHandle().id, new MobEffect(type.getId(), 0, 0)));
@ -300,6 +300,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
public boolean hasLineOfSight(Entity other) {
return getHandle().am().canSee(((CraftEntity) other).getHandle()); // am should be getEntitySenses
return getHandle().at().canSee(((CraftEntity) other).getHandle()); // am should be getEntitySenses
}
}

View file

@ -239,13 +239,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void playNote(Location loc, byte instrument, byte note) {
if (getHandle().netServerHandler == null) return;
getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), instrument, note));
int id = getHandle().world.getTypeId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument, note));
}
public void playNote(Location loc, Instrument instrument, Note note) {
if (getHandle().netServerHandler == null) return;
getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), instrument.getType(), note.getId()));
int id = getHandle().world.getTypeId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument.getType(), note.getId()));
}
public void playEffect(Location loc, Effect effect, int data) {
@ -368,7 +370,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public void setSneaking(boolean sneak) {
getHandle().setSneak(sneak);
getHandle().setSneaking(sneak);
}
public boolean isSneaking() {
@ -470,15 +472,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
public boolean isBanned() {
return server.getHandle().banByName.contains(getName().toLowerCase());
return server.getHandle().getNameBans().isBanned(getName().toLowerCase());
}
public void setBanned(boolean value) {
if (value) {
server.getHandle().addUserBan(getName().toLowerCase());
BanEntry entry = new BanEntry(getName().toLowerCase());
server.getHandle().getNameBans().add(entry);
} else {
server.getHandle().removeUserBan(getName().toLowerCase());
server.getHandle().getNameBans().remove(getName().toLowerCase());
}
server.getHandle().getNameBans().save();
}
public boolean isWhitelisted() {
@ -508,14 +513,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return;
}
getHandle().itemInWorldManager.setGameMode(mode.getValue());
getHandle().itemInWorldManager.setGameMode(EnumGamemode.a(mode.getValue()));
getHandle().netServerHandler.sendPacket(new Packet70Bed(3, mode.getValue()));
}
}
@Override
public GameMode getGameMode() {
return GameMode.getByValue(getHandle().itemInWorldManager.getGameMode());
return GameMode.getByValue(getHandle().itemInWorldManager.getGameMode().a());
}
public void giveExp(int exp) {

View file

@ -63,7 +63,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
if (xbtypes != null) {
chunk = new Chunk(this.world, x, z);
ChunkSection[] csect = chunk.h();
ChunkSection[] csect = chunk.i();
int scnt = Math.min(csect.length, xbtypes.length);
// Loop through returned sections
@ -100,7 +100,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
if (btypes != null) {
chunk = new Chunk(this.world, x, z);
ChunkSection[] csect = chunk.h();
ChunkSection[] csect = chunk.i();
int scnt = Math.min(csect.length, btypes.length);
for (int sec = 0; sec < scnt; sec++) {
@ -118,7 +118,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
chunk = new Chunk(this.world, x, z); // Create empty chunk
ChunkSection[] csect = chunk.h();
ChunkSection[] csect = chunk.i();
scnt = Math.min(scnt, csect.length);
// Loop through sections
@ -153,7 +153,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
}
}
// Set biome grid
byte[] biomeIndex = chunk.l();
byte[] biomeIndex = chunk.m();
for (int i = 0; i < biomeIndex.length; i++) {
biomeIndex[i] = (byte) (biomegrid.biome[i].id & 0xFF);
}
@ -215,4 +215,12 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
public ChunkPosition findNearestMapFeature(World world, String type, int x, int y, int z) {
return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, x, y, z) : null;
}
public int getLoadedChunks() {
return 0;
}
public String getName() {
return "CustomChunkGenerator";
}
}

View file

@ -68,4 +68,12 @@ public class NormalChunkGenerator extends InternalChunkGenerator {
public ChunkPosition findNearestMapFeature(World world, String string, int i, int i1, int i2) {
return provider.findNearestMapFeature(world, string, i, i1, i2);
}
public int getLoadedChunks() {
return 0;
}
public String getName() {
return "NormalWorldGenerator";
}
}

View file

@ -79,8 +79,8 @@ public class CraftContainer extends Container {
int type = getNotchInventoryType(cachedType);
IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
this.d.clear();
this.e.clear();
this.a.clear();
this.b.clear();
if (typeChanged) {
setupSlots(top, bottom);
}
@ -275,4 +275,7 @@ public class CraftContainer extends Container {
// End copy from ContainerBrewingStand
}
public boolean c(EntityHuman entity) {
return true;
}
}

View file

@ -1,6 +1,6 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.FurnaceRecipes;
import net.minecraft.server.RecipesFurnace;
import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack;
@ -20,6 +20,6 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe {
public void addToCraftingManager() {
ItemStack result = this.getResult();
ItemStack input = this.getInput();
FurnaceRecipes.getInstance().registerRecipe(input.getTypeId(), CraftItemStack.createNMSItemStack(result));
RecipesFurnace.getInstance().registerRecipe(input.getTypeId(), CraftItemStack.createNMSItemStack(result), 0.1f);
}
}

View file

@ -1,6 +1,5 @@
package org.bukkit.craftbukkit.inventory;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
@ -8,6 +7,8 @@ import java.util.ListIterator;
import net.minecraft.server.ContainerEnchantTableInventory;
import net.minecraft.server.IInventory;
import net.minecraft.server.InventoryCrafting;
import net.minecraft.server.InventoryEnderChest;
import net.minecraft.server.InventoryMerchant;
import net.minecraft.server.PlayerInventory;
import net.minecraft.server.TileEntityBrewingStand;
import net.minecraft.server.TileEntityDispenser;
@ -411,6 +412,10 @@ public class CraftInventory implements Inventory {
return InventoryType.BREWING;
} else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) {
return ((CraftInventoryCustom.MinecraftInventory) inventory).getType();
} else if (inventory instanceof InventoryEnderChest) {
return InventoryType.ENDER_CHEST;
} else if (inventory instanceof InventoryMerchant) {
return InventoryType.MERCHANT;
} else {
return InventoryType.CHEST;
}

View file

@ -1,6 +1,6 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.CraftingRecipe;
import net.minecraft.server.IRecipe;
import net.minecraft.server.IInventory;
import net.minecraft.server.InventoryCrafting;
@ -132,7 +132,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
}
public Recipe getRecipe() {
CraftingRecipe recipe = ((InventoryCrafting)getInventory()).currentRecipe;
IRecipe recipe = ((InventoryCrafting)getInventory()).currentRecipe;
return recipe == null ? null : recipe.toBukkitRecipe();
}
}

View file

@ -139,5 +139,7 @@ public class CraftInventoryCustom extends CraftInventory {
public InventoryHolder getOwner() {
return owner;
}
public void startOpen() {}
}
}

View file

@ -0,0 +1,10 @@
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.InventoryMerchant;
import org.bukkit.inventory.MerchantInventory;
public class CraftInventoryMerchant extends CraftInventory implements MerchantInventory {
public CraftInventoryMerchant(InventoryMerchant merchant) {
super(merchant);
}
}

View file

@ -228,6 +228,8 @@ public class CraftItemStack extends ItemStack {
public static net.minecraft.server.ItemStack createNMSItemStack(ItemStack original) {
if (original == null || original.getTypeId() <= 0) {
return null;
} else if (original instanceof CraftItemStack) {
return ((CraftItemStack) original).getHandle();
}
return new CraftItemStack(original).getHandle();
}

View file

@ -6,17 +6,17 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import net.minecraft.server.CraftingManager;
import net.minecraft.server.CraftingRecipe;
import net.minecraft.server.FurnaceRecipes;
import net.minecraft.server.IRecipe;
import net.minecraft.server.RecipesFurnace;
public class RecipeIterator implements Iterator<Recipe> {
private Iterator<CraftingRecipe> recipes;
private Iterator<IRecipe> recipes;
private Iterator<Integer> smelting;
private Iterator<?> removeFrom = null;
public RecipeIterator() {
this.recipes = CraftingManager.getInstance().getRecipies().iterator();
this.smelting = FurnaceRecipes.getInstance().getRecipies().keySet().iterator();
this.recipes = CraftingManager.getInstance().getRecipes().iterator();
this.smelting = RecipesFurnace.getInstance().getRecipes().keySet().iterator();
}
public boolean hasNext() {
@ -34,7 +34,7 @@ public class RecipeIterator implements Iterator<Recipe> {
} else {
removeFrom = smelting;
int id = smelting.next();
CraftItemStack stack = new CraftItemStack(FurnaceRecipes.getInstance().getResult(id));
CraftItemStack stack = new CraftItemStack(RecipesFurnace.getInstance().getResult(id));
CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(stack, new ItemStack(id, 1, (short) -1));
return recipe;
}

View file

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.util;
import net.minecraft.server.ExceptionWorldConflict;
import net.minecraft.server.MinecraftServer;
public class ServerShutdownThread extends Thread {
@ -11,6 +12,15 @@ public class ServerShutdownThread extends Thread {
@Override
public void run() {
server.stop();
try {
server.stop();
} catch (ExceptionWorldConflict ex) {
ex.printStackTrace();
} finally {
try {
server.reader.getTerminal().restore();
} catch (Exception e) {
}
}
}
}