add methods for older sponge api versions

This commit is contained in:
Luck 2016-11-11 22:54:09 +00:00
parent c4ea626e33
commit e9131f729a
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 27 additions and 23 deletions

View File

@ -70,6 +70,7 @@ class SpongeCommand extends CommandManager implements CommandCallable {
}
}
// For API 4
public List<String> getSuggestions(CommandSource source, String s) throws CommandException {
try (Timing ignored = plugin.getTimings().time(LPTiming.COMMAND_TAB_COMPLETE)) {
return onTabComplete(plugin.getSenderFactory().wrap(source), Splitter.on(' ').splitToList(s));

View File

@ -60,6 +60,7 @@ public class MigrationUtils {
}
// Migrate options
try {
Map<Set<Context>, Map<String, String>> opts = subject.getSubjectData().getAllOptions();
for (Map.Entry<Set<Context>, Map<String, String>> e : opts.entrySet()) {
ContextSet context = LuckPermsService.convertContexts(e.getKey());
@ -82,6 +83,10 @@ public class MigrationUtils {
}
}
}
} catch (Throwable ignored) {
// Ignore. This is just so older versions of Sponge API can be used.
}
// Migrate parents
Map<Set<Context>, List<Subject>> parents = subject.getSubjectData().getAllParents();

View File

@ -34,7 +34,6 @@ import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.service.context.Context;
import org.spongepowered.api.service.permission.MemorySubjectData;
import org.spongepowered.api.service.permission.Subject;
import org.spongepowered.api.service.permission.SubjectCollection;
import org.spongepowered.api.util.Tristate;
import java.io.IOException;
@ -51,7 +50,7 @@ public class PersistedSubject implements Subject {
private final String identifier;
private final LuckPermsService service;
private final SubjectCollection containingCollection;
private final PersistedCollection containingCollection;
private final PersistedSubjectData subjectData;
private final MemorySubjectData transientSubjectData;
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.service = service;
this.containingCollection = containingCollection;

View File

@ -33,7 +33,6 @@ import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.service.context.Context;
import org.spongepowered.api.service.permission.MemorySubjectData;
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.util.Tristate;
@ -50,10 +49,10 @@ public class SimpleSubject implements Subject {
private final String identifier;
private final LuckPermsService service;
private final SubjectCollection containingCollection;
private final SimpleCollection containingCollection;
private final MemorySubjectData subjectData;
public SimpleSubject(String identifier, LuckPermsService service, SubjectCollection containingCollection) {
public SimpleSubject(String identifier, LuckPermsService service, SimpleCollection containingCollection) {
this.identifier = identifier;
this.service = service;
this.containingCollection = containingCollection;