Fix getAllNodes cache not working properly, remove pre-process contexts on Bungee & cleanup some unused methods

This commit is contained in:
Luck
2017-03-11 17:55:50 +00:00
Unverified
parent a35fd80763
commit bce7fa871d
11 changed files with 65 additions and 57 deletions
@@ -27,7 +27,7 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import me.lucko.luckperms.common.utils.ExtractedContexts;
@@ -37,7 +37,7 @@ import me.lucko.luckperms.common.utils.ExtractedContexts;
@AllArgsConstructor(staticName = "of")
public class GetAllNodesRequest {
private final ImmutableList<String> excludedGroups;
private final ImmutableSet<String> excludedGroups;
private final ExtractedContexts contexts;
}
@@ -29,7 +29,6 @@ import lombok.RequiredArgsConstructor;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
@@ -61,6 +60,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
import me.lucko.luckperms.exceptions.ObjectLacksException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -257,7 +257,7 @@ public abstract class PermissionHolder {
private SortedSet<LocalizedNode> getAllNodesCacheApply(GetAllNodesRequest getAllNodesHolder) {
// Expand the holder.
List<String> excludedGroups = new ArrayList<>(getAllNodesHolder.getExcludedGroups());
Set<String> excludedGroups = new HashSet<>(getAllNodesHolder.getExcludedGroups());
ExtractedContexts contexts = getAllNodesHolder.getContexts();
// Don't register users, as they cannot be inherited.
@@ -436,8 +436,8 @@ public abstract class PermissionHolder {
* @param contexts context to decide if groups should be applied
* @return a set of nodes
*/
public SortedSet<LocalizedNode> getAllNodes(List<String> excludedGroups, ExtractedContexts contexts) {
return getAllNodesCache.getUnchecked(GetAllNodesRequest.of(excludedGroups == null ? ImmutableList.of() : ImmutableList.copyOf(excludedGroups), contexts));
public SortedSet<LocalizedNode> getAllNodes(Collection<String> excludedGroups, ExtractedContexts contexts) {
return getAllNodesCache.getUnchecked(GetAllNodesRequest.of(excludedGroups == null ? ImmutableSet.of() : ImmutableSet.copyOf(excludedGroups), contexts));
}
/**
@@ -345,14 +345,6 @@ public interface LuckPermsPlugin {
*/
Set<UUID> getIgnoringLogs();
/**
* Gets the UUID of a player. Used as a backup for migration
*
* @param playerName the players name
* @return a uuid if found, or null if not
*/
UUID getUuidFromUsername(String playerName);
/**
* Gets the update task buffer of the platform, used for scheduling and running update tasks.
*
@@ -22,6 +22,7 @@
package me.lucko.luckperms.common.utils;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
@@ -31,6 +32,7 @@ import me.lucko.luckperms.api.context.ImmutableContextSet;
import me.lucko.luckperms.api.context.MutableContextSet;
@Getter
@EqualsAndHashCode
@ToString
public class ExtractedContexts {
public static ExtractedContexts generate(Contexts contexts) {