@@ -89,6 +89,7 @@ public class CommandHandler {
|
|||||||
CommandMethod commandMethod = new CommandMethod(methodName, Sets.newHashSet(cmd.aliases()), cmd.desc(), perm, command, method, autofiller);
|
CommandMethod commandMethod = new CommandMethod(methodName, Sets.newHashSet(cmd.aliases()), cmd.desc(), perm, command, method, autofiller);
|
||||||
|
|
||||||
command.addMethod(methodName, commandMethod);
|
command.addMethod(methodName, commandMethod);
|
||||||
|
commandMethod.getAliases().forEach(alias -> command.addAlias(alias, methodName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public abstract class CommandInstance extends BukkitCommand {
|
|||||||
protected final CommandHandler commandHandler;
|
protected final CommandHandler commandHandler;
|
||||||
|
|
||||||
private final Map<String, CommandMethod> methods;
|
private final Map<String, CommandMethod> methods;
|
||||||
|
private final Map<String, String> aliasesToNames;
|
||||||
|
|
||||||
private static final String MANAGE_PERMISSION = "terminatorplus.manage";
|
private static final String MANAGE_PERMISSION = "terminatorplus.manage";
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ public abstract class CommandInstance extends BukkitCommand {
|
|||||||
|
|
||||||
this.commandHandler = handler;
|
this.commandHandler = handler;
|
||||||
this.methods = new HashMap<>();
|
this.methods = new HashMap<>();
|
||||||
|
this.aliasesToNames = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, CommandMethod> getMethods() {
|
public Map<String, CommandMethod> getMethods() {
|
||||||
@@ -45,6 +47,10 @@ public abstract class CommandInstance extends BukkitCommand {
|
|||||||
methods.put(name, method);
|
methods.put(name, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addAlias(String alias, String name) {
|
||||||
|
aliasesToNames.put(alias, name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(@Nonnull CommandSender sender, @Nonnull String label, @Nonnull String[] args) {
|
public boolean execute(@Nonnull CommandSender sender, @Nonnull String label, @Nonnull String[] args) {
|
||||||
if (!sender.hasPermission(MANAGE_PERMISSION)) {
|
if (!sender.hasPermission(MANAGE_PERMISSION)) {
|
||||||
@@ -61,8 +67,8 @@ public abstract class CommandInstance extends BukkitCommand {
|
|||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
method = methods.get("");
|
method = methods.get("");
|
||||||
} else if (methods.containsKey(args[0])) {
|
} else if (methods.containsKey(aliasesToNames.getOrDefault(args[0], args[0]))) {
|
||||||
method = methods.get(args[0]);
|
method = methods.get(aliasesToNames.getOrDefault(args[0], args[0]));
|
||||||
} else {
|
} else {
|
||||||
method = methods.get("");
|
method = methods.get("");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -526,7 +526,7 @@ public class BotCommand extends CommandInstance {
|
|||||||
private double parseDoubleOrRelative(String pos, Location loc, int type) {
|
private double parseDoubleOrRelative(String pos, Location loc, int type) {
|
||||||
if (loc == null || pos.length() == 0 || pos.charAt(0) != '~')
|
if (loc == null || pos.length() == 0 || pos.charAt(0) != '~')
|
||||||
return Double.parseDouble(pos);
|
return Double.parseDouble(pos);
|
||||||
double relative = Double.parseDouble(pos.substring(1));
|
double relative = pos.length() == 1 ? 0 : Double.parseDouble(pos.substring(1));
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0:
|
case 0:
|
||||||
return relative + Math.round(loc.getX() * 1000) / 1000D;
|
return relative + Math.round(loc.getX() * 1000) / 1000D;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ tasks.processResources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.jar {
|
tasks.jar {
|
||||||
from(configurations.compileClasspath.get().map { if (it.isDirectory()) it else zipTree(it) })
|
from(configurations.compileClasspath.get().map { if (it.getName().endsWith(".jar")) zipTree(it) else it })
|
||||||
archiveFileName.set(jarName + ".jar")
|
archiveFileName.set(jarName + ".jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user