1
0
mirror of https://github.com/lucko/LuckPerms.git synced 2025-09-09 13:50:52 +02:00

More progress towards 1.6: add transient permissions

This commit is contained in:
Luck
2016-08-27 22:01:17 +01:00
parent 2ea9b36c77
commit 2a305b1c55
17 changed files with 560 additions and 244 deletions

View File

@@ -30,7 +30,10 @@ import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -49,6 +52,15 @@ class SpongeCommand extends CommandManager implements CommandCallable {
}
@Override
public List<String> getSuggestions(CommandSource source, String s, @Nullable Location<World> location) throws CommandException {
List<String> args = new ArrayList<>(Arrays.asList(Patterns.SPACE.split(s)));
if (s.endsWith(" ")) {
args.add("");
}
return onTabComplete(SpongeSenderFactory.get().wrap(source), args);
}
public List<String> getSuggestions(CommandSource source, String s) throws CommandException {
List<String> args = new ArrayList<>(Arrays.asList(Patterns.SPACE.split(s)));
if (s.endsWith(" ")) {
@@ -64,12 +76,12 @@ class SpongeCommand extends CommandManager implements CommandCallable {
}
@Override
public Optional<? extends Text> getShortDescription(CommandSource source) {
public Optional<Text> getShortDescription(CommandSource source) {
return Optional.of(Text.of("LuckPerms main command."));
}
@Override
public Optional<? extends Text> getHelp(CommandSource source) {
public Optional<Text> getHelp(CommandSource source) {
return Optional.of(Text.of("Type /perms for help."));
}

View File

@@ -25,10 +25,7 @@ package me.lucko.luckperms;
import me.lucko.luckperms.constants.Message;
import me.lucko.luckperms.users.User;
import me.lucko.luckperms.utils.AbstractListener;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.entity.DisplaceEntityEvent;
import org.spongepowered.api.event.network.ClientConnectionEvent;
import org.spongepowered.api.profile.GameProfile;
import org.spongepowered.api.text.serializer.TextSerializers;
@@ -75,8 +72,10 @@ public class SpongeListener extends AbstractListener {
refreshPlayer(e.getTargetEntity().getUniqueId());
}
// TODO Use reflection/any other method to refresh on world change
/*
@Listener
public void onPlayerTeleport(DisplaceEntityEvent.Teleport e) {
public void onPlayerTeleport(DisplaceEntityEvent e) {
final Entity entity = e.getTargetEntity();
if (!(entity instanceof Player)){
return;
@@ -84,6 +83,7 @@ public class SpongeListener extends AbstractListener {
refreshPlayer(entity.getUniqueId());
}
*/
@Listener
public void onClientLeave(ClientConnectionEvent.Disconnect e) {

View File

@@ -83,4 +83,9 @@ public class GroupCollection implements SubjectCollection {
.map(sub -> new AbstractMap.SimpleEntry<Subject, Boolean>(sub, sub.getPermissionValue(contexts, node).asBoolean()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
@Override
public Subject getDefaults() {
return null;
}
}

View File

@@ -101,4 +101,9 @@ public class UserCollection implements SubjectCollection {
.map(sub -> new AbstractMap.SimpleEntry<Subject, Boolean>(sub, sub.getPermissionValue(contexts, node).asBoolean()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
@Override
public Subject getDefaults() {
return null;
}
}