Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Jun 29, 2024
1 parent 4b5db86 commit d6e1f19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
// NBT-API
maven {
name = "codemc-repo"
url = uri("https://repo.codemc.org/repository/maven-public/")
url = uri("https://repo.codemc.io/repository/maven-public/")
}

// FoliaLib
Expand Down Expand Up @@ -80,7 +80,7 @@ tasks {
relocate("org.bstats", "cn.dreeam.surf.libs.bstats")
relocate("com.tcoded.folialib", "cn.dreeam.surf.libs.folialib")
relocate("com.cryptomorin.xseries", "cn.dreeam.surf.libs.xseries")
relocate("de.tr7zw.nbtapi", "cn.dreeam.surf.libs.nbtapi")
relocate("de.tr7zw.changeme.nbtapi", "cn.dreeam.surf.libs.nbtapi")
}

processResources {
Expand Down
32 changes: 23 additions & 9 deletions src/main/java/cn/dreeam/surf/modules/patch/NBTBan.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import cn.dreeam.surf.config.Config;
import cn.dreeam.surf.util.Util;
import de.tr7zw.nbtapi.NBT;
import de.tr7zw.changeme.nbtapi.NBT;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
Expand All @@ -19,15 +19,29 @@ public void onJoin(PlayerJoinEvent event) {
Inventory inv = event.getPlayer().getInventory();
AtomicInteger itemSize = new AtomicInteger();

inv.forEach(i -> {
if (i != null && i.getType().name().contains("SHULKER_BOX")) {
itemSize.addAndGet(NBT.itemStackToNBT(i).toString().length());
// TODO
if (Util.majorVersion >= 20 && Util.minorVersion >= 5) {
inv.forEach(i -> {
if (i != null && i.getType().name().contains("SHULKER_BOX")) {
itemSize.addAndGet(NBT.itemStackToNBT(i).toString().length());

if (itemSize.get() > Config.preventNBTBanLimit) {
inv.remove(i);
Util.sendMessage(event.getPlayer(), Config.preventNBTBanMessage);
if (itemSize.get() > Config.preventNBTBanLimit) {
inv.remove(i);
Util.sendMessage(event.getPlayer(), Config.preventNBTBanMessage);
}
}
}
});
});
} else {
inv.forEach(i -> {
if (i != null && i.getType().name().contains("SHULKER_BOX")) {
itemSize.addAndGet(NBT.itemStackToNBT(i).toString().length());

if (itemSize.get() > Config.preventNBTBanLimit) {
inv.remove(i);
Util.sendMessage(event.getPlayer(), Config.preventNBTBanMessage);
}
}
});
}
}
}

0 comments on commit d6e1f19

Please sign in to comment.