Skip to content

Commit

Permalink
Fixed Data Bug in 1_16_R3, fix for 1_14_R1 to 1_16_R2 comming soon
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauriichan committed Apr 14, 2021
1 parent f25b0df commit 83a1380
Show file tree
Hide file tree
Showing 33 changed files with 351 additions and 89 deletions.
20 changes: 10 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,52 +40,52 @@
<dependency>
<groupId>com.syntaxphoenix.syntaxapi</groupId>
<artifactId>java</artifactId>
<version>2.0.9</version>
<version>2.0.10</version>
</dependency>
<dependency>
<groupId>com.syntaxphoenix.syntaxapi</groupId>
<artifactId>data-nbtcontainer</artifactId>
<version>2.0.9</version>
<version>2.0.10</version>
</dependency>
<dependency>
<groupId>com.syntaxphoenix.syntaxapi</groupId>
<artifactId>data-base</artifactId>
<version>2.0.9</version>
<version>2.0.10</version>
</dependency>
<dependency>
<groupId>com.syntaxphoenix.syntaxapi</groupId>
<artifactId>net</artifactId>
<version>2.0.10</version>
<version>2.0.11</version>
</dependency>
<dependency>
<groupId>com.syntaxphoenix.syntaxapi</groupId>
<artifactId>command</artifactId>
<version>2.0.8</version>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>com.syntaxphoenix.syntaxapi</groupId>
<artifactId>nbt</artifactId>
<version>2.0.7</version>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>com.syntaxphoenix.syntaxapi</groupId>
<artifactId>version</artifactId>
<version>2.0.7</version>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>com.syntaxphoenix.syntaxapi</groupId>
<artifactId>reflection</artifactId>
<version>2.0.6</version>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>com.syntaxphoenix.syntaxapi</groupId>
<artifactId>key</artifactId>
<version>2.0.6</version>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>com.syntaxphoenix.syntaxapi</groupId>
<artifactId>random</artifactId>
<version>2.0.6</version>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import org.bukkit.inventory.ItemStack;

import com.syntaxphoenix.syntaxapi.data.DataAdapterContext;
import com.syntaxphoenix.syntaxapi.data.DataType;
import com.syntaxphoenix.syntaxapi.nbt.NbtCompound;
import com.syntaxphoenix.syntaxapi.nbt.NbtList;
import com.syntaxphoenix.syntaxapi.nbt.NbtTag;

import net.sourcewriters.minecraft.versiontools.reflection.data.WrapType;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrappedContext;
import net.sourcewriters.minecraft.versiontools.reflection.entity.NmsEntityType;

