Cleanup
This commit is contained in:
parent
dd50193c18
commit
1c229d54d9
@ -26,7 +26,6 @@ import lombok.Getter;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import me.lucko.luckperms.ApiHandler;
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.Logger;
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
@ -40,6 +39,7 @@ import me.lucko.luckperms.bukkit.model.DefaultsProvider;
|
||||
import me.lucko.luckperms.bukkit.model.LPPermissible;
|
||||
import me.lucko.luckperms.bukkit.vault.VaultHook;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.api.ApiHandler;
|
||||
import me.lucko.luckperms.common.api.ApiProvider;
|
||||
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||
|
@ -60,7 +60,7 @@ import static me.lucko.luckperms.api.MetaUtils.unescapeCharacters;
|
||||
* Normal inheritance rules DO NOT apply.
|
||||
* Permission Nodes = meta.node.value
|
||||
*
|
||||
* Node that special characters used within LuckPerms are escaped:
|
||||
* Note that special characters used within LuckPerms are escaped:
|
||||
* See {@link me.lucko.luckperms.api.MetaUtils#unescapeCharacters(String)}
|
||||
*/
|
||||
public class VaultChatHook extends Chat {
|
||||
|
@ -24,13 +24,13 @@ package me.lucko.luckperms.bungee;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import me.lucko.luckperms.ApiHandler;
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.Logger;
|
||||
import me.lucko.luckperms.api.PlatformType;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.api.context.MutableContextSet;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.api.ApiHandler;
|
||||
import me.lucko.luckperms.common.api.ApiProvider;
|
||||
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms.common.api;
|
||||
|
||||
import me.lucko.luckperms.LuckPerms;
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ApiHandler {
|
||||
private static Method REGISTER;
|
||||
private static Method UNREGISTER;
|
||||
static {
|
||||
try {
|
||||
REGISTER = LuckPerms.class.getDeclaredMethod("registerProvider", LuckPermsApi.class);
|
||||
REGISTER.setAccessible(true);
|
||||
|
||||
UNREGISTER = LuckPerms.class.getDeclaredMethod("unregisterProvider");
|
||||
UNREGISTER.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerProvider(LuckPermsApi luckPermsApi) {
|
||||
try {
|
||||
REGISTER.invoke(null, luckPermsApi);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void unregisterProvider() {
|
||||
try {
|
||||
UNREGISTER.invoke(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -36,13 +36,6 @@ import java.util.regex.Pattern;
|
||||
|
||||
@UtilityClass
|
||||
public class Patterns {
|
||||
public static final Pattern COMMAND_SEPARATOR = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
|
||||
public static final Pattern NON_ALPHA_NUMERIC = Pattern.compile("[\\/\\$\\.\\- ]");
|
||||
public static final Pattern NON_ALPHA_NUMERIC_SPACE = Pattern.compile("[\\/\\$\\.\\-]");
|
||||
public static final Pattern NON_USERNAME = Pattern.compile("[^A-Za-z0-9_ ]");
|
||||
public static final Pattern SHORTHAND_NODE = Pattern.compile("\\.\\([^.]+\\)");
|
||||
public static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]");
|
||||
public static final Pattern NODE_CONTEXTS = Pattern.compile("\\(.+\\).*");
|
||||
private static final LoadingCache<String, Pattern> CACHE = CacheBuilder.newBuilder()
|
||||
.build(new CacheLoader<String, Pattern>() {
|
||||
@Override
|
||||
@ -56,6 +49,14 @@ public class Patterns {
|
||||
}
|
||||
});
|
||||
|
||||
public static final Pattern COMMAND_SEPARATOR = Pattern.compile(" (?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
|
||||
public static final Pattern NON_ALPHA_NUMERIC = Pattern.compile("[\\/\\$\\.\\- ]");
|
||||
public static final Pattern NON_ALPHA_NUMERIC_SPACE = Pattern.compile("[\\/\\$\\.\\-]");
|
||||
public static final Pattern NON_USERNAME = Pattern.compile("[^A-Za-z0-9_ ]");
|
||||
public static final Pattern SHORTHAND_NODE = Pattern.compile("\\.\\([^.]+\\)");
|
||||
public static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('§') + "[0-9A-FK-OR]");
|
||||
public static final Pattern NODE_CONTEXTS = Pattern.compile("\\(.+\\).*");
|
||||
|
||||
public static Pattern compile(String regex) {
|
||||
try {
|
||||
return CACHE.get(regex);
|
||||
|
@ -35,125 +35,125 @@ import java.util.List;
|
||||
@Getter
|
||||
public enum Permission {
|
||||
|
||||
SYNC(l("sync"), Type.NONE),
|
||||
INFO(l("info"), Type.NONE),
|
||||
VERBOSE(l("verbose"), Type.NONE),
|
||||
IMPORT(l("import"), Type.NONE),
|
||||
SYNC(list("sync"), Type.NONE),
|
||||
INFO(list("info"), Type.NONE),
|
||||
VERBOSE(list("verbose"), Type.NONE),
|
||||
IMPORT(list("import"), Type.NONE),
|
||||
|
||||
CREATE_GROUP(l("creategroup"), Type.NONE),
|
||||
DELETE_GROUP(l("deletegroup"), Type.NONE),
|
||||
LIST_GROUPS(l("listgroups"), Type.NONE),
|
||||
CREATE_GROUP(list("creategroup"), Type.NONE),
|
||||
DELETE_GROUP(list("deletegroup"), Type.NONE),
|
||||
LIST_GROUPS(list("listgroups"), Type.NONE),
|
||||
|
||||
CREATE_TRACK(l("createtrack"), Type.NONE),
|
||||
DELETE_TRACK(l("deletetrack"), Type.NONE),
|
||||
LIST_TRACKS(l("listtracks"), Type.NONE),
|
||||
CREATE_TRACK(list("createtrack"), Type.NONE),
|
||||
DELETE_TRACK(list("deletetrack"), Type.NONE),
|
||||
LIST_TRACKS(list("listtracks"), Type.NONE),
|
||||
|
||||
USER_INFO(l("info"), Type.USER),
|
||||
USER_PERM_INFO(l("permission.info", "listnodes"), Type.USER),
|
||||
USER_PERM_SET(l("permission.set", "setpermission"), Type.USER),
|
||||
USER_PERM_UNSET(l("permission.unset", "unsetpermission"), Type.USER),
|
||||
USER_PERM_SETTEMP(l("permission.settemp", "settemppermission"), Type.USER),
|
||||
USER_PERM_UNSETTEMP(l("permission.unsettemp", "unsettemppermission"), Type.USER),
|
||||
USER_PERM_CHECK(l("permission.check", "haspermission"), Type.USER),
|
||||
USER_PERM_CHECK_INHERITS(l("permission.checkinherits", "inheritspermission"), Type.USER),
|
||||
USER_PARENT_INFO(l("parent.info", "listgroups"), Type.USER),
|
||||
USER_PARENT_SET(l("parent.set"), Type.USER),
|
||||
USER_PARENT_ADD(l("parent.add", "addgroup"), Type.USER),
|
||||
USER_PARENT_REMOVE(l("parent.remove", "removegroup"), Type.USER),
|
||||
USER_PARENT_ADDTEMP(l("parent.addtemp", "addtempgroup"), Type.USER),
|
||||
USER_PARENT_REMOVETEMP(l("parent.removetemp", "removetempgroup"), Type.USER),
|
||||
USER_PARENT_CLEAR(l("parent.clear"), Type.USER),
|
||||
USER_META_INFO(l("meta.info", "chatmeta"), Type.USER),
|
||||
USER_META_SET(l("meta.set", "setmeta"), Type.USER),
|
||||
USER_META_UNSET(l("meta.unset", "unsetmeta"), Type.USER),
|
||||
USER_META_SETTEMP(l("meta.settemp", "settempmeta"), Type.USER),
|
||||
USER_META_UNSETTEMP(l("meta.unsettemp", "unsettempmeta"), Type.USER),
|
||||
USER_META_ADDPREFIX(l("meta.addprefix", "addprefix"), Type.USER),
|
||||
USER_META_ADDSUFFIX(l("meta.addsuffix", "addsuffix"), Type.USER),
|
||||
USER_META_REMOVEPREFIX(l("meta.removeprefix", "removeprefix"), Type.USER),
|
||||
USER_META_REMOVESUFFIX(l("meta.removesuffix", "removesuffix"), Type.USER),
|
||||
USER_META_ADDTEMP_PREFIX(l("meta.addtempprefix", "addtempprefix"), Type.USER),
|
||||
USER_META_ADDTEMP_SUFFIX(l("meta.addtempsuffix", "addtempsuffix"), Type.USER),
|
||||
USER_META_REMOVETEMP_PREFIX(l("meta.removetempprefix", "removetempprefix"), Type.USER),
|
||||
USER_META_REMOVETEMP_SUFFIX(l("meta.removetempsuffix", "removetempsuffix"), Type.USER),
|
||||
USER_META_CLEAR(l("meta.clear", "clearmeta"), Type.USER),
|
||||
USER_GETUUID(l("getuuid"), Type.USER),
|
||||
USER_SWITCHPRIMARYGROUP(l("switchprimarygroup", "setprimarygroup"), Type.USER),
|
||||
USER_SHOWTRACKS(l("showtracks"), Type.USER),
|
||||
USER_PROMOTE(l("promote"), Type.USER),
|
||||
USER_DEMOTE(l("demote"), Type.USER),
|
||||
USER_BULKCHANGE(l("bulkchange"), Type.USER),
|
||||
USER_CLEAR(l("clear"), Type.USER),
|
||||
USER_INFO(list("info"), Type.USER),
|
||||
USER_PERM_INFO(list("permission.info", "listnodes"), Type.USER),
|
||||
USER_PERM_SET(list("permission.set", "setpermission"), Type.USER),
|
||||
USER_PERM_UNSET(list("permission.unset", "unsetpermission"), Type.USER),
|
||||
USER_PERM_SETTEMP(list("permission.settemp", "settemppermission"), Type.USER),
|
||||
USER_PERM_UNSETTEMP(list("permission.unsettemp", "unsettemppermission"), Type.USER),
|
||||
USER_PERM_CHECK(list("permission.check", "haspermission"), Type.USER),
|
||||
USER_PERM_CHECK_INHERITS(list("permission.checkinherits", "inheritspermission"), Type.USER),
|
||||
USER_PARENT_INFO(list("parent.info", "listgroups"), Type.USER),
|
||||
USER_PARENT_SET(list("parent.set"), Type.USER),
|
||||
USER_PARENT_ADD(list("parent.add", "addgroup"), Type.USER),
|
||||
USER_PARENT_REMOVE(list("parent.remove", "removegroup"), Type.USER),
|
||||
USER_PARENT_ADDTEMP(list("parent.addtemp", "addtempgroup"), Type.USER),
|
||||
USER_PARENT_REMOVETEMP(list("parent.removetemp", "removetempgroup"), Type.USER),
|
||||
USER_PARENT_CLEAR(list("parent.clear"), Type.USER),
|
||||
USER_META_INFO(list("meta.info", "chatmeta"), Type.USER),
|
||||
USER_META_SET(list("meta.set", "setmeta"), Type.USER),
|
||||
USER_META_UNSET(list("meta.unset", "unsetmeta"), Type.USER),
|
||||
USER_META_SETTEMP(list("meta.settemp", "settempmeta"), Type.USER),
|
||||
USER_META_UNSETTEMP(list("meta.unsettemp", "unsettempmeta"), Type.USER),
|
||||
USER_META_ADDPREFIX(list("meta.addprefix", "addprefix"), Type.USER),
|
||||
USER_META_ADDSUFFIX(list("meta.addsuffix", "addsuffix"), Type.USER),
|
||||
USER_META_REMOVEPREFIX(list("meta.removeprefix", "removeprefix"), Type.USER),
|
||||
USER_META_REMOVESUFFIX(list("meta.removesuffix", "removesuffix"), Type.USER),
|
||||
USER_META_ADDTEMP_PREFIX(list("meta.addtempprefix", "addtempprefix"), Type.USER),
|
||||
USER_META_ADDTEMP_SUFFIX(list("meta.addtempsuffix", "addtempsuffix"), Type.USER),
|
||||
USER_META_REMOVETEMP_PREFIX(list("meta.removetempprefix", "removetempprefix"), Type.USER),
|
||||
USER_META_REMOVETEMP_SUFFIX(list("meta.removetempsuffix", "removetempsuffix"), Type.USER),
|
||||
USER_META_CLEAR(list("meta.clear", "clearmeta"), Type.USER),
|
||||
USER_GETUUID(list("getuuid"), Type.USER),
|
||||
USER_SWITCHPRIMARYGROUP(list("switchprimarygroup", "setprimarygroup"), Type.USER),
|
||||
USER_SHOWTRACKS(list("showtracks"), Type.USER),
|
||||
USER_PROMOTE(list("promote"), Type.USER),
|
||||
USER_DEMOTE(list("demote"), Type.USER),
|
||||
USER_BULKCHANGE(list("bulkchange"), Type.USER),
|
||||
USER_CLEAR(list("clear"), Type.USER),
|
||||
|
||||
GROUP_INFO(l("info"), Type.GROUP),
|
||||
GROUP_PERM_INFO(l("permission.info", "listnodes"), Type.GROUP),
|
||||
GROUP_PERM_SET(l("permission.set", "setpermission"), Type.GROUP),
|
||||
GROUP_PERM_UNSET(l("permission.unset", "unsetpermission"), Type.GROUP),
|
||||
GROUP_PERM_SETTEMP(l("permission.settemp", "settemppermission"), Type.GROUP),
|
||||
GROUP_PERM_UNSETTEMP(l("permission.unsettemp", "unsettemppermission"), Type.GROUP),
|
||||
GROUP_PERM_CHECK(l("permission.check", "haspermission"), Type.GROUP),
|
||||
GROUP_PERM_CHECK_INHERITS(l("permission.checkinherits", "inheritspermission"), Type.GROUP),
|
||||
GROUP_PARENT_INFO(l("parent.info", "listparents"), Type.GROUP),
|
||||
GROUP_PARENT_SET(l("parent.set"), Type.GROUP),
|
||||
GROUP_PARENT_ADD(l("parent.add", "setinherit"), Type.GROUP),
|
||||
GROUP_PARENT_REMOVE(l("parent.remove", "unsetinherit"), Type.GROUP),
|
||||
GROUP_PARENT_ADDTEMP(l("parent.addtemp", "settempinherit"), Type.GROUP),
|
||||
GROUP_PARENT_REMOVETEMP(l("parent.removetemp", "unsettempinherit"), Type.GROUP),
|
||||
GROUP_PARENT_CLEAR(l("parent.clear"), Type.GROUP),
|
||||
GROUP_META_INFO(l("meta.info", "chatmeta"), Type.GROUP),
|
||||
GROUP_META_SET(l("meta.set", "setmeta"), Type.GROUP),
|
||||
GROUP_META_UNSET(l("meta.unset", "unsetmeta"), Type.GROUP),
|
||||
GROUP_META_SETTEMP(l("meta.settemp", "settempmeta"), Type.GROUP),
|
||||
GROUP_META_UNSETTEMP(l("meta.unsettemp", "unsettempmeta"), Type.GROUP),
|
||||
GROUP_META_ADDPREFIX(l("meta.addprefix", "addprefix"), Type.GROUP),
|
||||
GROUP_META_ADDSUFFIX(l("meta.addsuffix", "addsuffix"), Type.GROUP),
|
||||
GROUP_META_REMOVEPREFIX(l("meta.removeprefix", "removeprefix"), Type.GROUP),
|
||||
GROUP_META_REMOVESUFFIX(l("meta.removesuffix", "removesuffix"), Type.GROUP),
|
||||
GROUP_META_ADDTEMP_PREFIX(l("meta.addtempprefix", "addtempprefix"), Type.GROUP),
|
||||
GROUP_META_ADDTEMP_SUFFIX(l("meta.addtempsuffix", "addtempsuffix"), Type.GROUP),
|
||||
GROUP_META_REMOVETEMP_PREFIX(l("meta.removetempprefix", "removetempprefix"), Type.GROUP),
|
||||
GROUP_META_REMOVETEMP_SUFFIX(l("meta.removetempsuffix", "removetempsuffix"), Type.GROUP),
|
||||
GROUP_META_CLEAR(l("meta.clear", "clearmeta"), Type.GROUP),
|
||||
GROUP_SHOWTRACKS(l("showtracks"), Type.GROUP),
|
||||
GROUP_SETWEIGHT(l("setweight"), Type.GROUP),
|
||||
GROUP_BULKCHANGE(l("bulkchange"), Type.GROUP),
|
||||
GROUP_CLEAR(l("clear"), Type.GROUP),
|
||||
GROUP_RENAME(l("rename"), Type.GROUP),
|
||||
GROUP_CLONE(l("clone"), Type.GROUP),
|
||||
GROUP_INFO(list("info"), Type.GROUP),
|
||||
GROUP_PERM_INFO(list("permission.info", "listnodes"), Type.GROUP),
|
||||
GROUP_PERM_SET(list("permission.set", "setpermission"), Type.GROUP),
|
||||
GROUP_PERM_UNSET(list("permission.unset", "unsetpermission"), Type.GROUP),
|
||||
GROUP_PERM_SETTEMP(list("permission.settemp", "settemppermission"), Type.GROUP),
|
||||
GROUP_PERM_UNSETTEMP(list("permission.unsettemp", "unsettemppermission"), Type.GROUP),
|
||||
GROUP_PERM_CHECK(list("permission.check", "haspermission"), Type.GROUP),
|
||||
GROUP_PERM_CHECK_INHERITS(list("permission.checkinherits", "inheritspermission"), Type.GROUP),
|
||||
GROUP_PARENT_INFO(list("parent.info", "listparents"), Type.GROUP),
|
||||
GROUP_PARENT_SET(list("parent.set"), Type.GROUP),
|
||||
GROUP_PARENT_ADD(list("parent.add", "setinherit"), Type.GROUP),
|
||||
GROUP_PARENT_REMOVE(list("parent.remove", "unsetinherit"), Type.GROUP),
|
||||
GROUP_PARENT_ADDTEMP(list("parent.addtemp", "settempinherit"), Type.GROUP),
|
||||
GROUP_PARENT_REMOVETEMP(list("parent.removetemp", "unsettempinherit"), Type.GROUP),
|
||||
GROUP_PARENT_CLEAR(list("parent.clear"), Type.GROUP),
|
||||
GROUP_META_INFO(list("meta.info", "chatmeta"), Type.GROUP),
|
||||
GROUP_META_SET(list("meta.set", "setmeta"), Type.GROUP),
|
||||
GROUP_META_UNSET(list("meta.unset", "unsetmeta"), Type.GROUP),
|
||||
GROUP_META_SETTEMP(list("meta.settemp", "settempmeta"), Type.GROUP),
|
||||
GROUP_META_UNSETTEMP(list("meta.unsettemp", "unsettempmeta"), Type.GROUP),
|
||||
GROUP_META_ADDPREFIX(list("meta.addprefix", "addprefix"), Type.GROUP),
|
||||
GROUP_META_ADDSUFFIX(list("meta.addsuffix", "addsuffix"), Type.GROUP),
|
||||
GROUP_META_REMOVEPREFIX(list("meta.removeprefix", "removeprefix"), Type.GROUP),
|
||||
GROUP_META_REMOVESUFFIX(list("meta.removesuffix", "removesuffix"), Type.GROUP),
|
||||
GROUP_META_ADDTEMP_PREFIX(list("meta.addtempprefix", "addtempprefix"), Type.GROUP),
|
||||
GROUP_META_ADDTEMP_SUFFIX(list("meta.addtempsuffix", "addtempsuffix"), Type.GROUP),
|
||||
GROUP_META_REMOVETEMP_PREFIX(list("meta.removetempprefix", "removetempprefix"), Type.GROUP),
|
||||
GROUP_META_REMOVETEMP_SUFFIX(list("meta.removetempsuffix", "removetempsuffix"), Type.GROUP),
|
||||
GROUP_META_CLEAR(list("meta.clear", "clearmeta"), Type.GROUP),
|
||||
GROUP_SHOWTRACKS(list("showtracks"), Type.GROUP),
|
||||
GROUP_SETWEIGHT(list("setweight"), Type.GROUP),
|
||||
GROUP_BULKCHANGE(list("bulkchange"), Type.GROUP),
|
||||
GROUP_CLEAR(list("clear"), Type.GROUP),
|
||||
GROUP_RENAME(list("rename"), Type.GROUP),
|
||||
GROUP_CLONE(list("clone"), Type.GROUP),
|
||||
|
||||
TRACK_INFO(l("info"), Type.TRACK),
|
||||
TRACK_APPEND(l("append"), Type.TRACK),
|
||||
TRACK_INSERT(l("insert"), Type.TRACK),
|
||||
TRACK_REMOVE(l("remove"), Type.TRACK),
|
||||
TRACK_CLEAR(l("clear"), Type.TRACK),
|
||||
TRACK_RENAME(l("rename"), Type.TRACK),
|
||||
TRACK_CLONE(l("clone"), Type.TRACK),
|
||||
TRACK_INFO(list("info"), Type.TRACK),
|
||||
TRACK_APPEND(list("append"), Type.TRACK),
|
||||
TRACK_INSERT(list("insert"), Type.TRACK),
|
||||
TRACK_REMOVE(list("remove"), Type.TRACK),
|
||||
TRACK_CLEAR(list("clear"), Type.TRACK),
|
||||
TRACK_RENAME(list("rename"), Type.TRACK),
|
||||
TRACK_CLONE(list("clone"), Type.TRACK),
|
||||
|
||||
LOG_RECENT(l("recent"), Type.LOG),
|
||||
LOG_USER_HISTORY(l("userhistory"), Type.LOG),
|
||||
LOG_GROUP_HISTORY(l("grouphistory"), Type.LOG),
|
||||
LOG_TRACK_HISTORY(l("trackhistory"), Type.LOG),
|
||||
LOG_SEARCH(l("search"), Type.LOG),
|
||||
LOG_NOTIFY(l("notify"), Type.LOG),
|
||||
LOG_EXPORT(l("export"), Type.LOG),
|
||||
LOG_RECENT(list("recent"), Type.LOG),
|
||||
LOG_USER_HISTORY(list("userhistory"), Type.LOG),
|
||||
LOG_GROUP_HISTORY(list("grouphistory"), Type.LOG),
|
||||
LOG_TRACK_HISTORY(list("trackhistory"), Type.LOG),
|
||||
LOG_SEARCH(list("search"), Type.LOG),
|
||||
LOG_NOTIFY(list("notify"), Type.LOG),
|
||||
LOG_EXPORT(list("export"), Type.LOG),
|
||||
|
||||
SPONGE_PERMISSION_INFO(l("permission.info"), Type.SPONGE),
|
||||
SPONGE_PERMISSION_SET(l("permission.set"), Type.SPONGE),
|
||||
SPONGE_PERMISSION_CLEAR(l("permission.clear"), Type.SPONGE),
|
||||
SPONGE_PARENT_INFO(l("parent.info"), Type.SPONGE),
|
||||
SPONGE_PARENT_ADD(l("parent.add"), Type.SPONGE),
|
||||
SPONGE_PARENT_REMOVE(l("parent.remove"), Type.SPONGE),
|
||||
SPONGE_PARENT_CLEAR(l("parent.clear"), Type.SPONGE),
|
||||
SPONGE_OPTION_INFO(l("option.info"), Type.SPONGE),
|
||||
SPONGE_OPTION_SET(l("option.set"), Type.SPONGE),
|
||||
SPONGE_OPTION_UNSET(l("option.unset"), Type.SPONGE),
|
||||
SPONGE_OPTION_CLEAR(l("option.clear"), Type.SPONGE),
|
||||
SPONGE_PERMISSION_INFO(list("permission.info"), Type.SPONGE),
|
||||
SPONGE_PERMISSION_SET(list("permission.set"), Type.SPONGE),
|
||||
SPONGE_PERMISSION_CLEAR(list("permission.clear"), Type.SPONGE),
|
||||
SPONGE_PARENT_INFO(list("parent.info"), Type.SPONGE),
|
||||
SPONGE_PARENT_ADD(list("parent.add"), Type.SPONGE),
|
||||
SPONGE_PARENT_REMOVE(list("parent.remove"), Type.SPONGE),
|
||||
SPONGE_PARENT_CLEAR(list("parent.clear"), Type.SPONGE),
|
||||
SPONGE_OPTION_INFO(list("option.info"), Type.SPONGE),
|
||||
SPONGE_OPTION_SET(list("option.set"), Type.SPONGE),
|
||||
SPONGE_OPTION_UNSET(list("option.unset"), Type.SPONGE),
|
||||
SPONGE_OPTION_CLEAR(list("option.clear"), Type.SPONGE),
|
||||
|
||||
MIGRATION(l("migration"), Type.NONE);
|
||||
MIGRATION(list("migration"), Type.NONE);
|
||||
|
||||
private static final String IDENTIFIER = "luckperms.";
|
||||
|
||||
private static List<String> l(String... args) {
|
||||
private static List<String> list(String... args) {
|
||||
return Arrays.asList(args);
|
||||
}
|
||||
|
||||
|
@ -161,13 +161,9 @@ public class AbstractStorage implements Storage {
|
||||
|
||||
private interface Delegated {
|
||||
String getName();
|
||||
|
||||
boolean isAcceptingLogins();
|
||||
|
||||
void setAcceptingLogins(boolean b);
|
||||
|
||||
void init();
|
||||
|
||||
void shutdown();
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
package me.lucko.luckperms.common.storage.backing;
|
||||
|
||||
import lombok.Cleanup;
|
||||
|
||||
import me.lucko.luckperms.api.LogEntry;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.constants.Constants;
|
||||
@ -143,15 +141,15 @@ abstract class FlatfileBacking extends AbstractBacking {
|
||||
Map<String, String> cache = new HashMap<>();
|
||||
|
||||
try {
|
||||
@Cleanup FileReader fileReader = new FileReader(uuidData);
|
||||
@Cleanup BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||
|
||||
Properties props = new Properties();
|
||||
props.load(bufferedReader);
|
||||
for (String key : props.stringPropertyNames()) {
|
||||
cache.put(key, props.getProperty(key));
|
||||
try (FileReader fileReader = new FileReader(uuidData)) {
|
||||
try (BufferedReader bufferedReader = new BufferedReader(fileReader)) {
|
||||
Properties props = new Properties();
|
||||
props.load(bufferedReader);
|
||||
for (String key : props.stringPropertyNames()) {
|
||||
cache.put(key, props.getProperty(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -160,12 +158,13 @@ abstract class FlatfileBacking extends AbstractBacking {
|
||||
|
||||
private void saveUUIDCache(Map<String, String> cache) {
|
||||
try {
|
||||
@Cleanup FileWriter fileWriter = new FileWriter(uuidData);
|
||||
@Cleanup BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
||||
|
||||
Properties properties = new Properties();
|
||||
properties.putAll(cache);
|
||||
properties.store(bufferedWriter, null);
|
||||
try (FileWriter fileWriter = new FileWriter(uuidData)) {
|
||||
try (BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)) {
|
||||
Properties properties = new Properties();
|
||||
properties.putAll(cache);
|
||||
properties.store(bufferedWriter, null);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
package me.lucko.luckperms.common.storage.backing;
|
||||
|
||||
import lombok.Cleanup;
|
||||
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
@ -35,6 +33,7 @@ import me.lucko.luckperms.common.core.model.User;
|
||||
import me.lucko.luckperms.common.managers.GroupManager;
|
||||
import me.lucko.luckperms.common.managers.TrackManager;
|
||||
import me.lucko.luckperms.common.managers.impl.GenericUserManager;
|
||||
import me.lucko.luckperms.common.utils.ThrowingFunction;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
@ -69,29 +68,35 @@ public class JSONBacking extends FlatfileBacking {
|
||||
super(plugin, "JSON", pluginDir);
|
||||
}
|
||||
|
||||
private boolean doWrite(File file, WriteOperation writeOperation) {
|
||||
private boolean fileToWriter(File file, ThrowingFunction<JsonWriter, Boolean> writeOperation) {
|
||||
boolean success = false;
|
||||
try {
|
||||
@Cleanup FileWriter fileWriter = new FileWriter(file);
|
||||
@Cleanup BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
||||
@Cleanup JsonWriter jsonWriter = new JsonWriter(bufferedWriter);
|
||||
jsonWriter.setIndent(" ");
|
||||
success = writeOperation.onRun(jsonWriter);
|
||||
jsonWriter.flush();
|
||||
} catch (IOException e) {
|
||||
try (FileWriter fileWriter = new FileWriter(file)) {
|
||||
try (BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)) {
|
||||
try (JsonWriter jsonWriter = new JsonWriter(bufferedWriter)) {
|
||||
jsonWriter.setIndent(" ");
|
||||
success = writeOperation.apply(jsonWriter);
|
||||
jsonWriter.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
private boolean doRead(File file, ReadOperation readOperation) {
|
||||
private boolean fileToReader(File file, ThrowingFunction<JsonReader, Boolean> readOperation) {
|
||||
boolean success = false;
|
||||
try {
|
||||
@Cleanup FileReader fileReader = new FileReader(file);
|
||||
@Cleanup BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||
@Cleanup JsonReader jsonReader = new JsonReader(bufferedReader);
|
||||
success = readOperation.onRun(jsonReader);
|
||||
} catch (IOException e) {
|
||||
try (FileReader fileReader = new FileReader(file)) {
|
||||
try (BufferedReader bufferedReader = new BufferedReader(fileReader)) {
|
||||
try (JsonReader jsonReader = new JsonReader(bufferedReader)) {
|
||||
success = readOperation.apply(jsonReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return success;
|
||||
@ -105,12 +110,12 @@ public class JSONBacking extends FlatfileBacking {
|
||||
return call(() -> {
|
||||
File userFile = new File(usersDir, uuid.toString() + ".json");
|
||||
if (userFile.exists()) {
|
||||
return doRead(userFile, reader -> {
|
||||
return fileToReader(userFile, reader -> {
|
||||
reader.beginObject();
|
||||
reader.nextName(); // uuid record
|
||||
reader.nextString(); // uuid
|
||||
reader.nextName(); // name record
|
||||
String name1 = reader.nextString(); // name
|
||||
String name = reader.nextString(); // name
|
||||
reader.nextName(); // primaryGroup record
|
||||
user.setPrimaryGroup(reader.nextString()); // primaryGroup
|
||||
reader.nextName(); // perms
|
||||
@ -128,15 +133,15 @@ public class JSONBacking extends FlatfileBacking {
|
||||
boolean save = plugin.getUserManager().giveDefaultIfNeeded(user, false);
|
||||
|
||||
if (user.getName() == null || user.getName().equalsIgnoreCase("null")) {
|
||||
user.setName(name1);
|
||||
user.setName(name);
|
||||
} else {
|
||||
if (!name1.equalsIgnoreCase(user.getName())) {
|
||||
if (!name.equalsIgnoreCase(user.getName())) {
|
||||
save = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (save) {
|
||||
doWrite(userFile, writer -> {
|
||||
fileToWriter(userFile, writer -> {
|
||||
writer.beginObject();
|
||||
writer.name("uuid").value(user.getUuid().toString());
|
||||
writer.name("name").value(user.getName());
|
||||
@ -190,7 +195,7 @@ public class JSONBacking extends FlatfileBacking {
|
||||
}
|
||||
}
|
||||
|
||||
return doWrite(userFile, writer -> {
|
||||
return fileToWriter(userFile, writer -> {
|
||||
writer.beginObject();
|
||||
writer.name("uuid").value(user.getUuid().toString());
|
||||
writer.name("name").value(user.getName());
|
||||
@ -218,7 +223,7 @@ public class JSONBacking extends FlatfileBacking {
|
||||
|
||||
for (File file : files) {
|
||||
Map<String, Boolean> nodes = new HashMap<>();
|
||||
doRead(file, reader -> {
|
||||
fileToReader(file, reader -> {
|
||||
reader.beginObject();
|
||||
reader.nextName(); // uuid record
|
||||
reader.nextString(); // uuid
|
||||
@ -273,7 +278,7 @@ public class JSONBacking extends FlatfileBacking {
|
||||
return call(() -> {
|
||||
File groupFile = new File(groupsDir, name + ".json");
|
||||
if (groupFile.exists()) {
|
||||
return doRead(groupFile, reader -> {
|
||||
return fileToReader(groupFile, reader -> {
|
||||
reader.beginObject();
|
||||
reader.nextName(); // name record
|
||||
reader.nextString(); // name
|
||||
@ -299,7 +304,7 @@ public class JSONBacking extends FlatfileBacking {
|
||||
return false;
|
||||
}
|
||||
|
||||
return doWrite(groupFile, writer -> {
|
||||
return fileToWriter(groupFile, writer -> {
|
||||
writer.beginObject();
|
||||
writer.name("name").value(group.getName());
|
||||
writer.name("perms");
|
||||
@ -325,7 +330,7 @@ public class JSONBacking extends FlatfileBacking {
|
||||
try {
|
||||
return call(() -> {
|
||||
File groupFile = new File(groupsDir, name + ".json");
|
||||
return groupFile.exists() && doRead(groupFile, reader -> {
|
||||
return groupFile.exists() && fileToReader(groupFile, reader -> {
|
||||
reader.beginObject();
|
||||
reader.nextName(); // name record
|
||||
reader.nextString(); // name
|
||||
@ -380,7 +385,7 @@ public class JSONBacking extends FlatfileBacking {
|
||||
}
|
||||
}
|
||||
|
||||
return doWrite(groupFile, writer -> {
|
||||
return fileToWriter(groupFile, writer -> {
|
||||
writer.beginObject();
|
||||
writer.name("name").value(group.getName());
|
||||
writer.name("perms");
|
||||
@ -422,7 +427,7 @@ public class JSONBacking extends FlatfileBacking {
|
||||
return call(() -> {
|
||||
File trackFile = new File(tracksDir, name + ".json");
|
||||
if (trackFile.exists()) {
|
||||
return doRead(trackFile, reader -> {
|
||||
return fileToReader(trackFile, reader -> {
|
||||
reader.beginObject();
|
||||
reader.nextName(); // name record
|
||||
reader.nextString(); // name
|
||||
@ -445,7 +450,7 @@ public class JSONBacking extends FlatfileBacking {
|
||||
return false;
|
||||
}
|
||||
|
||||
return doWrite(trackFile, writer -> {
|
||||
return fileToWriter(trackFile, writer -> {
|
||||
writer.beginObject();
|
||||
writer.name("name").value(track.getName());
|
||||
writer.name("groups");
|
||||
@ -471,7 +476,7 @@ public class JSONBacking extends FlatfileBacking {
|
||||
try {
|
||||
return call(() -> {
|
||||
File trackFile = new File(tracksDir, name + ".json");
|
||||
return trackFile.exists() && doRead(trackFile, reader -> {
|
||||
return trackFile.exists() && fileToReader(trackFile, reader -> {
|
||||
reader.beginObject();
|
||||
reader.nextName(); // name record
|
||||
reader.nextString(); // name
|
||||
@ -525,7 +530,7 @@ public class JSONBacking extends FlatfileBacking {
|
||||
}
|
||||
}
|
||||
|
||||
return doWrite(trackFile, writer -> {
|
||||
return fileToWriter(trackFile, writer -> {
|
||||
writer.beginObject();
|
||||
writer.name("name").value(track.getName());
|
||||
writer.name("groups");
|
||||
@ -558,12 +563,4 @@ public class JSONBacking extends FlatfileBacking {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
interface WriteOperation {
|
||||
boolean onRun(JsonWriter writer) throws IOException;
|
||||
}
|
||||
|
||||
interface ReadOperation {
|
||||
boolean onRun(JsonReader reader) throws IOException;
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
package me.lucko.luckperms.common.storage.backing;
|
||||
|
||||
import lombok.Cleanup;
|
||||
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.core.UserIdentifier;
|
||||
import me.lucko.luckperms.common.core.model.Group;
|
||||
@ -49,6 +47,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static me.lucko.luckperms.common.core.model.PermissionHolder.exportToLegacy;
|
||||
@ -74,25 +73,29 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
super(plugin, "YAML", pluginDir);
|
||||
}
|
||||
|
||||
private boolean doRead(File file, ReadOperation readOperation) {
|
||||
private boolean readMapFromFile(File file, Function<Map<String, Object>, Boolean> readOperation) {
|
||||
boolean success = false;
|
||||
try {
|
||||
@Cleanup FileReader fileReader = new FileReader(file);
|
||||
@Cleanup BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||
success = readOperation.onRun((Map<String, Object>) getYaml().load(bufferedReader));
|
||||
try (FileReader fileReader = new FileReader(file)) {
|
||||
try (BufferedReader bufferedReader = new BufferedReader(fileReader)) {
|
||||
success = readOperation.apply((Map<String, Object>) getYaml().load(bufferedReader));
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
private boolean doWrite(File file, Map<String, Object> values) {
|
||||
private boolean writeMapToFile(File file, Map<String, Object> values) {
|
||||
try {
|
||||
@Cleanup FileWriter fileWriter = new FileWriter(file);
|
||||
@Cleanup BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
||||
getYaml().dump(values, bufferedWriter);
|
||||
bufferedWriter.flush();
|
||||
return true;
|
||||
try (FileWriter fileWriter = new FileWriter(file)) {
|
||||
try (BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)) {
|
||||
getYaml().dump(values, bufferedWriter);
|
||||
bufferedWriter.flush();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
@ -107,7 +110,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
return call(() -> {
|
||||
File userFile = new File(usersDir, uuid.toString() + ".yml");
|
||||
if (userFile.exists()) {
|
||||
return doRead(userFile, values -> {
|
||||
return readMapFromFile(userFile, values -> {
|
||||
// User exists, let's load.
|
||||
String name = (String) values.get("name");
|
||||
user.setPrimaryGroup((String) values.get("primary-group"));
|
||||
@ -130,7 +133,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
data.put("name", user.getName());
|
||||
data.put("primary-group", user.getPrimaryGroup());
|
||||
data.put("perms", exportToLegacy(user.getNodes()));
|
||||
doWrite(userFile, data);
|
||||
writeMapToFile(userFile, data);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@ -176,7 +179,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
values.put("name", user.getName());
|
||||
values.put("primary-group", user.getPrimaryGroup());
|
||||
values.put("perms", exportToLegacy(user.getNodes()));
|
||||
return doWrite(userFile, values);
|
||||
return writeMapToFile(userFile, values);
|
||||
}, false);
|
||||
} finally {
|
||||
user.getIoLock().unlock();
|
||||
@ -191,7 +194,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
|
||||
for (File file : files) {
|
||||
Map<String, Boolean> nodes = new HashMap<>();
|
||||
doRead(file, values -> {
|
||||
readMapFromFile(file, values -> {
|
||||
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
|
||||
nodes.putAll(perms);
|
||||
return true;
|
||||
@ -231,7 +234,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
return call(() -> {
|
||||
File groupFile = new File(groupsDir, name + ".yml");
|
||||
if (groupFile.exists()) {
|
||||
return doRead(groupFile, values -> {
|
||||
return readMapFromFile(groupFile, values -> {
|
||||
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
|
||||
group.setNodes(perms);
|
||||
return true;
|
||||
@ -247,7 +250,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
Map<String, Object> values = new HashMap<>();
|
||||
values.put("name", group.getName());
|
||||
values.put("perms", exportToLegacy(group.getNodes()));
|
||||
return doWrite(groupFile, values);
|
||||
return writeMapToFile(groupFile, values);
|
||||
}
|
||||
}, false);
|
||||
} finally {
|
||||
@ -262,7 +265,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
try {
|
||||
return call(() -> {
|
||||
File groupFile = new File(groupsDir, name + ".yml");
|
||||
return groupFile.exists() && doRead(groupFile, values -> {
|
||||
return groupFile.exists() && readMapFromFile(groupFile, values -> {
|
||||
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
|
||||
group.setNodes(perms);
|
||||
return true;
|
||||
@ -309,7 +312,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
Map<String, Object> values = new HashMap<>();
|
||||
values.put("name", group.getName());
|
||||
values.put("perms", exportToLegacy(group.getNodes()));
|
||||
return doWrite(groupFile, values);
|
||||
return writeMapToFile(groupFile, values);
|
||||
}, false);
|
||||
} finally {
|
||||
group.getIoLock().unlock();
|
||||
@ -340,7 +343,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
return call(() -> {
|
||||
File trackFile = new File(tracksDir, name + ".yml");
|
||||
if (trackFile.exists()) {
|
||||
return doRead(trackFile, values -> {
|
||||
return readMapFromFile(trackFile, values -> {
|
||||
track.setGroups((List<String>) values.get("groups"));
|
||||
return true;
|
||||
});
|
||||
@ -356,7 +359,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
values.put("name", track.getName());
|
||||
values.put("groups", track.getGroups());
|
||||
|
||||
return doWrite(trackFile, values);
|
||||
return writeMapToFile(trackFile, values);
|
||||
}
|
||||
}, false);
|
||||
} finally {
|
||||
@ -371,7 +374,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
try {
|
||||
return call(() -> {
|
||||
File trackFile = new File(tracksDir, name + ".yml");
|
||||
return trackFile.exists() && doRead(trackFile, values -> {
|
||||
return trackFile.exists() && readMapFromFile(trackFile, values -> {
|
||||
track.setGroups((List<String>) values.get("groups"));
|
||||
return true;
|
||||
});
|
||||
@ -416,7 +419,7 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
Map<String, Object> values = new HashMap<>();
|
||||
values.put("name", track.getName());
|
||||
values.put("groups", track.getGroups());
|
||||
return doWrite(trackFile, values);
|
||||
return writeMapToFile(trackFile, values);
|
||||
}, false);
|
||||
} finally {
|
||||
track.getIoLock().unlock();
|
||||
@ -438,8 +441,4 @@ public class YAMLBacking extends FlatfileBacking {
|
||||
track.getIoLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
interface ReadOperation {
|
||||
boolean onRun(Map<String, Object> values);
|
||||
}
|
||||
}
|
||||
|
@ -126,15 +126,10 @@ public class BufferedOutputStorage implements Storage, Runnable {
|
||||
|
||||
private interface Exclude {
|
||||
Storage force();
|
||||
|
||||
CompletableFuture<Void> shutdown();
|
||||
|
||||
CompletableFuture<Boolean> saveUser(User user);
|
||||
|
||||
CompletableFuture<Boolean> saveGroup(Group group);
|
||||
|
||||
CompletableFuture<Boolean> saveTrack(Track track);
|
||||
|
||||
CompletableFuture<Boolean> saveUUIDData(String username, UUID uuid);
|
||||
}
|
||||
}
|
||||
|
@ -263,11 +263,8 @@ public class TolerantStorage implements Storage {
|
||||
|
||||
private interface Delegated {
|
||||
String getName();
|
||||
|
||||
boolean isAcceptingLogins();
|
||||
|
||||
void setAcceptingLogins(boolean b);
|
||||
|
||||
void init();
|
||||
}
|
||||
}
|
||||
|
@ -20,18 +20,25 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.lucko.luckperms;
|
||||
package me.lucko.luckperms.common.utils;
|
||||
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ApiHandler {
|
||||
public interface ThrowingFunction<T, R> {
|
||||
|
||||
public static void registerProvider(LuckPermsApi luckPermsApi) {
|
||||
LuckPerms.registerProvider(luckPermsApi);
|
||||
R apply(T t) throws Exception;
|
||||
|
||||
default <V> ThrowingFunction<V, R> compose(ThrowingFunction<? super V, ? extends T> before) {
|
||||
Objects.requireNonNull(before);
|
||||
return (V v) -> apply(before.apply(v));
|
||||
}
|
||||
|
||||
public static void unregisterProvider() {
|
||||
LuckPerms.unregisterProvider();
|
||||
default <V> ThrowingFunction<T, V> andThen(ThrowingFunction<? super R, ? extends V> after) {
|
||||
Objects.requireNonNull(after);
|
||||
return (T t) -> after.apply(apply(t));
|
||||
}
|
||||
|
||||
static <T> ThrowingFunction<T, T> identity() {
|
||||
return t -> t;
|
||||
}
|
||||
}
|
@ -26,11 +26,11 @@ import lombok.Getter;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import me.lucko.luckperms.ApiHandler;
|
||||
import me.lucko.luckperms.api.Contexts;
|
||||
import me.lucko.luckperms.api.LuckPermsApi;
|
||||
import me.lucko.luckperms.api.PlatformType;
|
||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.api.ApiHandler;
|
||||
import me.lucko.luckperms.common.api.ApiProvider;
|
||||
import me.lucko.luckperms.common.caching.handlers.CachedStateManager;
|
||||
import me.lucko.luckperms.common.calculators.CalculatorFactory;
|
||||
|
Loading…
Reference in New Issue
Block a user