mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-09 22:48:35 +00:00
Add and apply .editorconfig from P2 (#1195)
* Consistenty use javax annotations. - Unfortunately jetbrains annotations seem to be exposed transitively via core somewhere, but with the correct IDE settings, annotations can be defaulted to javax - Cleaning up of import order in #1195 - Must be merged before #1195 * Add and apply .editorconfig from P2 - Does not rearrange entries * Address some comments * add back some javadoc comments * Address final comments Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
@ -31,6 +31,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
private final YAMLProcessor config;
|
||||
private final Map<String, Set<String>> userPermissionsCache = new HashMap<>();
|
||||
private final Set<String> defaultPermissionsCache = new HashSet<>();
|
||||
@ -41,14 +42,14 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public static YAMLNode generateDefaultPerms(YAMLNode section) {
|
||||
section.setProperty("groups.default.permissions", new String[] {
|
||||
"worldedit.reload",
|
||||
"worldedit.selection",
|
||||
"worlds.creative.worldedit.region"
|
||||
section.setProperty("groups.default.permissions", new String[]{
|
||||
"worldedit.reload",
|
||||
"worldedit.selection",
|
||||
"worlds.creative.worldedit.region"
|
||||
});
|
||||
section.setProperty("groups.admins.permissions", new String[] { "*" });
|
||||
section.setProperty("users.sk89q.permissions", new String[] { "worldedit" });
|
||||
section.setProperty("users.sk89q.groups", new String[] { "admins" });
|
||||
section.setProperty("groups.admins.permissions", new String[]{"*"});
|
||||
section.setProperty("users.sk89q.permissions", new String[]{"worldedit"});
|
||||
section.setProperty("users.sk89q.groups", new String[]{"admins"});
|
||||
return section;
|
||||
}
|
||||
|
||||
|
@ -174,4 +174,5 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
||||
public String getDetectionMessage() {
|
||||
return "Using the Bukkit Permissions API.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,10 +20,11 @@
|
||||
package com.sk89q.wepif;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
@ -123,7 +124,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
defaultPermissionsCache = userGroupPermissions.get("default");
|
||||
}
|
||||
|
||||
BufferedReader buff = null;
|
||||
BufferedReader buff = null;
|
||||
|
||||
try {
|
||||
FileReader input = new FileReader(this.userFile);
|
||||
|
@ -28,6 +28,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
public class GroupManagerResolver extends DinnerPermsResolver {
|
||||
|
||||
private final WorldsHolder worldsHolder;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
@ -128,4 +129,5 @@ public class GroupManagerResolver extends DinnerPermsResolver {
|
||||
public String getDetectionMessage() {
|
||||
return "GroupManager detected! Using GroupManager for permissions.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
||||
} catch (Throwable t) {
|
||||
String group = Permissions.Security.getGroup(player.getWorld().getName(), player.getName());
|
||||
if (group != null) {
|
||||
groups = new String[] { group };
|
||||
groups = new String[]{group};
|
||||
}
|
||||
}
|
||||
if (groups == null) {
|
||||
|
@ -27,6 +27,7 @@ import ru.tehkode.permissions.PermissionManager;
|
||||
import ru.tehkode.permissions.PermissionUser;
|
||||
|
||||
public class PermissionsExResolver extends DinnerPermsResolver {
|
||||
|
||||
private final PermissionManager manager;
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
@ -90,4 +91,5 @@ public class PermissionsExResolver extends DinnerPermsResolver {
|
||||
public String getDetectionMessage() {
|
||||
return "PermissionsEx detected! Using PermissionsEx for permissions.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.wepif;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public interface PermissionsProvider {
|
||||
|
||||
boolean hasPermission(String name, String permission);
|
||||
|
||||
boolean hasPermission(String worldName, String name, String permission);
|
||||
@ -37,4 +38,5 @@ public interface PermissionsProvider {
|
||||
boolean inGroup(OfflinePlayer player, String group);
|
||||
|
||||
String[] getGroups(OfflinePlayer player);
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,9 @@
|
||||
package com.sk89q.wepif;
|
||||
|
||||
public interface PermissionsResolver extends PermissionsProvider {
|
||||
|
||||
void load();
|
||||
|
||||
String getDetectionMessage();
|
||||
|
||||
}
|
||||
|
@ -41,23 +41,23 @@ import java.util.List;
|
||||
public class PermissionsResolverManager implements PermissionsResolver {
|
||||
|
||||
private static final String CONFIG_HEADER = "#\r\n"
|
||||
+ "# WEPIF Configuration File\r\n"
|
||||
+ "#\r\n"
|
||||
+ "# This file handles permissions configuration for every plugin using WEPIF\r\n"
|
||||
+ "#\r\n"
|
||||
+ "# About editing this file:\r\n"
|
||||
+ "# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If\r\n"
|
||||
+ "# you use an editor like Notepad++ (recommended for Windows users), you\r\n"
|
||||
+ "# must configure it to \"replace tabs with spaces.\" In Notepad++, this can\r\n"
|
||||
+ "# be changed in Settings > Preferences > Language Menu.\r\n"
|
||||
+ "# - Don't get rid of the indents. They are indented so some entries are\r\n"
|
||||
+ "# in categories (like \"enforce-single-session\" is in the \"protection\"\r\n"
|
||||
+ "# category.\r\n"
|
||||
+ "# - If you want to check the format of this file before putting it\r\n"
|
||||
+ "# into WEPIF, paste it into https://yaml-online-parser.appspot.com/\r\n"
|
||||
+ "# and see if it gives \"ERROR:\".\r\n"
|
||||
+ "# - Lines starting with # are comments and so they are ignored.\r\n"
|
||||
+ "\r\n";
|
||||
+ "# WEPIF Configuration File\r\n"
|
||||
+ "#\r\n"
|
||||
+ "# This file handles permissions configuration for every plugin using WEPIF\r\n"
|
||||
+ "#\r\n"
|
||||
+ "# About editing this file:\r\n"
|
||||
+ "# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If\r\n"
|
||||
+ "# you use an editor like Notepad++ (recommended for Windows users), you\r\n"
|
||||
+ "# must configure it to \"replace tabs with spaces.\" In Notepad++, this can\r\n"
|
||||
+ "# be changed in Settings > Preferences > Language Menu.\r\n"
|
||||
+ "# - Don't get rid of the indents. They are indented so some entries are\r\n"
|
||||
+ "# in categories (like \"enforce-single-session\" is in the \"protection\"\r\n"
|
||||
+ "# category.\r\n"
|
||||
+ "# - If you want to check the format of this file before putting it\r\n"
|
||||
+ "# into WEPIF, paste it into https://yaml-online-parser.appspot.com/\r\n"
|
||||
+ "# and see if it gives \"ERROR:\".\r\n"
|
||||
+ "# - Lines starting with # are comments and so they are ignored.\r\n"
|
||||
+ "\r\n";
|
||||
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
@ -86,15 +86,15 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
private final List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
|
||||
PluginPermissionsResolver.class,
|
||||
PermissionsExResolver.class,
|
||||
bPermissionsResolver.class,
|
||||
GroupManagerResolver.class,
|
||||
NijiPermissionsResolver.class,
|
||||
VaultResolver.class,
|
||||
DinnerPermsResolver.class,
|
||||
FlatFilePermissionsResolver.class
|
||||
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[]{
|
||||
PluginPermissionsResolver.class,
|
||||
PermissionsExResolver.class,
|
||||
bPermissionsResolver.class,
|
||||
GroupManagerResolver.class,
|
||||
NijiPermissionsResolver.class,
|
||||
VaultResolver.class,
|
||||
DinnerPermsResolver.class,
|
||||
FlatFilePermissionsResolver.class
|
||||
};
|
||||
|
||||
protected PermissionsResolverManager(Plugin plugin) {
|
||||
@ -221,7 +221,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
} else {
|
||||
List<String> disabledResolvers = config.getStringList("resolvers.disabled", new ArrayList<>());
|
||||
List<String> stagedEnabled = config.getStringList("resolvers.enabled", null);
|
||||
for (Iterator<String> i = stagedEnabled.iterator(); i.hasNext();) {
|
||||
for (Iterator<String> i = stagedEnabled.iterator(); i.hasNext(); ) {
|
||||
String nextName = i.next();
|
||||
Class<?> next = null;
|
||||
try {
|
||||
@ -242,11 +242,11 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
|
||||
for (Class<?> clazz : availableResolvers) {
|
||||
if (!stagedEnabled.contains(clazz.getSimpleName())
|
||||
&& !disabledResolvers.contains(clazz.getSimpleName())) {
|
||||
&& !disabledResolvers.contains(clazz.getSimpleName())) {
|
||||
disabledResolvers.add(clazz.getSimpleName());
|
||||
LOGGER.info("New permissions resolver: "
|
||||
+ clazz.getSimpleName() + " detected. "
|
||||
+ "Added to disabled resolvers list.");
|
||||
+ clazz.getSimpleName() + " detected. "
|
||||
+ "Added to disabled resolvers list.");
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
@ -272,9 +272,11 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
}
|
||||
|
||||
public static class MissingPluginException extends Exception {
|
||||
|
||||
}
|
||||
|
||||
class ServerListener implements org.bukkit.event.Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
@ -303,6 +305,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
||||
void register(Plugin plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ public class PluginPermissionsResolver implements PermissionsResolver {
|
||||
|
||||
public static PermissionsResolver factory(Server server, YAMLProcessor config) {
|
||||
// Looking for service
|
||||
RegisteredServiceProvider<PermissionsProvider> serviceProvider = server.getServicesManager().getRegistration(PermissionsProvider.class);
|
||||
RegisteredServiceProvider<PermissionsProvider> serviceProvider = server.getServicesManager().getRegistration(
|
||||
PermissionsProvider.class);
|
||||
|
||||
if (serviceProvider != null) {
|
||||
return new PluginPermissionsResolver(serviceProvider.getProvider(), serviceProvider.getPlugin());
|
||||
|
Reference in New Issue
Block a user