From 6c1e2f1280d21934716f5701672a9cf0c9edf9a7 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 13 Feb 2024 21:01:09 -0600 Subject: [PATCH] implement server side restrictions --- src/engine/objects/ItemBase.java | 12 ++++++++---- src/engine/objects/PlayerCharacter.java | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/engine/objects/ItemBase.java b/src/engine/objects/ItemBase.java index 4200ab7f..6f449203 100644 --- a/src/engine/objects/ItemBase.java +++ b/src/engine/objects/ItemBase.java @@ -969,14 +969,16 @@ public class ItemBase { } public Boolean ValidClass(Enum.ClassType base,Enum.ClassType profession){ - if(this.requiredClasses.isEmpty() && this.restrictedClasses.isEmpty()) + boolean requiredEmpty = this.requiredClasses == null || this.requiredClasses.isEmpty(); + boolean restrictedEmpty = this.restrictedClasses == null || this.restrictedClasses.isEmpty(); + if(requiredEmpty && restrictedEmpty) return true; - if(this.requiredClasses.isEmpty() == false) + if(this.requiredClasses != null && this.requiredClasses.isEmpty() == false) if(this.requiredClasses.contains(base) || this.requiredClasses.contains(profession)) return true; - if(this.restrictedClasses.isEmpty() == false) + if(this.restrictedClasses != null && this.restrictedClasses.isEmpty() == false) if(this.restrictedClasses.contains(base) == false && this.restrictedClasses.contains(profession) == false) return true; @@ -984,7 +986,9 @@ public class ItemBase { } public Boolean ValidDiscipline(EnumSet discs){ - if(this.requiredDiscs.isEmpty() && this.restrictedDiscs.isEmpty()) + boolean requiredEmpty = this.requiredDiscs == null || this.requiredDiscs.isEmpty(); + boolean restrictedEmpty = this.restrictedDiscs == null || this.restrictedDiscs.isEmpty(); + if(requiredEmpty && restrictedEmpty) return true; for(Enum.DisciplineType disc : discs){ diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index c973b61c..eecca954 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4575,11 +4575,15 @@ public class PlayerCharacter extends AbstractCharacter { else this.absGender = SexType.FEMALE; + for(CharacterRune rune : this.runes){ try { DisciplineType disc = DisciplineType.valueOf(RuneBase.getRuneBase(rune.getRuneBaseID()).getName().replace("-", "").replace(" ", "")); if (disc != null) { - this.absDisciplines.add(disc); + if(this.absDisciplines == null) + this.absDisciplines = EnumSet.of(disc); + else + this.absDisciplines.add(disc); } } catch(Exception e){