From fcb0fcadeb6d922b9ed443983363ec8c55406823 Mon Sep 17 00:00:00 2001 From: Luck Date: Thu, 13 Oct 2016 20:36:08 +0100 Subject: [PATCH] Fix StackOverflowException --- .../service/persisted/PersistedSubject.java | 26 ++++++++++++++----- .../sponge/service/simple/SimpleSubject.java | 22 ++++++++++++---- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/persisted/PersistedSubject.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/persisted/PersistedSubject.java index d49bee84..1e6f2a75 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/persisted/PersistedSubject.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/persisted/PersistedSubject.java @@ -120,11 +120,15 @@ public class PersistedSubject implements Subject { @Override public boolean isChildOf(@NonNull Set contexts, @NonNull Subject subject) { - return subjectData.getParents(contexts).contains(subject) || - transientSubjectData.getParents(contexts).contains(subject) || - getContainingCollection().getDefaults().getParents(contexts).contains(subject) || - service.getDefaults().getParents(contexts).contains(subject); - + if (getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) { + return subjectData.getParents(contexts).contains(subject) || + transientSubjectData.getParents(contexts).contains(subject); + } else { + return subjectData.getParents(contexts).contains(subject) || + transientSubjectData.getParents(contexts).contains(subject) || + getContainingCollection().getDefaults().getParents(contexts).contains(subject) || + service.getDefaults().getParents(contexts).contains(subject); + } } @Override @@ -132,8 +136,12 @@ public class PersistedSubject implements Subject { List s = new ArrayList<>(); s.addAll(subjectData.getParents(contexts)); s.addAll(transientSubjectData.getParents(contexts)); - s.addAll(getContainingCollection().getDefaults().getParents(contexts)); - s.addAll(service.getDefaults().getParents(contexts)); + + if (!getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) { + s.addAll(getContainingCollection().getDefaults().getParents(contexts)); + s.addAll(service.getDefaults().getParents(contexts)); + } + return ImmutableList.copyOf(s); } @@ -156,6 +164,10 @@ public class PersistedSubject implements Subject { } } + if (getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) { + return Optional.empty(); + } + res = getContainingCollection().getDefaults().getOption(set, key); if (res.isPresent()) { return res; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/simple/SimpleSubject.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/simple/SimpleSubject.java index f55f3f4d..b8686283 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/simple/SimpleSubject.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/simple/SimpleSubject.java @@ -97,17 +97,25 @@ public class SimpleSubject implements Subject { @Override public boolean isChildOf(@NonNull Set contexts, @NonNull Subject subject) { - return subjectData.getParents(contexts).contains(subject) || - getContainingCollection().getDefaults().getParents(contexts).contains(subject) || - service.getDefaults().getParents(contexts).contains(subject); + if (getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) { + return subjectData.getParents(contexts).contains(subject); + } else { + return subjectData.getParents(contexts).contains(subject) || + getContainingCollection().getDefaults().getParents(contexts).contains(subject) || + service.getDefaults().getParents(contexts).contains(subject); + } } @Override public List getParents(@NonNull Set contexts) { List s = new ArrayList<>(); s.addAll(subjectData.getParents(contexts)); - s.addAll(getContainingCollection().getDefaults().getParents(contexts)); - s.addAll(service.getDefaults().getParents(contexts)); + + if (!getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")){ + s.addAll(getContainingCollection().getDefaults().getParents(contexts)); + s.addAll(service.getDefaults().getParents(contexts)); + } + return ImmutableList.copyOf(s); } @@ -125,6 +133,10 @@ public class SimpleSubject implements Subject { } } + if (getContainingCollection().getIdentifier().equalsIgnoreCase("defaults")) { + return Optional.empty(); + } + res = getContainingCollection().getDefaults().getOption(set, key); if (res.isPresent()) { return res;