mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Fix command duplication
This commit is contained in:
parent
9b5958da31
commit
a4f8292f04
@ -40,6 +40,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
permission = "plots.delete",
|
||||
description = "Delete a plot",
|
||||
usage = "/plot delete",
|
||||
aliases = "dispose",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = RequiredType.NONE
|
||||
)
|
||||
|
@ -124,14 +124,6 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
createCommand(new Copy());
|
||||
createCommand(new Chat());
|
||||
createCommand(new Trim());
|
||||
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
createCommand(new Cluster());
|
||||
}
|
||||
|
||||
// Broken
|
||||
// createCommand(new DebugUUID());
|
||||
|
||||
}
|
||||
|
||||
public static boolean no_permission(final PlotPlayer player, final String permission) {
|
||||
@ -141,7 +133,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
|
||||
public static List<Command<PlotPlayer>> getCommands(final CommandCategory category, final PlotPlayer player) {
|
||||
List<Command<PlotPlayer>> commands = new ArrayList<>();
|
||||
for (Command<PlotPlayer> command : instance.getCommands()) {
|
||||
for (Command<PlotPlayer> command : getInstance().getCommands()) {
|
||||
if (category != null && !command.getCategory().equals(category)) {
|
||||
continue;
|
||||
}
|
||||
@ -330,14 +322,18 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
args = new String[parts.length - 2];
|
||||
System.arraycopy(parts, 2, args, 0, args.length);
|
||||
}
|
||||
Command<PlotPlayer> cmd = null;
|
||||
cmd = this.commands.get(label);
|
||||
Command<PlotPlayer> cmd;
|
||||
if (label != null) {
|
||||
cmd = getInstance().commands.get(label);
|
||||
}
|
||||
else {
|
||||
cmd = null;
|
||||
}
|
||||
if (cmd == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_SUBCOMMAND);
|
||||
{
|
||||
List<Command<PlotPlayer>> cmds = getCommands(null, plr);
|
||||
cmd = new StringComparison<>(label, cmds).getMatchObject();
|
||||
if (cmd == null) {
|
||||
if (label == null || (cmd = new StringComparison<>(label, cmds).getMatchObject()) == null) {
|
||||
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, "/plot help");
|
||||
}
|
||||
else {
|
||||
|
@ -78,7 +78,7 @@ public class plugin extends SubCommand {
|
||||
add(String.format("$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92"));
|
||||
add(String.format("$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"));
|
||||
add(String.format("$2>> $1&lWebsite$2: $1http://plotsquared.com"));
|
||||
add(String.format("$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? PS.get().IMP.getPluginVersion() : PS.get().update)));
|
||||
add(String.format("$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? StringMan.join(PS.get().IMP.getPluginVersion(), ".") : PS.get().update)));
|
||||
}
|
||||
};
|
||||
for (final String s : strings) {
|
||||
|
@ -96,6 +96,7 @@ public class Settings {
|
||||
* Default kill road mobs: true
|
||||
*/
|
||||
public final static boolean KILL_ROAD_MOBS_DEFAULT = false;
|
||||
public final static boolean KILL_ROAD_VEHICLES_DEFAULT = false;
|
||||
/**
|
||||
* Default mob pathfinding: true
|
||||
*/
|
||||
@ -132,6 +133,7 @@ public class Settings {
|
||||
* Kill road mobs?
|
||||
*/
|
||||
public static boolean KILL_ROAD_MOBS;
|
||||
public static boolean KILL_ROAD_VEHICLES;
|
||||
/**
|
||||
* mob pathfinding?
|
||||
*/
|
||||
|
@ -14,6 +14,8 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.metadata.MetadataValueAdapter;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
|
@ -11,8 +11,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.Cluster;
|
||||
import com.intellectualcrafters.plot.commands.DebugUUID;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
@ -27,6 +29,9 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
public BukkitCommand() {
|
||||
MainCommand.getInstance().addCommand(new DebugUUID());
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
MainCommand.getInstance().addCommand(new Cluster());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,6 +60,8 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
return null;
|
||||
}
|
||||
final Set<String> tabOptions = new HashSet<>();
|
||||
System.out.print(MainCommand.getInstance() + " mc");
|
||||
System.out.print(MainCommand.getInstance().getCommands() + " gc");
|
||||
ArrayList<Command<PlotPlayer>> commands = MainCommand.getInstance().getCommands();
|
||||
String best = new StringComparison(strings[0], commands).getBestMatch();
|
||||
tabOptions.add(best);
|
||||
|
@ -3,6 +3,7 @@ package com.plotsquared.general.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -51,7 +52,8 @@ public class CommandManager<T extends CommandCaller> {
|
||||
}
|
||||
|
||||
final public ArrayList<Command<T>> getCommands() {
|
||||
ArrayList<Command<T>> result = new ArrayList<>(this.commands.values());
|
||||
HashSet<Command<T>> set = new HashSet<>(this.commands.values());
|
||||
ArrayList<Command<T>> result = new ArrayList<>(set);
|
||||
Collections.sort(result, new Comparator<Command<T>>() {
|
||||
@Override
|
||||
public int compare(Command<T> a, Command<T> b) {
|
||||
|
@ -33,7 +33,7 @@ public class SpongeCommand implements CommandCallable {
|
||||
catch (Exception e) {
|
||||
pp = ConsolePlayer.getConsole();
|
||||
}
|
||||
if (MainCommand.onCommand(pp, cmd.getName(), string.split(" "))) {
|
||||
if (MainCommand.onCommand(pp, cmd.getName(), string.length() == 0 ? new String[] {} : string.split(" "))) {
|
||||
return CommandResult.success();
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user