Expand Down Expand Up @@ -38,5 +40,7 @@ protected BukkitConversion(V versionControl) {
public abstract NbtCompound itemToCompound(ItemStack itemStack);

public abstract WrappedContext<DataAdapterContext> createContext(DataAdapterContext context);

public abstract <P, C> WrapType<P, C> wrap(DataType<P, C> dataType);

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ public DataProvider getDataProvider() {
public abstract PacketHandler<?> getPacketHandler();

public abstract BukkitConversion<?> getBukkitConversion();

public void shutdown() {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Set;

import com.syntaxphoenix.syntaxapi.data.IDataContainer;
import com.syntaxphoenix.syntaxapi.utils.key.IKey;
import com.syntaxphoenix.syntaxapi.utils.key.Namespace;
import com.syntaxphoenix.syntaxapi.utils.key.NamespacedKey;

Expand Down Expand Up @@ -48,9 +49,13 @@ public abstract class WrappedContainer {
public abstract boolean isEmpty();

public abstract int size();

protected IKey syntaxKey(String key) {
return NamespacedKey.fromStringOrCompute(key, key0 -> Namespace.of(NAMESPACE_STRING).create(key0));
}

protected SyntaxKey wrappedKey(String key) {
return new SyntaxKey(NamespacedKey.fromStringOrCompute(key, key0 -> Namespace.of(NAMESPACE_STRING).create(key0)));
return new SyntaxKey(syntaxKey(key));
}

public <P, C> C getOrDefault(String key, WrapType<P, C> type, C value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
package net.sourcewriters.minecraft.versiontools.reflection.data.type;

import com.syntaxphoenix.syntaxapi.data.DataAdapterContext;
import com.syntaxphoenix.syntaxapi.data.DataType;
import com.syntaxphoenix.syntaxapi.data.IDataContainer;
import com.syntaxphoenix.syntaxapi.data.PrimitiveDataType;

import net.sourcewriters.minecraft.versiontools.reflection.VersionControl;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrapType;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrappedContainer;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrappedContext;
import net.sourcewriters.minecraft.versiontools.utils.minecraft.Skin;

public final class SkinDataType implements WrapType<WrappedContainer, Skin> {
public final class SkinDataType implements DataType<IDataContainer, Skin> {

public static final SkinDataType INSTANCE = new SkinDataType();
public static final WrapType<?, Skin> INSTANCE = VersionControl.get().getBukkitConversion().wrap(new SkinDataType());

private SkinDataType() {}

@Override
public Class<Skin> getComplexWrapped() {
public Class<Skin> getComplex() {
return Skin.class;
}

@Override
public Class<WrappedContainer> getPrimitiveWrapped() {
return WrappedContainer.class;
public Class<IDataContainer> getPrimitive() {
return IDataContainer.class;
}

@Override
public Skin wrapToComplex(WrappedContainer primitive, WrappedContext<?> context) {
IDataContainer container = primitive.getAsSyntaxContainer();
public IDataContainer toPrimitive(DataAdapterContext context, Skin complex) {
IDataContainer container = context.newDataContainer();
container.set("name", complex.getName(), PrimitiveDataType.STRING);
container.set("value", complex.getValue(), PrimitiveDataType.STRING);
container.set("signature", complex.getSignature(), PrimitiveDataType.STRING);
return container;
}

@Override
public Skin fromPrimitive(DataAdapterContext context, IDataContainer container) {
String name = container.get("name", PrimitiveDataType.STRING);
String value = container.get("value", PrimitiveDataType.STRING);
String signature = container.get("signature", PrimitiveDataType.STRING);
if(name == null || value == null || signature == null) {
return null;
}
return new Skin(name, value, signature, false);
}

@Override
public WrappedContainer wrapToPrimitive(Skin complex, WrappedContext<?> context) {
WrappedContainer wrapped = context.newContainer();
IDataContainer container = wrapped.getAsSyntaxContainer();
container.set("name", complex.getName(), PrimitiveDataType.STRING);
container.set("value", complex.getValue(), PrimitiveDataType.STRING);
container.set("signature", complex.getSignature(), PrimitiveDataType.STRING);
return wrapped;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public SyntaxKey(NamespacedKey key) {
}

public SyntaxKey(IKey key) {
this.key = NamespacedKey.fromStringOrCompute(key.toString(), key0 -> Namespace.of(NAMESPACE_STRING).create(key0));
if (key instanceof NamespacedKey) {
this.key = (NamespacedKey) key;
} else {
this.key = NamespacedKey.fromStringOrCompute(key.asString(), key0 -> Namespace.of(NAMESPACE_STRING).create(key0));
}
}

@Override
Expand Down Expand Up @@ -57,7 +61,7 @@ public String getKey() {

@Override
public String toString() {
return key.toString();
return key.asString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.entity.EntityType;

import com.syntaxphoenix.syntaxapi.data.DataAdapterContext;
import com.syntaxphoenix.syntaxapi.data.DataType;
import com.syntaxphoenix.syntaxapi.nbt.NbtByte;
import com.syntaxphoenix.syntaxapi.nbt.NbtByteArray;
import com.syntaxphoenix.syntaxapi.nbt.NbtCompound;
Expand Down Expand Up @@ -38,8 +39,10 @@
import net.minecraft.server.v1_10_R1.NBTTagShort;
import net.minecraft.server.v1_10_R1.NBTTagString;
import net.sourcewriters.minecraft.versiontools.reflection.BukkitConversion;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrapType;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrappedContext;
import net.sourcewriters.minecraft.versiontools.reflection.data.wrap.SimpleSyntaxContext;
import net.sourcewriters.minecraft.versiontools.reflection.data.wrap.SimpleWrapType;
import net.sourcewriters.minecraft.versiontools.reflection.entity.NmsEntityType;
import net.sourcewriters.minecraft.versiontools.reflection.reflect.ReflectionProvider;

Expand Down Expand Up @@ -220,4 +223,9 @@ public WrappedContext<DataAdapterContext> createContext(DataAdapterContext conte
return new SimpleSyntaxContext(context);
}

@Override
public <P, C> WrapType<P, C> wrap(DataType<P, C> dataType) {
return new SimpleWrapType<P, C>(dataType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.entity.EntityType;

import com.syntaxphoenix.syntaxapi.data.DataAdapterContext;
import com.syntaxphoenix.syntaxapi.data.DataType;
import com.syntaxphoenix.syntaxapi.nbt.NbtByte;
import com.syntaxphoenix.syntaxapi.nbt.NbtByteArray;
import com.syntaxphoenix.syntaxapi.nbt.NbtCompound;
Expand Down Expand Up @@ -38,8 +39,10 @@
import net.minecraft.server.v1_11_R1.NBTTagShort;
import net.minecraft.server.v1_11_R1.NBTTagString;
import net.sourcewriters.minecraft.versiontools.reflection.BukkitConversion;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrapType;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrappedContext;
import net.sourcewriters.minecraft.versiontools.reflection.data.wrap.SimpleSyntaxContext;
import net.sourcewriters.minecraft.versiontools.reflection.data.wrap.SimpleWrapType;
import net.sourcewriters.minecraft.versiontools.reflection.entity.NmsEntityType;
import net.sourcewriters.minecraft.versiontools.reflection.reflect.ReflectionProvider;

Expand Down Expand Up @@ -217,4 +220,9 @@ public WrappedContext<DataAdapterContext> createContext(DataAdapterContext conte
return new SimpleSyntaxContext(context);
}

@Override
public <P, C> WrapType<P, C> wrap(DataType<P, C> dataType) {
return new SimpleWrapType<P, C>(dataType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.entity.EntityType;

import com.syntaxphoenix.syntaxapi.data.DataAdapterContext;
import com.syntaxphoenix.syntaxapi.data.DataType;
import com.syntaxphoenix.syntaxapi.nbt.NbtByte;
import com.syntaxphoenix.syntaxapi.nbt.NbtByteArray;
import com.syntaxphoenix.syntaxapi.nbt.NbtCompound;
Expand Down Expand Up @@ -39,8 +40,10 @@
import net.minecraft.server.v1_12_R1.NBTTagShort;
import net.minecraft.server.v1_12_R1.NBTTagString;
import net.sourcewriters.minecraft.versiontools.reflection.BukkitConversion;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrapType;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrappedContext;
import net.sourcewriters.minecraft.versiontools.reflection.data.wrap.SimpleSyntaxContext;
import net.sourcewriters.minecraft.versiontools.reflection.data.wrap.SimpleWrapType;
import net.sourcewriters.minecraft.versiontools.reflection.entity.NmsEntityType;
import net.sourcewriters.minecraft.versiontools.reflection.reflect.ReflectionProvider;

Expand Down Expand Up @@ -215,4 +218,9 @@ public WrappedContext<DataAdapterContext> createContext(DataAdapterContext conte
return new SimpleSyntaxContext(context);
}

@Override
public <P, C> WrapType<P, C> wrap(DataType<P, C> dataType) {
return new SimpleWrapType<P, C>(dataType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.entity.EntityType;

import com.syntaxphoenix.syntaxapi.data.DataAdapterContext;
import com.syntaxphoenix.syntaxapi.data.DataType;
import com.syntaxphoenix.syntaxapi.nbt.NbtByte;
import com.syntaxphoenix.syntaxapi.nbt.NbtByteArray;
import com.syntaxphoenix.syntaxapi.nbt.NbtCompound;
Expand Down Expand Up @@ -39,8 +40,10 @@
import net.minecraft.server.v1_13_R1.NBTTagShort;
import net.minecraft.server.v1_13_R1.NBTTagString;
import net.sourcewriters.minecraft.versiontools.reflection.BukkitConversion;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrapType;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrappedContext;
import net.sourcewriters.minecraft.versiontools.reflection.data.wrap.SimpleSyntaxContext;
import net.sourcewriters.minecraft.versiontools.reflection.data.wrap.SimpleWrapType;
import net.sourcewriters.minecraft.versiontools.reflection.entity.NmsEntityType;

public class BukkitConversion1_13_R1 extends BukkitConversion<VersionControl1_13_R1> {
Expand Down Expand Up @@ -207,4 +210,9 @@ public WrappedContext<DataAdapterContext> createContext(DataAdapterContext conte
return new SimpleSyntaxContext(context);
}

@Override
public <P, C> WrapType<P, C> wrap(DataType<P, C> dataType) {
return new SimpleWrapType<P, C>(dataType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.entity.EntityType;

import com.syntaxphoenix.syntaxapi.data.DataAdapterContext;
import com.syntaxphoenix.syntaxapi.data.DataType;
import com.syntaxphoenix.syntaxapi.nbt.NbtByte;
import com.syntaxphoenix.syntaxapi.nbt.NbtByteArray;
import com.syntaxphoenix.syntaxapi.nbt.NbtCompound;
Expand Down Expand Up @@ -39,8 +40,10 @@
import net.minecraft.server.v1_13_R2.NBTTagShort;
import net.minecraft.server.v1_13_R2.NBTTagString;
import net.sourcewriters.minecraft.versiontools.reflection.BukkitConversion;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrapType;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrappedContext;
import net.sourcewriters.minecraft.versiontools.reflection.data.wrap.SimpleSyntaxContext;
import net.sourcewriters.minecraft.versiontools.reflection.data.wrap.SimpleWrapType;
import net.sourcewriters.minecraft.versiontools.reflection.entity.NmsEntityType;

public class BukkitConversion1_13_R2 extends BukkitConversion<VersionControl1_13_R2> {
Expand Down Expand Up @@ -207,4 +210,9 @@ public WrappedContext<DataAdapterContext> createContext(DataAdapterContext conte
return new SimpleSyntaxContext(context);
}

@Override
public <P, C> WrapType<P, C> wrap(DataType<P, C> dataType) {
return new SimpleWrapType<P, C>(dataType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.entity.EntityType;

import com.syntaxphoenix.syntaxapi.data.DataAdapterContext;
import com.syntaxphoenix.syntaxapi.data.DataType;
import com.syntaxphoenix.syntaxapi.nbt.NbtByte;
import com.syntaxphoenix.syntaxapi.nbt.NbtByteArray;
import com.syntaxphoenix.syntaxapi.nbt.NbtCompound;
Expand Down Expand Up @@ -39,9 +40,11 @@
import net.minecraft.server.v1_14_R1.NBTTagShort;
import net.minecraft.server.v1_14_R1.NBTTagString;
import net.sourcewriters.minecraft.versiontools.reflection.BukkitConversion;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrapType;
import net.sourcewriters.minecraft.versiontools.reflection.data.WrappedContext;
import net.sourcewriters.minecraft.versiontools.reflection.entity.NmsEntityType;
import net.sourcewriters.minecraft.versiontools.reflection.provider.v1_14_R1.data.BukkitContext1_14_R1;
import net.sourcewriters.minecraft.versiontools.reflection.provider.v1_14_R1.data.BukkitType1_14_R1;

public class BukkitConversion1_14_R1 extends BukkitConversion<VersionControl1_14_R1> {

Expand Down Expand Up @@ -207,4 +210,9 @@ public WrappedContext<DataAdapterContext> createContext(DataAdapterContext conte
return new BukkitContext1_14_R1(context);
}

@Override
public <P, C> WrapType<P, C> wrap(DataType<P, C> dataType) {
return new BukkitType1_14_R1<>(dataType);
}

}
Loading

0 comments on commit 83a1380

Please sign in to comment.