Farewell, lombok!

Also replaced some optionals with simple nullable objects
This commit is contained in:
KennyTV 2020-01-27 19:41:59 +01:00
parent aca265956f
commit 83ef8572c1
35 changed files with 438 additions and 195 deletions

View File

@ -10,14 +10,10 @@
package nl.matsv.viabackwards.api.entities.blockitem; package nl.matsv.viabackwards.api.entities.blockitem;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import nl.matsv.viabackwards.utils.Block; import nl.matsv.viabackwards.utils.Block;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag; import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
@RequiredArgsConstructor
@Getter
public class BlockItemSettings { public class BlockItemSettings {
private final int id; private final int id;
private Item repItem; private Item repItem;
@ -25,6 +21,10 @@ public class BlockItemSettings {
private BlockEntityHandler blockEntityHandler; private BlockEntityHandler blockEntityHandler;
private ItemHandler itemHandler; private ItemHandler itemHandler;
public BlockItemSettings(int id) {
this.id = id;
}
public BlockItemSettings repItem(Item item) { public BlockItemSettings repItem(Item item) {
this.repItem = item; this.repItem = item;
return this; return this;
@ -61,6 +61,26 @@ public class BlockItemSettings {
return itemHandler != null; return itemHandler != null;
} }
public int getId() {
return id;
}
public Item getRepItem() {
return repItem;
}
public Block getRepBlock() {
return repBlock;
}
public BlockEntityHandler getBlockEntityHandler() {
return blockEntityHandler;
}
public ItemHandler getItemHandler() {
return itemHandler;
}
public interface BlockEntityHandler { public interface BlockEntityHandler {
CompoundTag handleOrNewCompoundTag(int block, CompoundTag tag); CompoundTag handleOrNewCompoundTag(int block, CompoundTag tag);
} }
@ -68,5 +88,4 @@ public class BlockItemSettings {
public interface ItemHandler { public interface ItemHandler {
Item handle(Item i); Item handle(Item i);
} }
} }

View File

@ -10,17 +10,13 @@
package nl.matsv.viabackwards.api.entities.meta; package nl.matsv.viabackwards.api.entities.meta;
import lombok.Getter;
import lombok.ToString;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException; import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import us.myles.ViaVersion.api.entities.EntityType; import us.myles.ViaVersion.api.entities.EntityType;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
@ToString
@Getter
public class MetaHandlerSettings { public class MetaHandlerSettings {
private EntityType filterType; private EntityType filterType;
private boolean filterFamily = false; private boolean filterFamily;
private int filterIndex = -1; private int filterIndex = -1;
private MetaHandler handler; private MetaHandler handler;
@ -97,4 +93,26 @@ public class MetaHandlerSettings {
} }
return !hasIndex() || metadata.getId() == filterIndex; return !hasIndex() || metadata.getId() == filterIndex;
} }
public EntityType getFilterType() {
return filterType;
}
public int getFilterIndex() {
return filterIndex;
}
public MetaHandler getHandler() {
return handler;
}
@Override
public String toString() {
return "MetaHandlerSettings{" +
"filterType=" + filterType +
", filterFamily=" + filterFamily +
", filterIndex=" + filterIndex +
", handler=" + handler +
'}';
}
} }

View File

