Fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package si.jernejtdo.LitePermissions.Spigot.Permissible;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -15,6 +16,7 @@ import si.jernejtdo.LitePermissions.Spigot.data.UserData;
|
||||
public class CustomPermissible extends PermissibleBase {
|
||||
|
||||
private final Player player;
|
||||
private final Map<String, Boolean> permissionCache = new HashMap<>();
|
||||
|
||||
public CustomPermissible(ServerOperator opable) {
|
||||
super(opable);
|
||||
@@ -36,12 +38,16 @@ public class CustomPermissible extends PermissibleBase {
|
||||
}
|
||||
|
||||
public boolean checkPermissions(String inName) {
|
||||
// ✅ Check if cached
|
||||
if (permissionCache.containsKey(inName)) {
|
||||
return permissionCache.get(inName);
|
||||
}
|
||||
|
||||
LitePermissions plugin = LitePermissions.getPlugin();
|
||||
UserData user = plugin.getUserData(player.getUniqueId());
|
||||
|
||||
boolean result = false;
|
||||
String source = "none";
|
||||
|
||||
String world = player.getWorld().getName().toLowerCase();
|
||||
|
||||
if (user != null) {
|
||||
@@ -75,16 +81,22 @@ public class CustomPermissible extends PermissibleBase {
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ Store in cache
|
||||
permissionCache.put(inName, result);
|
||||
|
||||
// ✅ Log only once per permission
|
||||
plugin.sendConsoleMessage("&a" + player.getName() +
|
||||
"&f permission (&e" + inName + "&f): &6" + result + " &7[source: " + source + "]");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
// Optional: call this if permissions change and you want to clear cache
|
||||
public void clearPermissionCache() {
|
||||
permissionCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Fri Jul 11 20:52:35 CEST 2025
|
||||
#Fri Jul 11 21:36:22 CEST 2025
|
||||
artifactId=LitePermissions
|
||||
groupId=si.jernejtdo
|
||||
m2e.projectLocation=D\:\\Codespace\\JernejTDO\\LitePermissions
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user