mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-10-31 23:59:33 +01:00
Formatting
This commit is contained in:
parent
fba0a59324
commit
c1147cb9f7
@ -1,7 +1,7 @@
|
||||
sudo: false
|
||||
|
||||
language: java
|
||||
jdk:
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
- openjdk11
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class DeathListener extends ViaBukkitListener {
|
||||
@Override
|
||||
public void run() {
|
||||
// If online
|
||||
if(getUserConnection(p) != null) {
|
||||
if (getUserConnection(p) != null) {
|
||||
PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p));
|
||||
try {
|
||||
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
|
||||
|
@ -164,7 +164,7 @@ public class BukkitViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean is1_12NBTArrayFix() {
|
||||
return getBoolean("chat-nbt-fix", true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean is1_12QuickMoveActionFix() {
|
||||
return getBoolean("quick-move-action-fix", false);
|
||||
|
@ -203,7 +203,7 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean is1_12NBTArrayFix() {
|
||||
return getBoolean("chat-nbt-fix", true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean is1_12QuickMoveActionFix() {
|
||||
return false;
|
||||
|
@ -208,7 +208,7 @@ public class UserConnection {
|
||||
/**
|
||||
* Sends a raw packet to the server
|
||||
*
|
||||
* @param packet Raw packet to be sent
|
||||
* @param packet Raw packet to be sent
|
||||
* @param currentThread If {@code true} executes immediately, {@code false} submits a task to EventLoop
|
||||
*/
|
||||
public void sendRawPacketToServer(final ByteBuf packet, boolean currentThread) {
|
||||
@ -248,5 +248,7 @@ public class UserConnection {
|
||||
*
|
||||
* @param packet Raw packet to be sent
|
||||
*/
|
||||
public void sendRawPacketToServer(ByteBuf packet) { sendRawPacketToServer(packet, false); }
|
||||
public void sendRawPacketToServer(ByteBuf packet) {
|
||||
sendRawPacketToServer(packet, false);
|
||||
}
|
||||
}
|
||||
|
@ -9,26 +9,27 @@ import java.util.Map;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum BlockFace {
|
||||
NORTH(0, 0, -1, EnumAxis.Z), SOUTH(0, 0, 1, EnumAxis.Z), EAST(1, 0, 0, EnumAxis.X), WEST(-1, 0, 0, EnumAxis.X), TOP(0, 1, 0, EnumAxis.Y), BOTTOM(0, -1, 0, EnumAxis.Y);
|
||||
NORTH(0, 0, -1, EnumAxis.Z), SOUTH(0, 0, 1, EnumAxis.Z), EAST(1, 0, 0, EnumAxis.X), WEST(-1, 0, 0, EnumAxis.X), TOP(0, 1, 0, EnumAxis.Y), BOTTOM(0, -1, 0, EnumAxis.Y);
|
||||
|
||||
private static Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
||||
static {
|
||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||
opposites.put(BlockFace.SOUTH, BlockFace.NORTH);
|
||||
opposites.put(BlockFace.EAST, BlockFace.WEST);
|
||||
opposites.put(BlockFace.WEST, BlockFace.EAST);
|
||||
opposites.put(BlockFace.TOP, BlockFace.BOTTOM);
|
||||
opposites.put(BlockFace.BOTTOM, BlockFace.TOP);
|
||||
}
|
||||
private static Map<BlockFace, BlockFace> opposites = new HashMap<>();
|
||||
|
||||
private int modX, modY, modZ;
|
||||
private EnumAxis axis;
|
||||
static {
|
||||
opposites.put(BlockFace.NORTH, BlockFace.SOUTH);
|
||||
opposites.put(BlockFace.SOUTH, BlockFace.NORTH);
|
||||
opposites.put(BlockFace.EAST, BlockFace.WEST);
|
||||
opposites.put(BlockFace.WEST, BlockFace.EAST);
|
||||
opposites.put(BlockFace.TOP, BlockFace.BOTTOM);
|
||||
opposites.put(BlockFace.BOTTOM, BlockFace.TOP);
|
||||
}
|
||||
|
||||
public BlockFace opposite() {
|
||||
return opposites.get(this);
|
||||
}
|
||||
private int modX, modY, modZ;
|
||||
private EnumAxis axis;
|
||||
|
||||
public enum EnumAxis {
|
||||
X, Y, Z;
|
||||
}
|
||||
public BlockFace opposite() {
|
||||
return opposites.get(this);
|
||||
}
|
||||
|
||||
public enum EnumAxis {
|
||||
X, Y, Z;
|
||||
}
|
||||
}
|
||||
|
@ -9,16 +9,16 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class BaseChunk implements Chunk {
|
||||
protected int x;
|
||||
protected int z;
|
||||
protected boolean groundUp;
|
||||
protected int bitmask;
|
||||
protected ChunkSection[] sections;
|
||||
protected int[] biomeData;
|
||||
protected List<CompoundTag> blockEntities;
|
||||
protected int x;
|
||||
protected int z;
|
||||
protected boolean groundUp;
|
||||
protected int bitmask;
|
||||
protected ChunkSection[] sections;
|
||||
protected int[] biomeData;
|
||||
protected List<CompoundTag> blockEntities;
|
||||
|
||||
@Override
|
||||
public boolean isBiomeData() {
|
||||
return biomeData != null;
|
||||
}
|
||||
@Override
|
||||
public boolean isBiomeData() {
|
||||
return biomeData != null;
|
||||
}
|
||||
}
|
||||
|
@ -98,22 +98,22 @@ public class ChunkSection {
|
||||
}
|
||||
|
||||
public void replacePaletteEntry(int oldId, int newId) {
|
||||
Integer index = inversePalette.remove(oldId);
|
||||
if (index == null) return;
|
||||
inversePalette.put(newId, index);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.get(i) == oldId) palette.set(i, newId);
|
||||
}
|
||||
Integer index = inversePalette.remove(oldId);
|
||||
if (index == null) return;
|
||||
inversePalette.put(newId, index);
|
||||
for (int i = 0; i < palette.size(); i++) {
|
||||
if (palette.get(i) == oldId) palette.set(i, newId);
|
||||
}
|
||||
}
|
||||
|
||||
public void addPaletteEntry(int id) {
|
||||
inversePalette.put(id, palette.size());
|
||||
palette.add(id);
|
||||
inversePalette.put(id, palette.size());
|
||||
palette.add(id);
|
||||
}
|
||||
|
||||
public void clearPalette() {
|
||||
palette.clear();
|
||||
inversePalette.clear();
|
||||
palette.clear();
|
||||
inversePalette.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -124,14 +124,14 @@ public class ChunkSection {
|
||||
* @param id The raw or flat id of the block
|
||||
*/
|
||||
public void setFlatBlock(int idx, int id) {
|
||||
Integer index = inversePalette.get(id);
|
||||
if (index == null) {
|
||||
index = palette.size();
|
||||
palette.add(id);
|
||||
inversePalette.put(id, index);
|
||||
}
|
||||
Integer index = inversePalette.get(id);
|
||||
if (index == null) {
|
||||
index = palette.size();
|
||||
palette.add(id);
|
||||
inversePalette.put(id, index);
|
||||
}
|
||||
|
||||
blocks[idx] = index;
|
||||
blocks[idx] = index;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,8 +57,8 @@ public class ProtocolRegistry {
|
||||
registerProtocol(new Protocol1_12_2TO1_12_1(), Collections.singletonList(ProtocolVersion.v1_12_2.getId()), ProtocolVersion.v1_12_1.getId());
|
||||
|
||||
registerProtocol(new Protocol1_13To1_12_2(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_12_2.getId());
|
||||
registerProtocol(new Protocol1_13_1To1_13(), Arrays.asList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13.getId());
|
||||
registerProtocol(new Protocol1_13_2To1_13_1(), Arrays.asList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_13_1.getId());
|
||||
registerProtocol(new Protocol1_13_1To1_13(), Arrays.asList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13.getId());
|
||||
registerProtocol(new Protocol1_13_2To1_13_1(), Arrays.asList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_13_1.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ public class ProtocolRegistry {
|
||||
* Base Protocols registered later have higher priority
|
||||
* Only one base protocol will be added to pipeline
|
||||
*
|
||||
* @param baseProtocol Base Protocol to register
|
||||
* @param baseProtocol Base Protocol to register
|
||||
* @param supportedProtocols Versions that baseProtocol supports
|
||||
*/
|
||||
public static void registerBaseProtocol(Protocol baseProtocol, Range<Integer> supportedProtocols) {
|
||||
|
@ -6,24 +6,24 @@ import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.MetaTypeTemplate;
|
||||
|
||||
public class Metadata1_13_2Type extends MetaTypeTemplate {
|
||||
@Override
|
||||
public Metadata read(ByteBuf buffer) throws Exception {
|
||||
short index = buffer.readUnsignedByte();
|
||||
@Override
|
||||
public Metadata read(ByteBuf buffer) throws Exception {
|
||||
short index = buffer.readUnsignedByte();
|
||||
|
||||
if (index == 0xff) return null; //End of metadata
|
||||
MetaType1_13_2 type = MetaType1_13_2.byId(buffer.readByte());
|
||||
if (index == 0xff) return null; //End of metadata
|
||||
MetaType1_13_2 type = MetaType1_13_2.byId(buffer.readByte());
|
||||
|
||||
return new Metadata(index, type, type.getType().read(buffer));
|
||||
}
|
||||
return new Metadata(index, type, type.getType().read(buffer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, Metadata object) throws Exception {
|
||||
if (object == null) {
|
||||
buffer.writeByte(255);
|
||||
} else {
|
||||
buffer.writeByte(object.getId());
|
||||
buffer.writeByte(object.getMetaType().getTypeID());
|
||||
object.getMetaType().getType().write(buffer, object.getValue());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void write(ByteBuf buffer, Metadata object) throws Exception {
|
||||
if (object == null) {
|
||||
buffer.writeByte(255);
|
||||
} else {
|
||||
buffer.writeByte(object.getId());
|
||||
buffer.writeByte(object.getMetaType().getTypeID());
|
||||
object.getMetaType().getType().write(buffer, object.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import java.util.List;
|
||||
|
||||
public class Types1_13_2 {
|
||||
/**
|
||||
* Metadata list type for 1.13
|
||||
*/
|
||||
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_13_2Type();
|
||||
/**
|
||||
* Metadata list type for 1.13
|
||||
*/
|
||||
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_13_2Type();
|
||||
|
||||
/**
|
||||
* Metadata type for 1.13
|
||||
*/
|
||||
public static final Type<Metadata> METADATA = new Metadata1_13_2Type();
|
||||
/**
|
||||
* Metadata type for 1.13
|
||||
*/
|
||||
public static final Type<Metadata> METADATA = new Metadata1_13_2Type();
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class MetadataRewriter {
|
||||
public static void handleMetadata(int entityId, EntityType type, List<Metadata> metadatas, UserConnection connection) {
|
||||
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
||||
try {
|
||||
if(metadata.getValue() instanceof Item) {
|
||||
if (metadata.getValue() instanceof Item) {
|
||||
// Apply rewrite
|
||||
EntityIdRewriter.toClientItem((Item) metadata.getValue());
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ public class TranslateRewriter {
|
||||
public static boolean toClient(JsonElement element, UserConnection user) {
|
||||
if (element instanceof JsonObject) {
|
||||
JsonObject obj = (JsonObject) element;
|
||||
if(obj.has("translate")) {
|
||||
if(obj.get("translate").getAsString().equals("chat.type.achievement")) {
|
||||
if (obj.has("translate")) {
|
||||
if (obj.get("translate").getAsString().equals("chat.type.achievement")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -14,68 +14,68 @@ import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.WorldPackets
|
||||
import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.types.Particle1_13_2Type;
|
||||
|
||||
public class Protocol1_13_2To1_13_1 extends Protocol {
|
||||
public static final Particle1_13_2Type PARTICLE_TYPE = new Particle1_13_2Type();
|
||||
public static final Particle1_13_2Type PARTICLE_TYPE = new Particle1_13_2Type();
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
InventoryPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
EntityPackets.register(this);
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
InventoryPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
EntityPackets.register(this);
|
||||
|
||||
//Edit Book
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM);
|
||||
}
|
||||
});
|
||||
//Edit Book
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM);
|
||||
}
|
||||
});
|
||||
|
||||
// Advancements
|
||||
registerOutgoing(State.PLAY, 0x51, 0x51, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
// Advancements
|
||||
registerOutgoing(State.PLAY, 0x51, 0x51, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN))
|
||||
wrapper.passthrough(Type.STRING);
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN))
|
||||
wrapper.passthrough(Type.STRING);
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
Item icon = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
Item icon = wrapper.read(Type.FLAT_ITEM);
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,84 +14,84 @@ import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class EntityPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
// Spawn mob packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
map(Type.BYTE); // 8 - Head Pitch
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 12 - Metadata
|
||||
public static void register(Protocol protocol) {
|
||||
// Spawn mob packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
map(Type.BYTE); // 8 - Head Pitch
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
|
||||
if (metadata.getMetaType() == MetaType1_13.Slot) {
|
||||
metadata.setMetaType(MetaType1_13_2.Slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
|
||||
if (metadata.getMetaType() == MetaType1_13.Slot) {
|
||||
metadata.setMetaType(MetaType1_13_2.Slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn player packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
map(Type.DOUBLE); // 3 - Y
|
||||
map(Type.DOUBLE); // 4 - Z
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata
|
||||
// Spawn player packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
map(Type.DOUBLE); // 3 - Y
|
||||
map(Type.DOUBLE); // 4 - Z
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
|
||||
if (metadata.getMetaType() == MetaType1_13.Slot) {
|
||||
metadata.setMetaType(MetaType1_13_2.Slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
|
||||
if (metadata.getMetaType() == MetaType1_13.Slot) {
|
||||
metadata.setMetaType(MetaType1_13_2.Slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Metadata packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 1 - Metadata list
|
||||
// Metadata packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 1 - Metadata list
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
|
||||
if (metadata.getMetaType() == MetaType1_13.Slot) {
|
||||
metadata.setMetaType(MetaType1_13_2.Slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
|
||||
if (metadata.getMetaType() == MetaType1_13.Slot) {
|
||||
metadata.setMetaType(MetaType1_13_2.Slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,143 +9,143 @@ import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class InventoryPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
public static void register(Protocol protocol) {
|
||||
|
||||
/*
|
||||
Outgoing packets
|
||||
*/
|
||||
|
||||
// Set slot packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value
|
||||
}
|
||||
});
|
||||
// Set slot packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value
|
||||
}
|
||||
});
|
||||
|
||||
// Window items packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.FLAT_ITEM_ARRAY, Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values
|
||||
}
|
||||
});
|
||||
// Window items packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.FLAT_ITEM_ARRAY, Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values
|
||||
}
|
||||
});
|
||||
|
||||
// Plugin message
|
||||
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // Channel
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
String channel = wrapper.get(Type.STRING, 0);
|
||||
if (channel.equals("minecraft:trader_list") || channel.equals("trader_list")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
// Plugin message
|
||||
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // Channel
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
String channel = wrapper.get(Type.STRING, 0);
|
||||
if (channel.equals("minecraft:trader_list") || channel.equals("trader_list")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
// Input Item
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
// Output Item
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
// Input Item
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
// Output Item
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
}
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem) {
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.VAR_INT); // 1 - Slot ID
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Item
|
||||
}
|
||||
});
|
||||
// Entity Equipment Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.VAR_INT); // 1 - Slot ID
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Item
|
||||
}
|
||||
});
|
||||
|
||||
// Declare Recipes
|
||||
protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int recipesNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < recipesNo; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Id
|
||||
String type = wrapper.passthrough(Type.STRING);
|
||||
if (type.equals("crafting_shapeless")) {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i1 = 0; i1 < ingredientsNo; i1++) {
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT));
|
||||
}
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
} else if (type.equals("crafting_shaped")) {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
for (int i1 = 0; i1 < ingredientsNo; i1++) {
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT));
|
||||
}
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
} else if (type.equals("smelting")) {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
// Ingredient start
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT));
|
||||
// Ingredient end
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// Declare Recipes
|
||||
protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int recipesNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < recipesNo; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Id
|
||||
String type = wrapper.passthrough(Type.STRING);
|
||||
if (type.equals("crafting_shapeless")) {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i1 = 0; i1 < ingredientsNo; i1++) {
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT));
|
||||
}
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
} else if (type.equals("crafting_shaped")) {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
for (int i1 = 0; i1 < ingredientsNo; i1++) {
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT));
|
||||
}
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
} else if (type.equals("smelting")) {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
// Ingredient start
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_ITEM_ARRAY_VAR_INT));
|
||||
// Ingredient end
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
Incoming packets
|
||||
*/
|
||||
|
||||
// Click window packet
|
||||
protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item
|
||||
}
|
||||
}
|
||||
);
|
||||
// Click window packet
|
||||
protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Creative Inventory Action
|
||||
protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.SHORT); // 0 - Slot
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
// Creative Inventory Action
|
||||
protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.SHORT); // 0 - Slot
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,32 +9,32 @@ import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class WorldPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
//spawn particle
|
||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
map(Type.BOOLEAN); // 1 - Long Distance
|
||||
map(Type.FLOAT); // 2 - X
|
||||
map(Type.FLOAT); // 3 - Y
|
||||
map(Type.FLOAT); // 4 - Z
|
||||
map(Type.FLOAT); // 5 - Offset X
|
||||
map(Type.FLOAT); // 6 - Offset Y
|
||||
map(Type.FLOAT); // 7 - Offset Z
|
||||
map(Type.FLOAT); // 8 - Particle Data
|
||||
map(Type.INT); // 9 - Particle Count
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 27) {
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
public static void register(Protocol protocol) {
|
||||
//spawn particle
|
||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
map(Type.BOOLEAN); // 1 - Long Distance
|
||||
map(Type.FLOAT); // 2 - X
|
||||
map(Type.FLOAT); // 3 - Y
|
||||
map(Type.FLOAT); // 4 - Z
|
||||
map(Type.FLOAT); // 5 - Offset X
|
||||
map(Type.FLOAT); // 6 - Offset Y
|
||||
map(Type.FLOAT); // 7 - Offset Z
|
||||
map(Type.FLOAT); // 8 - Particle Data
|
||||
map(Type.INT); // 9 - Particle Count
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 27) {
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public abstract class AbstractFenceConnectionHandler extends ConnectionHandler {
|
||||
private Set<Integer> blockStates = new HashSet<>();
|
||||
private Map<Byte, Integer> connectedBlockStates = new HashMap<>();
|
||||
|
||||
public AbstractFenceConnectionHandler(String blockConnections, String key){
|
||||
public AbstractFenceConnectionHandler(String blockConnections, String key) {
|
||||
this.blockConnections = blockConnections;
|
||||
|
||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||
|
@ -8,11 +8,11 @@ import java.util.Map;
|
||||
public class BlockData {
|
||||
private Map<String, Boolean[]> connectData = new HashMap<>();
|
||||
|
||||
public void put(String key, Boolean[] booleans){
|
||||
public void put(String key, Boolean[] booleans) {
|
||||
connectData.put(key, booleans);
|
||||
}
|
||||
|
||||
public boolean connectsTo(String blockConnection, BlockFace face){
|
||||
public boolean connectsTo(String blockConnection, BlockFace face) {
|
||||
final Boolean[] booleans = connectData.get(blockConnection);
|
||||
return booleans != null && booleans[face.ordinal()];
|
||||
}
|
||||
|
@ -10,52 +10,52 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
class ChestConnectionHandler extends ConnectionHandler {
|
||||
private static Map<Integer, BlockFace> chestFacings = new HashMap<>();
|
||||
private static Map<Byte, Integer> connectedStates = new HashMap<>();
|
||||
private static Set<Integer> trappedChests = new HashSet<>();
|
||||
private static Map<Integer, BlockFace> chestFacings = new HashMap<>();
|
||||
private static Map<Byte, Integer> connectedStates = new HashMap<>();
|
||||
private static Set<Integer> trappedChests = new HashSet<>();
|
||||
|
||||
static void init() {
|
||||
ChestConnectionHandler connectionHandler = new ChestConnectionHandler();
|
||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||
String key = blockState.getKey().split("\\[")[0];
|
||||
if (!key.equals("minecraft:chest") && !key.equals("minecraft:trapped_chest")) continue;
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
if (blockData.getValue("waterlogged").equals("true")) continue;
|
||||
chestFacings.put(blockState.getValue(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase()));
|
||||
if (key.equalsIgnoreCase("minecraft:trapped_chest")) trappedChests.add(blockState.getValue());
|
||||
connectedStates.put(getStates(blockData), blockState.getValue());
|
||||
ConnectionData.connectionHandlerMap.put(blockState.getValue(), connectionHandler);
|
||||
}
|
||||
}
|
||||
static void init() {
|
||||
ChestConnectionHandler connectionHandler = new ChestConnectionHandler();
|
||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||
String key = blockState.getKey().split("\\[")[0];
|
||||
if (!key.equals("minecraft:chest") && !key.equals("minecraft:trapped_chest")) continue;
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
if (blockData.getValue("waterlogged").equals("true")) continue;
|
||||
chestFacings.put(blockState.getValue(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase()));
|
||||
if (key.equalsIgnoreCase("minecraft:trapped_chest")) trappedChests.add(blockState.getValue());
|
||||
connectedStates.put(getStates(blockData), blockState.getValue());
|
||||
ConnectionData.connectionHandlerMap.put(blockState.getValue(), connectionHandler);
|
||||
}
|
||||
}
|
||||
|
||||
private static Byte getStates(WrappedBlockData blockData) {
|
||||
byte states = 0;
|
||||
String type = blockData.getValue("type");
|
||||
if (type.equals("left")) states |= 1;
|
||||
if (type.equals("right")) states |= 2;
|
||||
states |= (BlockFace.valueOf(blockData.getValue("facing").toUpperCase()).ordinal() << 2);
|
||||
if (blockData.getMinecraftKey().equals("minecraft:trapped_chest")) states |= 16;
|
||||
return states;
|
||||
}
|
||||
private static Byte getStates(WrappedBlockData blockData) {
|
||||
byte states = 0;
|
||||
String type = blockData.getValue("type");
|
||||
if (type.equals("left")) states |= 1;
|
||||
if (type.equals("right")) states |= 2;
|
||||
states |= (BlockFace.valueOf(blockData.getValue("facing").toUpperCase()).ordinal() << 2);
|
||||
if (blockData.getMinecraftKey().equals("minecraft:trapped_chest")) states |= 16;
|
||||
return states;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int connect(UserConnection user, Position position, int blockState) {
|
||||
BlockFace facing = chestFacings.get(blockState);
|
||||
byte states = 0;
|
||||
states |= (facing.ordinal() << 2);
|
||||
boolean trapped = trappedChests.contains(blockState);
|
||||
if (trapped) states |= 16;
|
||||
int relative;
|
||||
if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.NORTH))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.WEST ? 1 : 2;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.SOUTH))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.EAST ? 1 : 2;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.WEST))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.NORTH ? 2 : 1;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.EAST))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.SOUTH ? 2 : 1;
|
||||
}
|
||||
Integer newBlockState = connectedStates.get(states);
|
||||
return newBlockState == null ? blockState : newBlockState;
|
||||
}
|
||||
@Override
|
||||
public int connect(UserConnection user, Position position, int blockState) {
|
||||
BlockFace facing = chestFacings.get(blockState);
|
||||
byte states = 0;
|
||||
states |= (facing.ordinal() << 2);
|
||||
boolean trapped = trappedChests.contains(blockState);
|
||||
if (trapped) states |= 16;
|
||||
int relative;
|
||||
if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.NORTH))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.WEST ? 1 : 2;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.SOUTH))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.EAST ? 1 : 2;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.WEST))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.NORTH ? 2 : 1;
|
||||
} else if (chestFacings.containsKey(relative = getBlockData(user, position.getRelative(BlockFace.EAST))) && trapped == trappedChests.contains(relative)) {
|
||||
states |= facing == BlockFace.SOUTH ? 2 : 1;
|
||||
}
|
||||
Integer newBlockState = connectedStates.get(states);
|
||||
return newBlockState == null ? blockState : newBlockState;
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,12 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.provi
|
||||
public abstract class ConnectionHandler {
|
||||
public abstract int connect(UserConnection user, Position position, int blockState);
|
||||
|
||||
public int getBlockData(UserConnection user, Position position) {
|
||||
return Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, position);
|
||||
public int getBlockData(UserConnection user, Position position) {
|
||||
return Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, position);
|
||||
}
|
||||
|
||||
public boolean canConnect(int id) {
|
||||
ConnectionHandler handler = ConnectionData.connectionHandlerMap.get(id);
|
||||
return handler != null && handler == this;
|
||||
ConnectionHandler handler = ConnectionData.connectionHandlerMap.get(id);
|
||||
return handler != null && handler == this;
|
||||
}
|
||||
}
|
||||
|
@ -39,11 +39,15 @@ public class RedstoneConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
|
||||
private static int getState(String value) {
|
||||
switch (value){
|
||||
case "none": return 0;
|
||||
case "side" : return 1;
|
||||
case "up" : return 2;
|
||||
default: return 0;
|
||||
switch (value) {
|
||||
case "none":
|
||||
return 0;
|
||||
case "side":
|
||||
return 1;
|
||||
case "up":
|
||||
return 2;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,82 +11,82 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TripwireConnectionHandler extends ConnectionHandler {
|
||||
private static Map<Integer, TripwireData> tripwireDataMap = new HashMap<>();
|
||||
private static Map<Byte, Integer> connectedBlocks = new HashMap<>();
|
||||
private static Map<Integer, BlockFace> tripwireHooks = new HashMap<>();
|
||||
private static Map<Integer, TripwireData> tripwireDataMap = new HashMap<>();
|
||||
private static Map<Byte, Integer> connectedBlocks = new HashMap<>();
|
||||
private static Map<Integer, BlockFace> tripwireHooks = new HashMap<>();
|
||||
|
||||
static void init() {
|
||||
TripwireConnectionHandler connectionHandler = new TripwireConnectionHandler();
|
||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||
String key = blockState.getKey().split("\\[")[0];
|
||||
static void init() {
|
||||
TripwireConnectionHandler connectionHandler = new TripwireConnectionHandler();
|
||||
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
|
||||
String key = blockState.getKey().split("\\[")[0];
|
||||
|
||||
if (key.equals("minecraft:tripwire_hook")) {
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
tripwireHooks.put(blockState.getValue(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase()));
|
||||
} else if (key.equals("minecraft:tripwire")) {
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
if (key.equals("minecraft:tripwire_hook")) {
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
tripwireHooks.put(blockState.getValue(), BlockFace.valueOf(blockData.getValue("facing").toUpperCase()));
|
||||
} else if (key.equals("minecraft:tripwire")) {
|
||||
WrappedBlockData blockData = WrappedBlockData.fromString(blockState.getKey());
|
||||
|
||||
TripwireData tripwireData = new TripwireData(
|
||||
blockData.getValue("attached").equals("true"),
|
||||
blockData.getValue("disarmed").equals("true"),
|
||||
blockData.getValue("powered").equals("true")
|
||||
);
|
||||
TripwireData tripwireData = new TripwireData(
|
||||
blockData.getValue("attached").equals("true"),
|
||||
blockData.getValue("disarmed").equals("true"),
|
||||
blockData.getValue("powered").equals("true")
|
||||
);
|
||||
|
||||
tripwireDataMap.put(blockState.getValue(), tripwireData);
|
||||
connectedBlocks.put(getStates(blockData), blockState.getValue());
|
||||
tripwireDataMap.put(blockState.getValue(), tripwireData);
|
||||
connectedBlocks.put(getStates(blockData), blockState.getValue());
|
||||
|
||||
ConnectionData.connectionHandlerMap.put(blockState.getValue(), connectionHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
ConnectionData.connectionHandlerMap.put(blockState.getValue(), connectionHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static byte getStates(WrappedBlockData blockData) {
|
||||
byte b = 0;
|
||||
if (blockData.getValue("attached").equals("true")) b |= 1;
|
||||
if (blockData.getValue("disarmed").equals("true")) b |= 2;
|
||||
if (blockData.getValue("powered").equals("true")) b |= 4;
|
||||
if (blockData.getValue("east").equals("true")) b |= 8;
|
||||
if (blockData.getValue("north").equals("true")) b |= 16;
|
||||
if (blockData.getValue("south").equals("true")) b |= 32;
|
||||
if (blockData.getValue("west").equals("true")) b |= 64;
|
||||
return b;
|
||||
}
|
||||
private static byte getStates(WrappedBlockData blockData) {
|
||||
byte b = 0;
|
||||
if (blockData.getValue("attached").equals("true")) b |= 1;
|
||||
if (blockData.getValue("disarmed").equals("true")) b |= 2;
|
||||
if (blockData.getValue("powered").equals("true")) b |= 4;
|
||||
if (blockData.getValue("east").equals("true")) b |= 8;
|
||||
if (blockData.getValue("north").equals("true")) b |= 16;
|
||||
if (blockData.getValue("south").equals("true")) b |= 32;
|
||||
if (blockData.getValue("west").equals("true")) b |= 64;
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int connect(UserConnection user, Position position, int blockState) {
|
||||
TripwireData tripwireData = tripwireDataMap.get(blockState);
|
||||
if (tripwireData == null) return blockState;
|
||||
byte b = 0;
|
||||
if (tripwireData.isAttached()) b |= 1;
|
||||
if (tripwireData.isDisarmed()) b |= 2;
|
||||
if (tripwireData.isPowered()) b |= 4;
|
||||
@Override
|
||||
public int connect(UserConnection user, Position position, int blockState) {
|
||||
TripwireData tripwireData = tripwireDataMap.get(blockState);
|
||||
if (tripwireData == null) return blockState;
|
||||
byte b = 0;
|
||||
if (tripwireData.isAttached()) b |= 1;
|
||||
if (tripwireData.isDisarmed()) b |= 2;
|
||||
if (tripwireData.isPowered()) b |= 4;
|
||||
|
||||
int east = getBlockData(user, position.getRelative(BlockFace.EAST));
|
||||
int north = getBlockData(user, position.getRelative(BlockFace.NORTH));
|
||||
int south = getBlockData(user, position.getRelative(BlockFace.SOUTH));
|
||||
int west = getBlockData(user, position.getRelative(BlockFace.WEST));
|
||||
int east = getBlockData(user, position.getRelative(BlockFace.EAST));
|
||||
int north = getBlockData(user, position.getRelative(BlockFace.NORTH));
|
||||
int south = getBlockData(user, position.getRelative(BlockFace.SOUTH));
|
||||
int west = getBlockData(user, position.getRelative(BlockFace.WEST));
|
||||
|
||||
if (tripwireDataMap.containsKey(east) || tripwireHooks.get(east) == BlockFace.WEST) {
|
||||
b |= 8;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(north) || tripwireHooks.get(north) == BlockFace.SOUTH) {
|
||||
b |= 16;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(south) || tripwireHooks.get(south) == BlockFace.NORTH) {
|
||||
b |= 32;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(west) || tripwireHooks.get(west) == BlockFace.EAST) {
|
||||
b |= 64;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(east) || tripwireHooks.get(east) == BlockFace.WEST) {
|
||||
b |= 8;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(north) || tripwireHooks.get(north) == BlockFace.SOUTH) {
|
||||
b |= 16;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(south) || tripwireHooks.get(south) == BlockFace.NORTH) {
|
||||
b |= 32;
|
||||
}
|
||||
if (tripwireDataMap.containsKey(west) || tripwireHooks.get(west) == BlockFace.EAST) {
|
||||
b |= 64;
|
||||
}
|
||||
|
||||
Integer newBlockState = connectedBlocks.get(b);
|
||||
return newBlockState == null ? blockState : newBlockState;
|
||||
}
|
||||
Integer newBlockState = connectedBlocks.get(b);
|
||||
return newBlockState == null ? blockState : newBlockState;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
private static class TripwireData {
|
||||
private final boolean attached, disarmed, powered;
|
||||
}
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
private static class TripwireData {
|
||||
private final boolean attached, disarmed, powered;
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import us.myles.ViaVersion.api.minecraft.BlockFace;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
|
||||
public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
||||
private static final BlockFace[] BLOCK_FACES = { BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST };
|
||||
private static final int[] OPPOSITES = { 3, 2, 1, 0 };
|
||||
private static final BlockFace[] BLOCK_FACES = {BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.WEST};
|
||||
private static final int[] OPPOSITES = {3, 2, 1, 0};
|
||||
|
||||
static void init() {
|
||||
new WallConnectionHandler("cobbleWallConnections", "minecraft:cobblestone_wall");
|
||||
@ -32,7 +32,8 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
||||
}
|
||||
|
||||
public boolean up(UserConnection user, Position position) {
|
||||
if(isWall(getBlockData(user, position.getRelative(BlockFace.BOTTOM))) || isWall(getBlockData(user, position.getRelative(BlockFace.TOP))))return true;
|
||||
if (isWall(getBlockData(user, position.getRelative(BlockFace.BOTTOM))) || isWall(getBlockData(user, position.getRelative(BlockFace.TOP))))
|
||||
return true;
|
||||
int blockFaces = getBlockFaces(user, position);
|
||||
if (blockFaces == 0 || blockFaces == 0xF) return true;
|
||||
for (int i = 0; i < BLOCK_FACES.length; i++) {
|
||||
@ -51,7 +52,7 @@ public class WallConnectionHandler extends AbstractFenceConnectionHandler {
|
||||
return blockFaces;
|
||||
}
|
||||
|
||||
private boolean isWall(int id){
|
||||
private boolean isWall(int id) {
|
||||
return getBlockStates().contains(id);
|
||||
}
|
||||
}
|
||||
|
@ -16,19 +16,27 @@ public class BlockConnectionProvider implements Provider {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void storeBlock(UserConnection connection, Position position, int blockState) {};
|
||||
public void storeBlock(UserConnection connection, Position position, int blockState) {
|
||||
|
||||
public void removeBlock(UserConnection connection, Position position) {};
|
||||
}
|
||||
|
||||
public void removeBlock(UserConnection connection, Position position) {
|
||||
|
||||
}
|
||||
|
||||
public void storeBlock(UserConnection connection, long x, long y, long z, int blockState) {
|
||||
storeBlock(connection, new Position(x, y, z), blockState);
|
||||
}
|
||||
|
||||
public void clearStorage(UserConnection connection) {};
|
||||
public void clearStorage(UserConnection connection) {
|
||||
|
||||
public void unloadChunk(UserConnection connection, int x, int z) {};
|
||||
}
|
||||
|
||||
public boolean storesBlocks(){
|
||||
public void unloadChunk(UserConnection connection, int x, int z) {
|
||||
|
||||
}
|
||||
|
||||
public boolean storesBlocks() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ public class WorldPackets {
|
||||
protocol.registerOutgoing(State.PLAY, 0x1D, 0x1F, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
if(Via.getConfig().isServersideBlockConnections()){
|
||||
if (Via.getConfig().isServersideBlockConnections()) {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
|
@ -34,29 +34,29 @@ public class BlockConnectionStorage extends StoredObject {
|
||||
Pair pair = getPair(position);
|
||||
Map<BlockPositon, Integer> map = getChunkMap(pair);
|
||||
map.remove(new BlockPositon(position));
|
||||
if(map.isEmpty()){
|
||||
if (map.isEmpty()) {
|
||||
blockStorage.remove(pair);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
public void clear() {
|
||||
blockStorage.clear();
|
||||
}
|
||||
|
||||
public void unloadChunk(int x, int z){
|
||||
public void unloadChunk(int x, int z) {
|
||||
blockStorage.remove(new Pair<>(x, z));
|
||||
}
|
||||
|
||||
private Map<BlockPositon, Integer> getChunkMap(Pair pair){
|
||||
private Map<BlockPositon, Integer> getChunkMap(Pair pair) {
|
||||
Map<BlockPositon, Integer> map = blockStorage.get(pair);
|
||||
if(map == null){
|
||||
if (map == null) {
|
||||
map = new HashMap<>();
|
||||
blockStorage.put(pair, map);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private Pair<Integer, Integer> getPair(Position position){
|
||||
private Pair<Integer, Integer> getPair(Position position) {
|
||||
int chunkX = (int) (position.getX() >> 4);
|
||||
int chunkZ = (int) (position.getZ() >> 4);
|
||||
return new Pair<>(chunkX, chunkZ);
|
||||
@ -65,8 +65,9 @@ public class BlockConnectionStorage extends StoredObject {
|
||||
@EqualsAndHashCode
|
||||
@Data
|
||||
private class BlockPositon {
|
||||
int x,y,z;
|
||||
public BlockPositon(Position position){
|
||||
int x, y, z;
|
||||
|
||||
public BlockPositon(Position position) {
|
||||
x = position.getX().intValue();
|
||||
y = position.getY().intValue();
|
||||
z = position.getZ().intValue();
|
||||
|
@ -186,7 +186,7 @@ public class ItemRewriter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void rewriteBookToServer(Item item) {
|
||||
short id = item.getId();
|
||||
if (id != 387) {
|
||||
@ -212,7 +212,7 @@ public class ItemRewriter {
|
||||
stag.setValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static String fixBookSpaceChars(String str) {
|
||||
if (!str.startsWith(" ")) {
|
||||
return str;
|
||||
|
@ -121,8 +121,8 @@ public class WorldPackets {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientChunks clientChunks = wrapper.user().get(ClientChunks.class);
|
||||
Chunk1_9to1_8Type type = new Chunk1_9to1_8Type(clientChunks);
|
||||
Chunk1_8 chunk = (Chunk1_8) wrapper.read(type);
|
||||
Chunk1_9to1_8Type type = new Chunk1_9to1_8Type(clientChunks);
|
||||
Chunk1_8 chunk = (Chunk1_8) wrapper.read(type);
|
||||
if (chunk.isUnloadPacket()) {
|
||||
wrapper.setId(0x1D);
|
||||
|
||||
@ -311,7 +311,7 @@ public class WorldPackets {
|
||||
// Blocking patch
|
||||
if (Via.getConfig().isShieldBlocking()) {
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
|
||||
|
||||
if (item != null && Protocol1_9TO1_8.isSword(item.getId())) {
|
||||
if (hand == 0) {
|
||||
if (!tracker.isBlocking()) {
|
||||
|
@ -258,7 +258,7 @@ public class EntityTracker extends StoredObject {
|
||||
} else {
|
||||
wrapper.write(Type.BYTE, (byte) 3);
|
||||
}
|
||||
wrapper.write(Type.STRING_ARRAY, new String[] {getUser().get(ProtocolInfo.class).getUsername()});
|
||||
wrapper.write(Type.STRING_ARRAY, new String[]{getUser().get(ProtocolInfo.class).getUsername()});
|
||||
} else {
|
||||
wrapper.write(Type.BYTE, (byte) 1); // remove team
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
|
||||
// Read biome data
|
||||
if (bytesLeft >= BIOME_DATA_LENGTH) {
|
||||
biomeData = new int[BIOME_DATA_LENGTH];
|
||||
for (int i = 0; i < BIOME_DATA_LENGTH; i++){
|
||||
for (int i = 0; i < BIOME_DATA_LENGTH; i++) {
|
||||
biomeData[i] = input.readByte() & 0xFF;
|
||||
}
|
||||
bytesLeft -= BIOME_DATA_LENGTH;
|
||||
|
@ -185,7 +185,7 @@ public class SpongeViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean is1_12NBTArrayFix() {
|
||||
return getBoolean("chat-nbt-fix", true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean is1_12QuickMoveActionFix() {
|
||||
return false;
|
||||
|
@ -24,7 +24,7 @@ public class SpongeBlockConnectionProvider extends BlockConnectionProvider {
|
||||
try {
|
||||
block = Class.forName("net.minecraft.block.Block");
|
||||
blockStateIds = ReflectionUtil.get(
|
||||
ReflectionUtil.getStatic(block, "field_176229_d", Object.class),
|
||||
ReflectionUtil.getStatic(block, "field_176229_d", Object.class),
|
||||
"field_148749_a", Map.class);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Via.getPlatform().getLogger().warning("net.minecraft.block.Block not found! Are you using Lantern?");
|
||||
|
@ -53,8 +53,8 @@ public class VelocityServerHandler {
|
||||
// Check if ViaVersion can support that version
|
||||
Object connection = ReflectionUtil.invoke(e.getPlayer(), "getConnection");
|
||||
setNextProtocolVersion.invoke(connection, ProtocolVersion.getProtocolVersion(protocols == null
|
||||
? user.get(ProtocolInfo.class).getProtocolVersion()
|
||||
: protocolId));
|
||||
? user.get(ProtocolInfo.class).getProtocolVersion()
|
||||
: protocolId));
|
||||
|
||||
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e1) {
|
||||
e1.printStackTrace();
|
||||
@ -133,7 +133,7 @@ public class VelocityServerHandler {
|
||||
}
|
||||
|
||||
Object connection = ReflectionUtil.invoke(e.getPlayer(), "getConnection");
|
||||
ProtocolVersion version = (ProtocolVersion) ReflectionUtil.invoke(connection,"getNextProtocolVersion");
|
||||
ProtocolVersion version = (ProtocolVersion) ReflectionUtil.invoke(connection, "getNextProtocolVersion");
|
||||
setProtocolVersion.invoke(connection, version);
|
||||
}
|
||||
}
|
||||
|
@ -56,21 +56,21 @@ public class ProtocolDetectorService implements Runnable {
|
||||
public static void probeServer(final RegisteredServer serverInfo) {
|
||||
final String key = serverInfo.getServerInfo().getName();
|
||||
serverInfo.ping().thenAccept((serverPing) -> {
|
||||
if (serverPing != null && serverPing.getVersion() != null) {
|
||||
detectedProtocolIds.put(key, serverPing.getVersion().getProtocol());
|
||||
if (((VelocityViaConfig) Via.getConfig()).isVelocityPingSave()) {
|
||||
Map<String, Integer> servers = ((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols();
|
||||
Integer protocol = servers.get(key);
|
||||
if (protocol != null && protocol == serverPing.getVersion().getProtocol()) {
|
||||
return;
|
||||
}
|
||||
// Ensure we're the only ones writing to the config
|
||||
synchronized (Via.getPlatform().getConfigurationProvider()) {
|
||||
servers.put(key, serverPing.getVersion().getProtocol());
|
||||
}
|
||||
// Save
|
||||
Via.getPlatform().getConfigurationProvider().saveConfig();
|
||||
if (serverPing != null && serverPing.getVersion() != null) {
|
||||
detectedProtocolIds.put(key, serverPing.getVersion().getProtocol());
|
||||
if (((VelocityViaConfig) Via.getConfig()).isVelocityPingSave()) {
|
||||
Map<String, Integer> servers = ((VelocityViaConfig) Via.getConfig()).getVelocityServerProtocols();
|
||||
Integer protocol = servers.get(key);
|
||||
if (protocol != null && protocol == serverPing.getVersion().getProtocol()) {
|
||||
return;
|
||||
}
|
||||
// Ensure we're the only ones writing to the config
|
||||
synchronized (Via.getPlatform().getConfigurationProvider()) {
|
||||
servers.put(key, serverPing.getVersion().getProtocol());
|
||||
}
|
||||
// Save
|
||||
Via.getPlatform().getConfigurationProvider().saveConfig();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user