Skip to content

Commit

Permalink
Also suppport old ProtocolLib
Browse files Browse the repository at this point in the history
  • Loading branch information
Leymooo committed Jun 3, 2020
1 parent bdfcd70 commit 88943ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ru/leymooo/fixer/ItemChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ private boolean isCrashItem(ItemStack stack, NbtCompound tag, Material mat) {
return true;
}
int tagL = tag.toString().length();
if (hasLongArrayTag(tag)) {
if (plugin.isLongArraysSupported() && hasLongArrayTag(tag)) {
return true;
}
if ((mat == Material.NAME_TAG || tiles.contains(mat)) && tagL > 600) {
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/ru/leymooo/fixer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;

import com.comphenix.protocol.wrappers.nbt.NbtType;
import me.catcoder.updatechecker.PluginUpdater;
import me.catcoder.updatechecker.UpdaterException;
import me.catcoder.updatechecker.UpdaterResult;
Expand All @@ -24,6 +25,7 @@ public class Main extends JavaPlugin {
private MagicAPI mapi;
private ItemChecker checker;
private ProtocolManager manager;
private boolean longArraysSupported;
private final PluginUpdater updater = new PluginUpdater(this, "Dimatert9", "ItemFixer");

@Override
Expand All @@ -33,7 +35,7 @@ public void onEnable() {
setEnabled(false);
return;
}

checkLongArraySupport();
saveDefaultConfig();
checkNewConfig();
PluginManager pmanager = Bukkit.getPluginManager();
Expand Down Expand Up @@ -105,4 +107,15 @@ private void checkUpdate() {
}
}).start();
}

private void checkLongArraySupport() {
try {
NbtType type = NbtType.TAG_LONG_ARRAY;
this.longArraysSupported = NbtType.valueOf("TAG_LONG_ARRAY") != null || type != null;
} catch (Throwable e) {}
}

public boolean isLongArraysSupported() {
return longArraysSupported;
}
}

0 comments on commit 88943ff

Please sign in to comment.