Skip to content

Commit

Permalink
Merge branch 'ds58:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq authored Mar 7, 2024
2 parents 76a9ff8 + c384c90 commit 398a757
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
allprojects {
group = 'com.ruinscraft'
version = '1.11.2'
version = '1.11.3'
}

subprojects {
Expand Down

0 comments on commit 398a757

Please sign in to comment.