Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a9cb86563 | ||
|
|
87b1919863 | ||
|
|
d164e413c2 | ||
|
|
76d7db044f | ||
|
|
046ebb8ecc | ||
|
|
bccde04ace | ||
|
|
9385f03722 | ||
|
|
b48fc17ead | ||
|
|
b50d0075ca | ||
|
|
84d006c71d | ||
|
|
212da9c46c | ||
|
|
8edb7048a1 | ||
|
|
abe3c4b0c9 | ||
|
|
c6d3c97c65 | ||
|
|
13c6a9d612 | ||
|
|
7d2ef743ac | ||
|
|
598d0f96d8 | ||
|
|
cbc22922d3 | ||
|
|
49783d36c2 | ||
|
|
70d91b4f87 | ||
|
|
17f3d13267 | ||
|
|
559674bf58 | ||
|
|
fbc298bc30 | ||
|
|
e36902c441 | ||
|
|
805c78989a | ||
|
|
85e416171c | ||
|
|
b55c0d0783 | ||
|
|
33b4b3835f | ||
|
|
8ccd772105 | ||
|
|
8677c632df | ||
|
|
560476c56f | ||
|
|
20bbe7cec6 | ||
|
|
1a002486d0 | ||
|
|
26fcdfe3bc | ||
|
|
4af98b220c | ||
|
|
a79533bf72 | ||
|
|
e3510d01d6 |
No files matched your search
@@ -1,15 +1,17 @@
|
||||
# ViaVersion 0.9.3
|
||||
# ViaVersion 0.9.7
|
||||
[](https://travis-ci.org/MylesIsCool/ViaVersion)
|
||||
[](https://gitter.im/MylesIsCool/ViaVersion)
|
||||
|
||||
**Allows the connection of 1.9 clients to 1.8**
|
||||
**1.10 clients on 1.8 / 1.9 servers**
|
||||
**Allows the connection of higher client versions to lower server versions**
|
||||
|
||||
This took 100s hours of work, so if you enjoy this consider looking into contacting me and supporting my projects.
|
||||
Allows 1.10, 1.9 on 1.8 server and 1.10 on a 1.9 server.
|
||||
|
||||
**User Docs:** https://docs.viaversion.com/display/VIAVERSION/
|
||||
|
||||
**Contributor Chat:** https://gitter.im/MylesIsCool/ViaVersion
|
||||
|
||||
|
||||
|
||||
Sources:
|
||||
--------
|
||||
|
||||
@@ -21,12 +23,12 @@ Sources:
|
||||
|
||||
|
||||
|
||||
Contributors:
|
||||
All Time Contributors:
|
||||
--------
|
||||
|
||||
**Myself** (harhar)
|
||||
|
||||
**Matsv/StamBoom**
|
||||
**Matsv**
|
||||
|
||||
**HugoDaBosss**
|
||||
|
||||
@@ -40,6 +42,10 @@ Contributors:
|
||||
|
||||
**lenis0012**
|
||||
|
||||
**fuzzy_bot**
|
||||
|
||||
**joserobjr**
|
||||
|
||||
|
||||
|
||||
Releases / Dev Builds:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>0.9.4</version>
|
||||
<version>0.9.7</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ViaVersion</name>
|
||||
|
||||
@@ -4,6 +4,7 @@ import us.myles.ViaVersion.api.ViaVersionConfig;
|
||||
import us.myles.ViaVersion.util.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class ViaConfig implements ViaVersionConfig {
|
||||
private final ViaVersionPlugin plugin;
|
||||
@@ -150,8 +151,33 @@ public class ViaConfig implements ViaVersionConfig {
|
||||
return plugin.getConfig().getBoolean("nms-player-ticking", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplacePistons() {
|
||||
return plugin.getConfig().getBoolean("replace-pistons", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPistonReplacementId() {
|
||||
return plugin.getConfig().getInt("replacement-piston-id", 0);
|
||||
}
|
||||
|
||||
public boolean isAutoTeam() {
|
||||
// Collision has to be enabled first
|
||||
return isPreventCollision() && plugin.getConfig().getBoolean("auto-team", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForceJsonTransform() {
|
||||
return plugin.getConfig().getBoolean("force-json-transform", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getBlockedProtocols() {
|
||||
return plugin.getConfig().getIntegerList("block-protocols");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockedDisconnectMsg() {
|
||||
return plugin.getConfig().getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import us.myles.ViaVersion.handlers.ViaVersionInitializer;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.update.UpdateListener;
|
||||
import us.myles.ViaVersion.update.UpdateUtil;
|
||||
import us.myles.ViaVersion.util.ConcurrentList;
|
||||
import us.myles.ViaVersion.util.ListWrapper;
|
||||
import us.myles.ViaVersion.util.ProtocolSupportUtil;
|
||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||
@@ -53,6 +54,20 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
@Getter
|
||||
private ViaConfig conf;
|
||||
|
||||
public ViaVersionPlugin() {
|
||||
// Check if we're using protocol support too
|
||||
protocolSupport = Bukkit.getPluginManager().getPlugin("ProtocolSupport") != null;
|
||||
|
||||
if (protocolSupport) {
|
||||
getLogger().info("Patching to prevent concurrency issues...");
|
||||
try {
|
||||
patchLists();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Config magic
|
||||
@@ -87,9 +102,6 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
compatSpigotBuild = false;
|
||||
}
|
||||
|
||||
// Check if we're using protocol support too
|
||||
protocolSupport = Bukkit.getPluginManager().getPlugin("ProtocolSupport") != null;
|
||||
|
||||
// Generate classes needed (only works if it's compat or ps)
|
||||
ClassGenerator.generate();
|
||||
lateBind = !isBinded();
|
||||
@@ -248,6 +260,27 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void patchLists() throws Exception {
|
||||
Object connection = getServerConnection();
|
||||
if (connection == null) {
|
||||
getLogger().warning("We failed to find the ServerConnection? :( What server are you running?");
|
||||
return;
|
||||
}
|
||||
for (Field field : connection.getClass().getDeclaredFields()) {
|
||||
field.setAccessible(true);
|
||||
final Object value = field.get(connection);
|
||||
if (value instanceof List) {
|
||||
if (!(value instanceof ConcurrentList)) {
|
||||
ConcurrentList list = new ConcurrentList();
|
||||
list.addAll((List) value);
|
||||
field.set(connection, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isBinded() {
|
||||
try {
|
||||
Object connection = getServerConnection();
|
||||
@@ -417,7 +450,10 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
|
||||
@Override
|
||||
public SortedSet<Integer> getSupportedVersions() {
|
||||
return ProtocolRegistry.getSupportedVersions();
|
||||
SortedSet<Integer> outputSet = new TreeSet<>(ProtocolRegistry.getSupportedVersions());
|
||||
outputSet.removeAll(getConf().getBlockedProtocols());
|
||||
|
||||
return outputSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package us.myles.ViaVersion.api;
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
@@ -223,6 +224,7 @@ public class PacketWrapper {
|
||||
}
|
||||
if (readableObjects.size() > 0) {
|
||||
packetValues.addAll(readableObjects);
|
||||
readableObjects.clear();
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
@@ -267,10 +269,59 @@ public class PacketWrapper {
|
||||
|
||||
private void writeRemaining(ByteBuf output) {
|
||||
if (inputBuffer != null) {
|
||||
output.writeBytes(inputBuffer);
|
||||
output.writeBytes(inputBuffer, inputBuffer.readableBytes());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this packet to the associated user.
|
||||
* Be careful not to send packets twice.
|
||||
* (Sends it after current)
|
||||
*
|
||||
* @param packetProtocol - The protocol version of the packet.
|
||||
* @param skipCurrentPipeline - Skip the current pipeline
|
||||
* @throws Exception if it fails to write
|
||||
*/
|
||||
public void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) throws Exception {
|
||||
if (!isCancelled()) {
|
||||
ByteBuf output = constructPacket(packetProtocol, skipCurrentPipeline);
|
||||
user().sendRawPacket(output);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Let the packet go through the protocol pipes and write it to ByteBuf
|
||||
*
|
||||
* @param packetProtocol - The protocol version of the packet.
|
||||
* @param skipCurrentPipeline - Skip the current pipeline
|
||||
* @return Packet buffer
|
||||
* @throws Exception if it fails to write
|
||||
*/
|
||||
private ByteBuf constructPacket(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) throws Exception {
|
||||
// Apply current pipeline
|
||||
List<Protocol> protocols = new ArrayList<>(user().get(ProtocolInfo.class).getPipeline().pipes());
|
||||
// Other way if outgoing
|
||||
Collections.reverse(protocols);
|
||||
int index = 0;
|
||||
for (int i = 0; i < protocols.size(); i++) {
|
||||
if (protocols.get(i).getClass().equals(packetProtocol)) {
|
||||
index = skipCurrentPipeline ? (i + 1) : (i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset reader before we start
|
||||
resetReader();
|
||||
|
||||
// Apply other protocols
|
||||
apply(Direction.OUTGOING, user().get(ProtocolInfo.class).getState(), index, protocols);
|
||||
// Send
|
||||
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
|
||||
writeToBuffer(output);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this packet to the associated user.
|
||||
* Be careful not to send packets twice.
|
||||
@@ -280,25 +331,25 @@ public class PacketWrapper {
|
||||
* @throws Exception if it fails to write
|
||||
*/
|
||||
public void send(Class<? extends Protocol> packetProtocol) throws Exception {
|
||||
send(packetProtocol, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this packet to the associated user.
|
||||
* Be careful not to send packets twice.
|
||||
* (Sends it after current)
|
||||
* Also returns the packets ChannelFuture
|
||||
*
|
||||
* @param packetProtocol - The protocol version of the packet.
|
||||
* @return The packets ChannelFuture
|
||||
* @throws Exception if it fails to write
|
||||
*/
|
||||
public ChannelFuture sendFuture(Class<? extends Protocol> packetProtocol) throws Exception {
|
||||
if (!isCancelled()) {
|
||||
// Apply current pipeline
|
||||
List<Protocol> protocols = new ArrayList<>(user().get(ProtocolInfo.class).getPipeline().pipes());
|
||||
// Other way if outgoing
|
||||
Collections.reverse(protocols);
|
||||
int index = 0;
|
||||
for (int i = 0; i < protocols.size(); i++) {
|
||||
if (protocols.get(i).getClass().equals(packetProtocol)) {
|
||||
index = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Apply other protocols
|
||||
apply(Direction.OUTGOING, user().get(ProtocolInfo.class).getState(), index, protocols);
|
||||
// Send
|
||||
ByteBuf output = inputBuffer == null ? Unpooled.buffer() : inputBuffer.alloc().buffer();
|
||||
writeToBuffer(output);
|
||||
user().sendRawPacket(output);
|
||||
ByteBuf output = constructPacket(packetProtocol, true);
|
||||
return user().sendRawPacketFuture(output);
|
||||
}
|
||||
return user().getChannel().newFailedFuture(new Exception("Cancelled packet"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,6 +444,10 @@ public class PacketWrapper {
|
||||
* Reset the reader, so that it can be read again.
|
||||
*/
|
||||
public void resetReader() {
|
||||
// Move readable objects are packet values
|
||||
this.packetValues.addAll(readableObjects);
|
||||
this.readableObjects.clear();
|
||||
// Move all packet values to the readable for next packet.
|
||||
this.readableObjects.addAll(packetValues);
|
||||
this.packetValues.clear();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import us.myles.ViaVersion.api.boss.BossBar;
|
||||
import us.myles.ViaVersion.api.boss.BossColor;
|
||||
import us.myles.ViaVersion.api.boss.BossStyle;
|
||||
import us.myles.ViaVersion.api.command.ViaVersionCommand;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.UUID;
|
||||
@@ -114,6 +115,8 @@ public interface ViaVersionAPI {
|
||||
|
||||
/**
|
||||
* Get the supported protocol versions
|
||||
* This method removes any blocked protocol versions.
|
||||
* @see ProtocolRegistry#getSupportedVersions() for full list.
|
||||
*
|
||||
* @return a list of protocol versions
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package us.myles.ViaVersion.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ViaVersionConfig {
|
||||
|
||||
/**
|
||||
@@ -172,4 +174,39 @@ public interface ViaVersionConfig {
|
||||
* @return if true, enabled
|
||||
*/
|
||||
boolean isNMSPlayerTicking();
|
||||
|
||||
/**
|
||||
* Replace extended pistons on 1.10 chunk loading.
|
||||
*
|
||||
* @return True if to replace them
|
||||
*/
|
||||
boolean isReplacePistons();
|
||||
|
||||
/**
|
||||
* Get the id for replacing extended pistons.
|
||||
*
|
||||
* @return The integer id
|
||||
*/
|
||||
int getPistonReplacementId();
|
||||
|
||||
/**
|
||||
* Force json transform
|
||||
*
|
||||
* @return True if enabled
|
||||
*/
|
||||
boolean isForceJsonTransform();
|
||||
|
||||
/**
|
||||
* Get the blocked protocols
|
||||
*
|
||||
* @return An Integer list
|
||||
*/
|
||||
List<Integer> getBlockedProtocols();
|
||||
|
||||
/**
|
||||
* Get the custom disconnect message
|
||||
*
|
||||
* @return Disconnect message
|
||||
*/
|
||||
String getBlockedDisconnectMsg();
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package us.myles.ViaVersion.api.data;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter(AccessLevel.PROTECTED)
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class StoredObject {
|
||||
private UserConnection user;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package us.myles.ViaVersion.api.data;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import lombok.Data;
|
||||
@@ -85,6 +86,17 @@ public class UserConnection {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a raw packet to the player with returning the future
|
||||
*
|
||||
* @param packet The raw packet to send
|
||||
* @return ChannelFuture of the packet being sent
|
||||
*/
|
||||
public ChannelFuture sendRawPacketFuture(final ByteBuf packet) {
|
||||
final ChannelHandler handler = channel.pipeline().get("encoder");
|
||||
return channel.pipeline().context(handler).writeAndFlush(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a raw packet to the player (netty thread)
|
||||
*
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
package us.myles.ViaVersion.api.minecraft.chunks;
|
||||
|
||||
public interface Chunk {
|
||||
int getX();
|
||||
|
||||
int getZ();
|
||||
|
||||
ChunkSection[] getSections();
|
||||
|
||||
boolean isGroundUp();
|
||||
|
||||
boolean isBiomeData();
|
||||
|
||||
byte[] getBiomeData();
|
||||
|
||||
int getBitmask();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package us.myles.ViaVersion.api.minecraft.chunks;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public interface ChunkSection {
|
||||
int getBlockId(int x, int y, int z);
|
||||
|
||||
void writeBlocks(ByteBuf output) throws Exception;
|
||||
|
||||
void writeBlockLight(ByteBuf output) throws Exception;
|
||||
|
||||
boolean hasSkyLight();
|
||||
|
||||
void writeSkyLight(ByteBuf output) throws Exception;
|
||||
}
|
||||
@@ -79,6 +79,11 @@ public class ProtocolRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the versions compatible with the server.
|
||||
*
|
||||
* @return Read-only set of the versions.
|
||||
*/
|
||||
public static SortedSet<Integer> getSupportedVersions() {
|
||||
return Collections.unmodifiableSortedSet(new TreeSet<>(supportedVersions));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.type.types.*;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -6,7 +6,7 @@ import us.myles.ViaVersion.api.type.TypeConverter;
|
||||
|
||||
public class UnsignedByteType extends Type<Short> implements TypeConverter<Short> {
|
||||
public UnsignedByteType() {
|
||||
super(Short.class);
|
||||
super("Unsigned Byte", Short.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package us.myles.ViaVersion.protocols.base;
|
||||
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -21,6 +25,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.Direction;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -31,6 +36,8 @@ public class BaseProtocol extends Protocol {
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
/* Outgoing Packets */
|
||||
|
||||
// Status Response Packet
|
||||
registerOutgoing(State.STATUS, 0x00, 0x00, new PacketRemapper() { // Status Response Packet
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@@ -43,20 +50,26 @@ public class BaseProtocol extends Protocol {
|
||||
try {
|
||||
JSONObject json = (JSONObject) new JSONParser().parse(originalStatus);
|
||||
JSONObject version = (JSONObject) json.get("version");
|
||||
if (ViaVersion.getConfig().isSendSupportedVersions())
|
||||
int protocolVersion = ((Long) version.get("protocol")).intValue();
|
||||
|
||||
if (ViaVersion.getConfig().isSendSupportedVersions()) //Send supported versions
|
||||
version.put("supportedVersions", ViaVersion.getInstance().getSupportedVersions());
|
||||
if (ProtocolRegistry.SERVER_PROTOCOL == -1) {
|
||||
Long original = (Long) version.get("protocol");
|
||||
ProtocolRegistry.SERVER_PROTOCOL = original.intValue();
|
||||
}
|
||||
|
||||
if (ProtocolRegistry.SERVER_PROTOCOL == -1) // Set the Server protocol if the detection on startup failed
|
||||
ProtocolRegistry.SERVER_PROTOCOL = protocolVersion;
|
||||
|
||||
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), ProtocolRegistry.SERVER_PROTOCOL);
|
||||
if (protocols != null) {
|
||||
if ((long) version.get("protocol") != 9999) //Fix serverlistplus
|
||||
if (protocolVersion != 9999) //Fix ServerListPlus
|
||||
version.put("protocol", info.getProtocolVersion());
|
||||
} else {
|
||||
// not compatible :(, *plays very sad violin*
|
||||
wrapper.user().setActive(false);
|
||||
}
|
||||
|
||||
if (ViaVersion.getConfig().getBlockedProtocols().contains(info.getProtocolVersion()))
|
||||
version.put("protocol", -1); // Show blocked versions as outdated
|
||||
|
||||
wrapper.set(Type.STRING, 0, json.toJSONString()); // Update value
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
@@ -88,6 +101,10 @@ public class BaseProtocol extends Protocol {
|
||||
info.setUsername(wrapper.get(Type.STRING, 1));
|
||||
// Add to ported clients
|
||||
((ViaVersionPlugin) ViaVersion.getInstance()).addPortedClient(wrapper.user());
|
||||
|
||||
if (info.getPipeline().pipes().size() == 1 && info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol
|
||||
wrapper.user().setActive(false);
|
||||
|
||||
if (ViaVersion.getInstance().isDebug()) {
|
||||
// Print out the route to console
|
||||
((ViaVersionPlugin) ViaVersion.getInstance()).getLogger().log(Level.INFO, "{0} logged in with protocol {1}, Route: {2}",
|
||||
@@ -130,11 +147,6 @@ public class BaseProtocol extends Protocol {
|
||||
pipeline.add(prot.getValue());
|
||||
}
|
||||
wrapper.set(Type.VAR_INT, 0, ProtocolRegistry.SERVER_PROTOCOL);
|
||||
} else {
|
||||
if (state == 2) {
|
||||
// not compatible :(, *plays very sad violin*
|
||||
wrapper.user().setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Change state
|
||||
@@ -151,7 +163,34 @@ public class BaseProtocol extends Protocol {
|
||||
registerIncoming(State.STATUS, 0x00, 0x00); // Status Request Packet
|
||||
registerIncoming(State.STATUS, 0x01, 0x01); // Status Ping Packet
|
||||
|
||||
registerIncoming(State.LOGIN, 0x00, 0x00); // Login Start Packet
|
||||
// Login Start Packet
|
||||
registerIncoming(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(final PacketWrapper wrapper) throws Exception {
|
||||
int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion();
|
||||
if (ViaVersion.getConfig().getBlockedProtocols().contains(protocol)) {
|
||||
if (!wrapper.user().getChannel().isOpen()) return;
|
||||
|
||||
PacketWrapper disconnectPacket = new PacketWrapper(0x00, null, wrapper.user()); // Disconnect Packet
|
||||
Protocol1_9TO1_8.FIX_JSON.write(disconnectPacket, ChatColor.translateAlternateColorCodes('&', ViaVersion.getConfig().getBlockedDisconnectMsg()));
|
||||
wrapper.cancel(); // cancel current
|
||||
|
||||
// Send and close
|
||||
ChannelFuture future = disconnectPacket.sendFuture(BaseProtocol.class);
|
||||
future.addListener(new GenericFutureListener<Future<? super Void>>() {
|
||||
@Override
|
||||
public void operationComplete(Future<? super Void> future) throws Exception {
|
||||
wrapper.user().getChannel().close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}); // Login Start Packet
|
||||
registerIncoming(State.LOGIN, 0x01, 0x01); // Encryption Response Packet
|
||||
}
|
||||
|
||||
|
||||
+2
-21
@@ -26,9 +26,6 @@ public class BlockEntity {
|
||||
types.put("UNKNOWN", 7);
|
||||
types.put("EndGateway", 8);
|
||||
types.put("Sign", 9);
|
||||
|
||||
//I didn't see anything that didn't work about chests
|
||||
// types.put("Chest", -1);
|
||||
}
|
||||
|
||||
public static void handle(List<CompoundTag> tags, UserConnection connection) {
|
||||
@@ -45,21 +42,13 @@ public class BlockEntity {
|
||||
if (newId == -1)
|
||||
continue;
|
||||
|
||||
|
||||
int x = (int) tag.get("x").getValue();
|
||||
int y = (int) tag.get("y").getValue();
|
||||
int z = (int) tag.get("z").getValue();
|
||||
|
||||
Position pos = new Position((long) x, (long) y, (long) z);
|
||||
|
||||
if (newId != 9) {
|
||||
updateBlockEntity(pos, (short) newId, tag, connection);
|
||||
} else {
|
||||
String[] lines = new String[4];
|
||||
for (int i = 1; i < 5; i++)
|
||||
lines[i - 1] = (String) tag.get("Text" + i).getValue();
|
||||
updateSign(pos, lines, connection);
|
||||
}
|
||||
updateBlockEntity(pos, (short) newId, tag, connection);
|
||||
} catch (Exception e) {
|
||||
if (ViaVersion.getInstance().isDebug()) {
|
||||
System.out.println("Block Entity: " + e.getMessage() + ": " + tag);
|
||||
@@ -73,14 +62,6 @@ public class BlockEntity {
|
||||
wrapper.write(Type.POSITION, pos);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, id);
|
||||
wrapper.write(Type.NBT, tag);
|
||||
wrapper.send(Protocol1_9_1_2TO1_9_3_4.class);
|
||||
}
|
||||
|
||||
private static void updateSign(Position pos, String[] lines, UserConnection connection) throws Exception {
|
||||
PacketWrapper wrapper = new PacketWrapper(0x46, null, connection);
|
||||
wrapper.write(Type.POSITION, pos);
|
||||
for (String s : lines)
|
||||
wrapper.write(Type.STRING, s);
|
||||
wrapper.send(Protocol1_9_1_2TO1_9_3_4.class);
|
||||
wrapper.send(Protocol1_9_1_2TO1_9_3_4.class, false);
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -14,7 +14,16 @@ public class Chunk1_9_3_4 implements Chunk {
|
||||
private int z;
|
||||
private boolean groundUp;
|
||||
private int bitmask;
|
||||
private byte[] sections;
|
||||
private ChunkSection1_9_3_4[] sections;
|
||||
List<CompoundTag> blockEntities;
|
||||
|
||||
@Override
|
||||
public boolean isBiomeData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBiomeData() {
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -31,7 +31,7 @@ public class Chunk1_9_3_4Type extends BaseChunkType {
|
||||
for (int i = 0; i < blockEntities; i++) {
|
||||
nbtData.add(Type.NBT.read(input));
|
||||
}
|
||||
return new Chunk1_9_3_4(chunkX, chunkZ, groundUp, primaryBitmask, sections, nbtData);
|
||||
return new Chunk1_9_3_4(chunkX, chunkZ, groundUp, primaryBitmask, new ChunkSection1_9_3_4[] {new ChunkSection1_9_3_4(sections)}, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,8 +46,8 @@ public class Chunk1_9_3_4Type extends BaseChunkType {
|
||||
buffer.writeBoolean(chunk.isGroundUp());
|
||||
Type.VAR_INT.write(buffer, chunk.getBitmask());
|
||||
|
||||
Type.VAR_INT.write(buffer, chunk.getSections().length);
|
||||
buffer.writeBytes(chunk.getSections());
|
||||
Type.VAR_INT.write(buffer, chunk.getSections()[0].getData().length);
|
||||
buffer.writeBytes(chunk.getSections()[0].getData());
|
||||
|
||||
// no block entities as it's earlier
|
||||
}
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
|
||||
public class ChunkSection1_9_3_4 implements ChunkSection {
|
||||
private final byte[] data;
|
||||
|
||||
public ChunkSection1_9_3_4(byte[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockId(int x, int y, int z) {
|
||||
throw new UnsupportedOperationException("Invalid chunk type!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBlocks(ByteBuf output) throws Exception {
|
||||
throw new UnsupportedOperationException("Invalid chunk type!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBlockLight(ByteBuf output) throws Exception {
|
||||
throw new UnsupportedOperationException("Invalid chunk type!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSkyLight() {
|
||||
throw new UnsupportedOperationException("Invalid chunk type!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSkyLight(ByteBuf output) throws Exception {
|
||||
throw new UnsupportedOperationException("Invalid chunk type!");
|
||||
}
|
||||
}
|
||||
+35
-22
@@ -2,22 +2,32 @@ package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.bukkit.World;
|
||||
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks.ChunkSection1_9to1_8;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
|
||||
public class Chunk1_9_1_2Type extends BaseChunkType {
|
||||
public Chunk1_9_1_2Type() {
|
||||
super("1.9.1/2 Chunk");
|
||||
public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
|
||||
|
||||
public Chunk1_9_1_2Type(ClientWorld clientWorld) {
|
||||
super(clientWorld, Chunk.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk read(ByteBuf input) throws Exception {
|
||||
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
||||
boolean replacePistons = world.getUser().get(ProtocolInfo.class).getPipeline().contains(Protocol1_10To1_9_3_4.class) && ViaVersion.getConfig().isReplacePistons();
|
||||
int replacementId = ViaVersion.getConfig().getPistonReplacementId();
|
||||
|
||||
int chunkX = input.readInt();
|
||||
int chunkZ = input.readInt();
|
||||
|
||||
@@ -39,29 +49,29 @@ public class Chunk1_9_1_2Type extends BaseChunkType {
|
||||
if (!usedSections.get(i)) continue; // Section not set
|
||||
ChunkSection1_9_1_2 section = new ChunkSection1_9_1_2();
|
||||
sections[i] = section;
|
||||
// WIP.
|
||||
// section.readBlocks(input);
|
||||
// section.readBlockLight(input);
|
||||
// section.readSkyLight(input);
|
||||
/*
|
||||
BlockStorage blocks = new BlockStorage(in);
|
||||
NibbleArray3d blocklight = new NibbleArray3d(in, 2048); (1024 bytes)
|
||||
NibbleArray3d skylight = hasSkylight ? new NibbleArray3d(in, 2048) : null; (1024 bytes)
|
||||
chunks[index] = new Chunk(blocks, blocklight, skylight);
|
||||
*/
|
||||
section.readBlocks(input);
|
||||
section.readBlockLight(input);
|
||||
if (world.getEnvironment() == World.Environment.NORMAL) {
|
||||
section.readSkyLight(input);
|
||||
}
|
||||
if (replacePistons) {
|
||||
if (section.getPalette().contains(36)) {
|
||||
section.getPalette().set(section.getPalette().indexOf(36), replacementId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
byte[] biomeData = groundUp ? new byte[256] : null;
|
||||
if (groundUp)
|
||||
if (groundUp) {
|
||||
input.readBytes(biomeData);
|
||||
}
|
||||
|
||||
return new Chunk1_9_1_2(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, new ArrayList<CompoundTag>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf output, Chunk input) throws Exception {
|
||||
if (!(input instanceof Chunk1_9_1_2))
|
||||
throw new Exception("Tried to send the wrong chunk type from 1.9.3-4 chunk: " + input.getClass());
|
||||
Chunk1_9_1_2 chunk = (Chunk1_9_1_2) input;
|
||||
public void write(ByteBuf output, ClientWorld world, Chunk input) throws Exception {
|
||||
Chunk chunk = input;
|
||||
|
||||
output.writeInt(chunk.getX());
|
||||
output.writeInt(chunk.getZ());
|
||||
@@ -71,7 +81,7 @@ public class Chunk1_9_1_2Type extends BaseChunkType {
|
||||
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
for (int i = 0; i < 16; i++) {
|
||||
ChunkSection1_9_1_2 section = chunk.getSections()[i];
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) continue; // Section not set
|
||||
section.writeBlocks(buf);
|
||||
section.writeBlockLight(buf);
|
||||
@@ -89,7 +99,10 @@ public class Chunk1_9_1_2Type extends BaseChunkType {
|
||||
if (chunk.isBiomeData()) {
|
||||
output.writeBytes(chunk.getBiomeData());
|
||||
}
|
||||
}
|
||||
|
||||
// Type.NBT_ARRAY.write(output, tags.toArray(new CompoundTag[0])); Written by the handler
|
||||
@Override
|
||||
public Class<? extends Type> getBaseClass() {
|
||||
return BaseChunkType.class;
|
||||
}
|
||||
}
|
||||
+101
-5
@@ -3,12 +3,14 @@ package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.Getter;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ChunkSection1_9_1_2 {
|
||||
public class ChunkSection1_9_1_2 implements ChunkSection {
|
||||
/**
|
||||
* Size (dimensions) of blocks in a chunks section.
|
||||
*/
|
||||
@@ -20,7 +22,7 @@ public class ChunkSection1_9_1_2 {
|
||||
/**
|
||||
* Length of the block data array.
|
||||
*/
|
||||
|
||||
@Getter
|
||||
private final List<Integer> palette = Lists.newArrayList();
|
||||
private final int[] blocks;
|
||||
private final NibbleArray blockLight;
|
||||
@@ -45,9 +47,9 @@ public class ChunkSection1_9_1_2 {
|
||||
setBlock(index(x, y, z), type, data);
|
||||
}
|
||||
|
||||
public int getBlockId(int x, int y, int z){
|
||||
public int getBlockId(int x, int y, int z) {
|
||||
int index = blocks[index(x, y, z)];
|
||||
return palette.indexOf(index) >> 4;
|
||||
return palette.get(index) >> 4;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +90,101 @@ public class ChunkSection1_9_1_2 {
|
||||
}
|
||||
|
||||
private int index(int x, int y, int z) {
|
||||
return z << 8 | y << 4 | x;
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read blocks from input stream.
|
||||
* This reads all the block related data:
|
||||
* <ul>
|
||||
* <li>Block length/palette type</li>
|
||||
* <li>Palette</li>
|
||||
* <li>Block hashes/palette reference</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param input The buffer to read from.
|
||||
* @throws Exception
|
||||
*/
|
||||
public void readBlocks(ByteBuf input) throws Exception {
|
||||
palette.clear();
|
||||
|
||||
// Reaad bits per block
|
||||
int bitsPerBlock = input.readUnsignedByte();
|
||||
long maxEntryValue = (1L << bitsPerBlock) - 1;
|
||||
|
||||
if (bitsPerBlock == 0) {
|
||||
bitsPerBlock = 13;
|
||||
}
|
||||
if (bitsPerBlock < 4) {
|
||||
bitsPerBlock = 4;
|
||||
}
|
||||
if (bitsPerBlock > 8) {
|
||||
bitsPerBlock = 13;
|
||||
}
|
||||
int paletteLength = Type.VAR_INT.read(input);
|
||||
// Read palette
|
||||
for (int i = 0; i < paletteLength; i++) {
|
||||
if (bitsPerBlock != 13) {
|
||||
palette.add(Type.VAR_INT.read(input));
|
||||
} else {
|
||||
Type.VAR_INT.read(input);
|
||||
}
|
||||
}
|
||||
|
||||
// Read blocks
|
||||
Long[] blockData = Type.LONG_ARRAY.read(input);
|
||||
if (blockData.length > 0) {
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
int bitIndex = i * bitsPerBlock;
|
||||
int startIndex = bitIndex / 64;
|
||||
int endIndex = ((i + 1) * bitsPerBlock - 1) / 64;
|
||||
int startBitSubIndex = bitIndex % 64;
|
||||
int val;
|
||||
if (startIndex == endIndex) {
|
||||
val = (int) (blockData[startIndex] >>> startBitSubIndex & maxEntryValue);
|
||||
} else {
|
||||
int endBitSubIndex = 64 - startBitSubIndex;
|
||||
val = (int) ((blockData[startIndex] >>> startBitSubIndex | blockData[endIndex] << endBitSubIndex) & maxEntryValue);
|
||||
}
|
||||
|
||||
if (bitsPerBlock == 13) {
|
||||
int type = val >> 4;
|
||||
int data = val & 0xF;
|
||||
|
||||
setBlock(i, type, data);
|
||||
} else {
|
||||
blocks[i] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read block light from buffer.
|
||||
*
|
||||
* @param input The buffer to read from
|
||||
*/
|
||||
public void readBlockLight(ByteBuf input) {
|
||||
byte[] handle = new byte[LIGHT_LENGTH];
|
||||
input.readBytes(handle);
|
||||
blockLight.setHandle(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read sky light from buffer.
|
||||
* Note: Only sent in overworld!
|
||||
*
|
||||
* @param input The buffer to read from
|
||||
*/
|
||||
public void readSkyLight(ByteBuf input) {
|
||||
byte[] handle = new byte[LIGHT_LENGTH];
|
||||
input.readBytes(handle);
|
||||
if (skyLight != null) {
|
||||
skyLight.setHandle(handle);
|
||||
return;
|
||||
}
|
||||
|
||||
this.skyLight = new NibbleArray(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ public class FakeTileEntity {
|
||||
register(Arrays.asList(Material.SIGN_POST, Material.WALL_SIGN), "Sign");
|
||||
register(Material.MOB_SPAWNER, "MobSpawner");
|
||||
register(Material.NOTE_BLOCK, "Music");
|
||||
register(Material.PISTON_BASE, "Piston");
|
||||
register(Arrays.asList(Material.PISTON_BASE, Material.PISTON_EXTENSION, Material.PISTON_STICKY_BASE, Material.PISTON_MOVING_PIECE), "Piston");
|
||||
register(Arrays.asList(Material.BREWING_STAND, Material.CAULDRON), "Cauldron");
|
||||
register(Material.ENCHANTMENT_TABLE, "EnchantTable");
|
||||
register(Arrays.asList(Material.ENDER_PORTAL, Material.ENDER_PORTAL_FRAME), "Airportal");
|
||||
@@ -38,7 +38,7 @@ public class FakeTileEntity {
|
||||
register(Arrays.asList(Material.REDSTONE_COMPARATOR, Material.REDSTONE_COMPARATOR_OFF, Material.REDSTONE_COMPARATOR_ON), "Comparator");
|
||||
register(Material.FLOWER_POT, "FlowerPot");
|
||||
register(Arrays.asList(Material.STANDING_BANNER, Material.WALL_BANNER, Material.BANNER), "Banner");
|
||||
register(209, "EndGateway"); // todo test
|
||||
register(209, "EndGateway");
|
||||
register(Material.COMMAND.getId(), "Control");
|
||||
}
|
||||
|
||||
|
||||
+58
-29
@@ -6,15 +6,14 @@ import org.spacehq.opennbt.tag.builtin.StringTag;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks.Chunk1_9to1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks.ChunkSection1_9to1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.types.ChunkType;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -74,35 +73,65 @@ public class Protocol1_9_3TO1_9_1_2 extends Protocol {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientChunks clientChunks = wrapper.user().get(ClientChunks.class);
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
ChunkType type = new ChunkType(clientChunks);
|
||||
if (wrapper.isReadable(type, 0)) {
|
||||
Chunk1_9to1_8 chunk = (Chunk1_9to1_8) wrapper.read(type);
|
||||
Chunk1_9_1_2Type type = new Chunk1_9_1_2Type(clientWorld);
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
List<CompoundTag> tags = new ArrayList<>();
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection1_9to1_8 section = chunk.getSections()[i];
|
||||
if (section == null)
|
||||
continue;
|
||||
List<CompoundTag> tags = new ArrayList<>();
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null)
|
||||
continue;
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
for (int y = 0; y < 16; y++)
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int block = section.getBlockId(x, y, z);
|
||||
if (FakeTileEntity.hasBlock(block)) {
|
||||
// NOT SURE WHY Y AND Z WORK THIS WAY, TODO: WORK OUT WHY THIS IS OR FIX W/E BROKE IT
|
||||
tags.add(FakeTileEntity.getFromBlock(x + (chunk.getX() << 4), z + (i << 4), y + (chunk.getZ() << 4), block));
|
||||
}
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int block = section.getBlockId(x, y, z);
|
||||
if (FakeTileEntity.hasBlock(block)) {
|
||||
tags.add(FakeTileEntity.getFromBlock(x + (chunk.getX() << 4), y + (i << 4), z + (chunk.getZ() << 4), block));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wrapper.write(type, chunk);
|
||||
wrapper.write(Type.NBT_ARRAY, tags.toArray(new CompoundTag[0]));
|
||||
} else {
|
||||
wrapper.passthroughAll();
|
||||
wrapper.write(Type.VAR_INT, 0);
|
||||
}
|
||||
|
||||
wrapper.write(Type.NBT_ARRAY, tags.toArray(new CompoundTag[0]));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Join (save dimension id)
|
||||
registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Respawn (save dimension id)
|
||||
registerOutgoing(State.PLAY, 0x33, 0x33, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 0);
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -110,7 +139,7 @@ public class Protocol1_9_3TO1_9_1_2 extends Protocol {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
|
||||
public void init(UserConnection user) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.World;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
@Getter
|
||||
public class ClientWorld extends StoredObject {
|
||||
private World.Environment environment;
|
||||
|
||||
public ClientWorld(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public void setEnvironment(int environmentId) {
|
||||
this.environment = getEnvFromId(environmentId);
|
||||
}
|
||||
|
||||
private World.Environment getEnvFromId(int id) {
|
||||
switch(id) {
|
||||
case -1:
|
||||
return World.Environment.NETHER;
|
||||
case 0:
|
||||
return World.Environment.NORMAL;
|
||||
case 1:
|
||||
return World.Environment.THE_END;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid environment id:" + id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,11 +213,9 @@ public class ItemRewriter {
|
||||
item.setId((short) 438); // splash id
|
||||
item.setData((short) (item.getData() - 8192));
|
||||
}
|
||||
if (POTION_ID_TO_NAME.containsKey((int) item.getData())) {
|
||||
String name = POTION_ID_TO_NAME.get((int) item.getData());
|
||||
StringTag potion = new StringTag("Potion", "minecraft:" + name);
|
||||
tag.put(potion);
|
||||
}
|
||||
String name = potionNameFromDamage(item.getData());
|
||||
StringTag potion = new StringTag("Potion", "minecraft:" + name);
|
||||
tag.put(potion);
|
||||
item.setTag(tag);
|
||||
item.setData((short) 0);
|
||||
}
|
||||
@@ -245,10 +243,113 @@ public class ItemRewriter {
|
||||
}
|
||||
}
|
||||
|
||||
public static String potionNameFromDamage(short damage) {
|
||||
String cached = POTION_ID_TO_NAME.get((int) damage);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
if (damage == 0) {
|
||||
return "water";
|
||||
}
|
||||
|
||||
int effect = damage & 0xF;
|
||||
int name = damage & 0x3F;
|
||||
boolean enhanced = (damage & 0x20) > 0;
|
||||
boolean extended = (damage & 0x40) > 0;
|
||||
|
||||
boolean canEnhance = true;
|
||||
boolean canExtend = true;
|
||||
|
||||
String id;
|
||||
switch (effect) {
|
||||
case 1:
|
||||
id = "regeneration";
|
||||
break;
|
||||
case 2:
|
||||
id = "swiftness";
|
||||
break;
|
||||
case 3:
|
||||
id = "fire_resistance";
|
||||
canEnhance = false;
|
||||
break;
|
||||
case 4:
|
||||
id = "poison";
|
||||
break;
|
||||
case 5:
|
||||
id = "healing";
|
||||
canExtend = false;
|
||||
break;
|
||||
case 6:
|
||||
id = "night_vision";
|
||||
canEnhance = false;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
id = "weakness";
|
||||
canEnhance = false;
|
||||
break;
|
||||
case 9:
|
||||
id = "strength";
|
||||
break;
|
||||
case 10:
|
||||
id = "slowness";
|
||||
canEnhance = false;
|
||||
break;
|
||||
case 11:
|
||||
id = "leaping";
|
||||
break;
|
||||
case 12:
|
||||
id = "harming";
|
||||
canExtend = false;
|
||||
break;
|
||||
case 13:
|
||||
id = "water_breathing";
|
||||
canEnhance = false;
|
||||
break;
|
||||
case 14:
|
||||
id = "invisibility";
|
||||
canEnhance = false;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
canEnhance = false;
|
||||
canExtend = false;
|
||||
switch (name) {
|
||||
case 0:
|
||||
id = "mundane";
|
||||
break;
|
||||
case 16:
|
||||
id = "awkward";
|
||||
break;
|
||||
case 32:
|
||||
id = "thick";
|
||||
break;
|
||||
default:
|
||||
id = "empty";
|
||||
}
|
||||
}
|
||||
|
||||
if (effect > 0) {
|
||||
if (canEnhance && enhanced) {
|
||||
id = "strong_" + id;
|
||||
} else if (canExtend && extended) {
|
||||
id = "long_" + id;
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public static int getNewEffectID(int oldID) {
|
||||
if (oldID >= 16384) {
|
||||
oldID -= 8192;
|
||||
}
|
||||
if (POTION_INDEX.containsKey(oldID)) {
|
||||
return POTION_INDEX.get(oldID);
|
||||
}
|
||||
|
||||
oldID = POTION_NAME_TO_ID.get(potionNameFromDamage((short) oldID));
|
||||
return POTION_INDEX.containsKey(oldID) ? POTION_INDEX.get(oldID) : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,7 @@ public class Protocol1_9TO1_8 extends Protocol {
|
||||
line = "{\"text\":\"\"}";
|
||||
} else {
|
||||
if ((!line.startsWith("\"") || !line.endsWith("\"")) && (!line.startsWith("{") || !line.endsWith("}"))) {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("text", line);
|
||||
return gson.toJson(jsonObject);
|
||||
return constructJson(line);
|
||||
}
|
||||
if (line.startsWith("\"") && line.endsWith("\"")) {
|
||||
line = "{\"text\":" + line + "}";
|
||||
@@ -52,12 +50,22 @@ public class Protocol1_9TO1_8 extends Protocol {
|
||||
try {
|
||||
gson.fromJson(line, JsonObject.class);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Invalid JSON String: \"" + line + "\" Please report this issue to the ViaVersion Github: " + e.getMessage());
|
||||
return "{\"text\":\"\"}";
|
||||
if (ViaVersion.getConfig().isForceJsonTransform()) {
|
||||
return constructJson(line);
|
||||
} else {
|
||||
System.out.println("Invalid JSON String: \"" + line + "\" Please report this issue to the ViaVersion Github: " + e.getMessage());
|
||||
return "{\"text\":\"\"}";
|
||||
}
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
private static String constructJson(String text) {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("text", text);
|
||||
return gson.toJson(jsonObject);
|
||||
}
|
||||
|
||||
public static Item getHandItem(final UserConnection info) {
|
||||
if (HandItemCache.CACHE) {
|
||||
return HandItemCache.getHandItem(info.get(ProtocolInfo.class).getUuid());
|
||||
|
||||
+10
@@ -36,4 +36,14 @@ public class Chunk1_9to1_8 implements Chunk {
|
||||
public boolean hasBiomeData() {
|
||||
return biomeData != null && groundUp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBiomeData() {
|
||||
return biomeData != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBitmask() {
|
||||
return primaryBitmask;
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -3,12 +3,13 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ChunkSection1_9to1_8 {
|
||||
public class ChunkSection1_9to1_8 implements ChunkSection {
|
||||
/**
|
||||
* Size (dimensions) of blocks in a chunks section.
|
||||
*/
|
||||
@@ -88,7 +89,7 @@ public class ChunkSection1_9to1_8 {
|
||||
}
|
||||
|
||||
private int index(int x, int y, int z) {
|
||||
return z << 8 | y << 4 | x;
|
||||
return y << 8 | z << 4 | x;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
-2
@@ -3,7 +3,10 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.storage;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
@@ -26,8 +29,10 @@ public class ClientChunks extends StoredObject {
|
||||
try {
|
||||
mapChunkBulkRef = new ReflectionUtil.ClassReflection(ReflectionUtil.nms("PacketPlayOutMapChunkBulk"));
|
||||
mapChunkRef = new ReflectionUtil.ClassReflection(ReflectionUtil.nms("PacketPlayOutMapChunk"));
|
||||
obfuscateRef = Class.forName("org.spigotmc.AntiXray").getMethod("obfuscate", int.class, int.class, int.class, byte[].class, ReflectionUtil.nms("World"));
|
||||
worldRef = ReflectionUtil.nms("World");
|
||||
if (ViaVersion.getInstance().isSpigot()) {
|
||||
obfuscateRef = Class.forName("org.spigotmc.AntiXray").getMethod("obfuscate", int.class, int.class, int.class, byte[].class, ReflectionUtil.nms("World"));
|
||||
worldRef = ReflectionUtil.nms("World");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to initialise chunks reflection", e);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.types;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.bukkit.Bukkit;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks.Chunk1_9to1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.chunks.ChunkSection1_9to1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
|
||||
@@ -46,6 +49,9 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
|
||||
|
||||
@Override
|
||||
public Chunk read(ByteBuf input, ClientChunks param) throws Exception {
|
||||
boolean replacePistons = param.getUser().get(ProtocolInfo.class).getPipeline().contains(Protocol1_10To1_9_3_4.class) && ViaVersion.getConfig().isReplacePistons();
|
||||
int replacementId = ViaVersion.getConfig().getPistonReplacementId();
|
||||
|
||||
int chunkX = input.readInt();
|
||||
int chunkZ = input.readInt();
|
||||
long chunkHash = toLong(chunkX, chunkZ);
|
||||
@@ -93,7 +99,8 @@ public class ChunkType extends PartialType<Chunk, ClientChunks> {
|
||||
int mask = blockBuf.get();
|
||||
int type = mask >> 4;
|
||||
int data = mask & 0xF;
|
||||
|
||||
if (replacePistons && type == 36)
|
||||
type = replacementId;
|
||||
section.setBlock(j, type, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
package us.myles.ViaVersion.util;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by wea_ondara licensed under MIT
|
||||
* Same license as in LICENSE
|
||||
*
|
||||
* Taken from:
|
||||
* https://github.com/weaondara/BungeePerms/blob/master/src/main/java/net/alpenblock/bungeeperms/util/ConcurrentList.java
|
||||
* @param <E> List Type
|
||||
*/
|
||||
public class ConcurrentList<E> extends ArrayList<E> {
|
||||
|
||||
private final Object lock = new Object();
|
||||
|
||||
@Override
|
||||
public boolean add(E e) {
|
||||
synchronized (lock) {
|
||||
return super.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, E element) {
|
||||
synchronized (lock) {
|
||||
super.add(index, element);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends E> c) {
|
||||
synchronized (lock) {
|
||||
return super.addAll(c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends E> c) {
|
||||
synchronized (lock) {
|
||||
return super.addAll(index, c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
synchronized (lock) {
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public Object clone() {
|
||||
synchronized (lock) {
|
||||
ConcurrentList<E> clist = (ConcurrentList<E>) super.clone();
|
||||
clist.modCount = 0;
|
||||
Field f = ArrayList.class.getDeclaredField("elementData");
|
||||
f.setAccessible(true);
|
||||
f.set(clist, Arrays.copyOf((Object[]) f.get(this), this.size()));
|
||||
|
||||
return clist;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
synchronized (lock) {
|
||||
return super.contains(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ensureCapacity(int minCapacity) {
|
||||
synchronized (lock) {
|
||||
super.ensureCapacity(minCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
synchronized (lock) {
|
||||
return super.get(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
synchronized (lock) {
|
||||
return super.indexOf(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
synchronized (lock) {
|
||||
return super.lastIndexOf(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
synchronized (lock) {
|
||||
return super.remove(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
synchronized (lock) {
|
||||
return super.remove(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
synchronized (lock) {
|
||||
return super.removeAll(c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
synchronized (lock) {
|
||||
return super.retainAll(c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
synchronized (lock) {
|
||||
return super.set(index, element);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> subList(int fromIndex, int toIndex) {
|
||||
synchronized (lock) {
|
||||
return super.subList(fromIndex, toIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
synchronized (lock) {
|
||||
return super.toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
synchronized (lock) {
|
||||
return super.toArray(a);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trimToSize() {
|
||||
synchronized (lock) {
|
||||
super.trimToSize();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<E> listIterator() {
|
||||
return new ListItr(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return new Itr();
|
||||
}
|
||||
|
||||
private class Itr implements Iterator<E> {
|
||||
|
||||
protected int cursor;
|
||||
protected int lastRet;
|
||||
final ConcurrentList l;
|
||||
|
||||
public Itr() {
|
||||
cursor = 0;
|
||||
lastRet = -1;
|
||||
l = (ConcurrentList) ConcurrentList.this.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return cursor < l.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
int i = cursor;
|
||||
if (i >= l.size()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
cursor = i + 1;
|
||||
return (E) l.get(lastRet = i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if (lastRet < 0) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
l.remove(lastRet);
|
||||
ConcurrentList.this.remove(lastRet);
|
||||
cursor = lastRet;
|
||||
lastRet = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public class ListItr extends Itr implements ListIterator<E> {
|
||||
|
||||
ListItr(int index) {
|
||||
super();
|
||||
cursor = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrevious() {
|
||||
return cursor > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextIndex() {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int previousIndex() {
|
||||
return cursor - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E previous() {
|
||||
int i = cursor - 1;
|
||||
if (i < 0) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
cursor = i;
|
||||
return (E) l.get(lastRet = i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(E e) {
|
||||
if (lastRet < 0) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
l.set(lastRet, e);
|
||||
ConcurrentList.this.set(lastRet, e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(E e) {
|
||||
int i = cursor;
|
||||
l.add(i, e);
|
||||
ConcurrentList.this.add(i, e);
|
||||
cursor = i + 1;
|
||||
lastRet = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package us.myles.ViaVersion.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class ListWrapper implements List {
|
||||
public final Object lock = new Object();
|
||||
private final List list;
|
||||
|
||||
public ListWrapper(List inputList) {
|
||||
@@ -20,123 +18,169 @@ public abstract class ListWrapper implements List {
|
||||
|
||||
@Override
|
||||
public synchronized int size() {
|
||||
return this.list.size();
|
||||
synchronized (lock) {
|
||||
return this.list.size();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isEmpty() {
|
||||
return this.list.isEmpty();
|
||||
synchronized (lock) {
|
||||
return this.list.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean contains(Object o) {
|
||||
return this.list.contains(o);
|
||||
synchronized (lock) {
|
||||
return this.list.contains(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Iterator iterator() {
|
||||
return this.list.iterator();
|
||||
synchronized (lock) {
|
||||
return listIterator();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Object[] toArray() {
|
||||
return this.list.toArray();
|
||||
synchronized (lock) {
|
||||
return this.list.toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean add(Object o) {
|
||||
handleAdd(o);
|
||||
return this.list.add(o);
|
||||
synchronized (lock) {
|
||||
handleAdd(o);
|
||||
return this.list.add(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean remove(Object o) {
|
||||
return this.list.remove(o);
|
||||
synchronized (lock) {
|
||||
return this.list.remove(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean addAll(Collection c) {
|
||||
for (Object o : c) {
|
||||
handleAdd(o);
|
||||
synchronized (lock) {
|
||||
for (Object o : c) {
|
||||
handleAdd(o);
|
||||
}
|
||||
return this.list.addAll(c);
|
||||
}
|
||||
return this.list.addAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean addAll(int index, Collection c) {
|
||||
for (Object o : c) {
|
||||
handleAdd(o);
|
||||
synchronized (lock) {
|
||||
for (Object o : c) {
|
||||
handleAdd(o);
|
||||
}
|
||||
return this.list.addAll(index, c);
|
||||
}
|
||||
return this.list.addAll(index, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void clear() {
|
||||
this.list.clear();
|
||||
synchronized (lock) {
|
||||
this.list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Object get(int index) {
|
||||
return this.list.get(index);
|
||||
synchronized (lock) {
|
||||
return this.list.get(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Object set(int index, Object element) {
|
||||
return this.list.set(index, element);
|
||||
synchronized (lock) {
|
||||
return this.list.set(index, element);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void add(int index, Object element) {
|
||||
this.list.add(index, element);
|
||||
synchronized (lock) {
|
||||
this.list.add(index, element);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Object remove(int index) {
|
||||
return this.list.remove(index);
|
||||
synchronized (lock) {
|
||||
return this.list.remove(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int indexOf(Object o) {
|
||||
return this.list.indexOf(o);
|
||||
synchronized (lock) {
|
||||
return this.list.indexOf(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int lastIndexOf(Object o) {
|
||||
return this.list.lastIndexOf(o);
|
||||
synchronized (lock) {
|
||||
return this.list.lastIndexOf(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ListIterator listIterator() {
|
||||
return this.list.listIterator();
|
||||
synchronized (lock) {
|
||||
return this.list.listIterator();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized ListIterator listIterator(int index) {
|
||||
return this.list.listIterator(index);
|
||||
synchronized (lock) {
|
||||
return this.list.listIterator(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized List subList(int fromIndex, int toIndex) {
|
||||
return this.list.subList(fromIndex, toIndex);
|
||||
synchronized (lock) {
|
||||
return this.list.subList(fromIndex, toIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean retainAll(Collection c) {
|
||||
return this.list.retainAll(c);
|
||||
synchronized (lock) {
|
||||
return this.list.retainAll(c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean removeAll(Collection c) {
|
||||
return this.list.removeAll(c);
|
||||
synchronized (lock) {
|
||||
return this.list.removeAll(c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean containsAll(Collection c) {
|
||||
return this.list.containsAll(c);
|
||||
synchronized (lock) {
|
||||
return this.list.containsAll(c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Object[] toArray(Object[] a) {
|
||||
return this.list.toArray(a);
|
||||
synchronized (lock) {
|
||||
return this.list.toArray(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,28 +12,34 @@
|
||||
checkforupdates: true
|
||||
# Send the supported versions with the Status (Ping) response packet
|
||||
send-supported-versions: false
|
||||
# Block specific Minecraft protocols that ViaVersion allows
|
||||
# List of all Minecraft protocol versions: http://wiki.vg/Protocol_version_numbers
|
||||
block-protocols: []
|
||||
# Change the blocked disconnect message
|
||||
block-disconnect-msg: "You are using an unsupported Minecraft version!"
|
||||
#
|
||||
#----------------------------------------------------------#
|
||||
# GLOBAL PACKET LIMITER #
|
||||
#----------------------------------------------------------#
|
||||
#
|
||||
# Anti-Cheat, Packets Per Second (PPS) limiter
|
||||
#
|
||||
# Packets Per Second (PPS) limiter (Use -1 on max-pps and tracking-period to disable)
|
||||
# Clients by default send around 20-90 packets per second.
|
||||
|
||||
#
|
||||
# What is the maximum per second a client can send (Use %pps to display their pps)
|
||||
# Use -1 to disable.
|
||||
max-pps: 600
|
||||
max-pps-kick-msg: "You are sending too many packets!"
|
||||
|
||||
#
|
||||
# We can also kick them if over a period they send over a threshold a certain amount of times.
|
||||
|
||||
#
|
||||
# Period to track (in seconds)
|
||||
# Use -1 to disable.
|
||||
tracking-period: 6
|
||||
# How many packets per second counts as a warning
|
||||
tracking-warning-pps: 120
|
||||
# How many warnings over the interval can we have
|
||||
# This can never be higher than "tracking-interval"
|
||||
# This can never be higher than "tracking-period"
|
||||
tracking-max-warnings: 4
|
||||
tracking-max-kick-msg: "You are sending too many packets, :("
|
||||
#
|
||||
@@ -70,4 +76,10 @@ use-new-deathmessages: false
|
||||
# Should we cache our items, this will prevent server from being lagged out, however the cost is a constant task caching items
|
||||
item-cache: true
|
||||
# Patch the Anti xray to work on 1.9 & 1.10 (If your server is 1.8) This can cost more performance, so disable it if you don't use it.
|
||||
anti-xray-patch: true
|
||||
anti-xray-patch: true
|
||||
# Should we replace extended pistons to fix 1.10.1 (Only on chunk load)
|
||||
replace-pistons: false
|
||||
# What id should we replace with, default is air. (careful of players getting stuck standing on them)
|
||||
replacement-piston-id: 0
|
||||
# Force the string -> json transform
|
||||
force-json-transform: false
|
||||
Reference in new issue
Block a user