Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/buildtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ checkVersion () {

checkVersion "1.19" "17"
checkVersion "1.19.3" "17"
checkVersion "1.19.4" "17"
checkVersion "1.19.4" "17"
checkVersion "1.20" "17"
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
<plugin.flatten.version>1.2.7</plugin.flatten.version>
<plugin.specialsource.version>1.2.4</plugin.specialsource.version>

<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<java.version>16</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<java.version>17</java.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand All @@ -56,7 +56,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>${plugin.compile.version}</version>
<configuration>
<release>16</release>
<release>17</release>
</configuration>
</plugin>
<plugin>
Expand Down
1 change: 1 addition & 0 deletions zip-nms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<module>zip-nms-v1_19_R1</module>
<module>zip-nms-v1_19_R2</module>
<module>zip-nms-v1_19_R3</module>
<module>zip-nms-v1_20_R1</module>
</modules>
</project>
66 changes: 66 additions & 0 deletions zip-nms/zip-nms-v1_20_R1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<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.imprex</groupId>
<artifactId>zip-nms</artifactId>
<version>${revision}</version>
</parent>

<artifactId>zip-nms-v1_20_R1</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>net.imprex</groupId>
<artifactId>zip-nms-api</artifactId>
<version>${revision}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>${plugin.specialsource.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.20-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.20-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:1.20-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.20-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package net.imprex.zip.nms.v1_20_R1;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;

import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;

import net.imprex.zip.common.ReflectionUtil;
import net.imprex.zip.nms.api.NmsManager;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.Tag;

public class ZipNmsManager implements NmsManager {

private static final Class<?> CRAFTMETASKULL_CLASS = ReflectionUtil.getCraftBukkitClass("inventory.CraftMetaSkull");
private static final Method CRAFTMETASKULL_SET_PROFILE = ReflectionUtil.getMethod(CRAFTMETASKULL_CLASS,
"setProfile", GameProfile.class);

public byte[] nbtToBinary(CompoundTag compound) {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
NbtIo.writeCompressed(compound, outputStream);
return outputStream.toByteArray();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}

public CompoundTag binaryToNBT(byte[] binary) {
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(binary)) {
return NbtIo.readCompressed(inputStream);
} catch (Exception e) {
e.printStackTrace();
}
return new CompoundTag();
}

@Override
public byte[] itemstackToBinary(ItemStack[] items) {
CompoundTag inventory = new CompoundTag();
ListTag list = new ListTag();
for (ItemStack itemStack : items) {
net.minecraft.world.item.ItemStack craftItem = CraftItemStack.asNMSCopy(itemStack);
list.add(craftItem.save(new CompoundTag()));
}
inventory.put("i", list);
return nbtToBinary(inventory);
}

@Override
public List<ItemStack> binaryToItemStack(byte[] binary) {
CompoundTag nbt = binaryToNBT(binary);
List<ItemStack> items = new ArrayList<>();
if (nbt.contains("i", 9)) {
ListTag list = nbt.getList("i", 10);
for (Tag base : list) {
if (base instanceof CompoundTag) {
items.add(CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.of((CompoundTag) base)));
}
}
}
return items;
}

@Override
public void setSkullProfile(SkullMeta meta, String texture) {
try {
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "");
gameProfile.getProperties().put("textures", new Property("textures", texture));
CRAFTMETASKULL_SET_PROFILE.invoke(meta, gameProfile);
} catch (Exception e) {
throw new ClassCastException("Error by setting skull profile");
}
}

@Override
public boolean isAir(Material material) {
return material == null || material == Material.AIR;
}
}
6 changes: 6 additions & 0 deletions zip-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,11 @@
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.imprex</groupId>
<artifactId>zip-nms-v1_20_R1</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion zip-plugin/src/main/java/net/imprex/zip/UpdateSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/**
* @author Imprex-Development
* @see https://github.com/Imprex-Development/orebfuscator/blob/master/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/UpdateSystem.java
* @see <a href="https://github.com/Imprex-Development/orebfuscator/blob/master/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/UpdateSystem.java">UpdateSystem.java</a>
*/
public class UpdateSystem {

Expand Down
63 changes: 63 additions & 0 deletions zip-plugin/src/main/resources/config/config-1.20.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
general:
checkForUpdates: true
verbose: false
locale: en_US
type:
big:
uniqueName: 'big'
displayName: '&7Big &eBackpack'
inventoryRows: 6
customModelData: 3
texture: 'ewogICJ0aW1lc3RhbXAiIDogMTYzMzg2MjQwNTg4NSwKICAicHJvZmlsZUlkIiA6ICI1NjY3NWIyMjMyZjA0ZWUwODkxNzllOWM5MjA2Y2ZlOCIsCiAgInByb2ZpbGVOYW1lIiA6ICJUaGVJbmRyYSIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9kYTMzMTY5YjcyY2Y4OTE4YjgyYzViZDI3Y2JhOWVlNmMwZWI4OTE2NDA0MDQ4MGJiMjdmODUzNGUwZmE1ODA3IiwKICAgICAgIm1ldGFkYXRhIiA6IHsKICAgICAgICAibW9kZWwiIDogInNsaW0iCiAgICAgIH0KICAgIH0KICB9Cn0='
lore:
- '&aA Big Backpack'
recipe:
discover: true
group: 'null'
patternOne: 'LCL'
patternTwo: 'ECE'
patternThree: 'DCD'
patternMapping:
L: LEATHER
E: LEAD
C: CHEST
D: DIAMOND
medium:
uniqueName: 'medium'
displayName: '&7Medium &eBackpack'
inventoryRows: 3
customModelData: 2
texture: 'ewogICJ0aW1lc3RhbXAiIDogMTY3NDM0NDQ0MzY4NywKICAicHJvZmlsZUlkIiA6ICIxMzdmMjg3MjUwOTE0ZmI4YjA0ZTYwYjg4MWUwZWE2YiIsCiAgInByb2ZpbGVOYW1lIiA6ICJub3JtYWxpc2luZyIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS9lZjhlZDY4NWIzYzNjYWI4NDM1ZDBmNmIwZDJkZGI0NmRmYTNhYzk2ZmUyZjlhNmQ3NDhmNzExOTFjMGI1MjJiIgogICAgfQogIH0KfQ=='
lore:
- '&aA Medium Backpack'
recipe:
discover: true
group: 'null'
patternOne: 'LSL'
patternTwo: 'ECE'
patternThree: 'ICI'
patternMapping:
L: LEATHER
S: STICK
E: LEAD
C: CHEST
I: IRON_INGOT
small:
uniqueName: 'small'
displayName: '&7Small &eBackpack'
inventoryRows: 1
customModelData: 1
texture: 'ewogICJ0aW1lc3RhbXAiIDogMTYxMzM4Nzk2NDUxNSwKICAicHJvZmlsZUlkIiA6ICJkZTU3MWExMDJjYjg0ODgwOGZlN2M5ZjQ0OTZlY2RhZCIsCiAgInByb2ZpbGVOYW1lIiA6ICJNSEZfTWluZXNraW4iLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGFlMTg3MTQ1ZWU3MzJlN2MwMDkwNWE5YzE2ZWQxZTQzYmE4OGQ1NjI0YTZmNGFmODI5ZjEwNDUzZmNjOTE2NSIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9'
lore:
- '&aA Small Backpack'
recipe:
discover: true
group: 'null'
patternOne: 'LSL'
patternTwo: 'ECE'
patternThree: 'LLL'
patternMapping:
L: LEATHER
S: STICK
E: LEAD
C: CHEST