This commit is contained in:
Luck 2016-11-13 19:30:46 +00:00
parent 59fd337e44
commit 18a3dfd604
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
11 changed files with 29 additions and 34 deletions

View File

@ -24,7 +24,6 @@ package me.lucko.luckperms.bukkit;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import me.lucko.luckperms.api.data.Callback;
import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.constants.Patterns;
@ -50,7 +49,7 @@ class BukkitCommand extends CommandManager implements CommandExecutor, TabExecut
plugin.getSenderFactory().wrap(sender),
label,
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(Joiner.on(' ').join(args))),
Callback.empty()
null
);
return true;
}

View File

@ -24,7 +24,6 @@ package me.lucko.luckperms.bungee;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import me.lucko.luckperms.api.data.Callback;
import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.constants.Patterns;
@ -50,7 +49,7 @@ class BungeeCommand extends Command implements TabExecutor {
plugin.getSenderFactory().wrap(sender),
"bperms",
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(Joiner.on(' ').join(args))),
Callback.empty()
null
);
}

View File

@ -40,8 +40,6 @@ import static me.lucko.luckperms.common.core.PermissionHolder.exportToLegacy;
@SuppressWarnings("unused")
@AllArgsConstructor
public class PermissionHolderLink implements PermissionHolder {
@NonNull
private final me.lucko.luckperms.common.core.PermissionHolder master;
@Override

View File

@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands;
import com.google.common.collect.ImmutableList;
import lombok.AllArgsConstructor;
import lombok.Getter;
import me.lucko.luckperms.api.data.Callback;
import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.commands.group.CreateGroup;
import me.lucko.luckperms.common.commands.group.DeleteGroup;
@ -49,6 +48,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@AllArgsConstructor
@ -88,10 +88,12 @@ public class CommandManager {
* @param args the arguments provided
* @param result the callback to be called when the command has fully executed
*/
public void onCommand(Sender sender, String label, List<String> args, Callback<CommandResult> result) {
public void onCommand(Sender sender, String label, List<String> args, Consumer<CommandResult> result) {
plugin.doAsync(() -> {
CommandResult r = onCommand(sender, label, args);
plugin.doSync(() -> result.onComplete(r));
if (result != null) {
plugin.doSync(() -> result.accept(r));
}
});
}
@ -344,6 +346,8 @@ public class CommandManager {
case "removetempsuffix":
args.add(2, "meta");
break;
default:
break;
}
// Provide lazy set rewrite

View File

@ -50,15 +50,15 @@ public abstract class SingleCommand extends BaseCommand<Void, Void> {
@Override
public void sendUsage(Sender sender, String label) {
String usage = "";
StringBuilder sb = new StringBuilder();
if (getArgs().isPresent()) {
usage += "&3 - &7";
sb.append("&3 - &7");
for (Arg arg : getArgs().get()) {
usage += arg.asPrettyString() + " ";
sb.append(arg.asPrettyString()).append(" ");
}
}
Util.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + usage);
Util.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString());
}
@Override

View File

@ -55,15 +55,15 @@ public abstract class SubCommand<T> extends Command<T, Void> {
*/
@Override
public void sendUsage(Sender sender, String label) {
String usage = "";
StringBuilder sb = new StringBuilder();
if (getArgs().isPresent()) {
usage += "&3 - &7";
sb.append("&3 - &7");
for (Arg arg : getArgs().get()) {
usage += arg.asPrettyString() + " ";
sb.append(arg.asPrettyString()).append(" ");
}
}
Util.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + usage);
Util.sendPluginMessage(sender, "&3> &a" + getName().toLowerCase() + sb.toString());
}
@Override

View File

@ -75,15 +75,15 @@ public abstract class SharedSubCommand {
}
public void sendUsage(Sender sender) {
String usage = "";
StringBuilder sb = new StringBuilder();
if (args != null) {
usage += "&3 - &7";
sb.append("&3 - &7");
for (Arg arg : args) {
usage += arg.asPrettyString() + " ";
sb.append(arg.asPrettyString()).append(" ");
}
}
Util.sendPluginMessage(sender, "&3> &a" + getName() + usage);
Util.sendPluginMessage(sender, "&3> &a" + getName() + sb.toString());
}
public void sendDetailedUsage(Sender sender) {

View File

@ -70,17 +70,13 @@ public class PermissionCheckInherits extends SharedSubCommand {
break;
}
String location = null;
if (result.getLocation().isPresent()) {
if (result.getLocation().get().equals(holder.getObjectName())) {
location = "self";
} else {
location = result.getLocation().get();
}
String location = result.getLocation().orElse(null);
if (location != null && location.equalsIgnoreCase(holder.getObjectName())) {
location = "self";
}
Util.sendPluginMessage(sender, "&b" + node + ": " + Util.formatTristate(result.getResult()) +
(result.getLocation().isPresent() ? " &7(inherited from &a" + location + "&7)" : ""));
(location != null ? " &7(inherited from &a" + location + "&7)" : ""));
return CommandResult.SUCCESS;
}
}

View File

@ -98,7 +98,7 @@ public class LogRecent extends SubCommand<Log> {
return showLog(p, uuid, sender, log);
} catch (NumberFormatException e) {
// Invalid page
return showLog(-1, null, null, null);
return showLog(-1, null, sender, log);
}
}
@ -116,7 +116,7 @@ public class LogRecent extends SubCommand<Log> {
return showLog(p, u, sender, log);
} catch (NumberFormatException e) {
// Invalid page
return showLog(-1, null, null, null);
return showLog(-1, null, sender, log);
}
}
}

View File

@ -62,7 +62,7 @@ public class LogUserHistory extends SubCommand<Log> {
page = Integer.parseInt(args.get(1));
} catch (NumberFormatException e) {
// invalid page
return showLog(-1, null, null, null);
return showLog(-1, null, sender, log);
}
}

View File

@ -24,7 +24,6 @@ package me.lucko.luckperms.sponge;
import co.aikar.timings.Timing;
import com.google.common.base.Splitter;
import me.lucko.luckperms.api.data.Callback;
import me.lucko.luckperms.common.commands.CommandManager;
import me.lucko.luckperms.common.commands.utils.Util;
import me.lucko.luckperms.common.constants.Patterns;
@ -57,7 +56,7 @@ class SpongeCommand extends CommandManager implements CommandCallable {
plugin.getSenderFactory().wrap(source),
"perms",
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(s)),
Callback.empty()
null
);
return CommandResult.success();
}