Skip to content

Commit

Permalink
Make custom potion effects check less agressive
Browse files Browse the repository at this point in the history
  • Loading branch information
ds58 committed Mar 5, 2024
1 parent 7e12b79 commit 8a860e8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.ruinscraft.panilla.api.IPanilla;
import com.ruinscraft.panilla.api.config.PStrictness;
import com.ruinscraft.panilla.api.nbt.INbtTagCompound;
import com.ruinscraft.panilla.api.nbt.INbtTagList;
import com.ruinscraft.panilla.api.nbt.NbtDataType;

public class NbtCheck_CustomPotionEffects extends NbtCheck {

Expand All @@ -12,7 +14,43 @@ public NbtCheck_CustomPotionEffects() {

@Override
public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panilla) {
return NbtCheckResult.FAIL;
String using = null;

if (tag.hasKey(getName())) {
using = getName();
} else {
for (String alias : getAliases()) {
if (tag.hasKey(alias)) {
using = alias;
}
}
}

if (using == null) {
throw new IllegalStateException("Unknown custom potion effects tag");
}

INbtTagList effectsList = tag.getList(using, NbtDataType.COMPOUND);

for (int i = 0; i < effectsList.size(); i++) {
INbtTagCompound effect = effectsList.getCompound(i);

if (effect.hasKeyOfType("amplifier", NbtDataType.BYTE)) {
short amplifier = effect.getByte("amplifier");
if (amplifier > 32) {
return NbtCheckResult.CRITICAL;
}
}

if (effect.hasKeyOfType("Amplifier", NbtDataType.BYTE)) {
short amplifier = effect.getByte("Amplifier");
if (amplifier > 32) {
return NbtCheckResult.CRITICAL;
}
}
}

return NbtCheckResult.PASS;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ private static NbtCheckResult checkEffectsTag(INbtTagList effectsList) {
return NbtCheckResult.CRITICAL;
}
}

if (effect.hasKeyOfType("Amplifier", NbtDataType.BYTE)) {
short amplifier = effect.getByte("Amplifier");
if (amplifier > 32) {
return NbtCheckResult.CRITICAL;
}
}
}

return NbtCheckResult.PASS;
Expand Down

0 comments on commit 8a860e8

Please sign in to comment.