FlamePaper patches + Upgrade netty

This commit is contained in:
beaness 2022-06-24 19:14:59 +02:00
parent e48bcb5e7a
commit ba3cdc59cc
18 changed files with 978 additions and 198 deletions

View File

@ -38,7 +38,7 @@
<dependency> <dependency>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
<artifactId>netty-all</artifactId> <artifactId>netty-all</artifactId>
<version>4.0.23.Final</version> <version>4.1.78.Final</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -48,7 +48,12 @@ public class BlockChest extends BlockContainer {
for (EnumDirection enumdirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) { for (EnumDirection enumdirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
BlockPosition blockposition1 = blockposition.shift(enumdirection); BlockPosition blockposition1 = blockposition.shift(enumdirection);
IBlockData iblockdata1 = world.getType(blockposition1); // FlamePaper start - Dont load chunks for chests
final IBlockData iblockdata1 = world.isLoaded(blockposition1) ? world.getType(blockposition1) : null;
if (iblockdata1 == null) {
continue;
}
// FlamePaper end
if (iblockdata1.getBlock() == this) { if (iblockdata1.getBlock() == this) {
this.e(world, blockposition1, iblockdata1); this.e(world, blockposition1, iblockdata1);

View File

@ -1491,4 +1491,15 @@ public class Chunk {
private EnumTileEntityState() {} private EnumTileEntityState() {}
} }
// FlamePaper start - Hopper item lookup optimization
public int getItemCount(BlockPosition blockPosition) {
int k = MathHelper.floor(blockPosition.getY() / 16.0D);
k = Math.max(0, k);
k = Math.min(this.entitySlices.length - 1, k);
return itemCounts[k];
}
// FlamePaper end - Hopper item lookup optimization
} }

View File

@ -264,7 +264,7 @@ public class ChunkProviderServer implements IChunkProvider {
} }
public void saveChunkNOP(Chunk chunk) { public void saveChunkNOP(Chunk chunk) {
if (this.chunkLoader != null) { if (canSave() && this.chunkLoader != null) {
try { try {
this.chunkLoader.b(this.world, chunk); this.chunkLoader.b(this.world, chunk);
} catch (Exception exception) { } catch (Exception exception) {
@ -275,7 +275,7 @@ public class ChunkProviderServer implements IChunkProvider {
} }
public void saveChunk(Chunk chunk) { public void saveChunk(Chunk chunk) {
if (this.chunkLoader != null) { if (canSave() && this.chunkLoader != null) {
try { try {
chunk.setLastSaved(this.world.getTime()); chunk.setLastSaved(this.world.getTime());
this.chunkLoader.a(this.world, chunk); this.chunkLoader.a(this.world, chunk);
@ -410,8 +410,8 @@ public class ChunkProviderServer implements IChunkProvider {
} }
// SportPaper end // SportPaper end
public boolean unloadChunks() { public boolean unloadChunks(boolean force) {
if (!this.world.savingDisabled) { if (canSave() || force) {
// CraftBukkit start // CraftBukkit start
Server server = this.world.getServer(); Server server = this.world.getServer();
// SportPaper start // SportPaper start
@ -434,6 +434,10 @@ public class ChunkProviderServer implements IChunkProvider {
return this.chunkProvider.unloadChunks(); return this.chunkProvider.unloadChunks();
} }
public boolean unloadChunks() {
return unloadChunks(false);
}
public boolean canSave() { public boolean canSave() {
return !this.world.savingDisabled; return !this.world.savingDisabled;
} }

View File

@ -106,6 +106,11 @@ public abstract class Container {
} }
public Slot getSlot(int i) { public Slot getSlot(int i) {
final int lastIndex = this.c.size() - 1;
if (i > lastIndex) {
i = lastIndex;
}
return this.c.get(i); return this.c.get(i);
} }

View File

@ -463,6 +463,12 @@ public abstract class Entity implements ICommandListener {
public void move(double d0, double d1, double d2) { public void move(double d0, double d1, double d2) {
if (this.loadChunks) loadChunks(); // PaperSpigot - Load chunks if (this.loadChunks) loadChunks(); // PaperSpigot - Load chunks
// FlamePaper start - Disable Unloaded Chunk Movement
if (!world.chunkProvider.isChunkLoaded((int) locX >> 4, (int) locZ >> 4)) {
this.a(this.getBoundingBox().c(d0, d1, d2));
this.recalcPosition();
} else
// FlamePaper end - Disable Unloaded Chunk Movement
if (this.noclip) { if (this.noclip) {
this.a(this.getBoundingBox().c(d0, d1, d2)); this.a(this.getBoundingBox().c(d0, d1, d2));
this.recalcPosition(); this.recalcPosition();

View File

@ -0,0 +1,299 @@
package net.minecraft.server;
import java.lang.reflect.Type;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
public interface IChatBaseComponent extends Iterable<IChatBaseComponent> {
IChatBaseComponent setChatModifier(ChatModifier chatmodifier);
ChatModifier getChatModifier();
IChatBaseComponent a(String s);
IChatBaseComponent addSibling(IChatBaseComponent ichatbasecomponent);
String getText();
String c();
List<IChatBaseComponent> a();
IChatBaseComponent f();
class ChatSerializer implements JsonDeserializer<IChatBaseComponent>, JsonSerializer<IChatBaseComponent> {
private static final int CHATCOMPONENT_LIMIT = 128;
private static final Gson a;
public ChatSerializer() {}
public IChatBaseComponent a(int extraCount, String lastElement, JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
if (jsonelement.isJsonPrimitive()) {
return new ChatComponentText(jsonelement.getAsString());
} else if (!jsonelement.isJsonObject()) {
if (jsonelement.isJsonArray()) {
JsonArray jsonarray = jsonelement.getAsJsonArray();
// FlamePaper start - Limit ChatComponents
if (jsonarray.size() > CHATCOMPONENT_LIMIT) {
throw new JsonParseException("Too many ChatComponent array elements");
}
// FlamePaper end - Limit Chatcomponents
IChatBaseComponent ichatbasecomponent = null;
Iterator iterator = jsonarray.iterator();
while (iterator.hasNext()) {
JsonElement jsonelement1 = (JsonElement) iterator.next();
// FlamePaper start - Limit ChatComponents
if (jsonelement1.isJsonArray()) {
throw new JsonParseException("Stacked ChatComponent array");
}
// FlamePaper end - Limit Chatcomponents
IChatBaseComponent ichatbasecomponent1 = this.a(jsonelement1, (Type) jsonelement1.getClass(), jsondeserializationcontext);
if (ichatbasecomponent == null) {
ichatbasecomponent = ichatbasecomponent1;
} else {
ichatbasecomponent.addSibling(ichatbasecomponent1);
}
}
return ichatbasecomponent;
} else {
throw new JsonParseException("Don\'t know how to turn " + jsonelement.toString() + " into a Component");
}
} else {
JsonObject jsonobject = jsonelement.getAsJsonObject();
Object object;
if (jsonobject.has("text")) {
object = new ChatComponentText(jsonobject.get("text").getAsString());
} else if (jsonobject.has("translate")) {
String s = jsonobject.get("translate").getAsString();
if (jsonobject.has("with")) {
JsonArray jsonarray1 = jsonobject.getAsJsonArray("with");
// FlamePaper start - Limit ChatComponents
if (jsonarray1.size() > CHATCOMPONENT_LIMIT) {
throw new JsonParseException("Too many ChatComponent array elements in with");
}
// FlamePaper end - Limit Chatcomponents
// FlamePaper start - Limit ChatComponents
if (lastElement != null && lastElement.equals("with")) {
throw new JsonParseException("Stacked with ChatComponent elements");
}
// FlamePaper end - Limit Chatcomponents
Object[] aobject = new Object[jsonarray1.size()];
for (int i = 0; i < aobject.length; ++i) {
// FlamePaper start - Limit ChatComponents
if (jsonarray1.get(i).isJsonArray()) {
throw new JsonParseException("Stacked ChatComponent array in with element");
}
// FlamePaper end - Limit Chatcomponents
aobject[i] = this.a(extraCount, "with", jsonarray1.get(i), type, jsondeserializationcontext);
if (aobject[i] instanceof ChatComponentText) {
ChatComponentText chatcomponenttext = (ChatComponentText) aobject[i];
if (chatcomponenttext.getChatModifier().g() && chatcomponenttext.a().isEmpty()) {
aobject[i] = chatcomponenttext.g();
}
}
}
object = new ChatMessage(s, aobject);
} else {
object = new ChatMessage(s, new Object[0]);
}
} else if (jsonobject.has("score")) {
JsonObject jsonobject1 = jsonobject.getAsJsonObject("score");
if (!jsonobject1.has("name") || !jsonobject1.has("objective")) {
throw new JsonParseException("A score component needs a least a name and an objective");
}
object = new ChatComponentScore(ChatDeserializer.h(jsonobject1, "name"), ChatDeserializer.h(jsonobject1, "objective"));
if (jsonobject1.has("value")) {
((ChatComponentScore) object).b(ChatDeserializer.h(jsonobject1, "value"));
}
} else {
if (!jsonobject.has("selector")) {
throw new JsonParseException("Don\'t know how to turn " + jsonelement.toString() + " into a Component");
}
object = new ChatComponentSelector(ChatDeserializer.h(jsonobject, "selector"));
}
if (jsonobject.has("extra")) {
JsonArray jsonarray2 = jsonobject.getAsJsonArray("extra");
// FlamePaper start - Limit ChatComponents
if (jsonarray2.size() > CHATCOMPONENT_LIMIT) {
throw new JsonParseException("Too many ChatComponent array elements in extra");
}
// FlamePaper end - Limit Chatcomponents
// FlamePaper start - Limit ChatComponents
if (extraCount > CHATCOMPONENT_LIMIT) {
throw new JsonParseException("Too many stacked extra ChatComponent elements");
}
// FlamePaper end - Limit Chatcomponents
if (jsonarray2.size() <= 0) {
throw new JsonParseException("Unexpected empty array of components");
}
for (int j = 0; j < jsonarray2.size(); ++j) {
// FlamePaper start - Limit ChatComponents
if (jsonarray2.get(j).isJsonArray()) {
throw new JsonParseException("Stacked ChatComponent array in extra element");
}
// FlamePaper end - Limit Chatcomponents
((IChatBaseComponent) object).addSibling(this.a(++extraCount, "extra", jsonarray2.get(j), type, jsondeserializationcontext));
}
}
((IChatBaseComponent) object).setChatModifier((ChatModifier) jsondeserializationcontext.deserialize(jsonelement, ChatModifier.class));
return (IChatBaseComponent) object;
}
}
public IChatBaseComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
return a(0, null, jsonelement, type, jsondeserializationcontext);
}
private void a(ChatModifier chatmodifier, JsonObject jsonobject, JsonSerializationContext jsonserializationcontext) {
JsonElement jsonelement = jsonserializationcontext.serialize(chatmodifier);
if (jsonelement.isJsonObject()) {
JsonObject jsonobject1 = (JsonObject) jsonelement;
Iterator iterator = jsonobject1.entrySet().iterator();
while (iterator.hasNext()) {
Entry entry = (Entry) iterator.next();
jsonobject.add((String) entry.getKey(), (JsonElement) entry.getValue());
}
}
}
public JsonElement a(IChatBaseComponent ichatbasecomponent, Type type, JsonSerializationContext jsonserializationcontext) {
if (ichatbasecomponent instanceof ChatComponentText && ichatbasecomponent.getChatModifier().g() && ichatbasecomponent.a().isEmpty()) {
return new JsonPrimitive(((ChatComponentText) ichatbasecomponent).g());
} else {
JsonObject jsonobject = new JsonObject();
if (!ichatbasecomponent.getChatModifier().g()) {
this.a(ichatbasecomponent.getChatModifier(), jsonobject, jsonserializationcontext);
}
if (!ichatbasecomponent.a().isEmpty()) {
JsonArray jsonarray = new JsonArray();
Iterator iterator = ichatbasecomponent.a().iterator();
while (iterator.hasNext()) {
IChatBaseComponent ichatbasecomponent1 = (IChatBaseComponent) iterator.next();
jsonarray.add(this.a(ichatbasecomponent1, (Type) ichatbasecomponent1.getClass(), jsonserializationcontext));
}
jsonobject.add("extra", jsonarray);
}
if (ichatbasecomponent instanceof ChatComponentText) {
jsonobject.addProperty("text", ((ChatComponentText) ichatbasecomponent).g());
} else if (ichatbasecomponent instanceof ChatMessage) {
ChatMessage chatmessage = (ChatMessage) ichatbasecomponent;
jsonobject.addProperty("translate", chatmessage.i());
if (chatmessage.j() != null && chatmessage.j().length > 0) {
JsonArray jsonarray1 = new JsonArray();
Object[] aobject = chatmessage.j();
int i = aobject.length;
for (int j = 0; j < i; ++j) {
Object object = aobject[j];
if (object instanceof IChatBaseComponent) {
jsonarray1.add(this.a((IChatBaseComponent) object, (Type) object.getClass(), jsonserializationcontext));
} else {
jsonarray1.add(new JsonPrimitive(String.valueOf(object)));
}
}
jsonobject.add("with", jsonarray1);
}
} else if (ichatbasecomponent instanceof ChatComponentScore) {
ChatComponentScore chatcomponentscore = (ChatComponentScore) ichatbasecomponent;
JsonObject jsonobject1 = new JsonObject();
jsonobject1.addProperty("name", chatcomponentscore.g());
jsonobject1.addProperty("objective", chatcomponentscore.h());
jsonobject1.addProperty("value", chatcomponentscore.getText());
jsonobject.add("score", jsonobject1);
} else {
if (!(ichatbasecomponent instanceof ChatComponentSelector)) {
throw new IllegalArgumentException("Don\'t know how to serialize " + ichatbasecomponent + " as a Component");
}
ChatComponentSelector chatcomponentselector = (ChatComponentSelector) ichatbasecomponent;
jsonobject.addProperty("selector", chatcomponentselector.g());
}
return jsonobject;
}
}
public static String a(IChatBaseComponent ichatbasecomponent) {
return IChatBaseComponent.ChatSerializer.a.toJson(ichatbasecomponent);
}
public static IChatBaseComponent a(String s) {
return (IChatBaseComponent) IChatBaseComponent.ChatSerializer.a.fromJson(s, IChatBaseComponent.class);
}
@Override
public JsonElement serialize(IChatBaseComponent object, Type type, JsonSerializationContext jsonserializationcontext) {
return this.a((IChatBaseComponent) object, type, jsonserializationcontext);
}
@Override
public IChatBaseComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
return this.a(jsonelement, type, jsondeserializationcontext);
}
static {
GsonBuilder gsonbuilder = new GsonBuilder();
gsonbuilder.registerTypeHierarchyAdapter(IChatBaseComponent.class, new IChatBaseComponent.ChatSerializer());
gsonbuilder.registerTypeHierarchyAdapter(ChatModifier.class, new ChatModifier.ChatModifierSerializer());
gsonbuilder.registerTypeAdapterFactory(new ChatTypeAdapterFactory());
a = gsonbuilder.create();
}
}
}

View File

@ -154,6 +154,18 @@ public final class ItemStack {
org.bukkit.event.block.BlockPlaceEvent placeEvent = null; org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone(); List<BlockState> blocks = (List<BlockState>) world.capturedBlockStates.clone();
world.capturedBlockStates.clear(); world.capturedBlockStates.clear();
// FlamePaper start - Disable Nether Roof Interaction
if (world.getWorld().getEnvironment() == org.bukkit.World.Environment.NETHER) {
for (BlockState block : blocks) {
if (block.getY() >= 127) {
entityhuman.getBukkitEntity().sendMessage(org.bukkit.ChatColor.translateAlternateColorCodes('&', "&cCan't build on nether roof"));
return false;
}
}
}
// FlamePaper end - Disable Nether Roof Interaction
if (blocks.size() > 1) { if (blocks.size() > 1) {
placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ()); placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(world, entityhuman, blocks, blockposition.getX(), blockposition.getY(), blockposition.getZ());
} else if (blocks.size() == 1) { } else if (blocks.size() == 1) {

View File

@ -0,0 +1,117 @@
package net.minecraft.server;
import com.google.common.base.Charsets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import java.net.InetSocketAddress;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class LegacyPingHandler extends ChannelInboundHandlerAdapter {
private static final Logger a = LogManager.getLogger();
private ServerConnection b;
public LegacyPingHandler(ServerConnection serverconnection) {
this.b = serverconnection;
}
public void channelRead(ChannelHandlerContext channelhandlercontext, Object object) throws Exception {
ByteBuf bytebuf = (ByteBuf) object;
bytebuf.markReaderIndex();
boolean flag = true;
try {
if (bytebuf.readUnsignedByte() == 254) {
InetSocketAddress inetsocketaddress = (InetSocketAddress) channelhandlercontext.channel().remoteAddress();
MinecraftServer minecraftserver = this.b.d();
int i = bytebuf.readableBytes();
String s;
switch (i) {
case 0:
LegacyPingHandler.a.debug("Ping: (<1.3.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
s = String.format("%s\u00a7%d\u00a7%d", minecraftserver.getMotd(), minecraftserver.I(), minecraftserver.J());
this.a(channelhandlercontext, this.a(s));
break;
case 1:
if (bytebuf.readUnsignedByte() != 1) {
return;
}
LegacyPingHandler.a.debug("Ping: (1.4-1.5.x) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), minecraftserver.getMotd(), minecraftserver.I(), minecraftserver.J());
this.a(channelhandlercontext, this.a(s));
break;
default:
boolean flag1 = bytebuf.readUnsignedByte() == 1;
flag1 &= bytebuf.readUnsignedByte() == 250;
flag1 &= "MC|PingHost".equals(new String(bytebuf.readBytes(bytebuf.readShort() * 2).array(), Charsets.UTF_16BE));
int j = bytebuf.readUnsignedShort();
flag1 &= bytebuf.readUnsignedByte() >= 73;
flag1 &= 3 + bytebuf.readBytes(bytebuf.readShort() * 2).array().length + 4 == j;
flag1 &= bytebuf.readInt() <= '\uffff';
flag1 &= bytebuf.readableBytes() == 0;
if (!flag1) {
return;
}
LegacyPingHandler.a.debug("Ping: (1.6) from {}:{}", inetsocketaddress.getAddress(), inetsocketaddress.getPort());
String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", 127, minecraftserver.getVersion(), minecraftserver.getMotd(), minecraftserver.I(), minecraftserver.J());
ByteBuf bytebuf1 = this.a(s1);
try {
this.a(channelhandlercontext, bytebuf1);
} finally {
bytebuf1.release();
}
}
bytebuf.release();
flag = false;
return;
}
} catch (RuntimeException runtimeexception) {
return;
} finally {
if (flag) {
bytebuf.resetReaderIndex();
channelhandlercontext.channel().pipeline().remove("legacy_query");
channelhandlercontext.fireChannelRead(object);
}
}
}
private void a(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf) {
channelhandlercontext.pipeline().firstContext().writeAndFlush(bytebuf).addListener(ChannelFutureListener.CLOSE);
}
private ByteBuf a(String s) {
ByteBuf bytebuf = Unpooled.buffer();
bytebuf.writeByte(255);
char[] achar = s.toCharArray();
bytebuf.writeShort(achar.length);
char[] achar1 = achar;
int i = achar.length;
for (int j = 0; j < i; ++j) {
char c0 = achar1[j];
bytebuf.writeChar(c0);
}
return bytebuf;
}
}

View File

@ -166,7 +166,8 @@ public class LoginListener implements PacketLoginInListener, IUpdatePlayerListBo
} }
public String d() { public String d() {
return this.i != null ? this.i + " (" + this.networkManager.getSocketAddress().toString() + ")" : String.valueOf(this.networkManager.getSocketAddress()); String socketAddress = networkManager == null ? null : (networkManager.getSocketAddress() == null ? null : networkManager.getSocketAddress().toString());
return this.i != null ? this.i.toString() + " (" + socketAddress + ")" : socketAddress;
} }
public void a(PacketLoginInStart packetlogininstart) { public void a(PacketLoginInStart packetlogininstart) {

View File

@ -514,47 +514,12 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
} }
protected void k() { protected void k() {
boolean flag = true;
boolean flag1 = true;
boolean flag2 = true;
boolean flag3 = true;
int i = 0;
this.b("menu.generatingTerrain"); this.b("menu.generatingTerrain");
byte b0 = 0;
// CraftBukkit start - fire WorldLoadEvent and handle whether or not to keep the spawn in memory
for (int m = 0; m < worlds.size(); m++) {
WorldServer worldserver = this.worlds.get(m);
LOGGER.info("Preparing start region for level " + m + " (Seed: " + worldserver.getSeed() + ")");
if (!worldserver.getWorld().getKeepSpawnInMemory()) {
continue;
}
BlockPosition blockposition = worldserver.getSpawn();
long j = az();
i = 0;
for (int k = -192; k <= 192 && this.isRunning(); k += 16) {
for (int l = -192; l <= 192 && this.isRunning(); l += 16) {
long i1 = az();
if (i1 - j > 1000L) {
this.a_("Preparing spawn area", i * 100 / 625);
j = i1;
}
++i;
worldserver.chunkProviderServer.getChunkAt(blockposition.getX() + k >> 4, blockposition.getZ() + l >> 4);
}
}
}
for (WorldServer world : this.worlds) { for (WorldServer world : this.worlds) {
this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld())); this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(world.getWorld()));
} }
// CraftBukkit end
this.s(); this.s();
} }
// PaperSpigot End // PaperSpigot End

View File

@ -127,12 +127,14 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
this.channel = channelhandlercontext.channel(); this.channel = channelhandlercontext.channel();
this.l = this.channel.remoteAddress(); this.l = this.channel.remoteAddress();
// eSpigot start // eSpigot start
this.channel.config().setOption(ChannelOption.SO_KEEPALIVE, true); ChannelConfig config = this.channel.config();
this.channel.config().setOption(ChannelOption.TCP_NODELAY, true); config.setOption(ChannelOption.SO_KEEPALIVE, true);
this.channel.config().setOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); config.setOption(ChannelOption.TCP_NODELAY, true);
this.channel.config().setOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 32 * 1024); config.setOption(ChannelOption.TCP_FASTOPEN, 1);
this.channel.config().setOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024); config.setOption(ChannelOption.TCP_FASTOPEN_CONNECT, true);
this.channel.config().setOption(ChannelOption.IP_TOS, 0x18); config.setOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
config.setOption(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024, 32 * 1024));
config.setOption(ChannelOption.IP_TOS, 0x18);
// eSpigot end // eSpigot end
// Spigot Start // Spigot Start
@ -478,7 +480,10 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
} }
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet object) throws Exception { // CraftBukkit - fix decompile error protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet object) throws Exception { // CraftBukkit - fix decompile error
this.a(channelhandlercontext, object); // FlamePaper - Check if channel is opened before reading packet
if (g()) {
this.a(channelhandlercontext, object);
}
} }
// Spigot Start // Spigot Start

View File

@ -16,11 +16,14 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.nio.channels.GatheringByteChannel; import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel; import java.nio.channels.ScatteringByteChannel;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.UUID; import java.util.UUID;
import io.netty.util.ByteProcessor;
import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
// TacoSpigot start // TacoSpigot start
import net.techcable.tacospigot.CompatHacks; import net.techcable.tacospigot.CompatHacks;
@ -185,7 +188,7 @@ public class PacketDataSerializer extends ByteBuf {
return null; return null;
} else { } else {
this.readerIndex(i); this.readerIndex(i);
return NBTCompressedStreamTools.a(new ByteBufInputStream(this), new NBTReadLimiter(2097152L)); return NBTCompressedStreamTools.a(new ByteBufInputStream(this), new NBTReadLimiter(64000L)); // FlamePaper - Reduce NBT read limit
} }
} }
@ -239,7 +242,8 @@ public class PacketDataSerializer extends ByteBuf {
} else if (j < 0) { } else if (j < 0) {
throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!"); throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!");
} else { } else {
String s = new String(this.readBytes(j).array(), Charsets.UTF_8); String s = toString(readerIndex(), j, StandardCharsets.UTF_8);
readerIndex(readerIndex() + j);
if (s.length() > i) { if (s.length() > i) {
throw new DecoderException("The received string length is longer than maximum allowed (" + j + " > " + i + ")"); throw new DecoderException("The received string length is longer than maximum allowed (" + j + " > " + i + ")");
@ -259,8 +263,8 @@ public class PacketDataSerializer extends ByteBuf {
throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!"); throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!");
} else { } else {
int len = Math.min(toRead, maxLength); int len = Math.min(toRead, maxLength);
String s = new String(this.readBytes(len).array(), Charsets.UTF_8); String s = toString(readerIndex(), len, StandardCharsets.UTF_8);
readerIndex(readerIndex() + len);
int remaining = toRead - len; int remaining = toRead - len;
if (remaining > 0) { if (remaining > 0) {
this.skipBytes(remaining); this.skipBytes(remaining);
@ -283,462 +287,761 @@ public class PacketDataSerializer extends ByteBuf {
} }
} }
@Override
public int capacity() { public int capacity() {
return this.a.capacity(); return this.a.capacity();
} }
@Override
public ByteBuf capacity(int i) { public ByteBuf capacity(int i) {
return this.a.capacity(i); return this.a.capacity(i);
} }
@Override
public int maxCapacity() { public int maxCapacity() {
return this.a.maxCapacity(); return this.a.maxCapacity();
} }
@Override
public ByteBufAllocator alloc() { public ByteBufAllocator alloc() {
return this.a.alloc(); return this.a.alloc();
} }
@Override
public ByteOrder order() { public ByteOrder order() {
return this.a.order(); return this.a.order();
} }
@Override
public ByteBuf order(ByteOrder byteorder) { public ByteBuf order(ByteOrder byteorder) {
return this.a.order(byteorder); return this.a.order(byteorder);
} }
@Override
public ByteBuf unwrap() { public ByteBuf unwrap() {
return this.a.unwrap(); return this.a.unwrap();
} }
@Override
public boolean isDirect() { public boolean isDirect() {
return this.a.isDirect(); return this.a.isDirect();
} }
@Override
public boolean isReadOnly() {
return this.a.isReadOnly();
}
@Override
public ByteBuf asReadOnly() {
return this.a.asReadOnly();
}
@Override
public int readerIndex() { public int readerIndex() {
return this.a.readerIndex(); return this.a.readerIndex();
} }
@Override
public ByteBuf readerIndex(int i) { public ByteBuf readerIndex(int i) {
return this.a.readerIndex(i); return this.a.readerIndex(i);
} }
@Override
public int writerIndex() { public int writerIndex() {
return this.a.writerIndex(); return this.a.writerIndex();
} }
@Override
public ByteBuf writerIndex(int i) { public ByteBuf writerIndex(int i) {
return this.a.writerIndex(i); return this.a.writerIndex(i);
} }
@Override
public ByteBuf setIndex(int i, int j) { public ByteBuf setIndex(int i, int j) {
return this.a.setIndex(i, j); return this.a.setIndex(i, j);
} }
@Override
public int readableBytes() { public int readableBytes() {
return this.a.readableBytes(); return this.a.readableBytes();
} }
@Override
public int writableBytes() { public int writableBytes() {
return this.a.writableBytes(); return this.a.writableBytes();
} }
@Override
public int maxWritableBytes() { public int maxWritableBytes() {
return this.a.maxWritableBytes(); return this.a.maxWritableBytes();
} }
@Override
public boolean isReadable() { public boolean isReadable() {
return this.a.isReadable(); return this.a.isReadable();
} }
@Override
public boolean isReadable(int i) { public boolean isReadable(int i) {
return this.a.isReadable(i); return this.a.isReadable(i);
} }
@Override
public boolean isWritable() { public boolean isWritable() {
return this.a.isWritable(); return this.a.isWritable();
} }
@Override
public boolean isWritable(int i) { public boolean isWritable(int i) {
return this.a.isWritable(i); return this.a.isWritable(i);
} }
@Override
public ByteBuf clear() { public ByteBuf clear() {
return this.a.clear(); return this.a.clear();
} }
@Override
public ByteBuf markReaderIndex() { public ByteBuf markReaderIndex() {
return this.a.markReaderIndex(); return this.a.markReaderIndex();
} }
@Override
public ByteBuf resetReaderIndex() { public ByteBuf resetReaderIndex() {
return this.a.resetReaderIndex(); return this.a.resetReaderIndex();
} }
@Override
public ByteBuf markWriterIndex() { public ByteBuf markWriterIndex() {
return this.a.markWriterIndex(); return this.a.markWriterIndex();
} }
@Override
public ByteBuf resetWriterIndex() { public ByteBuf resetWriterIndex() {
return this.a.resetWriterIndex(); return this.a.resetWriterIndex();
} }
@Override
public ByteBuf discardReadBytes() { public ByteBuf discardReadBytes() {
return this.a.discardReadBytes(); return this.a.discardReadBytes();
} }
@Override
public ByteBuf discardSomeReadBytes() { public ByteBuf discardSomeReadBytes() {
return this.a.discardSomeReadBytes(); return this.a.discardSomeReadBytes();
} }
@Override
public ByteBuf ensureWritable(int i) { public ByteBuf ensureWritable(int i) {
return this.a.ensureWritable(i); return this.a.ensureWritable(i);
} }
@Override
public int ensureWritable(int i, boolean flag) { public int ensureWritable(int i, boolean flag) {
return this.a.ensureWritable(i, flag); return this.a.ensureWritable(i, flag);
} }
@Override
public boolean getBoolean(int i) { public boolean getBoolean(int i) {
return this.a.getBoolean(i); return this.a.getBoolean(i);
} }
@Override
public byte getByte(int i) { public byte getByte(int i) {
return this.a.getByte(i); return this.a.getByte(i);
} }
@Override
public short getUnsignedByte(int i) { public short getUnsignedByte(int i) {
return this.a.getUnsignedByte(i); return this.a.getUnsignedByte(i);
} }
@Override
public short getShort(int i) { public short getShort(int i) {
return this.a.getShort(i); return this.a.getShort(i);
} }
@Override
public short getShortLE(int i) {
return this.a.getShortLE(i);
}
@Override
public int getUnsignedShort(int i) { public int getUnsignedShort(int i) {
return this.a.getUnsignedShort(i); return this.a.getUnsignedShort(i);
} }
@Override
public int getUnsignedShortLE(int i) {
return this.a.getUnsignedShortLE(i);
}
@Override
public int getMedium(int i) { public int getMedium(int i) {
return this.a.getMedium(i); return this.a.getMedium(i);
} }
@Override
public int getMediumLE(int i) {
return this.a.getMediumLE(i);
}
@Override
public int getUnsignedMedium(int i) { public int getUnsignedMedium(int i) {
return this.a.getUnsignedMedium(i); return this.a.getUnsignedMedium(i);
} }
@Override
public int getUnsignedMediumLE(int i) {
return this.a.getUnsignedMediumLE(i);
}
@Override
public int getInt(int i) { public int getInt(int i) {
return this.a.getInt(i); return this.a.getInt(i);
} }
@Override
public int getIntLE(int i) {
return this.a.getIntLE(i);
}
@Override
public long getUnsignedInt(int i) { public long getUnsignedInt(int i) {
return this.a.getUnsignedInt(i); return this.a.getUnsignedInt(i);
} }
@Override
public long getUnsignedIntLE(int i) {
return this.a.getUnsignedIntLE(i);
}
@Override
public long getLongLE(int i) {
return this.a.getLongLE(i);
}
@Override
public long getLong(int i) { public long getLong(int i) {
return this.a.getLong(i); return this.a.getLong(i);
} }
@Override
public char getChar(int i) { public char getChar(int i) {
return this.a.getChar(i); return this.a.getChar(i);
} }
@Override
public float getFloat(int i) { public float getFloat(int i) {
return this.a.getFloat(i); return this.a.getFloat(i);
} }
@Override
public double getDouble(int i) { public double getDouble(int i) {
return this.a.getDouble(i); return this.a.getDouble(i);
} }
@Override
public ByteBuf getBytes(int i, ByteBuf bytebuf) { public ByteBuf getBytes(int i, ByteBuf bytebuf) {
return this.a.getBytes(i, bytebuf); return this.a.getBytes(i, bytebuf);
} }
@Override
public ByteBuf getBytes(int i, ByteBuf bytebuf, int j) { public ByteBuf getBytes(int i, ByteBuf bytebuf, int j) {
return this.a.getBytes(i, bytebuf, j); return this.a.getBytes(i, bytebuf, j);
} }
@Override
public ByteBuf getBytes(int i, ByteBuf bytebuf, int j, int k) { public ByteBuf getBytes(int i, ByteBuf bytebuf, int j, int k) {
return this.a.getBytes(i, bytebuf, j, k); return this.a.getBytes(i, bytebuf, j, k);
} }
@Override
public ByteBuf getBytes(int i, byte[] abyte) { public ByteBuf getBytes(int i, byte[] abyte) {
return this.a.getBytes(i, abyte); return this.a.getBytes(i, abyte);
} }
@Override
public ByteBuf getBytes(int i, byte[] abyte, int j, int k) { public ByteBuf getBytes(int i, byte[] abyte, int j, int k) {
return this.a.getBytes(i, abyte, j, k); return this.a.getBytes(i, abyte, j, k);
} }
@Override
public ByteBuf getBytes(int i, ByteBuffer bytebuffer) { public ByteBuf getBytes(int i, ByteBuffer bytebuffer) {
return this.a.getBytes(i, bytebuffer); return this.a.getBytes(i, bytebuffer);
} }
@Override
public ByteBuf getBytes(int i, OutputStream outputstream, int j) throws IOException { public ByteBuf getBytes(int i, OutputStream outputstream, int j) throws IOException {
return this.a.getBytes(i, outputstream, j); return this.a.getBytes(i, outputstream, j);
} }
@Override
public int getBytes(int i, GatheringByteChannel gatheringbytechannel, int j) throws IOException { public int getBytes(int i, GatheringByteChannel gatheringbytechannel, int j) throws IOException {
return this.a.getBytes(i, gatheringbytechannel, j); return this.a.getBytes(i, gatheringbytechannel, j);
} }
@Override
public int getBytes(int i, FileChannel fileChannel, long l, int i1) throws IOException {
return this.a.getBytes(i, fileChannel, l, i1);
}
@Override
public CharSequence getCharSequence(int i, int j, Charset charset) {
return this.a.getCharSequence(i, j, charset);
}
@Override
public ByteBuf setBoolean(int i, boolean flag) { public ByteBuf setBoolean(int i, boolean flag) {
return this.a.setBoolean(i, flag); return this.a.setBoolean(i, flag);
} }
@Override
public ByteBuf setByte(int i, int j) { public ByteBuf setByte(int i, int j) {
return this.a.setByte(i, j); return this.a.setByte(i, j);
} }
@Override
public ByteBuf setShort(int i, int j) { public ByteBuf setShort(int i, int j) {
return this.a.setShort(i, j); return this.a.setShort(i, j);
} }
@Override
public ByteBuf setShortLE(int i, int j) {
return this.a.setShortLE(i, j);
}
@Override
public ByteBuf setMedium(int i, int j) { public ByteBuf setMedium(int i, int j) {
return this.a.setMedium(i, j); return this.a.setMedium(i, j);
} }
@Override
public ByteBuf setMediumLE(int i, int j) {
return this.a.setMediumLE(i, j);
}
@Override
public ByteBuf setInt(int i, int j) { public ByteBuf setInt(int i, int j) {
return this.a.setInt(i, j); return this.a.setInt(i, j);
} }
@Override
public ByteBuf setIntLE(int i, int j) {
return this.a.setIntLE(i, j);
}
@Override
public ByteBuf setLong(int i, long j) { public ByteBuf setLong(int i, long j) {
return this.a.setLong(i, j); return this.a.setLong(i, j);
} }
@Override
public ByteBuf setLongLE(int i, long j) {
return this.a.setLongLE(i, j);
}
@Override
public ByteBuf setChar(int i, int j) { public ByteBuf setChar(int i, int j) {
return this.a.setChar(i, j); return this.a.setChar(i, j);
} }
@Override
public ByteBuf setFloat(int i, float f) { public ByteBuf setFloat(int i, float f) {
return this.a.setFloat(i, f); return this.a.setFloat(i, f);
} }
@Override
public ByteBuf setDouble(int i, double d0) { public ByteBuf setDouble(int i, double d0) {
return this.a.setDouble(i, d0); return this.a.setDouble(i, d0);
} }
@Override
public ByteBuf setBytes(int i, ByteBuf bytebuf) { public ByteBuf setBytes(int i, ByteBuf bytebuf) {
return this.a.setBytes(i, bytebuf); return this.a.setBytes(i, bytebuf);
} }
@Override
public ByteBuf setBytes(int i, ByteBuf bytebuf, int j) { public ByteBuf setBytes(int i, ByteBuf bytebuf, int j) {
return this.a.setBytes(i, bytebuf, j); return this.a.setBytes(i, bytebuf, j);
} }
@Override
public ByteBuf setBytes(int i, ByteBuf bytebuf, int j, int k) { public ByteBuf setBytes(int i, ByteBuf bytebuf, int j, int k) {
return this.a.setBytes(i, bytebuf, j, k); return this.a.setBytes(i, bytebuf, j, k);
} }
@Override
public ByteBuf setBytes(int i, byte[] abyte) { public ByteBuf setBytes(int i, byte[] abyte) {
return this.a.setBytes(i, abyte); return this.a.setBytes(i, abyte);
} }
@Override
public ByteBuf setBytes(int i, byte[] abyte, int j, int k) { public ByteBuf setBytes(int i, byte[] abyte, int j, int k) {
return this.a.setBytes(i, abyte, j, k); return this.a.setBytes(i, abyte, j, k);
} }
@Override
public ByteBuf setBytes(int i, ByteBuffer bytebuffer) { public ByteBuf setBytes(int i, ByteBuffer bytebuffer) {
return this.a.setBytes(i, bytebuffer); return this.a.setBytes(i, bytebuffer);
} }
@Override
public int setBytes(int i, InputStream inputstream, int j) throws IOException { public int setBytes(int i, InputStream inputstream, int j) throws IOException {
return this.a.setBytes(i, inputstream, j); return this.a.setBytes(i, inputstream, j);
} }
@Override
public int setBytes(int i, ScatteringByteChannel scatteringbytechannel, int j) throws IOException { public int setBytes(int i, ScatteringByteChannel scatteringbytechannel, int j) throws IOException {
return this.a.setBytes(i, scatteringbytechannel, j); return this.a.setBytes(i, scatteringbytechannel, j);
} }
@Override
public int setBytes(int i, FileChannel filechannel, long j, int k) throws IOException {
return this.a.setBytes(i, filechannel, j, k);
}
@Override
public ByteBuf setZero(int i, int j) { public ByteBuf setZero(int i, int j) {
return this.a.setZero(i, j); return this.a.setZero(i, j);
} }
@Override
public int setCharSequence(int i, CharSequence charsequence, Charset charset) {
return this.a.setCharSequence(i, charsequence, charset);
}
@Override
public boolean readBoolean() { public boolean readBoolean() {
return this.a.readBoolean(); return this.a.readBoolean();
} }
@Override
public byte readByte() { public byte readByte() {
return this.a.readByte(); return this.a.readByte();
} }
@Override
public short readUnsignedByte() { public short readUnsignedByte() {
return this.a.readUnsignedByte(); return this.a.readUnsignedByte();
} }
@Override
public short readShort() { public short readShort() {
return this.a.readShort(); return this.a.readShort();
} }
@Override
public short readShortLE() {
return this.a.readShortLE();
}
@Override
public int readUnsignedShort() { public int readUnsignedShort() {
return this.a.readUnsignedShort(); return this.a.readUnsignedShort();
} }
@Override
public int readUnsignedShortLE() {
return this.a.readUnsignedShortLE();
}
@Override
public int readMedium() { public int readMedium() {
return this.a.readMedium(); return this.a.readMedium();
} }
@Override
public int readMediumLE() {
return this.a.readMediumLE();
}
@Override
public int readUnsignedMedium() { public int readUnsignedMedium() {
return this.a.readUnsignedMedium(); return this.a.readUnsignedMedium();
} }
@Override
public int readUnsignedMediumLE() {
return this.a.readUnsignedMediumLE();
}
@Override
public int readInt() { public int readInt() {
return this.a.readInt(); return this.a.readInt();
} }
@Override
public int readIntLE() {
return this.a.readIntLE();
}
@Override
public long readUnsignedInt() { public long readUnsignedInt() {
return this.a.readUnsignedInt(); return this.a.readUnsignedInt();
} }
@Override
public long readUnsignedIntLE() {
return this.a.readUnsignedIntLE();
}
@Override
public long readLong() { public long readLong() {
return this.a.readLong(); return this.a.readLong();
} }
@Override
public long readLongLE() {
return this.a.readLongLE();
}
@Override
public char readChar() { public char readChar() {
return this.a.readChar(); return this.a.readChar();
} }
@Override
public float readFloat() { public float readFloat() {
return this.a.readFloat(); return this.a.readFloat();
} }
@Override
public double readDouble() { public double readDouble() {
return this.a.readDouble(); return this.a.readDouble();
} }
@Override
public ByteBuf readBytes(int i) { public ByteBuf readBytes(int i) {
return this.a.readBytes(i); return this.a.readBytes(i);
} }
@Override
public ByteBuf readSlice(int i) { public ByteBuf readSlice(int i) {
return this.a.readSlice(i); return this.a.readSlice(i);
} }
@Override
public ByteBuf readRetainedSlice(int i) {
return this.a.readRetainedSlice(i);
}
@Override
public ByteBuf readBytes(ByteBuf bytebuf) { public ByteBuf readBytes(ByteBuf bytebuf) {
return this.a.readBytes(bytebuf); return this.a.readBytes(bytebuf);
} }
@Override
public ByteBuf readBytes(ByteBuf bytebuf, int i) { public ByteBuf readBytes(ByteBuf bytebuf, int i) {
return this.a.readBytes(bytebuf, i); return this.a.readBytes(bytebuf, i);
} }
@Override
public ByteBuf readBytes(ByteBuf bytebuf, int i, int j) { public ByteBuf readBytes(ByteBuf bytebuf, int i, int j) {
return this.a.readBytes(bytebuf, i, j); return this.a.readBytes(bytebuf, i, j);
} }
@Override
public ByteBuf readBytes(byte[] abyte) { public ByteBuf readBytes(byte[] abyte) {
return this.a.readBytes(abyte); return this.a.readBytes(abyte);
} }
@Override
public ByteBuf readBytes(byte[] abyte, int i, int j) { public ByteBuf readBytes(byte[] abyte, int i, int j) {
return this.a.readBytes(abyte, i, j); return this.a.readBytes(abyte, i, j);
} }
@Override
public ByteBuf readBytes(ByteBuffer bytebuffer) { public ByteBuf readBytes(ByteBuffer bytebuffer) {
return this.a.readBytes(bytebuffer); return this.a.readBytes(bytebuffer);
} }
@Override
public ByteBuf readBytes(OutputStream outputstream, int i) throws IOException { public ByteBuf readBytes(OutputStream outputstream, int i) throws IOException {
return this.a.readBytes(outputstream, i); return this.a.readBytes(outputstream, i);
} }
@Override
public int readBytes(GatheringByteChannel gatheringbytechannel, int i) throws IOException { public int readBytes(GatheringByteChannel gatheringbytechannel, int i) throws IOException {
return this.a.readBytes(gatheringbytechannel, i); return this.a.readBytes(gatheringbytechannel, i);
} }
@Override
public CharSequence readCharSequence(int i, Charset charset) {
return this.a.readCharSequence(i, charset);
}
@Override
public int readBytes(FileChannel filechannel, long i, int j) throws IOException {
return this.a.readBytes(filechannel, i, j);
}
@Override
public ByteBuf skipBytes(int i) { public ByteBuf skipBytes(int i) {
return this.a.skipBytes(i); return this.a.skipBytes(i);
} }
@Override
public ByteBuf writeBoolean(boolean flag) { public ByteBuf writeBoolean(boolean flag) {
return this.a.writeBoolean(flag); return this.a.writeBoolean(flag);
} }
@Override
public ByteBuf writeByte(int i) { public ByteBuf writeByte(int i) {
return this.a.writeByte(i); return this.a.writeByte(i);
} }
@Override
public ByteBuf writeShort(int i) { public ByteBuf writeShort(int i) {
return this.a.writeShort(i); return this.a.writeShort(i);
} }
@Override
public ByteBuf writeShortLE(int i) {
return this.a.writeShortLE(i);
}
@Override
public ByteBuf writeMedium(int i) { public ByteBuf writeMedium(int i) {
return this.a.writeMedium(i); return this.a.writeMedium(i);
} }
@Override
public ByteBuf writeMediumLE(int i) {
return this.a.writeMediumLE(i);
}
@Override
public ByteBuf writeInt(int i) { public ByteBuf writeInt(int i) {
return this.a.writeInt(i); return this.a.writeInt(i);
} }
@Override
public ByteBuf writeIntLE(int i) {
return this.a.writeIntLE(i);
}
@Override
public ByteBuf writeLong(long i) { public ByteBuf writeLong(long i) {
return this.a.writeLong(i); return this.a.writeLong(i);
} }
@Override
public ByteBuf writeLongLE(long i) {
return this.a.writeLongLE(i);
}
@Override
public ByteBuf writeChar(int i) { public ByteBuf writeChar(int i) {
return this.a.writeChar(i); return this.a.writeChar(i);
} }
@Override
public ByteBuf writeFloat(float f) { public ByteBuf writeFloat(float f) {
return this.a.writeFloat(f); return this.a.writeFloat(f);
} }
@Override
public ByteBuf writeDouble(double d0) { public ByteBuf writeDouble(double d0) {
return this.a.writeDouble(d0); return this.a.writeDouble(d0);
} }
@Override
public ByteBuf writeBytes(ByteBuf bytebuf) { public ByteBuf writeBytes(ByteBuf bytebuf) {
return this.a.writeBytes(bytebuf); return this.a.writeBytes(bytebuf);
} }
@Override
public ByteBuf writeBytes(ByteBuf bytebuf, int i) { public ByteBuf writeBytes(ByteBuf bytebuf, int i) {
return this.a.writeBytes(bytebuf, i); return this.a.writeBytes(bytebuf, i);
} }
@Override
public ByteBuf writeBytes(ByteBuf bytebuf, int i, int j) { public ByteBuf writeBytes(ByteBuf bytebuf, int i, int j) {
return this.a.writeBytes(bytebuf, i, j); return this.a.writeBytes(bytebuf, i, j);
} }
@Override
public ByteBuf writeBytes(byte[] abyte) { public ByteBuf writeBytes(byte[] abyte) {
return this.a.writeBytes(abyte); return this.a.writeBytes(abyte);
} }
@Override
public ByteBuf writeBytes(byte[] abyte, int i, int j) { public ByteBuf writeBytes(byte[] abyte, int i, int j) {
return this.a.writeBytes(abyte, i, j); return this.a.writeBytes(abyte, i, j);
} }
@Override
public ByteBuf writeBytes(ByteBuffer bytebuffer) { public ByteBuf writeBytes(ByteBuffer bytebuffer) {
return this.a.writeBytes(bytebuffer); return this.a.writeBytes(bytebuffer);
} }
@Override
public int writeBytes(InputStream inputstream, int i) throws IOException { public int writeBytes(InputStream inputstream, int i) throws IOException {
return this.a.writeBytes(inputstream, i); return this.a.writeBytes(inputstream, i);
} }
@Override
public int writeBytes(ScatteringByteChannel scatteringbytechannel, int i) throws IOException { public int writeBytes(ScatteringByteChannel scatteringbytechannel, int i) throws IOException {
return this.a.writeBytes(scatteringbytechannel, i); return this.a.writeBytes(scatteringbytechannel, i);
} }
@Override
public int writeBytes(FileChannel filechannel, long i, int j) throws IOException {
return this.a.writeBytes(filechannel, i, j);
}
@Override
public ByteBuf writeZero(int i) { public ByteBuf writeZero(int i) {
return this.a.writeZero(i); return this.a.writeZero(i);
} }
@Override
public int writeCharSequence(CharSequence charsequence, Charset charset) {
return this.a.writeCharSequence(charsequence, charset);
}
@Override
public int indexOf(int i, int j, byte b0) { public int indexOf(int i, int j, byte b0) {
return this.a.indexOf(i, j, b0); return this.a.indexOf(i, j, b0);
} }
@Override
public int bytesBefore(byte b0) { public int bytesBefore(byte b0) {
return this.a.bytesBefore(b0); return this.a.bytesBefore(b0);
} }
@Override
public int bytesBefore(int i, byte b0) { public int bytesBefore(int i, byte b0) {
return this.a.bytesBefore(i, b0); return this.a.bytesBefore(i, b0);
} }
@Override
public int bytesBefore(int i, int j, byte b0) { public int bytesBefore(int i, int j, byte b0) {
return this.a.bytesBefore(i, j, b0); return this.a.bytesBefore(i, j, b0);
} }
@Override
public int forEachByte(int i, int j, ByteProcessor byteprocessor) {
return this.a.forEachByte(i, j, byteprocessor);
}
@Override
public int forEachByte(ByteProcessor byteprocessor) {
return this.a.forEachByte(byteprocessor);
}
@Override
public int forEachByteDesc(ByteProcessor byteprocessor) {
return this.a.forEachByteDesc(byteprocessor);
}
@Override
public int forEachByteDesc(int i, int j, ByteProcessor byteprocessor) {
return this.a.forEachByteDesc(i, j, byteprocessor);
}
public int forEachByte(ByteBufProcessor bytebufprocessor) { public int forEachByte(ByteBufProcessor bytebufprocessor) {
return this.a.forEachByte(bytebufprocessor); return this.a.forEachByte(bytebufprocessor);
} }
@ -755,110 +1058,162 @@ public class PacketDataSerializer extends ByteBuf {
return this.a.forEachByteDesc(i, j, bytebufprocessor); return this.a.forEachByteDesc(i, j, bytebufprocessor);
} }
@Override
public ByteBuf copy() { public ByteBuf copy() {
return this.a.copy(); return this.a.copy();
} }
@Override
public ByteBuf copy(int i, int j) { public ByteBuf copy(int i, int j) {
return this.a.copy(i, j); return this.a.copy(i, j);
} }
@Override
public ByteBuf slice() { public ByteBuf slice() {
return this.a.slice(); return this.a.slice();
} }
@Override
public ByteBuf retainedSlice() {
return this.a.retainedSlice();
}
@Override
public ByteBuf slice(int i, int j) { public ByteBuf slice(int i, int j) {
return this.a.slice(i, j); return this.a.slice(i, j);
} }
@Override
public ByteBuf retainedSlice(int i, int i1) {
return this.a.readRetainedSlice(i);
}
@Override
public ByteBuf duplicate() { public ByteBuf duplicate() {
return this.a.duplicate(); return this.a.duplicate();
} }
@Override
public ByteBuf retainedDuplicate() {
return this.a.retainedDuplicate();
}
@Override
public int nioBufferCount() { public int nioBufferCount() {
return this.a.nioBufferCount(); return this.a.nioBufferCount();
} }
@Override
public ByteBuffer nioBuffer() { public ByteBuffer nioBuffer() {
return this.a.nioBuffer(); return this.a.nioBuffer();
} }
@Override
public ByteBuffer nioBuffer(int i, int j) { public ByteBuffer nioBuffer(int i, int j) {
return this.a.nioBuffer(i, j); return this.a.nioBuffer(i, j);
} }
@Override
public ByteBuffer internalNioBuffer(int i, int j) { public ByteBuffer internalNioBuffer(int i, int j) {
return this.a.internalNioBuffer(i, j); return this.a.internalNioBuffer(i, j);
} }
@Override
public ByteBuffer[] nioBuffers() { public ByteBuffer[] nioBuffers() {
return this.a.nioBuffers(); return this.a.nioBuffers();
} }
@Override
public ByteBuffer[] nioBuffers(int i, int j) { public ByteBuffer[] nioBuffers(int i, int j) {
return this.a.nioBuffers(i, j); return this.a.nioBuffers(i, j);
} }
@Override
public boolean hasArray() { public boolean hasArray() {
return this.a.hasArray(); return this.a.hasArray();
} }
@Override
public byte[] array() { public byte[] array() {
return this.a.array(); return this.a.array();
} }
@Override
public int arrayOffset() { public int arrayOffset() {
return this.a.arrayOffset(); return this.a.arrayOffset();
} }
@Override
public boolean hasMemoryAddress() { public boolean hasMemoryAddress() {
return this.a.hasMemoryAddress(); return this.a.hasMemoryAddress();
} }
@Override
public long memoryAddress() { public long memoryAddress() {
return this.a.memoryAddress(); return this.a.memoryAddress();
} }
@Override
public String toString(Charset charset) { public String toString(Charset charset) {
return this.a.toString(charset); return this.a.toString(charset);
} }
@Override
public String toString(int i, int j, Charset charset) { public String toString(int i, int j, Charset charset) {
return this.a.toString(i, j, charset); return this.a.toString(i, j, charset);
} }
@Override
public int hashCode() { public int hashCode() {
return this.a.hashCode(); return this.a.hashCode();
} }
@Override
public boolean equals(Object object) { public boolean equals(Object object) {
return this.a.equals(object); return this.a.equals(object);
} }
@Override
public int compareTo(ByteBuf bytebuf) { public int compareTo(ByteBuf bytebuf) {
return this.a.compareTo(bytebuf); return this.a.compareTo(bytebuf);
} }
@Override
public String toString() { public String toString() {
return this.a.toString(); return this.a.toString();
} }
@Override
public ByteBuf retain(int i) { public ByteBuf retain(int i) {
return this.a.retain(i); return this.a.retain(i);
} }
@Override
public ByteBuf retain() { public ByteBuf retain() {
return this.a.retain(); return this.a.retain();
} }
@Override
public ByteBuf touch() {
return this.a.touch();
}
@Override
public ByteBuf touch(Object o) {
return this.a.touch(o);
}
@Override
public int refCnt() { public int refCnt() {
return this.a.refCnt(); return this.a.refCnt();
} }
@Override
public boolean release() { public boolean release() {
return this.a.release(); return this.a.release();
} }
@Override
public boolean release(int i) { public boolean release(int i) {
return this.a.release(i); return this.a.release(i);
} }

View File

@ -251,6 +251,14 @@ public class PlayerInteractManager {
BlockBreakEvent event = null; BlockBreakEvent event = null;
if (this.player instanceof EntityPlayer) { if (this.player instanceof EntityPlayer) {
// FlamePaper start - Disable Nether Roof Interaction
if (world.getWorld().getEnvironment() == org.bukkit.World.Environment.NETHER &&
blockposition.getY() >= 127) {
this.player.getBukkitEntity().sendMessage(org.bukkit.ChatColor.translateAlternateColorCodes('&', "&cCan't build on nether roof"));
this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
return false;
}
// FlamePaper end - Disable Nether Roof Interaction
org.bukkit.block.Block block = this.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); org.bukkit.block.Block block = this.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
// Sword + Creative mode pre-cancel // Sword + Creative mode pre-cancel

View File

@ -1,39 +1,56 @@
package net.minecraft.server; package net.minecraft.server;
import com.google.common.collect.Lists; //import com.google.common.collect.Lists;
import java.util.Arrays; //import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
// CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftHumanEntity; import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
// CraftBukkit end
// PaperSpigot start
import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.github.paperspigot.event.block.BeaconEffectEvent; import org.github.paperspigot.event.block.BeaconEffectEvent;
import java.util.List;
// PaperSpigot end // PaperSpigot end
public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlayerListBox, IInventory { public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlayerListBox, IInventory {
public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffectList.FASTER_MOVEMENT, MobEffectList.FASTER_DIG}, { MobEffectList.RESISTANCE, MobEffectList.JUMP}, { MobEffectList.INCREASE_DAMAGE}, { MobEffectList.REGENERATION}}; public static final MobEffectList[][] a = new MobEffectList[][]{{MobEffectList.FASTER_MOVEMENT, MobEffectList.FASTER_DIG}, {MobEffectList.RESISTANCE, MobEffectList.JUMP}, {MobEffectList.INCREASE_DAMAGE}, {MobEffectList.REGENERATION}};
private final List<TileEntityBeacon.BeaconColorTracker> f = Lists.newArrayList(); // CraftBukkit start - add fields and methods
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
// private final List<TileEntityBeacon.BeaconColorTracker> f = Lists.newArrayList();
private boolean i; private boolean i;
private int j = -1; private int j = -1;
private int k; private int k;
private int l; private int l;
private ItemStack inventorySlot; private ItemStack inventorySlot;
private String n; private String n;
// CraftBukkit start - add fields and methods
public List<HumanEntity> transaction = new java.util.ArrayList<>();
private int maxStack = MAX_STACK; private int maxStack = MAX_STACK;
public TileEntityBeacon() {
}
// NextSpigot - Start
public boolean isEnabled() {
return i;
}
public void setEnabled(boolean state) {
this.i = state;
}
public int getLevel() {
return j;
}
public void setLevel(int newLevel) {
this.j = newLevel;
}
// NextSpigot - end
public ItemStack[] getContents() { public ItemStack[] getContents() {
return new ItemStack[] { this.inventorySlot }; return new ItemStack[]{this.inventorySlot};
} }
public void onOpen(CraftHumanEntity who) { public void onOpen(CraftHumanEntity who) {
@ -47,14 +64,8 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
public List<HumanEntity> getViewers() { public List<HumanEntity> getViewers() {
return transaction; return transaction;
} }
public void setMaxStackSize(int size) {
maxStack = size;
}
// CraftBukkit end // CraftBukkit end
public TileEntityBeacon() {}
public void c() { public void c() {
if (this.world.getTime() % 80L == 0L) { if (this.world.getTime() % 80L == 0L) {
this.m(); this.m();
@ -68,29 +79,28 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
} }
private void A() { private void A() {
if (this.i && this.j > 0 && !this.world.isClientSide && this.k > 0) { if (isEnabled() && getLevel() > 0 && !this.world.isClientSide && this.k > 0) {
double d0 = this.j * 10 + 10; double radius = getLevel() * 10 + 10;
byte b0 = 0; byte b0 = 0;
if (this.j >= 4 && this.k == this.l) { if (getLevel() >= 4 && this.k == this.l) {
b0 = 1; b0 = 1;
} }
int i = this.position.getX(); int posX = this.position.getX();
int j = this.position.getY(); int posY = this.position.getY();
int k = this.position.getZ(); int posZ = this.position.getZ();
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(i, j, k, i + 1, j + 1, k + 1)).grow(d0, d0, d0).a(0.0D, this.world.getHeight(), 0.0D); AxisAlignedBB axisalignedbb = new AxisAlignedBB(posX, posY, posZ, posX + 1, posY + 1, posZ + 1)
List list = this.world.a(EntityHuman.class, axisalignedbb); .grow(radius, radius, radius).a(0.0D, this.world.getHeight(), 0.0D);
Iterator iterator = list.iterator();
List<EntityHuman> list = this.world.a(EntityHuman.class, axisalignedbb);
EntityHuman entityhuman;
// PaperSpigot start // PaperSpigot start
org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()); org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
PotionEffect primaryEffect = new PotionEffect(PotionEffectType.getById(this.k), 180, b0, true, true); PotionEffect primaryEffect = new PotionEffect(PotionEffectType.getById(this.k), 180, b0, true, true);
// PaperSpigot end // PaperSpigot end
while (iterator.hasNext()) { for (EntityHuman entityhuman : list) {
entityhuman = (EntityHuman) iterator.next();
// PaperSpigot start - BeaconEffectEvent // PaperSpigot start - BeaconEffectEvent
BeaconEffectEvent event = new BeaconEffectEvent(block, primaryEffect, (Player) entityhuman.getBukkitEntity(), true); BeaconEffectEvent event = new BeaconEffectEvent(block, primaryEffect, (Player) entityhuman.getBukkitEntity(), true);
if (CraftEventFactory.callEvent(event).isCancelled()) continue; if (CraftEventFactory.callEvent(event).isCancelled()) continue;
@ -100,12 +110,10 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
// PaperSpigot end // PaperSpigot end
} }
if (this.j >= 4 && this.k != this.l && this.l > 0) { if (getLevel() >= 4 && this.k != this.l && this.l > 0) {
iterator = list.iterator();
PotionEffect secondaryEffect = new PotionEffect(PotionEffectType.getById(this.l), 180, 0, true, true); // PaperSpigot PotionEffect secondaryEffect = new PotionEffect(PotionEffectType.getById(this.l), 180, 0, true, true); // PaperSpigot
while (iterator.hasNext()) { for (EntityHuman entityhuman : list) {
entityhuman = (EntityHuman) iterator.next();
// PaperSpigot start - BeaconEffectEvent // PaperSpigot start - BeaconEffectEvent
BeaconEffectEvent event = new BeaconEffectEvent(block, secondaryEffect, (Player) entityhuman.getBukkitEntity(), false); BeaconEffectEvent event = new BeaconEffectEvent(block, secondaryEffect, (Player) entityhuman.getBukkitEntity(), false);
if (CraftEventFactory.callEvent(event).isCancelled()) continue; if (CraftEventFactory.callEvent(event).isCancelled()) continue;
@ -116,95 +124,63 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
} }
} }
} }
} }
private void B() { private void B() {
int i = this.j; int prevLevel = getLevel();
int j = this.position.getX(); int posX = this.position.getX();
int k = this.position.getY(); int posY = this.position.getY();
int l = this.position.getZ(); int posZ = this.position.getZ();
setLevel(0);
setEnabled(true);
this.j = 0; BlockPosition.MutableBlockPosition mutableBlockPosition = new BlockPosition.MutableBlockPosition();
this.f.clear(); for (int y = posY + 1; y < 256; ++y) {
this.i = true; Block block = this.world
TileEntityBeacon.BeaconColorTracker tileentitybeacon_beaconcolortracker = new TileEntityBeacon.BeaconColorTracker(EntitySheep.a(EnumColor.WHITE)); .getType(mutableBlockPosition.c(posX, y, posZ))
.getBlock();
this.f.add(tileentitybeacon_beaconcolortracker); if (block != Blocks.STAINED_GLASS && block != Blocks.STAINED_GLASS_PANE
boolean flag = true; && block.p() >= 15 && block != Blocks.BEDROCK) {
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition(); setEnabled(false);
break;
int i1;
for (i1 = k + 1; i1 < 256; ++i1) {
IBlockData iblockdata = this.world.getType(blockposition_mutableblockposition.c(j, i1, l));
float[] afloat;
if (iblockdata.getBlock() == Blocks.STAINED_GLASS) {
afloat = EntitySheep.a(iblockdata.get(BlockStainedGlass.COLOR));
} else {
if (iblockdata.getBlock() != Blocks.STAINED_GLASS_PANE) {
if (iblockdata.getBlock().p() >= 15 && iblockdata.getBlock() != Blocks.BEDROCK) {
this.i = false;
this.f.clear();
break;
}
tileentitybeacon_beaconcolortracker.a();
continue;
}
afloat = EntitySheep.a(iblockdata.get(BlockStainedGlassPane.COLOR));
} }
if (!flag) {
afloat = new float[] { (tileentitybeacon_beaconcolortracker.b()[0] + afloat[0]) / 2.0F, (tileentitybeacon_beaconcolortracker.b()[1] + afloat[1]) / 2.0F, (tileentitybeacon_beaconcolortracker.b()[2] + afloat[2]) / 2.0F};
}
if (Arrays.equals(afloat, tileentitybeacon_beaconcolortracker.b())) {
tileentitybeacon_beaconcolortracker.a();
} else {
tileentitybeacon_beaconcolortracker = new TileEntityBeacon.BeaconColorTracker(afloat);
this.f.add(tileentitybeacon_beaconcolortracker);
}
flag = false;
} }
if (this.i) { if (isEnabled()) {
for (i1 = 1; i1 <= 4; this.j = i1++) { for (int layer = 1; layer <= 4; setLevel(layer++)) {
int j1 = k - i1; int layerY = posY - layer;
if (j1 < 0) { if (layerY < 0) {
break; break;
} }
boolean flag1 = true; boolean hasLayer = true;
for (int layerX = posX - layer; layerX <= posX + layer && hasLayer; ++layerX) {
for (int k1 = j - i1; k1 <= j + i1 && flag1; ++k1) { for (int layerZ = posZ - layer; layerZ <= posZ + layer; ++layerZ) {
for (int l1 = l - i1; l1 <= l + i1; ++l1) { Block block = this.world.getType(new BlockPosition(layerX, layerY, layerZ)).getBlock();
Block block = this.world.getType(new BlockPosition(k1, j1, l1)).getBlock();
if (block != Blocks.EMERALD_BLOCK && block != Blocks.GOLD_BLOCK && block != Blocks.DIAMOND_BLOCK && block != Blocks.IRON_BLOCK) { if (block != Blocks.EMERALD_BLOCK && block != Blocks.GOLD_BLOCK && block != Blocks.DIAMOND_BLOCK && block != Blocks.IRON_BLOCK) {
flag1 = false; hasLayer = false;
break; break;
} }
} }
} }
if (!flag1) { if (!hasLayer) {
break; break;
} }
} }
if (this.j == 0) { if (getLevel() == 0) {
this.i = false; setEnabled(false);
} }
} }
if (!this.world.isClientSide && this.j == 4 && i < this.j) { if (!this.world.isClientSide && getLevel() == 4 && prevLevel < getLevel()) {
AxisAlignedBB bb = new AxisAlignedBB(posX, posY, posZ, posX, posY - 4, posZ)
.grow(10.0D, 5.0D, 10.0D);
for (EntityHuman entityhuman : this.world.a(EntityHuman.class, (new AxisAlignedBB(j, k, l, j, k - 4, l)).grow(10.0D, 5.0D, 10.0D))) { for (EntityHuman entityhuman : this.world.a(EntityHuman.class, bb)) {
entityhuman.b(AchievementList.K); entityhuman.b(AchievementList.K);
} }
} }
@ -232,14 +208,14 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
super.a(nbttagcompound); super.a(nbttagcompound);
this.k = this.h(nbttagcompound.getInt("Primary")); this.k = this.h(nbttagcompound.getInt("Primary"));
this.l = this.h(nbttagcompound.getInt("Secondary")); this.l = this.h(nbttagcompound.getInt("Secondary"));
this.j = nbttagcompound.getInt("Levels"); setLevel(nbttagcompound.getInt("Levels"));
} }
public void b(NBTTagCompound nbttagcompound) { public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound); super.b(nbttagcompound);
nbttagcompound.setInt("Primary", this.k); nbttagcompound.setInt("Primary", this.k);
nbttagcompound.setInt("Secondary", this.l); nbttagcompound.setInt("Secondary", this.l);
nbttagcompound.setInt("Levels", this.j); nbttagcompound.setInt("Levels", getLevel());
} }
public int getSize() { public int getSize() {
@ -300,13 +276,19 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
return maxStack; // CraftBukkit return maxStack; // CraftBukkit
} }
public boolean a(EntityHuman entityhuman) { public void setMaxStackSize(int size) {
return this.world.getTileEntity(this.position) == this && entityhuman.e((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D; maxStack = size;
} }
public void startOpen(EntityHuman entityhuman) {} public boolean a(EntityHuman entityhuman) {
return this.world.getTileEntity(this.position) != this ? false : entityhuman.e((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
}
public void closeContainer(EntityHuman entityhuman) {} public void startOpen(EntityHuman entityhuman) {
}
public void closeContainer(EntityHuman entityhuman) {
}
public boolean b(int i, ItemStack itemstack) { public boolean b(int i, ItemStack itemstack) {
return itemstack.getItem() == Items.EMERALD || itemstack.getItem() == Items.DIAMOND || itemstack.getItem() == Items.GOLD_INGOT || itemstack.getItem() == Items.IRON_INGOT; return itemstack.getItem() == Items.EMERALD || itemstack.getItem() == Items.DIAMOND || itemstack.getItem() == Items.GOLD_INGOT || itemstack.getItem() == Items.IRON_INGOT;
@ -322,32 +304,32 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
public int getProperty(int i) { public int getProperty(int i) {
switch (i) { switch (i) {
case 0: case 0:
return this.j; return getLevel();
case 1: case 1:
return this.k; return this.k;
case 2: case 2:
return this.l; return this.l;
default: default:
return 0; return 0;
} }
} }
public void b(int i, int j) { public void b(int i, int j) {
switch (i) { switch (i) {
case 0: case 0:
this.j = j; setLevel(j);
break; break;
case 1: case 1:
this.k = this.h(j); this.k = this.h(j);
break; break;
case 2: case 2:
this.l = this.h(j); this.l = this.h(j);
} }
} }
@ -369,22 +351,22 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
} }
} }
public static class BeaconColorTracker { // public static class BeaconColorTracker {
//
private final float[] a; // private final float[] a;
private int b; // private int b;
//
public BeaconColorTracker(float[] afloat) { // public BeaconColorTracker(float[] afloat) {
this.a = afloat; // this.a = afloat;
this.b = 1; // this.b = 1;
} // }
//
protected void a() { // protected void a() {
++this.b; // ++this.b;
} // }
//
public float[] b() { // public float[] b() {
return this.a; // return this.a;
} // }
} // }
} }

View File

@ -6,6 +6,7 @@ import java.util.List;
// CraftBukkit start // CraftBukkit start
import org.bukkit.craftbukkit.entity.CraftHumanEntity; import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent;
@ -604,7 +605,9 @@ public class TileEntityHopper extends TileEntityContainer implements IHopper, IU
} }
} }
if (object == null) { Chunk chunk = world.getChunkAtWorldCoords(blockposition);
if (object == null && !org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(block).isOccluding() && chunk.getItemCount(blockposition) > 0) {
List list = world.a((Entity) null, new AxisAlignedBB(d0 - 0.5D, d1 - 0.5D, d2 - 0.5D, d0 + 0.5D, d1 + 0.5D, d2 + 0.5D), IEntitySelector.c); List list = world.a((Entity) null, new AxisAlignedBB(d0 - 0.5D, d1 - 0.5D, d2 - 0.5D, d0 + 0.5D, d1 + 0.5D, d2 + 0.5D), IEntitySelector.c);
if (list.size() > 0) { if (list.size() > 0) {

View File

@ -233,7 +233,10 @@ public class WorldServer extends World implements IAsyncTaskHandler {
// CraftBukkit end // CraftBukkit end
timings.doChunkUnload.startTiming(); // Spigot timings.doChunkUnload.startTiming(); // Spigot
this.methodProfiler.c("chunkSource"); this.methodProfiler.c("chunkSource");
this.chunkProvider.unloadChunks(); // Only unload if chunkProvider isn't null
if (this.chunkProvider != null) {
this.chunkProvider.unloadChunks();
}
int j = this.a(1.0F); int j = this.a(1.0F);
if (j != this.ab()) { if (j != this.ab()) {

View File

@ -34,9 +34,8 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
static final ItemMetaKey RESOLVED = new ItemMetaKey("resolved"); static final ItemMetaKey RESOLVED = new ItemMetaKey("resolved");
static final ItemMetaKey GENERATION = new ItemMetaKey("generation"); static final ItemMetaKey GENERATION = new ItemMetaKey("generation");
static final int MAX_PAGES = 50; static final int MAX_PAGES = 50;
static final int MAX_PAGE_LENGTH = 256; static final int MAX_PAGE_LENGTH = 340;
static final int MAX_TITLE_LENGTH = 16; static final int MAX_TITLE_LENGTH = 32;
protected String title; protected String title;
protected String author; protected String author;