@ -10,13 +10,6 @@
package nl.matsv.viabackwards.api.entities.storage; package nl.matsv.viabackwards.api.entities.storage;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
@RequiredArgsConstructor
@Getter
@ToString
public class EntityData { public class EntityData {
private final int id; private final int id;
private final boolean isObject; private final boolean isObject;
@ -26,6 +19,13 @@ public class EntityData {
private final int objectData; private final int objectData;
private MetaCreator defaultMeta; private MetaCreator defaultMeta;
public EntityData(int id, boolean isObject, int replacementId, int objectData) {
this.id = id;
this.isObject = isObject;
this.replacementId = replacementId;
this.objectData = objectData;
}
public EntityData mobName(String name) { public EntityData mobName(String name) {
this.mobName = name; this.mobName = name;
return this; return this;
@ -39,6 +39,42 @@ public class EntityData {
return this.defaultMeta != null; return this.defaultMeta != null;
} }
public int getId() {
return id;
}
public boolean isObject() {
return isObject;
}
public String getMobName() {
return mobName;
}
public int getReplacementId() {
return replacementId;
}
public int getObjectData() {
return objectData;
}
public MetaCreator getDefaultMeta() {
return defaultMeta;
}
@Override
public String toString() {
return "EntityData{" +
"id=" + id +
", isObject=" + isObject +
", mobName='" + mobName + '\'' +
", replacementId=" + replacementId +
", objectData=" + objectData +
", defaultMeta=" + defaultMeta +
'}';
}
public interface MetaCreator { public interface MetaCreator {
void handle(MetaStorage storage); void handle(MetaStorage storage);

View File

@ -10,10 +10,6 @@
package nl.matsv.viabackwards.api.entities.storage; package nl.matsv.viabackwards.api.entities.storage;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import us.myles.ViaVersion.api.data.StoredObject; import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
@ -63,14 +59,16 @@ public class EntityTracker extends StoredObject {
} }
} }
@RequiredArgsConstructor public static final class StoredEntity {
@Getter
@ToString
public static class StoredEntity {
private final int entityId; private final int entityId;
private final EntityType type; private final EntityType type;
private final Map<Class<? extends EntityStorage>, EntityStorage> storedObjects = new ConcurrentHashMap<>(); private final Map<Class<? extends EntityStorage>, EntityStorage> storedObjects = new ConcurrentHashMap<>();
private StoredEntity(final int entityId, final EntityType type) {
this.entityId = entityId;
this.type = type;
}
/** /**
* Get an object from the storage * Get an object from the storage
* *
@ -100,5 +98,22 @@ public class EntityTracker extends StoredObject {
public void put(EntityStorage object) { public void put(EntityStorage object) {
storedObjects.put(object.getClass(), object); storedObjects.put(object.getClass(), object);
} }
public int getEntityId() {
return entityId;
}
public EntityType getType() {
return type;
}
@Override
public String toString() {
return "StoredEntity{" +
"entityId=" + entityId +
", type=" + type +
", storedObjects=" + storedObjects +
'}';
}
} }
} }

View File

@ -10,17 +10,11 @@
package nl.matsv.viabackwards.api.entities.storage; package nl.matsv.viabackwards.api.entities.storage;
import lombok.*;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import java.util.List; import java.util.List;
import java.util.Optional;
@Getter
@Setter
@ToString
public class MetaStorage { public class MetaStorage {
@NonNull
private List<Metadata> metaDataList; private List<Metadata> metaDataList;
public MetaStorage(List<Metadata> metaDataList) { public MetaStorage(List<Metadata> metaDataList) {
@ -36,20 +30,20 @@ public class MetaStorage {
} }
public void delete(int index) { public void delete(int index) {
Optional<Metadata> data = get(index); metaDataList.removeIf(meta -> meta.getId() == index);
if (data.isPresent())
delete(data.get());
} }
public void add(Metadata data) { public void add(Metadata data) {
this.metaDataList.add(data); this.metaDataList.add(data);
} }
public Optional<Metadata> get(int index) { public Metadata get(int index) {
for (Metadata meta : this.metaDataList) for (Metadata meta : this.metaDataList) {
if (index == meta.getId()) if (index == meta.getId()) {
return Optional.of(meta); return meta;
return Optional.empty(); }
}
return null;
} }
public Metadata getOrDefault(int index, Metadata data) { public Metadata getOrDefault(int index, Metadata data) {
@ -57,10 +51,23 @@ public class MetaStorage {
} }
public Metadata getOrDefault(int index, boolean removeIfExists, Metadata data) { public Metadata getOrDefault(int index, boolean removeIfExists, Metadata data) {
Optional<Metadata> existingData = get(index); Metadata existingData = get(index);
if (removeIfExists && existingData != null) {
delete(existingData);
}
return existingData != null ? existingData : data;
}
if (removeIfExists && existingData.isPresent()) public List<Metadata> getMetaDataList() {
delete(existingData.get()); return metaDataList;
return existingData.orElse(data); }
public void setMetaDataList(List<Metadata> metaDataList) {
this.metaDataList = metaDataList;
}
@Override
public String toString() {
return "MetaStorage{" + "metaDataList=" + metaDataList + '}';
} }
} }

View File

@ -66,12 +66,12 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
return entityTypes.containsKey(type); return entityTypes.containsKey(type);
} }
protected Optional<EntityData> getEntityData(EntityType type) { protected EntityData getEntityData(EntityType type) {
return Optional.ofNullable(entityTypes.get(type)); return entityTypes.get(type);
} }
protected Optional<EntityData> getObjectData(ObjectType type) { protected EntityData getObjectData(ObjectType type) {
return Optional.ofNullable(objectTypes.get(type)); return objectTypes.get(type);
} }
protected EntityData regEntType(EntityType oldEnt, EntityType replacement) { protected EntityData regEntType(EntityType oldEnt, EntityType replacement) {
@ -158,16 +158,14 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
} }
// Handle Entity Name // Handle Entity Name
Optional<Metadata> opMd = storage.get(displayNameIndex); Metadata data = storage.get(displayNameIndex);
if (opMd.isPresent()) { if (data != null) {
Optional<EntityData> opEd = getEntityData(type); EntityData entityData = getEntityData(type);
if (opEd.isPresent()) { if (entityData != null) {
Metadata data = opMd.get(); if (entityData.getMobName() != null &&
EntityData entData = opEd.get();
if (entData.getMobName() != null &&
(data.getValue() == null || ((String) data.getValue()).isEmpty()) && (data.getValue() == null || ((String) data.getValue()).isEmpty()) &&
data.getMetaType().getTypeID() == displayNameMetaType.getTypeID()) { data.getMetaType().getTypeID() == displayNameMetaType.getTypeID()) {
String mobName = entData.getMobName(); String mobName = entityData.getMobName();
if (isDisplayNameJson) { if (isDisplayNameJson) {
mobName = ChatRewriter.legacyTextToJson(mobName); mobName = ChatRewriter.legacyTextToJson(mobName);
} }
@ -230,11 +228,10 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
MetaStorage storage = new MetaStorage(wrapper.get(newMetaType, 0)); MetaStorage storage = new MetaStorage(wrapper.get(newMetaType, 0));
handleMeta(wrapper.user(), entityId, storage); handleMeta(wrapper.user(), entityId, storage);
Optional<EntityData> optEntDat = getEntityData(type); EntityData entityData = getEntityData(type);
if (optEntDat.isPresent()) { if (entityData != null) {
EntityData data = optEntDat.get(); if (entityData.hasBaseMeta()) {
if (data.hasBaseMeta()) { entityData.getDefaultMeta().handle(storage);
data.getDefaultMeta().handle(storage);
} }
} }
@ -338,14 +335,12 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
MetaStorage storage = new MetaStorage(wrapper.get(metaType, 0)); MetaStorage storage = new MetaStorage(wrapper.get(metaType, 0));
handleMeta(wrapper.user(), entityId, storage); handleMeta(wrapper.user(), entityId, storage);
Optional<EntityData> optEntDat = getEntityData(type); EntityData entityData = getEntityData(type);
if (optEntDat.isPresent()) { if (entityData != null) {
EntityData data = optEntDat.get(); int replacementId = getOldEntityId(entityData.getReplacementId());
int replacementId = getOldEntityId(data.getReplacementId());
wrapper.set(Type.VAR_INT, 1, replacementId); wrapper.set(Type.VAR_INT, 1, replacementId);
if (data.hasBaseMeta()) { if (entityData.hasBaseMeta()) {
data.getDefaultMeta().handle(storage); entityData.getDefaultMeta().handle(storage);
} }
} }

View File

@ -10,8 +10,6 @@
package nl.matsv.viabackwards.api.rewriters; package nl.matsv.viabackwards.api.rewriters;
import lombok.AllArgsConstructor;
import lombok.Data;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import java.util.HashMap; import java.util.HashMap;
@ -67,12 +65,33 @@ public abstract class SoundRewriter<T extends BackwardsProtocol> extends Rewrite
return data != null ? data.getNewPitch() : 1F; return data != null ? data.getNewPitch() : 1F;
} }
@Data public static final class SoundData {
@AllArgsConstructor private final int replacementSound;
public static class SoundData { private final boolean changePitch;
private int replacementSound; private final float newPitch;
private boolean changePitch = false; private final boolean added;
private float newPitch = 1f;
private boolean added; private SoundData(int replacementSound, boolean changePitch, float newPitch, boolean added) {
this.replacementSound = replacementSound;
this.changePitch = changePitch;
this.newPitch = newPitch;
this.added = added;
}
public int getReplacementSound() {
return replacementSound;
}
public boolean isChangePitch() {
return changePitch;
}
public float getNewPitch() {
return newPitch;
}
public boolean isAdded() {
return added;
}
} }
} }

View File

@ -10,7 +10,6 @@
package nl.matsv.viabackwards.protocol.protocol1_10to1_11; package nl.matsv.viabackwards.protocol.protocol1_10to1_11;
import lombok.Getter;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.BlockItemPackets1_11; import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.BlockItemPackets1_11;
@ -22,9 +21,7 @@ import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_10To1_11 extends BackwardsProtocol { public class Protocol1_10To1_11 extends BackwardsProtocol {
@Getter
private EntityPackets1_11 entityPackets; // Required for the item rewriter private EntityPackets1_11 entityPackets; // Required for the item rewriter
@Getter
private BlockItemPackets1_11 blockItemPackets; private BlockItemPackets1_11 blockItemPackets;
@Override @Override
@ -51,4 +48,12 @@ public class Protocol1_10To1_11 extends BackwardsProtocol {
// Init protocol in EntityTracker // Init protocol in EntityTracker
user.get(EntityTracker.class).initProtocol(this); user.get(EntityTracker.class).initProtocol(this);
} }
public EntityPackets1_11 getEntityPackets() {
return entityPackets;
}
public BlockItemPackets1_11 getBlockItemPackets() {
return blockItemPackets;
}
} }

View File

@ -64,9 +64,8 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
Optional<Entity1_11Types.ObjectType> type = Entity1_11Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); Optional<Entity1_11Types.ObjectType> type = Entity1_11Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
if (type.isPresent()) { if (type.isPresent()) {
Optional<EntityData> optEntDat = getObjectData(type.get()); EntityData data = getObjectData(type.get());
if (optEntDat.isPresent()) { if (data != null) {
EntityData data = optEntDat.get();
wrapper.set(Type.BYTE, 0, ((Integer) data.getReplacementId()).byteValue()); wrapper.set(Type.BYTE, 0, ((Integer) data.getReplacementId()).byteValue());
if (data.getObjectData() != -1) if (data.getObjectData() != -1)
wrapper.set(Type.INT, 0, data.getObjectData()); wrapper.set(Type.INT, 0, data.getObjectData());
@ -141,12 +140,12 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
storage storage
); );
Optional<EntityData> optEntDat = getEntityData(type); EntityData entityData = getEntityData(type);
if (optEntDat.isPresent()) { if (entityData != null) {
EntityData data = optEntDat.get(); wrapper.set(Type.UNSIGNED_BYTE, 0, (short) entityData.getReplacementId());
wrapper.set(Type.UNSIGNED_BYTE, 0, ((Integer) data.getReplacementId()).shortValue()); if (entityData.hasBaseMeta()) {
if (data.hasBaseMeta()) entityData.getDefaultMeta().handle(storage);
data.getDefaultMeta().handle(storage); }
} }
// Rewrite Metadata // Rewrite Metadata
@ -425,10 +424,10 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
} }
private void handleZombieType(MetaStorage storage, int type) { private void handleZombieType(MetaStorage storage, int type) {
Optional<Metadata> meta = storage.get(13); Metadata meta = storage.get(13);
if (meta == null) {
if (!meta.isPresent())
storage.add(getZombieTypeMeta(type)); storage.add(getZombieTypeMeta(type));
}
} }
/* /*

View File

@ -10,18 +10,48 @@
package nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage; package nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import nl.matsv.viabackwards.api.entities.storage.EntityStorage; import nl.matsv.viabackwards.api.entities.storage.EntityStorage;
@Getter
@Setter
@ToString
public class ChestedHorseStorage implements EntityStorage { public class ChestedHorseStorage implements EntityStorage {
private boolean chested = false; private boolean chested;
private int liamaStrength;
private int liamaStrength = 0;
private int liamaCarpetColor = -1; private int liamaCarpetColor = -1;
private int liamaVariant = 0; private int liamaVariant;
public boolean isChested() {
return chested;
}
public void setChested(boolean chested) {
this.chested = chested;
}
public int getLiamaStrength() {
return liamaStrength;
}
public void setLiamaStrength(int liamaStrength) {
this.liamaStrength = liamaStrength;
}
public int getLiamaCarpetColor() {
return liamaCarpetColor;
}
public void setLiamaCarpetColor(int liamaCarpetColor) {
this.liamaCarpetColor = liamaCarpetColor;
}
public int getLiamaVariant() {
return liamaVariant;
}
public void setLiamaVariant(int liamaVariant) {
this.liamaVariant = liamaVariant;
}
@Override
public String toString() {
return "ChestedHorseStorage{" + "chested=" + chested + ", liamaStrength=" + liamaStrength + ", liamaCarpetColor=" + liamaCarpetColor + ", liamaVariant=" + liamaVariant + '}';
}
} }

View File

@ -10,15 +10,9 @@
package nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage; package nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import us.myles.ViaVersion.api.data.StoredObject; import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
@Getter
@ToString
@Setter
public class WindowTracker extends StoredObject { public class WindowTracker extends StoredObject {
private String inventory; private String inventory;
private int entityId = -1; private int entityId = -1;
@ -26,5 +20,26 @@ public class WindowTracker extends StoredObject {
public WindowTracker(UserConnection user) { public WindowTracker(UserConnection user) {
super(user); super(user);
} }
public String getInventory() {
return inventory;
}
public void setInventory(String inventory) {
this.inventory = inventory;
}
public int getEntityId() {
return entityId;
}
public void setEntityId(int entityId) {
this.entityId = entityId;
}
@Override
public String toString() {
return "WindowTracker{" + "inventory='" + inventory + '\'' + ", entityId=" + entityId + '}';
}
} }

View File

@ -10,7 +10,6 @@
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12; package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12;
import lombok.Getter;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker; import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
@ -18,7 +17,6 @@ import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.*;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@Getter
public class Protocol1_11_1To1_12 extends BackwardsProtocol { public class Protocol1_11_1To1_12 extends BackwardsProtocol {
private EntityPackets1_12 entityPackets; private EntityPackets1_12 entityPackets;
private BlockItemPackets1_12 blockItemPackets; private BlockItemPackets1_12 blockItemPackets;
@ -47,4 +45,12 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol {
// Init protocol in EntityTracker // Init protocol in EntityTracker
user.get(EntityTracker.class).initProtocol(this); user.get(EntityTracker.class).initProtocol(this);
} }
public EntityPackets1_12 getEntityPackets() {
return entityPackets;
}
public BlockItemPackets1_12 getBlockItemPackets() {
return blockItemPackets;
}
} }

View File

@ -10,11 +10,26 @@
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data; package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
import lombok.Data;
import nl.matsv.viabackwards.api.entities.storage.EntityStorage; import nl.matsv.viabackwards.api.entities.storage.EntityStorage;
@Data
public class ParrotStorage implements EntityStorage { public class ParrotStorage implements EntityStorage {
private boolean tamed = true; private boolean tamed = true;
private boolean sitting = true; private boolean sitting = true;
public boolean isTamed() {
return tamed;
}
public void setTamed(boolean tamed) {
this.tamed = tamed;
}
public boolean isSitting() {
return sitting;
}
public void setSitting(boolean sitting) {
this.sitting = sitting;
}
} }

View File

@ -10,9 +10,6 @@
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data; package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.ViaBackwards;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
@ -22,9 +19,6 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
@Getter
@Setter
@ToString
public class ShoulderTracker extends StoredObject { public class ShoulderTracker extends StoredObject {
private int entityId; private int entityId;
private String leftShoulder; private String leftShoulder;
@ -85,4 +79,33 @@ public class ShoulderTracker extends StoredObject {
return builder.toString(); return builder.toString();
} }
public int getEntityId() {
return entityId;
}
public void setEntityId(int entityId) {
this.entityId = entityId;
}
public String getLeftShoulder() {
return leftShoulder;
}
public void setLeftShoulder(String leftShoulder) {
this.leftShoulder = leftShoulder;
}
public String getRightShoulder() {
return rightShoulder;
}
public void setRightShoulder(String rightShoulder) {
this.rightShoulder = rightShoulder;
}
@Override
public String toString() {
return "ShoulderTracker{" + "entityId=" + entityId + ", leftShoulder='" + leftShoulder + '\'' + ", rightShoulder='" + rightShoulder + '\'' + '}';
}
} }

View File

@ -64,9 +64,8 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
if (type.isPresent()) { if (type.isPresent()) {
Optional<EntityData> optEntDat = getObjectData(type.get()); EntityData data = getObjectData(type.get());
if (optEntDat.isPresent()) { if (data != null) {
EntityData data = optEntDat.get();
wrapper.set(Type.BYTE, 0, ((Integer) data.getReplacementId()).byteValue()); wrapper.set(Type.BYTE, 0, ((Integer) data.getReplacementId()).byteValue());
if (data.getObjectData() != -1) if (data.getObjectData() != -1)
wrapper.set(Type.INT, 0, data.getObjectData()); wrapper.set(Type.INT, 0, data.getObjectData());

View File

@ -10,7 +10,6 @@
package nl.matsv.viabackwards.protocol.protocol1_11to1_11_1; package nl.matsv.viabackwards.protocol.protocol1_11to1_11_1;
import lombok.Getter;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1; import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1;
@ -18,7 +17,6 @@ import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets1_
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@Getter
public class Protocol1_11To1_11_1 extends BackwardsProtocol { public class Protocol1_11To1_11_1 extends BackwardsProtocol {
private EntityPackets1_11_1 entityPackets; private EntityPackets1_11_1 entityPackets;
@ -41,4 +39,8 @@ public class Protocol1_11To1_11_1 extends BackwardsProtocol {
// Init protocol in EntityTracker // Init protocol in EntityTracker
user.get(EntityTracker.class).initProtocol(this); user.get(EntityTracker.class).initProtocol(this);
} }
public EntityPackets1_11_1 getEntityPackets() {
return entityPackets;
}
} }

View File

@ -57,9 +57,8 @@ public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
Optional<Entity1_11Types.ObjectType> type = Entity1_11Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); Optional<Entity1_11Types.ObjectType> type = Entity1_11Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
if (type.isPresent()) { if (type.isPresent()) {
Optional<EntityData> optEntDat = getObjectData(type.get()); EntityData data = getObjectData(type.get());
if (optEntDat.isPresent()) { if (data != null) {
EntityData data = optEntDat.get();
wrapper.set(Type.BYTE, 0, ((Integer) data.getReplacementId()).byteValue()); wrapper.set(Type.BYTE, 0, ((Integer) data.getReplacementId()).byteValue());
if (data.getObjectData() != -1) if (data.getObjectData() != -1)
wrapper.set(Type.INT, 0, data.getObjectData()); wrapper.set(Type.INT, 0, data.getObjectData());

View File

@ -10,19 +10,26 @@
package nl.matsv.viabackwards.protocol.protocol1_12_1to1_12_2; package nl.matsv.viabackwards.protocol.protocol1_12_1to1_12_2;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import us.myles.ViaVersion.api.data.StoredObject; import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
@Getter
@Setter
@ToString
public class KeepAliveTracker extends StoredObject { public class KeepAliveTracker extends StoredObject {
private long keepAlive = Integer.MAX_VALUE; private long keepAlive = Integer.MAX_VALUE;
public KeepAliveTracker(UserConnection user) { public KeepAliveTracker(UserConnection user) {
super(user); super(user);
} }
public long getKeepAlive() {
return keepAlive;
}
public void setKeepAlive(long keepAlive) {
this.keepAlive = keepAlive;
}
@Override
public String toString() {
return "KeepAliveTracker{" + "keepAlive=" + keepAlive + '}';
}
} }

View File

@ -46,8 +46,8 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol {
@Override @Override
public void handle(PacketWrapper packetWrapper) throws Exception { public void handle(PacketWrapper packetWrapper) throws Exception {
int keepAlive = packetWrapper.read(Type.VAR_INT); int keepAlive = packetWrapper.read(Type.VAR_INT);
Long realKeepAlive = packetWrapper.user().get(KeepAliveTracker.class).getKeepAlive(); long realKeepAlive = packetWrapper.user().get(KeepAliveTracker.class).getKeepAlive();
if (keepAlive != realKeepAlive.hashCode()) { if (keepAlive != Long.hashCode(realKeepAlive)) {
packetWrapper.cancel(); // Wrong data, cancel packet packetWrapper.cancel(); // Wrong data, cancel packet
return; return;
} }

View File

@ -10,7 +10,6 @@
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13; package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13;
import lombok.Getter;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TranslatableComponent; import net.md_5.bungee.api.chat.TranslatableComponent;
import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.ViaBackwards;
@ -34,7 +33,6 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@Getter
public class Protocol1_12_2To1_13 extends BackwardsProtocol { public class Protocol1_12_2To1_13 extends BackwardsProtocol {
private BlockItemPackets1_13 blockItemPackets; private BlockItemPackets1_13 blockItemPackets;
@ -199,4 +197,8 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
} }
}; };
} }
public BlockItemPackets1_13 getBlockItemPackets() {
return blockItemPackets;
}
} }

View File

@ -10,9 +10,6 @@
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data; package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
@ -158,12 +155,18 @@ public class ParticleMapping {
int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data); int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data);
} }
@Data public static final class ParticleData {
@AllArgsConstructor
@RequiredArgsConstructor
public static class ParticleData {
private final int historyId; private final int historyId;
private ParticleHandler handler; private final ParticleHandler handler;
private ParticleData(int historyId, ParticleHandler handler) {
this.historyId = historyId;
this.handler = handler;
}
private ParticleData(int historyId) {
this(historyId, null);
}
public int[] rewriteData(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception { public int[] rewriteData(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
if (handler == null) return null; if (handler == null) return null;
@ -174,5 +177,13 @@ public class ParticleMapping {
if (handler == null) return null; if (handler == null) return null;
return handler.rewrite(protocol, data); return handler.rewrite(protocol, data);
} }
public int getHistoryId() {
return historyId;
}
public ParticleHandler getHandler() {
return handler;
}
} }
} }

View File

@ -11,10 +11,7 @@
package nl.matsv.viabackwards.protocol.protocol1_12to1_12_1; package nl.matsv.viabackwards.protocol.protocol1_12to1_12_1;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
public class Protocol1_12To1_12_1 extends BackwardsProtocol { public class Protocol1_12To1_12_1 extends BackwardsProtocol {

View File

@ -1,6 +1,5 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14; package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14;
import lombok.Getter;
import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
@ -20,7 +19,6 @@ import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@Getter
public class Protocol1_13_2To1_14 extends BackwardsProtocol { public class Protocol1_13_2To1_14 extends BackwardsProtocol {
private static final Integer[] A = new Integer[0]; private static final Integer[] A = new Integer[0];
@ -321,4 +319,12 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
if (!user.has(ChunkLightStorage.class)) if (!user.has(ChunkLightStorage.class))
user.put(new ChunkLightStorage(user)); user.put(new ChunkLightStorage(user));
} }
public BlockItemPackets1_14 getBlockItemPackets() {
return blockItemPackets;
}
public EntityPackets1_14 getEntityPackets() {
return entityPackets;
}
} }

View File

@ -6,7 +6,6 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.EntityTypeRewrite
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional;
public class EntityTypeMapping { public class EntityTypeMapping {
private static final Map<Integer, Integer> entityTypes = new HashMap<>(); private static final Map<Integer, Integer> entityTypes = new HashMap<>();
@ -42,11 +41,7 @@ public class EntityTypeMapping {
entityTypes.put(50, 48); // ocelot entityTypes.put(50, 48); // ocelot
} }
public static Optional<Integer> getOldId(int type1_14) { public static Integer getOldId(int type1_14) {
return Optional.ofNullable(entityTypes.get(type1_14)); return entityTypes.get(type1_14);
}
public static Optional<Integer> getObjectId(int type1_13) {
return Optional.ofNullable(oldEntityToOldObject.get(type1_13));
} }
} }

View File

@ -1,7 +1,6 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data; package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
import nl.matsv.viabackwards.api.rewriters.ItemRewriterBase; import nl.matsv.viabackwards.api.rewriters.ItemRewriterBase;
import nl.matsv.viabackwards.api.rewriters.LegacyBlockItemRewriter;
import nl.matsv.viabackwards.api.rewriters.RecipeRewriter; import nl.matsv.viabackwards.api.rewriters.RecipeRewriter;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;

View File

@ -29,8 +29,6 @@ import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.Optional;
public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> { public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
private EntityPositionHandler positionHandler; private EntityPositionHandler positionHandler;
@ -113,7 +111,8 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
int id = wrapper.get(Type.BYTE, 0); int id = wrapper.get(Type.BYTE, 0);
Entity1_13Types.EntityType entityType = Entity1_13Types.getTypeFromId(EntityTypeMapping.getOldId(id).orElse(id), false); Integer mappedId = EntityTypeMapping.getOldId(id);
Entity1_13Types.EntityType entityType = Entity1_13Types.getTypeFromId(mappedId != null ? mappedId : id, false);
Entity1_13Types.ObjectType objectType; Entity1_13Types.ObjectType objectType;
if (entityType.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT)) { if (entityType.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT)) {
objectType = Entity1_13Types.ObjectType.MINECART; objectType = Entity1_13Types.ObjectType.MINECART;
@ -186,17 +185,17 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
Entity1_14Types.EntityType entityType = Entity1_14Types.getTypeFromId(type); Entity1_14Types.EntityType entityType = Entity1_14Types.getTypeFromId(type);
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType); addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
Optional<Integer> oldId = EntityTypeMapping.getOldId(type); Integer oldId = EntityTypeMapping.getOldId(type);
if (!oldId.isPresent()) { if (oldId == null) {
Optional<EntityData> oldType = getEntityData(entityType); EntityData entityData = getEntityData(entityType);
if (!oldType.isPresent()) { if (entityData == null) {
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13.2 entity type for 1.14 entity type " + type + "/" + entityType); ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13.2 entity type for 1.14 entity type " + type + "/" + entityType);
wrapper.cancel(); wrapper.cancel();
} else { } else {
wrapper.set(Type.VAR_INT, 1, oldType.get().getReplacementId()); wrapper.set(Type.VAR_INT, 1, entityData.getReplacementId());
} }
} else { } else {
wrapper.set(Type.VAR_INT, 1, oldId.get()); wrapper.set(Type.VAR_INT, 1, oldId);
} }
} }
}); });
@ -583,6 +582,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
@Override @Override
protected int getOldEntityId(final int newId) { protected int getOldEntityId(final int newId) {
return EntityTypeMapping.getOldId(newId).orElse(newId); Integer oldId = EntityTypeMapping.getOldId(newId);
return oldId != null ? oldId : newId;
} }
} }

View File

@ -56,5 +56,6 @@ public class Protocol1_14_3To1_14_4 extends BackwardsProtocol {
} }
@Override @Override
public void init(UserConnection userConnection) {} public void init(UserConnection userConnection) {
}
} }

View File

@ -10,7 +10,6 @@
package nl.matsv.viabackwards.protocol.protocol1_9_4to1_10; package nl.matsv.viabackwards.protocol.protocol1_9_4to1_10;
import lombok.Getter;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.BlockItemPackets1_10; import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.BlockItemPackets1_10;
@ -20,7 +19,6 @@ import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.packets.SoundPackets1_
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@Getter
public class Protocol1_9_4To1_10 extends BackwardsProtocol { public class Protocol1_9_4To1_10 extends BackwardsProtocol {
private EntityPackets1_10 entityPackets; // Required for the item rewriter private EntityPackets1_10 entityPackets; // Required for the item rewriter
private BlockItemPackets1_10 blockItemPackets; private BlockItemPackets1_10 blockItemPackets;
@ -44,4 +42,12 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol {
// Init protocol in EntityTracker // Init protocol in EntityTracker
user.get(EntityTracker.class).initProtocol(this); user.get(EntityTracker.class).initProtocol(this);
} }
public EntityPackets1_10 getEntityPackets() {
return entityPackets;
}
public BlockItemPackets1_10 getBlockItemPackets() {
return blockItemPackets;
}
} }

View File

@ -64,9 +64,8 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
Optional<Entity1_11Types.ObjectType> type = Entity1_11Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); Optional<Entity1_11Types.ObjectType> type = Entity1_11Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
if (type.isPresent()) { if (type.isPresent()) {
Optional<EntityData> optEntDat = getObjectData(type.get()); EntityData data = getObjectData(type.get());
if (optEntDat.isPresent()) { if (data != null) {
EntityData data = optEntDat.get();
wrapper.set(Type.BYTE, 0, ((Integer) data.getReplacementId()).byteValue()); wrapper.set(Type.BYTE, 0, ((Integer) data.getReplacementId()).byteValue());
if (data.getObjectData() != -1) if (data.getObjectData() != -1)
wrapper.set(Type.INT, 0, data.getObjectData()); wrapper.set(Type.INT, 0, data.getObjectData());
@ -141,12 +140,11 @@ public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
storage storage
); );
Optional<EntityData> optEntDat = getEntityData(type); EntityData entityData = getEntityData(type);
if (optEntDat.isPresent()) { if (entityData != null) {
EntityData data = optEntDat.get(); wrapper.set(Type.UNSIGNED_BYTE, 0, (short) entityData.getReplacementId());
wrapper.set(Type.UNSIGNED_BYTE, 0, ((Integer) data.getReplacementId()).shortValue()); if (entityData.hasBaseMeta())
if (data.hasBaseMeta()) entityData.getDefaultMeta().handle(storage);
data.getDefaultMeta().handle(storage);
} }
// Rewrite Metadata // Rewrite Metadata

View File

@ -10,9 +10,6 @@
package nl.matsv.viabackwards.utils; package nl.matsv.viabackwards.utils;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode
public class Block { public class Block {
private final int id; private final int id;
private final int data; private final int data;
@ -38,4 +35,20 @@ public class Block {
public Block withData(final int data) { public Block withData(final int data) {
return new Block(this.id, data); return new Block(this.id, data);
} }
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Block block = (Block) o;
if (id != block.id) return false;
return data == block.data;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + data;
return result;
}
} }

View File

@ -10,7 +10,6 @@
package nl.matsv.viabackwards; package nl.matsv.viabackwards;
import lombok.Getter;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import nl.matsv.viabackwards.api.ViaBackwardsPlatform; import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
import nl.matsv.viabackwards.fabric.util.LoggerWrapper; import nl.matsv.viabackwards.fabric.util.LoggerWrapper;
@ -21,7 +20,6 @@ import java.nio.file.Path;
import java.util.logging.Logger; import java.util.logging.Logger;
public class ViaFabricAddon implements ViaBackwardsPlatform, Runnable { public class ViaFabricAddon implements ViaBackwardsPlatform, Runnable {
@Getter
private final Logger logger = new LoggerWrapper(LogManager.getLogger("ViaBackwards")); private final Logger logger = new LoggerWrapper(LogManager.getLogger("ViaBackwards"));
private File configDir; private File configDir;
@ -41,4 +39,9 @@ public class ViaFabricAddon implements ViaBackwardsPlatform, Runnable {
public File getDataFolder() { public File getDataFolder() {
return configDir; return configDir;
} }
@Override
public Logger getLogger() {
return logger;
}
} }

View File

@ -12,7 +12,11 @@
}, },
"environment": "*", "environment": "*",
"authors": [ "authors": [
"Matsv", "KennyTV", "Gerrygames", "creeper123123321", "ForceUpdate1" "Matsv",
"KennyTV",
"Gerrygames",
"creeper123123321",
"ForceUpdate1"
], ],
"entrypoints": { "entrypoints": {
"viafabric:via_api_initialized": [ "viafabric:via_api_initialized": [

View File

@ -50,13 +50,6 @@
</repositories> </repositories>
<dependencies> <dependencies>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
<!-- ViaVersion --> <!-- ViaVersion -->
<dependency> <dependency>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>

View File

@ -11,7 +11,6 @@
package nl.matsv.viabackwards; package nl.matsv.viabackwards;
import com.google.inject.Inject; import com.google.inject.Inject;
import lombok.Getter;
import nl.matsv.viabackwards.api.ViaBackwardsPlatform; import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
import nl.matsv.viabackwards.sponge.VersionInfo; import nl.matsv.viabackwards.sponge.VersionInfo;
import org.spongepowered.api.config.ConfigDir; import org.spongepowered.api.config.ConfigDir;
@ -34,7 +33,6 @@ import java.util.logging.Logger;
dependencies = {@Dependency(id = "viaversion")} dependencies = {@Dependency(id = "viaversion")}
) )
public class SpongePlugin implements ViaBackwardsPlatform { public class SpongePlugin implements ViaBackwardsPlatform {
@Getter
private Logger logger; private Logger logger;
@Inject @Inject
private org.slf4j.Logger loggerSlf4j; private org.slf4j.Logger loggerSlf4j;
@ -59,4 +57,9 @@ public class SpongePlugin implements ViaBackwardsPlatform {
public File getDataFolder() { public File getDataFolder() {
return configPath.toFile(); return configPath.toFile();
} }
@Override
public Logger getLogger() {
return logger;
}
} }

View File

@ -17,7 +17,6 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Dependency; import com.velocitypowered.api.plugin.Dependency;
import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.velocitypowered.api.plugin.annotation.DataDirectory;
import lombok.Getter;
import nl.matsv.viabackwards.api.ViaBackwardsPlatform; import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
import nl.matsv.viabackwards.velocity.VersionInfo; import nl.matsv.viabackwards.velocity.VersionInfo;
import us.myles.ViaVersion.sponge.util.LoggerWrapper; import us.myles.ViaVersion.sponge.util.LoggerWrapper;
@ -34,7 +33,6 @@ import java.util.logging.Logger;
dependencies = {@Dependency(id = "viaversion")} dependencies = {@Dependency(id = "viaversion")}
) )
public class VelocityPlugin implements ViaBackwardsPlatform { public class VelocityPlugin implements ViaBackwardsPlatform {
@Getter
private Logger logger; private Logger logger;
@Inject @Inject
private org.slf4j.Logger loggerSlf4j; private org.slf4j.Logger loggerSlf4j;
@ -59,4 +57,9 @@ public class VelocityPlugin implements ViaBackwardsPlatform {
public File getDataFolder() { public File getDataFolder() {
return configPath.toFile(); return configPath.toFile();
} }
@Override
public Logger getLogger() {
return logger;
}
} }