mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
cleanup
This commit is contained in:
parent
59fd337e44
commit
18a3dfd604
@ -24,7 +24,6 @@ package me.lucko.luckperms.bukkit;
|
|||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Splitter;
|
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.CommandManager;
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
import me.lucko.luckperms.common.constants.Patterns;
|
import me.lucko.luckperms.common.constants.Patterns;
|
||||||
@ -50,7 +49,7 @@ class BukkitCommand extends CommandManager implements CommandExecutor, TabExecut
|
|||||||
plugin.getSenderFactory().wrap(sender),
|
plugin.getSenderFactory().wrap(sender),
|
||||||
label,
|
label,
|
||||||
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(Joiner.on(' ').join(args))),
|
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(Joiner.on(' ').join(args))),
|
||||||
Callback.empty()
|
null
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ package me.lucko.luckperms.bungee;
|
|||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Splitter;
|
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.CommandManager;
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
import me.lucko.luckperms.common.constants.Patterns;
|
import me.lucko.luckperms.common.constants.Patterns;
|
||||||
@ -50,7 +49,7 @@ class BungeeCommand extends Command implements TabExecutor {
|
|||||||
plugin.getSenderFactory().wrap(sender),
|
plugin.getSenderFactory().wrap(sender),
|
||||||
"bperms",
|
"bperms",
|
||||||
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(Joiner.on(' ').join(args))),
|
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(Joiner.on(' ').join(args))),
|
||||||
Callback.empty()
|
null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,6 @@ import static me.lucko.luckperms.common.core.PermissionHolder.exportToLegacy;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class PermissionHolderLink implements PermissionHolder {
|
public class PermissionHolderLink implements PermissionHolder {
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private final me.lucko.luckperms.common.core.PermissionHolder master;
|
private final me.lucko.luckperms.common.core.PermissionHolder master;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.lucko.luckperms.api.data.Callback;
|
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
import me.lucko.luckperms.common.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.commands.group.CreateGroup;
|
import me.lucko.luckperms.common.commands.group.CreateGroup;
|
||||||
import me.lucko.luckperms.common.commands.group.DeleteGroup;
|
import me.lucko.luckperms.common.commands.group.DeleteGroup;
|
||||||
@ -49,6 +48,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ -88,10 +88,12 @@ public class CommandManager {
|
|||||||
* @param args the arguments provided
|
* @param args the arguments provided
|
||||||
* @param result the callback to be called when the command has fully executed
|
* @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(() -> {
|
plugin.doAsync(() -> {
|
||||||
CommandResult r = onCommand(sender, label, args);
|
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":
|
case "removetempsuffix":
|
||||||
args.add(2, "meta");
|
args.add(2, "meta");
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide lazy set rewrite
|
// Provide lazy set rewrite
|
||||||
|
@ -50,15 +50,15 @@ public abstract class SingleCommand extends BaseCommand<Void, Void> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendUsage(Sender sender, String label) {
|
public void sendUsage(Sender sender, String label) {
|
||||||
String usage = "";
|
StringBuilder sb = new StringBuilder();
|
||||||
if (getArgs().isPresent()) {
|
if (getArgs().isPresent()) {
|
||||||
usage += "&3 - &7";
|
sb.append("&3 - &7");
|
||||||
for (Arg arg : getArgs().get()) {
|
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
|
@Override
|
||||||
|
@ -55,15 +55,15 @@ public abstract class SubCommand<T> extends Command<T, Void> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void sendUsage(Sender sender, String label) {
|
public void sendUsage(Sender sender, String label) {
|
||||||
String usage = "";
|
StringBuilder sb = new StringBuilder();
|
||||||
if (getArgs().isPresent()) {
|
if (getArgs().isPresent()) {
|
||||||
usage += "&3 - &7";
|
sb.append("&3 - &7");
|
||||||
for (Arg arg : getArgs().get()) {
|
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
|
@Override
|
||||||
|
@ -75,15 +75,15 @@ public abstract class SharedSubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendUsage(Sender sender) {
|
public void sendUsage(Sender sender) {
|
||||||
String usage = "";
|
StringBuilder sb = new StringBuilder();
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
usage += "&3 - &7";
|
sb.append("&3 - &7");
|
||||||
for (Arg arg : args) {
|
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) {
|
public void sendDetailedUsage(Sender sender) {
|
||||||
|
@ -70,17 +70,13 @@ public class PermissionCheckInherits extends SharedSubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
String location = null;
|
String location = result.getLocation().orElse(null);
|
||||||
if (result.getLocation().isPresent()) {
|
if (location != null && location.equalsIgnoreCase(holder.getObjectName())) {
|
||||||
if (result.getLocation().get().equals(holder.getObjectName())) {
|
|
||||||
location = "self";
|
location = "self";
|
||||||
} else {
|
|
||||||
location = result.getLocation().get();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Util.sendPluginMessage(sender, "&b" + node + ": " + Util.formatTristate(result.getResult()) +
|
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;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public class LogRecent extends SubCommand<Log> {
|
|||||||
return showLog(p, uuid, sender, log);
|
return showLog(p, uuid, sender, log);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// Invalid page
|
// 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);
|
return showLog(p, u, sender, log);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// Invalid page
|
// Invalid page
|
||||||
return showLog(-1, null, null, null);
|
return showLog(-1, null, sender, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class LogUserHistory extends SubCommand<Log> {
|
|||||||
page = Integer.parseInt(args.get(1));
|
page = Integer.parseInt(args.get(1));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// invalid page
|
// invalid page
|
||||||
return showLog(-1, null, null, null);
|
return showLog(-1, null, sender, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ package me.lucko.luckperms.sponge;
|
|||||||
|
|
||||||
import co.aikar.timings.Timing;
|
import co.aikar.timings.Timing;
|
||||||
import com.google.common.base.Splitter;
|
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.CommandManager;
|
||||||
import me.lucko.luckperms.common.commands.utils.Util;
|
import me.lucko.luckperms.common.commands.utils.Util;
|
||||||
import me.lucko.luckperms.common.constants.Patterns;
|
import me.lucko.luckperms.common.constants.Patterns;
|
||||||
@ -57,7 +56,7 @@ class SpongeCommand extends CommandManager implements CommandCallable {
|
|||||||
plugin.getSenderFactory().wrap(source),
|
plugin.getSenderFactory().wrap(source),
|
||||||
"perms",
|
"perms",
|
||||||
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(s)),
|
Util.stripQuotes(Splitter.on(Patterns.COMMAND_SEPARATOR).omitEmptyStrings().splitToList(s)),
|
||||||
Callback.empty()
|
null
|
||||||
);
|
);
|
||||||
return CommandResult.success();
|
return CommandResult.success();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user