mirror of https://github.com/LOOHP/Limbo.git
Fixed error while checking permissions
This commit is contained in:
parent
f8e2cd0915
commit
8164571920
2
pom.xml
2
pom.xml
|
|
@ -4,7 +4,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>Limbo</groupId>
|
||||
<artifactId>Limbo</artifactId>
|
||||
<version>0.2.2-ALPHA</version>
|
||||
<version>0.2.3-ALPHA</version>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.loohp.limbo;
|
|||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ import com.loohp.limbo.Utils.DataTypeIO;
|
|||
|
||||
public class DeclareCommands {
|
||||
|
||||
public static PacketPlayOutDeclareCommands getDeclareCommandsPacket(CommandSender sender) throws Exception {
|
||||
public static PacketPlayOutDeclareCommands getDeclareCommandsPacket(CommandSender sender) throws IOException {
|
||||
List<String> commands = Limbo.getInstance().getPluginManager().getTabOptions(sender, new String[0]);
|
||||
|
||||
if (commands.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -25,18 +25,23 @@ public class PermissionsManager {
|
|||
@SuppressWarnings("unchecked")
|
||||
public void loadDefaultPermissionFile(File file) throws FileNotFoundException {
|
||||
FileConfiguration config = new FileConfiguration(file);
|
||||
permissions.put("default", new ArrayList<>());
|
||||
try {
|
||||
for (Object obj : config.get("groups", Map.class).keySet()) {
|
||||
String key = (String) obj;
|
||||
List<String> nodes = new ArrayList<>();
|
||||
nodes.addAll(config.get("groups." + key, List.class));
|
||||
permissions.put(key, nodes);
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
try {
|
||||
for (Object obj : config.get("players", Map.class).keySet()) {
|
||||
String key = (String) obj;
|
||||
List<String> groups = new ArrayList<>();
|
||||
groups.addAll(config.get("players." + key, List.class));
|
||||
users.put(key, groups);
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender sender, String permission) {
|
||||
|
|
@ -44,7 +49,7 @@ public class PermissionsManager {
|
|||
return true;
|
||||
} else if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (users.get(player.getName()).stream().anyMatch(each -> permissions.get(each).stream().anyMatch(node -> node.equalsIgnoreCase(permission)))) {
|
||||
if (users.get(player.getName()) != null && users.get(player.getName()).stream().anyMatch(each -> permissions.get(each).stream().anyMatch(node -> node.equalsIgnoreCase(permission)))) {
|
||||
return true;
|
||||
} else {
|
||||
return permissions.get("default").stream().anyMatch(node -> node.equalsIgnoreCase(permission));
|
||||
|
|
|
|||
|
|
@ -94,14 +94,14 @@ public class PluginManager {
|
|||
}
|
||||
}
|
||||
|
||||
public List<String> getTabOptions(CommandSender sender, String[] args) throws Exception {
|
||||
public List<String> getTabOptions(CommandSender sender, String[] args) {
|
||||
List<String> options = new ArrayList<>();
|
||||
for (Executor entry : executors) {
|
||||
if (entry.tab.isPresent()) {
|
||||
try {
|
||||
options.addAll(entry.tab.get().tabComplete(sender, args));
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error while passing tab completion \"" + args[0] + "\" to the plugin \"" + entry.plugin.getName() + "\"");
|
||||
System.err.println("Error while passing tab completion to the plugin \"" + entry.plugin.getName() + "\"");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue