Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-07 21:32:52 +02:00
Merge branch 'dev' of https://github.com/Matsv/ViaBackwards into 1.13_items
# Conflicts: # core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12_2to1_13/packets/BlockItemPackets1_13.java
Dieser Commit ist enthalten in:
Commit
e35f264e89
@ -81,5 +81,11 @@
|
||||
<artifactId>viabackwards-sponge</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-velocity</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -22,8 +22,8 @@ import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
import us.myles.ViaVersion.update.Version;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -54,21 +54,22 @@ public interface ViaBackwardsPlatform {
|
||||
*/
|
||||
Logger getLogger();
|
||||
|
||||
// TODO remove or better implement later
|
||||
default boolean isOutdated() {
|
||||
String minimumVVVersion = "2.0.0";
|
||||
boolean upToDate = false;
|
||||
try {
|
||||
Class<?> clazz = Class.forName("us.myles.ViaVersion.api.protocol.ProtocolVersion");
|
||||
Field v1_13 = clazz.getField("v1_13");
|
||||
Class<?> vvVersionInfo = Class.forName("us.myles.ViaVersion.sponge.VersionInfo");
|
||||
String vvVersion = (String) vvVersionInfo.getField("VERSION").get(null);
|
||||
|
||||
upToDate = (v1_13 != null);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException ignored) {
|
||||
upToDate = (vvVersion != null
|
||||
&& new Version(vvVersion).compareTo(new Version(minimumVVVersion + "--")) >= 0);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException ignored) {
|
||||
}
|
||||
|
||||
if (!upToDate) {
|
||||
getLogger().severe("================================");
|
||||
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
||||
getLogger().severe("PLEASE USE THE LATEST VERSION");
|
||||
getLogger().severe("PLEASE USE VIAVERSION " + minimumVVVersion + " OR NEWER");
|
||||
getLogger().severe("LINK: https://viaversion.com");
|
||||
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
||||
getLogger().severe("================================");
|
||||
|
@ -635,7 +635,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
ListTag ench = new ListTag("ench", CompoundTag.class);
|
||||
List<Tag> lore = new ArrayList<>();
|
||||
boolean dummyEnchatment = true;
|
||||
for (Tag enchantmentEntry : enchantments) {
|
||||
for (Tag enchantmentEntry : enchantments.clone()) {
|
||||
if (enchantmentEntry instanceof CompoundTag) {
|
||||
CompoundTag enchEntry = new CompoundTag("");
|
||||
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
|
||||
|
@ -465,13 +465,8 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
||||
// Remove boat splash timer
|
||||
registerMetaHandler().filter(EntityType.BOAT, 12).removed();
|
||||
|
||||
//Remove shooter UUID
|
||||
registerMetaHandler().filter(EntityType.ABSTRACT_ARROW, true, 7).removed();
|
||||
|
||||
registerMetaHandler().filter(EntityType.SPECTRAL_ARROW, 8).handleIndexChange(7);
|
||||
|
||||
// Remove Trident special loyalty level
|
||||
registerMetaHandler().filter(EntityType.TRIDENT, 8).removed();
|
||||
registerMetaHandler().filter(EntityType.TRIDENT, 7).removed();
|
||||
|
||||
// Handle new wolf colors
|
||||
registerMetaHandler().filter(EntityType.WOLF, 17).handle(e -> {
|
||||
|
@ -9,6 +9,7 @@ import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
@ -17,6 +18,25 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPacke
|
||||
public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||
// Login Plugin Request
|
||||
protocol.out(State.LOGIN, 0x04, -1, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
packetWrapper.cancel();
|
||||
packetWrapper.create(0x02, new ValueCreator() { // Plugin response
|
||||
@Override
|
||||
public void write(PacketWrapper newWrapper) throws Exception {
|
||||
newWrapper.write(Type.VAR_INT, packetWrapper.read(Type.VAR_INT)); // Packet id
|
||||
newWrapper.write(Type.BOOLEAN, false); // Success
|
||||
}
|
||||
}).sendToServer(Protocol1_12_2To1_13.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Plugin Message
|
||||
protocol.out(State.PLAY, 0x19, 0x18, new PacketRemapper() {
|
||||
|
@ -1,6 +1,9 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.EntityPackets1_13_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.InventoryPackets1_13_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.WorldPackets1_13_2;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@ -8,17 +11,14 @@ 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 nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.EntityPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.InventoryPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.WorldPackets;
|
||||
|
||||
public class Protocol1_13_1To1_13_2 extends BackwardsProtocol {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
InventoryPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
EntityPackets.register(this);
|
||||
InventoryPackets1_13_2.register(this);
|
||||
WorldPackets1_13_2.register(this);
|
||||
EntityPackets1_13_2.register(this);
|
||||
|
||||
//Edit Book
|
||||
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||
|
@ -12,7 +12,7 @@ import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13_2;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class EntityPackets {
|
||||
public class EntityPackets1_13_2 {
|
||||
|
||||
|
||||
public static void register(Protocol protocol) {
|
@ -7,7 +7,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class InventoryPackets {
|
||||
public class InventoryPackets1_13_2 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
|
@ -7,7 +7,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class WorldPackets {
|
||||
public class WorldPackets1_13_2 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
//spawn particle
|
||||
@ -24,6 +24,7 @@ public class WorldPackets {
|
||||
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 {
|
@ -1,48 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_13Types.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter {
|
||||
|
||||
public static void handleMetadata(int entityId, Entity1_13Types.EntityType type, List<Metadata> metadatas, UserConnection connection) {
|
||||
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
||||
try {
|
||||
// 1.13 changed item to flat item (no data)
|
||||
if (metadata.getMetaType() == MetaType1_13.Slot) {
|
||||
InventoryPackets.toClient((Item) metadata.getValue());
|
||||
} else if (metadata.getMetaType() == MetaType1_13.BlockID) {
|
||||
// Convert to new block id
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
if (type == null) continue;
|
||||
if (type.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT) && metadata.getId() == 9) {
|
||||
// New block format
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
if(type.is(EntityType.ITEM)){
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
metadatas.remove(metadata);
|
||||
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("An error occurred with entity metadata handler");
|
||||
Via.getPlatform().getLogger().warning("Metadata: " + metadata);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityPackets1_13_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets1_13_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@ -12,16 +13,15 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
EntityPackets.register(this);
|
||||
InventoryPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
new EntityPackets1_13_1().register(this);
|
||||
InventoryPackets1_13_1.register(this);
|
||||
WorldPackets1_13_1.register(this);
|
||||
|
||||
//Tab complete
|
||||
registerIncoming(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
@ -47,7 +47,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
InventoryPackets.toServer(wrapper.get(Type.FLAT_ITEM, 0));
|
||||
InventoryPackets1_13_1.toServer(wrapper.get(Type.FLAT_ITEM, 0));
|
||||
wrapper.write(Type.VAR_INT, 0);
|
||||
}
|
||||
});
|
||||
@ -128,7 +128,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
Item icon = wrapper.passthrough(Type.FLAT_ITEM);
|
||||
InventoryPackets.toClient(icon);
|
||||
InventoryPackets1_13_1.toClient(icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
@ -169,7 +169,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Integer[] items = wrapper.passthrough(Type.VAR_INT_ARRAY);
|
||||
for (int j = 0; j < items.length; j++) {
|
||||
items[j] = InventoryPackets.getOldItemId(items[j]);
|
||||
items[j] = InventoryPackets1_13_1.getOldItemId(items[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -214,9 +214,15 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
userConnection.put(new EntityTracker(userConnection));
|
||||
if (!userConnection.has(ClientWorld.class))
|
||||
userConnection.put(new ClientWorld(userConnection));
|
||||
public void init(UserConnection user) {
|
||||
// Register EntityTracker if it doesn't exist yet.
|
||||
if (!user.has(EntityTracker.class))
|
||||
user.put(new EntityTracker(user));
|
||||
|
||||
// Init protocol in EntityTracker
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
|
||||
if (!user.has(ClientWorld.class))
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
}
|
||||
|
@ -1,152 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.MetadataRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_13Types.EntityType;
|
||||
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.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker;
|
||||
|
||||
public class EntityPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
|
||||
//spawn entity
|
||||
protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - Data
|
||||
|
||||
// Track Entity
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
byte type = wrapper.get(Type.BYTE, 0);
|
||||
Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, true);
|
||||
|
||||
if (entType != null) {
|
||||
if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) {
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
wrapper.set(Type.INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
}
|
||||
// Register Type ID
|
||||
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// 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); // 12 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
|
||||
Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, false);
|
||||
|
||||
// Register Type ID
|
||||
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
||||
|
||||
MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 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); // 7 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
Entity1_13Types.EntityType entType = Entity1_13Types.EntityType.PLAYER;
|
||||
// Register Type ID
|
||||
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
||||
MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// Destroy entities
|
||||
protocol.registerOutgoing(State.PLAY, 0x35, 0x35, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
|
||||
wrapper.user().get(EntityTracker.class).removeEntity(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 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); // 1 - Metadata list
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
Optional<EntityType> type = wrapper.user().get(EntityTracker.class).get(entityId);
|
||||
MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,360 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_13;
|
||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_13.EntityType;
|
||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
||||
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.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_13To1_13_1 protocol) {
|
||||
|
||||
// Spawn Object
|
||||
protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - Data
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
byte type = wrapper.get(Type.BYTE, 0);
|
||||
EntityType entType = EntityType1_13.getTypeFromId(type, true);
|
||||
if (entType == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
|
||||
return;
|
||||
}
|
||||
|
||||
// Rewrite falling block
|
||||
if (entType.is(EntityType.FALLING_BLOCK)) {
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
wrapper.set(Type.INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
|
||||
// Track Entity
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
entityId,
|
||||
entType
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Experience Orb
|
||||
protocol.out(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
EntityType.XP_ORB
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Global Entity
|
||||
protocol.out(State.PLAY, 0x02, 0x02, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.BYTE);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
EntityType.LIGHTNING_BOLT
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Mob
|
||||
protocol.out(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); // 12 - Metadata
|
||||
|
||||
// Track Entity
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
|
||||
EntityType entityType = EntityType1_13.getTypeFromId(type, false);
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
entityType
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Rewrite Metadata
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
MetaStorage storage = new MetaStorage(wrapper.get(Types1_13.METADATA_LIST, 0));
|
||||
handleMeta(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
storage
|
||||
);
|
||||
|
||||
// Don't handle new ids / base meta since it's not used for this version
|
||||
|
||||
// Rewrite Metadata
|
||||
wrapper.set(
|
||||
Types1_13.METADATA_LIST,
|
||||
0,
|
||||
storage.getMetaDataList()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn player packet
|
||||
protocol.out(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); // 7 - Metadata
|
||||
|
||||
// Track Entity
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
EntityType.PLAYER
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Rewrite Metadata
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.set(
|
||||
Types1_13.METADATA_LIST,
|
||||
0,
|
||||
handleMeta(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
new MetaStorage(wrapper.get(Types1_13.METADATA_LIST, 0))
|
||||
).getMetaDataList()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//Spawn Painting
|
||||
protocol.out(State.PLAY, 0x04, 0x04, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
EntityType.PAINTING
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Join Game
|
||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
// Track Entity
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
addTrackedEntity(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.INT, 0),
|
||||
EntityType1_12.EntityType.PLAYER
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Save 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
|
||||
protocol.out(State.PLAY, 0x38, 0x38, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Dimension ID\
|
||||
|
||||
// Save dimension
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy entities
|
||||
protocol.out(State.PLAY, 0x35, 0x35, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
|
||||
getEntityTracker(wrapper.user()).removeEntity(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Metadata packet
|
||||
protocol.out(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Types1_13.METADATA_LIST); // 1 - Metadata list
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.set(
|
||||
Types1_13.METADATA_LIST,
|
||||
0,
|
||||
handleMeta(
|
||||
wrapper.user(),
|
||||
wrapper.get(Type.VAR_INT, 0),
|
||||
new MetaStorage(wrapper.get(Types1_13.METADATA_LIST, 0))
|
||||
).getMetaDataList()
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
|
||||
// Rewrite items & blocks
|
||||
registerMetaHandler().handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
|
||||
if (meta.getMetaType() == MetaType1_13.Slot) {
|
||||
InventoryPackets1_13_1.toClient((Item) meta.getValue());
|
||||
} else if (meta.getMetaType() == MetaType1_13.BlockID) {
|
||||
// Convert to new block id
|
||||
int data = (int) meta.getValue();
|
||||
meta.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
|
||||
return meta;
|
||||
});
|
||||
|
||||
// Remove shooter UUID
|
||||
registerMetaHandler().
|
||||
filter(EntityType.ABSTRACT_ARROW, true, 7)
|
||||
.removed();
|
||||
|
||||
// Move colors to old position
|
||||
registerMetaHandler().filter(EntityType.SPECTRAL_ARROW, 8)
|
||||
.handleIndexChange(7);
|
||||
|
||||
// Move loyalty level to old position
|
||||
registerMetaHandler().filter(EntityType.TRIDENT, 8)
|
||||
.handleIndexChange(7);
|
||||
|
||||
// Rewrite Minecart blocks
|
||||
registerMetaHandler()
|
||||
.filter(EntityType.MINECART_ABSTRACT, true, 9)
|
||||
.handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
|
||||
int data = (int) meta.getValue();
|
||||
meta.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
|
||||
return meta;
|
||||
});
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class InventoryPackets {
|
||||
public class InventoryPackets1_13_1 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
|
@ -13,7 +13,7 @@ import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class WorldPackets {
|
||||
public class WorldPackets1_13_1 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
//Chunk
|
||||
@ -109,7 +109,7 @@ public class WorldPackets {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
int data = wrapper.get(Type.INT, 1);
|
||||
if (id == 1010) { // Play record
|
||||
wrapper.set(Type.INT, 1, data = InventoryPackets.getNewItemId(data));
|
||||
wrapper.set(Type.INT, 1, data = InventoryPackets1_13_1.getNewItemId(data));
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
wrapper.set(Type.INT, 1, data = Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
}
|
||||
@ -118,42 +118,6 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
//join game
|
||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, 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 {
|
||||
// Store the player
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//respawn
|
||||
protocol.registerOutgoing(State.PLAY, 0x38, 0x38, 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//spawn particle
|
||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||
@Override
|
||||
@ -176,7 +140,7 @@ public class WorldPackets {
|
||||
int data = wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.set(Type.VAR_INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
} else if (id == 27) {
|
||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM));
|
||||
InventoryPackets1_13_1.toClient(wrapper.passthrough(Type.FLAT_ITEM));
|
||||
}
|
||||
}
|
||||
});
|
1
pom.xml
1
pom.xml
@ -28,6 +28,7 @@
|
||||
<module>bukkit</module>
|
||||
<module>bungee</module>
|
||||
<module>sponge</module>
|
||||
<module>velocity</module>
|
||||
<module>all</module>
|
||||
</modules>
|
||||
|
||||
|
@ -11,14 +11,14 @@
|
||||
package nl.matsv.viabackwards;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
import nl.matsv.viabackwards.sponge.VersionInfo;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.Order;
|
||||
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
||||
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
||||
import org.spongepowered.api.plugin.Dependency;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
@ -31,26 +31,21 @@ import java.util.logging.Logger;
|
||||
dependencies = {@Dependency(id = "viaversion")}
|
||||
)
|
||||
public class SpongePlugin implements ViaBackwardsPlatform {
|
||||
@Getter
|
||||
private Logger logger;
|
||||
@Inject
|
||||
private PluginContainer container;
|
||||
private org.slf4j.Logger loggerSlf4j;
|
||||
|
||||
@Listener(order = Order.LATE)
|
||||
public void onServerStart(GameAboutToStartServerEvent e) {
|
||||
public void onGameStart(GameInitializationEvent e) {
|
||||
// Setup Logger
|
||||
this.logger = new LoggerWrapper(container.getLogger());
|
||||
this.logger = new LoggerWrapper(loggerSlf4j);
|
||||
// Init!
|
||||
this.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
// TODO check how to for sponge, site was offline
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
// Not possible
|
||||
}
|
||||
}
|
||||
|
83
velocity/pom.xml
Normale Datei
83
velocity/pom.xml
Normale Datei
@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016 Matsv
|
||||
~
|
||||
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
~
|
||||
~ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
~
|
||||
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>2.4.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>viabackwards-velocity</artifactId>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources/</directory>
|
||||
<includes>
|
||||
<include>*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<!-- Stolen from ViaVersion ;) -->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>templating-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>filter-src</id>
|
||||
<goals>
|
||||
<goal>filter-sources</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>velocity-maven-repo</id>
|
||||
<name>Velocity maven repo</name>
|
||||
<url>https://repo.velocitypowered.com/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!-- Common Module -->
|
||||
<dependency>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Velocity API -->
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.velocity;
|
||||
|
||||
public class VersionInfo {
|
||||
public static final String VERSION = "${project.version}";
|
||||
}
|
51
velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java
Normale Datei
51
velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java
Normale Datei
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import lombok.Getter;
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
import nl.matsv.viabackwards.velocity.VersionInfo;
|
||||
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Plugin(id = "viabackwards",
|
||||
name = "ViaBackwards",
|
||||
version = VersionInfo.VERSION,
|
||||
authors = {"Matsv"},
|
||||
description = "Allow older Minecraft versions to connect to an newer server version.",
|
||||
dependencies = {@Dependency(id = "viaversion")}
|
||||
)
|
||||
public class VelocityPlugin implements ViaBackwardsPlatform {
|
||||
@Getter
|
||||
private Logger logger;
|
||||
@Inject
|
||||
private org.slf4j.Logger loggerSlf4j;
|
||||
|
||||
@Subscribe(order = PostOrder.LATE)
|
||||
public void onProxyStart(ProxyInitializeEvent e) {
|
||||
// Setup Logger
|
||||
this.logger = new LoggerWrapper(loggerSlf4j);
|
||||
// Init!
|
||||
this.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
// Not possible
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren