diff options
author | SHsuperCM <shsupercm@gmail.com> | 2021-09-19 14:20:19 +0300 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2021-09-19 14:20:19 +0300 |
commit | d9a8e8ff3264c199f627df7cd93ddc991e0942a6 (patch) | |
tree | beccda28ec4a339e7a22d9f4fc1136ed835ba392 /src | |
parent | 797202943d76e3d72cf2316f6cc11311f1a9a0c2 (diff) | |
download | CITResewn-d9a8e8ff3264c199f627df7cd93ddc991e0942a6.tar.gz CITResewn-d9a8e8ff3264c199f627df7cd93ddc991e0942a6.tar.bz2 CITResewn-d9a8e8ff3264c199f627df7cd93ddc991e0942a6.zip |
Fixed damage and stackSize properties not being used correctly in some cases
Fixes #34
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java index 1492d4f..857ca79 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java @@ -73,23 +73,23 @@ public abstract class CIT { this.damageMin = 0; this.damageMax = 0; } else { - if (damage.startsWith("-")) - throw new Exception("damage cannot be negative"); - if (this.damagePercentage = damage.contains("%")) damage = damage.replace("%", ""); if (damage.contains("-")) { String[] split = damage.split("-"); - if (split.length != 2) - throw new Exception("damage range must have 2 numbers"); + if (split.length > 2) + throw new Exception("damage range must have up to 2 numbers"); + + this.damageMin = split[0].isEmpty() ? Integer.MIN_VALUE : Integer.parseInt(split[0]); + this.damageMax = split.length == 1 ? Integer.MAX_VALUE : Integer.parseInt(split[1]); - if ((this.damageMin = Integer.parseInt(split[0])) > (this.damageMax = Integer.parseInt(split[1]))) + if (this.damageMin > this.damageMax) throw new Exception("damage range min is higher than max"); this.damageRange = this.damageMin < this.damageMax; } else { - this.damageRange = true; + this.damageRange = false; this.damageMin = this.damageMax = Integer.parseInt(damage); } } @@ -102,20 +102,20 @@ public abstract class CIT { this.stackMin = 0; this.stackMax = 0; } else { - if (stackSize.startsWith("-")) - throw new Exception("stackSize cannot be negative"); - if (stackSize.contains("-")) { String[] split = stackSize.split("-"); - if (split.length != 2) - throw new Exception("stackSize range must have 2 numbers"); + if (split.length > 2) + throw new Exception("stackSize range must have up to 2 numbers"); + + this.stackMin = split[0].isEmpty() ? Integer.MIN_VALUE : Integer.parseInt(split[0]); + this.stackMax = split.length == 1 ? Integer.MAX_VALUE : Integer.parseInt(split[1]); - if ((this.stackMin = Integer.parseInt(split[0])) > (this.stackMax = Integer.parseInt(split[1]))) + if (this.stackMin > this.stackMax) throw new Exception("stackSize range min is higher than max"); this.stackRange = this.stackMin < this.stackMax; } else { - this.stackRange = true; + this.stackRange = false; this.stackMin = this.stackMax = Integer.parseInt(stackSize); } } |