Skip to content

Commit d182f66

Browse files
committed
fix bug
1 parent c053690 commit d182f66

File tree

6 files changed

+23
-20
lines changed

6 files changed

+23
-20
lines changed

build.gradle.kts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import java.net.URI
33
plugins {
44
`java-library`
55
`maven-publish`
6-
id("io.papermc.paperweight.userdev") version "1.7.2"
6+
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17"
77
id("xyz.jpenilla.run-paper") version "2.3.0" // Adds runServer and runMojangMappedServer tasks for testing
88
}
99

1010
// = = =
1111

1212
val pluginName = "NyaaCore"
13-
val paperApiName = "1.21.3-R0.1-SNAPSHOT"
13+
val paperApiName = "1.21.5-R0.1-SNAPSHOT"
1414

1515
// = = =
1616

1717
group = "cat.nyaa"
18-
version ="9.5"
18+
version ="9.6"
1919

2020
java {
2121
// Configure the java toolchain. This allows gradle to auto-provision JDK 21 on systems that only have JDK 8 installed for example.
@@ -32,7 +32,9 @@ repositories {
3232

3333
dependencies {
3434
paperweight.paperDevBundle(paperApiName)
35-
compileOnly("net.essentialsx:EssentialsX:2.20.1") // soft dep
35+
compileOnly("net.essentialsx:EssentialsX:2.21.1") {
36+
exclude(group = "org.spigotmc", module = "spigot-api")
37+
} // soft dep
3638
compileOnly("org.jetbrains:annotations:24.1.0")
3739
// Testing
3840
testImplementation(platform("org.junit:junit-bom:5.10.3"))

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
1+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStorePath=wrapper/dists

src/main/java/cat/nyaa/nyaacore/utils/ItemStackUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static ItemStack itemFromBinary(byte[] nbt, int offset, int len) throws I
107107
CompoundTag reconstructedCompoundTag = CompoundTag.TYPE.load(dataInputStream, unlimitedNbtAccounter);
108108
dataInputStream.close();
109109
byteArrayInputStream.close();
110-
int dataVersion = reconstructedCompoundTag.getInt(NYAACORE_ITEMSTACK_DATAVERSION_KEY);
110+
int dataVersion = reconstructedCompoundTag.getInt(NYAACORE_ITEMSTACK_DATAVERSION_KEY).orElse(NYAACORE_ITEMSTACK_DEFAULT_DATAVERSION);
111111
if (dataVersion > 0) {
112112
reconstructedCompoundTag.remove(NYAACORE_ITEMSTACK_DATAVERSION_KEY);
113113
}

src/main/java/cat/nyaa/nyaacore/utils/ItemTagUtils.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static Optional<String> getString(ItemStack item, String key) {
1616
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
1717
CompoundTag tag = getTag(nmsItem);
1818
if (tag == null) return Optional.empty();
19-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getString(key));
19+
return !tag.contains(key) ? Optional.empty() : tag.getString(key);
2020
}
2121

2222
public static Optional<String> setString(ItemStack item, String key, String value) throws NoSuchFieldException, IllegalAccessException {
@@ -35,7 +35,7 @@ public static Optional<Integer> getInt(ItemStack item, String key) {
3535
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
3636
CompoundTag tag = getTag(nmsItem);
3737
if (tag == null) return Optional.empty();
38-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getInt(key));
38+
return !tag.contains(key) ? Optional.empty() : tag.getInt(key);
3939
}
4040

4141
public static Optional<Integer> setInt(ItemStack item, String key, int value) {
@@ -54,7 +54,7 @@ public static Optional<Double> getDouble(ItemStack item, String key) {
5454
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
5555
CompoundTag tag = getTag(nmsItem);
5656
if (tag == null) return Optional.empty();
57-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getDouble(key));
57+
return !tag.contains(key) ? Optional.empty() : tag.getDouble(key);
5858
}
5959

6060
public static Optional<Double> setDouble(ItemStack item, String key, double value) {
@@ -73,7 +73,7 @@ public static Optional<Short> getShort(ItemStack item, String key) {
7373
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
7474
CompoundTag tag = getTag(nmsItem);
7575
if (tag == null) return Optional.empty();
76-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getShort(key));
76+
return !tag.contains(key) ? Optional.empty() : tag.getShort(key);
7777
}
7878

7979
public static Optional<Short> setShort(ItemStack item, String key, short value) {
@@ -92,7 +92,7 @@ public static Optional<Byte> getByte(ItemStack item, String key) {
9292
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
9393
CompoundTag tag = getTag(nmsItem);
9494
if (tag == null) return Optional.empty();
95-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getByte(key));
95+
return !tag.contains(key) ? Optional.empty() : tag.getByte(key);
9696
}
9797

9898
public static Optional<Byte> setByte(ItemStack item, String key, byte value) {
@@ -111,7 +111,7 @@ public static Optional<Long> getLong(ItemStack item, String key) {
111111
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
112112
CompoundTag tag = getTag(nmsItem);
113113
if (tag == null) return Optional.empty();
114-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getLong(key));
114+
return !tag.contains(key) ? Optional.empty() : tag.getLong(key);
115115
}
116116

117117
public static Optional<Long> setLong(ItemStack item, String key, long value) {
@@ -130,7 +130,7 @@ public static Optional<long[]> getLongArray(ItemStack item, String key) {
130130
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
131131
CompoundTag tag = getTag(nmsItem);
132132
if (tag == null) return Optional.empty();
133-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getLongArray(key));
133+
return !tag.contains(key) ? Optional.empty() : tag.getLongArray(key);
134134
}
135135

136136
public static Optional<long[]> setLongArray(ItemStack item, String key, long[] value) {
@@ -149,7 +149,7 @@ public static Optional<int[]> getIntArray(ItemStack item, String key) {
149149
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
150150
CompoundTag tag = getTag(nmsItem);
151151
if (tag == null) return Optional.empty();
152-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getIntArray(key));
152+
return !tag.contains(key) ? Optional.empty() : tag.getIntArray(key);
153153
}
154154

155155
public static Optional<int[]> setIntArray(ItemStack item, String key, int[] value) {
@@ -168,7 +168,7 @@ public static Optional<byte[]> getByteArray(ItemStack item, String key) {
168168
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
169169
CompoundTag tag = getTag(nmsItem);
170170
if (tag == null) return Optional.empty();
171-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getByteArray(key));
171+
return !tag.contains(key) ? Optional.empty() : tag.getByteArray(key);
172172
}
173173

174174
public static Optional<byte[]> setByteArray(ItemStack item, String key, byte[] value) {
@@ -187,7 +187,7 @@ public static Optional<Boolean> getBoolean(ItemStack item, String key) {
187187
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
188188
CompoundTag tag = getTag(nmsItem);
189189
if (tag == null) return Optional.empty();
190-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getBoolean(key));
190+
return !tag.contains(key) ? Optional.empty() : tag.getBoolean(key);
191191
}
192192

193193
public static Optional<Boolean> setBoolean(ItemStack item, String key, boolean value) {
@@ -206,7 +206,7 @@ public static Optional<Float> getFloat(ItemStack item, String key) {
206206
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(item);
207207
CompoundTag tag = getTag(nmsItem);
208208
if (tag == null) return Optional.empty();
209-
return !tag.contains(key) ? Optional.empty() : Optional.of(tag.getFloat(key));
209+
return !tag.contains(key) ? Optional.empty() : tag.getFloat(key);
210210
}
211211

212212
public static Optional<Float> setFloat(ItemStack item, String key, float value) {

src/main/java/cat/nyaa/nyaacore/utils/NmsUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static void setEntityTag(Entity e, String tag) {
4040
CompoundTag nbtToBeMerged;
4141

4242
try {
43-
nbtToBeMerged = TagParser.parseTag(tag);
43+
nbtToBeMerged = TagParser.parseCompoundFully(tag);
4444
} catch (CommandSyntaxException ex) {
4545
throw new IllegalArgumentException("Invalid NBTTag string");
4646
}

src/main/java/cat/nyaa/nyaacore/utils/TeleportUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.bukkit.event.player.PlayerTeleportEvent;
88

99
import java.util.List;
10+
import java.util.concurrent.CompletableFuture;
1011

1112
public final class TeleportUtils {
1213
@Deprecated
@@ -17,14 +18,14 @@ public static boolean Teleport(Player player, Location loc) {
1718
Essentials ess = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
1819
if (ess != null) {
1920
try {
20-
ess.getUser(player).getTeleport().now(loc, false, PlayerTeleportEvent.TeleportCause.PLUGIN);
21+
ess.getUser(player).getAsyncTeleport().now(loc, false, PlayerTeleportEvent.TeleportCause.PLUGIN, CompletableFuture.completedFuture(true));
2122
return true;
2223
} catch (Exception e) {
2324
return false;
2425
}
2526
} else {
2627
player.setFallDistance(0);
27-
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
28+
player.teleportAsync(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
2829
return true;
2930
}
3031
}

0 commit comments

Comments
 (0)