-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21f3a6d
commit f67c301
Showing
36 changed files
with
2,314 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
*/dependency-reduced-pom.xml | ||
*.class | ||
*.jar | ||
/libraries/spigot/ | ||
/libraries/* | ||
/.settings/ | ||
/.project | ||
/.classpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
1.17.1 | ||
1.18.1 | ||
1.18.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ | |
1.16.4 | ||
1.17.1 | ||
1.18.1 | ||
1.18.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/.apt_generated/ | ||
/.apt_generated_tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>net.sourcewriters.minecraft</groupId> | ||
<artifactId>vcompat-parent</artifactId> | ||
<version>3.0.3</version> | ||
</parent> | ||
<artifactId>vcompat-1_18_R2</artifactId> | ||
|
||
<properties> | ||
<mapping.libPath>${project.basedir}/../libraries/mapping</mapping.libPath> | ||
<spigot.libPath>${project.basedir}/../libraries/spigot</spigot.libPath> | ||
<minecraft.version>1.18.2</minecraft.version> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>minecraft-libraries</id> | ||
<name>Minecraft Libraries</name> | ||
<url>https://libraries.minecraft.net</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>net.sourcewriters.minecraft</groupId> | ||
<artifactId>vcompat-api</artifactId> | ||
<version>${project.parent.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- Minecraft --> | ||
|
||
<dependency> | ||
<groupId>spigot</groupId> | ||
<artifactId>remapped</artifactId> | ||
<version>0.1</version> | ||
<scope>system</scope> | ||
<systemPath>${spigot.libPath}/spigot-${minecraft.version}.jar</systemPath> | ||
</dependency> | ||
<dependency> | ||
<groupId>it.unimi.dsi</groupId> | ||
<artifactId>fastutil</artifactId> | ||
<version>8.5.6</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.mojang</groupId> | ||
<artifactId>datafixerupper</artifactId> | ||
<version>1.0.20</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>jline</groupId> | ||
<artifactId>jline</artifactId> | ||
<version>2.12.1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>2.0.0-alpha1</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>net.md-5</groupId> | ||
<artifactId>specialsource-maven-plugin</artifactId> | ||
<version>1.2.2</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>remap</goal> | ||
</goals> | ||
<id>remap-obf</id> | ||
<configuration> | ||
<srgIn>org.spigotmc:minecraft-server:${minecraft.version}-R0.1-SNAPSHOT:txt:maps-mojang</srgIn> | ||
<reverse>true</reverse> | ||
<remappedDependencies>org.spigotmc:spigot:${minecraft.version}-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies> | ||
<remappedArtifactAttached>true</remappedArtifactAttached> | ||
<remappedClassifierName>remapped-obf</remappedClassifierName> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>remap</goal> | ||
</goals> | ||
<id>remap-spigot</id> | ||
<configuration> | ||
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile> | ||
<srgIn>org.spigotmc:minecraft-server:${minecraft.version}-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn> | ||
<remappedDependencies>org.spigotmc:spigot:${minecraft.version}-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
209 changes: 209 additions & 0 deletions
209
...a/net/sourcewriters/minecraft/vcompat/provider/impl/v1_18_R2/BukkitConversion1_18_R2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
package net.sourcewriters.minecraft.vcompat.provider.impl.v1_18_R2; | ||
|
||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; | ||
import org.bukkit.entity.EntityType; | ||
|
||
import net.minecraft.nbt.ByteArrayTag; | ||
import net.minecraft.nbt.ByteTag; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.nbt.DoubleTag; | ||
import net.minecraft.nbt.EndTag; | ||
import net.minecraft.nbt.FloatTag; | ||
import net.minecraft.nbt.IntArrayTag; | ||
import net.minecraft.nbt.IntTag; | ||
import net.minecraft.nbt.ListTag; | ||
import net.minecraft.nbt.LongArrayTag; | ||
import net.minecraft.nbt.LongTag; | ||
import net.minecraft.nbt.ShortTag; | ||
import net.minecraft.nbt.StringTag; | ||
import net.minecraft.nbt.Tag; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.sourcewriters.minecraft.vcompat.data.api.IDataAdapterContext; | ||
import net.sourcewriters.minecraft.vcompat.data.api.IDataType; | ||
import net.sourcewriters.minecraft.vcompat.provider.BukkitConversion; | ||
import net.sourcewriters.minecraft.vcompat.provider.data.WrapType; | ||
import net.sourcewriters.minecraft.vcompat.provider.data.WrappedContext; | ||
import net.sourcewriters.minecraft.vcompat.provider.entity.NmsEntityType; | ||
import net.sourcewriters.minecraft.vcompat.provider.impl.v1_18_R2.data.BukkitContext1_18_R2; | ||
import net.sourcewriters.minecraft.vcompat.provider.impl.v1_18_R2.data.BukkitType1_18_R2; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtByte; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtByteArray; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtCompound; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtDouble; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtEnd; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtFloat; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtInt; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtIntArray; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtList; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtLong; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtLongArray; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtShort; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtString; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtTag; | ||
import net.sourcewriters.minecraft.vcompat.shaded.syntaxapi.nbt.NbtType; | ||
|
||
public class BukkitConversion1_18_R2 extends BukkitConversion<VersionControl1_18_R2> { | ||
|
||
protected BukkitConversion1_18_R2(VersionControl1_18_R2 versionControl) { | ||
super(versionControl); | ||
} | ||
|
||
@Override | ||
public EntityType toEntityType(NmsEntityType type) { | ||
try { | ||
return EntityType.valueOf(type.name()); | ||
} catch (IllegalArgumentException ignore) { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public NmsEntityType fromEntityType(EntityType type) { | ||
try { | ||
return NmsEntityType.valueOf(type.name()); | ||
} catch (IllegalArgumentException ignore) { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public Tag toMinecraftTag(NbtTag tag) { | ||
switch (tag.getType()) { | ||
case END: | ||
return EndTag.INSTANCE; | ||
case BYTE: | ||
return ByteTag.valueOf(((NbtByte) tag).getValue()); | ||
case BYTE_ARRAY: | ||
return new ByteArrayTag(((NbtByteArray) tag).getValue()); | ||
case DOUBLE: | ||
return DoubleTag.valueOf(((NbtDouble) tag).getValue()); | ||
case FLOAT: | ||
return FloatTag.valueOf(((NbtFloat) tag).getValue()); | ||
case INT: | ||
return IntTag.valueOf(((NbtInt) tag).getValue()); | ||
case INT_ARRAY: | ||
return new IntArrayTag(((NbtIntArray) tag).getValue()); | ||
case LONG: | ||
return LongTag.valueOf(((NbtLong) tag).getValue()); | ||
case LONG_ARRAY: | ||
return new LongArrayTag(((NbtLongArray) tag).getValue()); | ||
case SHORT: | ||
return ShortTag.valueOf(((NbtShort) tag).getValue()); | ||
case STRING: | ||
return StringTag.valueOf(((NbtString) tag).getValue()); | ||
case LIST: | ||
return toMinecraftList((NbtList<?>) tag); | ||
case COMPOUND: | ||
return toMinecraftCompound((NbtCompound) tag); | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public NbtTag fromMinecraftTag(Object tag) { | ||
if (tag != null && tag instanceof Tag) { | ||
return fromMinecraftTag0((Tag) tag); | ||
} | ||
return null; | ||
} | ||
|
||
public NbtTag fromMinecraftTag0(Tag tag) { | ||
switch (NbtType.getById(tag.getId())) { | ||
case END: | ||
return NbtEnd.INSTANCE; | ||
case BYTE: | ||
return new NbtByte(((ByteTag) tag).getAsByte()); | ||
case BYTE_ARRAY: | ||
return new NbtByteArray(((ByteArrayTag) tag).getAsByteArray()); | ||
case DOUBLE: | ||
return new NbtDouble(((DoubleTag) tag).getAsDouble()); | ||
case FLOAT: | ||
return new NbtFloat(((FloatTag) tag).getAsFloat()); | ||
case INT: | ||
return new NbtInt(((IntTag) tag).getAsInt()); | ||
case INT_ARRAY: | ||
return new NbtIntArray(((IntArrayTag) tag).getAsIntArray()); | ||
case LONG: | ||
return new NbtLong(((LongTag) tag).getAsLong()); | ||
case LONG_ARRAY: | ||
return new NbtLongArray(((LongArrayTag) tag).getAsLongArray()); | ||
case SHORT: | ||
return new NbtShort(((ShortTag) tag).getAsShort()); | ||
case STRING: | ||
return new NbtString(((StringTag) tag).getAsString()); | ||
case LIST: | ||
return fromMinecraftList(tag); | ||
case COMPOUND: | ||
return fromMinecraftCompound(tag); | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public ListTag toMinecraftList(NbtList<?> list) { | ||
ListTag output = new ListTag(); | ||
for (NbtTag tag : list) { | ||
output.add(toMinecraftTag(tag)); | ||
} | ||
return output; | ||
} | ||
|
||
@Override | ||
public NbtList<NbtTag> fromMinecraftList(Object raw) { | ||
if (!(raw instanceof ListTag)) { | ||
return null; | ||
} | ||
ListTag list = (ListTag) raw; | ||
NbtList<NbtTag> output = new NbtList<>(NbtType.getById(list.getElementType())); | ||
for (Tag base : list) { | ||
output.add(fromMinecraftTag(base)); | ||
} | ||
return output; | ||
} | ||
|
||
@Override | ||
public CompoundTag toMinecraftCompound(NbtCompound compound) { | ||
NbtCompound compoundTag = compound; | ||
CompoundTag targetCompound = new CompoundTag(); | ||
for (String key : compoundTag.getKeys()) { | ||
targetCompound.put(key, toMinecraftTag(compoundTag.get(key))); | ||
} | ||
return targetCompound; | ||
} | ||
|
||
@Override | ||
public NbtCompound fromMinecraftCompound(Object raw) { | ||
if (!(raw instanceof CompoundTag)) { | ||
return null; | ||
} | ||
CompoundTag compoundTag = (CompoundTag) raw; | ||
NbtCompound targetCompound = new NbtCompound(); | ||
for (String key : compoundTag.getAllKeys()) { | ||
targetCompound.set(key, fromMinecraftTag(compoundTag.get(key))); | ||
} | ||
return targetCompound; | ||
} | ||
|
||
@Override | ||
public org.bukkit.inventory.ItemStack itemFromCompound(NbtCompound compound) { | ||
return CraftItemStack.asBukkitCopy(ItemStack.of(toMinecraftCompound(compound))); | ||
} | ||
|
||
@Override | ||
public NbtCompound itemToCompound(org.bukkit.inventory.ItemStack itemStack) { | ||
return fromMinecraftCompound(CraftItemStack.asNMSCopy(itemStack).save(new CompoundTag())); | ||
} | ||
|
||
@Override | ||
public WrappedContext<IDataAdapterContext> createContext(IDataAdapterContext context) { | ||
return new BukkitContext1_18_R2(context); | ||
} | ||
|
||
@Override | ||
public <P, C> WrapType<P, C> wrap(IDataType<P, C> dataType) { | ||
return new BukkitType1_18_R2<>(dataType); | ||
} | ||
|
||
} |
Oops, something went wrong.