Cleanup various message localisations, limit the size of the PermissionRegistry
This commit is contained in:
@@ -166,7 +166,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
||||
// before registering our permission service, copy any existing permission descriptions
|
||||
PermissionRegistry permissionRegistry = getPermissionRegistry();
|
||||
this.bootstrap.getGame().getServiceManager().provide(PermissionService.class)
|
||||
.ifPresent(ps -> ps.getDescriptions().stream().map(PermissionDescription::getId).forEach(permissionRegistry::offer));
|
||||
.ifPresent(ps -> ps.getDescriptions().stream().map(PermissionDescription::getId).forEach(permissionRegistry::insert));
|
||||
|
||||
if (this.bootstrap.getGame().getPluginManager().getPlugin("permissionsex").isPresent()) {
|
||||
getLogger().warn("Detected PermissionsEx - assuming it's loaded for migration.");
|
||||
@@ -268,7 +268,7 @@ public class LPSpongePlugin extends AbstractLuckPermsPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Command> getExtraCommands() {
|
||||
public List<Command<?, ?>> getExtraCommands() {
|
||||
return Collections.singletonList(new SpongeMainCommand(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class SpongeConfigAdapter extends AbstractConfigurationAdapter implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getObjectList(String path, List<String> def) {
|
||||
public List<String> getKeys(String path, List<String> def) {
|
||||
ConfigurationNode node = resolvePath(path);
|
||||
if (node.isVirtual()) {
|
||||
return def;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class OptionClear extends SubCommand<LPSubjectData> {
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared options matching contexts &bANY&a.");
|
||||
} else {
|
||||
subjectData.clearOptions(contextSet);
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared options matching contexts &b" + SpongeCommandUtils.contextToString(contextSet));
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared options matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class OptionInfo extends SubCommand<LPSubjectData> {
|
||||
}
|
||||
|
||||
for (Map.Entry<ImmutableContextSet, ImmutableMap<String, String>> e : options.entrySet()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.optionsToString(e.getValue()));
|
||||
MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.optionsToString(e.getValue()));
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -71,7 +71,7 @@ public class OptionInfo extends SubCommand<LPSubjectData> {
|
||||
}
|
||||
|
||||
MessageUtils.sendPluginMessage(sender, "&aShowing options matching contexts &b" +
|
||||
SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.optionsToString(options));
|
||||
SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.optionsToString(options));
|
||||
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class OptionSet extends SubCommand<LPSubjectData> {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args);
|
||||
|
||||
if (subjectData.setOption(contextSet, key, value).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet));
|
||||
MessageUtils.sendPluginMessage(sender, "&aSet &f\"" + key + "&f\"&a to &f\"" + value + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
} else {
|
||||
MessageUtils.sendPluginMessage(sender, "Unable to set option. Does the Subject already have it set?");
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class OptionUnset extends SubCommand<LPSubjectData> {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(1, args);
|
||||
|
||||
if (subjectData.unsetOption(contextSet, key).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet));
|
||||
MessageUtils.sendPluginMessage(sender, "&aUnset &f\"" + key + "&f\"&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
} else {
|
||||
MessageUtils.sendPluginMessage(sender, "Unable to unset option. Are you sure the Subject has it set?");
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ParentAdd extends SubCommand<LPSubjectData> {
|
||||
|
||||
if (subjectData.addParent(contextSet, subject.toReference()).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aAdded parent &b" + subject.getParentCollection().getIdentifier() +
|
||||
"&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet));
|
||||
"&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
} else {
|
||||
MessageUtils.sendPluginMessage(sender, "Unable to add parent. Does the Subject already have it added?");
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ParentClear extends SubCommand<LPSubjectData> {
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &bANY&a.");
|
||||
} else {
|
||||
subjectData.clearParents(contextSet);
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &b" + SpongeCommandUtils.contextToString(contextSet));
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared parents matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ParentInfo extends SubCommand<LPSubjectData> {
|
||||
}
|
||||
|
||||
for (Map.Entry<ImmutableContextSet, ImmutableList<LPSubjectReference>> e : parents.entrySet()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.parentsToString(e.getValue()));
|
||||
MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.parentsToString(e.getValue()));
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -72,7 +72,7 @@ public class ParentInfo extends SubCommand<LPSubjectData> {
|
||||
}
|
||||
|
||||
MessageUtils.sendPluginMessage(sender, "&aShowing parents matching contexts &b" +
|
||||
SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.parentsToString(parents));
|
||||
SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.parentsToString(parents));
|
||||
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ParentRemove extends SubCommand<LPSubjectData> {
|
||||
|
||||
if (subjectData.removeParent(contextSet, subject.toReference()).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aRemoved parent &b" + subject.getParentCollection().getIdentifier() +
|
||||
"&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet));
|
||||
"&a/&b" + subject.getIdentifier() + "&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
} else {
|
||||
MessageUtils.sendPluginMessage(sender, "Unable to remove parent. Are you sure the Subject has it added?");
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PermissionClear extends SubCommand<LPSubjectData> {
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &bANY&a.");
|
||||
} else {
|
||||
subjectData.clearPermissions(contextSet);
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &b" + SpongeCommandUtils.contextToString(contextSet));
|
||||
MessageUtils.sendPluginMessage(sender, "&aCleared permissions matching contexts &b" + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PermissionInfo extends SubCommand<LPSubjectData> {
|
||||
}
|
||||
|
||||
for (Map.Entry<ImmutableContextSet, ImmutableMap<String, Boolean>> e : permissions.entrySet()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey()) + "\n" + SpongeCommandUtils.nodesToString(e.getValue()));
|
||||
MessageUtils.sendPluginMessage(sender, "&3>> &bContext: " + SpongeCommandUtils.contextToString(e.getKey(), plugin.getLocaleManager()) + "\n" + SpongeCommandUtils.nodesToString(e.getValue()));
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -71,7 +71,7 @@ public class PermissionInfo extends SubCommand<LPSubjectData> {
|
||||
}
|
||||
|
||||
MessageUtils.sendPluginMessage(sender, "&aShowing permissions matching contexts &b" +
|
||||
SpongeCommandUtils.contextToString(contextSet) + "&a.\n" + SpongeCommandUtils.nodesToString(permissions));
|
||||
SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()) + "&a.\n" + SpongeCommandUtils.nodesToString(permissions));
|
||||
|
||||
}
|
||||
return CommandResult.SUCCESS;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PermissionSet extends SubCommand<LPSubjectData> {
|
||||
ImmutableContextSet contextSet = ArgumentParser.parseContextSponge(2, args);
|
||||
|
||||
if (subjectData.setPermission(contextSet, node, tristate).join()) {
|
||||
MessageUtils.sendPluginMessage(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeCommandUtils.contextToString(contextSet));
|
||||
MessageUtils.sendPluginMessage(sender, "&aSet &b" + node + "&a to &b" + tristate.toString().toLowerCase() + "&a in context " + SpongeCommandUtils.contextToString(contextSet, plugin.getLocaleManager()));
|
||||
} else {
|
||||
MessageUtils.sendPluginMessage(sender, "Unable to set permission. Does the Subject already have it set?");
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import me.lucko.luckperms.api.Tristate;
|
||||
import me.lucko.luckperms.api.context.ContextSet;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.sponge.service.model.LPSubjectReference;
|
||||
|
||||
import java.util.List;
|
||||
@@ -85,8 +86,8 @@ public final class SpongeCommandUtils {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String contextToString(ContextSet set) {
|
||||
return MessageUtils.contextSetToString(set);
|
||||
public static String contextToString(ContextSet set, LocaleManager localeManager) {
|
||||
return MessageUtils.contextSetToString(localeManager, set);
|
||||
}
|
||||
|
||||
private SpongeCommandUtils() {}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class LuckPermsService implements LPPermissionService {
|
||||
public LPPermissionDescription registerPermissionDescription(String id, Text description, PluginContainer owner) {
|
||||
SimplePermissionDescription desc = new SimplePermissionDescription(this, id, description, owner);
|
||||
this.permissionDescriptions.put(id, desc);
|
||||
this.plugin.getPermissionRegistry().offer(id);
|
||||
this.plugin.getPermissionRegistry().insert(id);
|
||||
return desc;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class LuckPermsService implements LPPermissionService {
|
||||
Map<String, LPPermissionDescription> descriptions = new HashMap<>(this.permissionDescriptions);
|
||||
|
||||
// collect known values from the permission vault
|
||||
for (String perm : this.plugin.getPermissionRegistry().getKnownPermissions()) {
|
||||
for (String perm : this.plugin.getPermissionRegistry().rootAsList()) {
|
||||
// don't override plugin defined values
|
||||
if (!descriptions.containsKey(perm)) {
|
||||
descriptions.put(perm, new SimplePermissionDescription(this, perm, null, null));
|
||||
|
||||
Reference in New Issue
Block a user