Cleanup parts of the sponge service implementation

This commit is contained in:
Luck
2018-03-01 08:48:39 +00:00
Unverified
parent 98fb9946e4
commit fbe84322b5
32 changed files with 632 additions and 884 deletions
@@ -62,7 +62,7 @@ public class ProgressLogger {
}
}
public void logErr(String msg) {
public void logError(String msg) {
if (this.pluginName == null) {
this.listeners.forEach(s -> this.logMessage.send(s, "Error -> " + msg));
} else {
@@ -80,7 +80,6 @@ public class ProgressLogger {
public void logProgress(String msg, int amount) {
if (amount % NOTIFY_FREQUENCY == 0) {
// migrated {} groups so far.
logAllProgress(msg, amount);
}
}
@@ -25,8 +25,30 @@
package me.lucko.luckperms.common.model;
import java.util.function.Supplier;
public enum NodeMapType {
ENDURING, TRANSIENT
ENDURING,
TRANSIENT;
// useful methods for fluent/conditional execution
public void run(Runnable ifEnduring, Runnable ifTransient) {
if (this == ENDURING) {
ifEnduring.run();
} else {
ifTransient.run();
}
}
public <T> T supply(Supplier<T> ifEnduring, Supplier<T> ifTransient) {
if (this == ENDURING) {
return ifEnduring.get();
} else {
return ifTransient.get();
}
}
}
@@ -262,6 +262,10 @@ public abstract class PermissionHolder {
return this.transientNodes;
}
public ImmutableSetMultimap<ImmutableContextSet, Node> getNodes(NodeMapType type) {
return getData(type).immutable();
}
public ImmutableSetMultimap<ImmutableContextSet, Node> getEnduringNodes() {
return this.enduringNodes.immutable();
}