add methods for older sponge api versions
This commit is contained in:
parent
c4ea626e33
commit
e9131f729a
@ -70,6 +70,7 @@ class SpongeCommand extends CommandManager implements CommandCallable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For API 4
|
||||||
public List<String> getSuggestions(CommandSource source, String s) throws CommandException {
|
public List<String> getSuggestions(CommandSource source, String s) throws CommandException {
|
||||||
try (Timing ignored = plugin.getTimings().time(LPTiming.COMMAND_TAB_COMPLETE)) {
|
try (Timing ignored = plugin.getTimings().time(LPTiming.COMMAND_TAB_COMPLETE)) {
|
||||||
return onTabComplete(plugin.getSenderFactory().wrap(source), Splitter.on(' ').splitToList(s));
|
return onTabComplete(plugin.getSenderFactory().wrap(source), Splitter.on(' ').splitToList(s));
|
||||||
|
@ -60,29 +60,34 @@ public class MigrationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Migrate options
|
// Migrate options
|
||||||
Map<Set<Context>, Map<String, String>> opts = subject.getSubjectData().getAllOptions();
|
try {
|
||||||
for (Map.Entry<Set<Context>, Map<String, String>> e : opts.entrySet()) {
|
Map<Set<Context>, Map<String, String>> opts = subject.getSubjectData().getAllOptions();
|
||||||
ContextSet context = LuckPermsService.convertContexts(e.getKey());
|
for (Map.Entry<Set<Context>, Map<String, String>> e : opts.entrySet()) {
|
||||||
|
ContextSet context = LuckPermsService.convertContexts(e.getKey());
|
||||||
|
|
||||||
MutableContextSet contexts = MutableContextSet.fromSet(context);
|
MutableContextSet contexts = MutableContextSet.fromSet(context);
|
||||||
String server = contexts.getValues("server").stream().findAny().orElse(null);
|
String server = contexts.getValues("server").stream().findAny().orElse(null);
|
||||||
String world = contexts.getValues("world").stream().findAny().orElse(null);
|
String world = contexts.getValues("world").stream().findAny().orElse(null);
|
||||||
contexts.removeAll("server");
|
contexts.removeAll("server");
|
||||||
contexts.removeAll("world");
|
contexts.removeAll("world");
|
||||||
|
|
||||||
for (Map.Entry<String, String> opt : e.getValue().entrySet()) {
|
for (Map.Entry<String, String> opt : e.getValue().entrySet()) {
|
||||||
if (opt.getKey().equalsIgnoreCase("prefix") || opt.getKey().equalsIgnoreCase("suffix")) {
|
if (opt.getKey().equalsIgnoreCase("prefix") || opt.getKey().equalsIgnoreCase("suffix")) {
|
||||||
try {
|
try {
|
||||||
holder.setPermission(new NodeBuilder(opt.getKey().toLowerCase() + ".100." + opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
holder.setPermission(new NodeBuilder(opt.getKey().toLowerCase() + ".100." + opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
||||||
} catch (ObjectAlreadyHasException ignored) {}
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
holder.setPermission(new NodeBuilder("meta." + opt.getKey() + "." + opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
holder.setPermission(new NodeBuilder("meta." + opt.getKey() + "." + opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build());
|
||||||
} catch (ObjectAlreadyHasException ignored) {}
|
} catch (ObjectAlreadyHasException ignored) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
// Ignore. This is just so older versions of Sponge API can be used.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Migrate parents
|
// Migrate parents
|
||||||
Map<Set<Context>, List<Subject>> parents = subject.getSubjectData().getAllParents();
|
Map<Set<Context>, List<Subject>> parents = subject.getSubjectData().getAllParents();
|
||||||
for (Map.Entry<Set<Context>, List<Subject>> e : parents.entrySet()) {
|
for (Map.Entry<Set<Context>, List<Subject>> e : parents.entrySet()) {
|
||||||
|
@ -34,7 +34,6 @@ import org.spongepowered.api.command.CommandSource;
|
|||||||
import org.spongepowered.api.service.context.Context;
|
import org.spongepowered.api.service.context.Context;
|
||||||
import org.spongepowered.api.service.permission.MemorySubjectData;
|
import org.spongepowered.api.service.permission.MemorySubjectData;
|
||||||
import org.spongepowered.api.service.permission.Subject;
|
import org.spongepowered.api.service.permission.Subject;
|
||||||
import org.spongepowered.api.service.permission.SubjectCollection;
|
|
||||||
import org.spongepowered.api.util.Tristate;
|
import org.spongepowered.api.util.Tristate;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -51,7 +50,7 @@ public class PersistedSubject implements Subject {
|
|||||||
private final String identifier;
|
private final String identifier;
|
||||||
|
|
||||||
private final LuckPermsService service;
|
private final LuckPermsService service;
|
||||||
private final SubjectCollection containingCollection;
|
private final PersistedCollection containingCollection;
|
||||||
private final PersistedSubjectData subjectData;
|
private final PersistedSubjectData subjectData;
|
||||||
private final MemorySubjectData transientSubjectData;
|
private final MemorySubjectData transientSubjectData;
|
||||||
private final BufferedRequest<Void> saveBuffer = new BufferedRequest<Void>(1000L, r -> PersistedSubject.this.service.getPlugin().doAsync(r)) {
|
private final BufferedRequest<Void> saveBuffer = new BufferedRequest<Void>(1000L, r -> PersistedSubject.this.service.getPlugin().doAsync(r)) {
|
||||||
@ -68,7 +67,7 @@ public class PersistedSubject implements Subject {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public PersistedSubject(String identifier, LuckPermsService service, SubjectCollection containingCollection) {
|
public PersistedSubject(String identifier, LuckPermsService service, PersistedCollection containingCollection) {
|
||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
this.service = service;
|
this.service = service;
|
||||||
this.containingCollection = containingCollection;
|
this.containingCollection = containingCollection;
|
||||||
|
@ -33,7 +33,6 @@ import org.spongepowered.api.command.CommandSource;
|
|||||||
import org.spongepowered.api.service.context.Context;
|
import org.spongepowered.api.service.context.Context;
|
||||||
import org.spongepowered.api.service.permission.MemorySubjectData;
|
import org.spongepowered.api.service.permission.MemorySubjectData;
|
||||||
import org.spongepowered.api.service.permission.Subject;
|
import org.spongepowered.api.service.permission.Subject;
|
||||||
import org.spongepowered.api.service.permission.SubjectCollection;
|
|
||||||
import org.spongepowered.api.service.permission.SubjectData;
|
import org.spongepowered.api.service.permission.SubjectData;
|
||||||
import org.spongepowered.api.util.Tristate;
|
import org.spongepowered.api.util.Tristate;
|
||||||
|
|
||||||
@ -50,10 +49,10 @@ public class SimpleSubject implements Subject {
|
|||||||
private final String identifier;
|
private final String identifier;
|
||||||
|
|
||||||
private final LuckPermsService service;
|
private final LuckPermsService service;
|
||||||
private final SubjectCollection containingCollection;
|
private final SimpleCollection containingCollection;
|
||||||
private final MemorySubjectData subjectData;
|
private final MemorySubjectData subjectData;
|
||||||
|
|
||||||
public SimpleSubject(String identifier, LuckPermsService service, SubjectCollection containingCollection) {
|
public SimpleSubject(String identifier, LuckPermsService service, SimpleCollection containingCollection) {
|
||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
this.service = service;
|
this.service = service;
|
||||||
this.containingCollection = containingCollection;
|
this.containingCollection = containingCollection;
|
||||||
|
Loading…
Reference in New Issue
Block a user