mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 23:26:45 +01:00
Fix errors
This commit is contained in:
parent
56fbeb60e5
commit
ed7a720470
@ -24,6 +24,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
@ -31,6 +33,7 @@ import com.intellectualcrafters.plot.generator.PlotGenerator;
|
|||||||
import com.intellectualsites.commands.CommandDeclaration;
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.CommandCaller;
|
import com.intellectualsites.commands.CommandCaller;
|
||||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||||
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import com.plotsquared.bukkit.generator.HybridGen;
|
import com.plotsquared.bukkit.generator.HybridGen;
|
||||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
@ -43,6 +46,8 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
|
import com.plotsquared.bukkit.util.SetupUtils;
|
||||||
import com.plotsquared.bukkit.util.UUIDHandler;
|
import com.plotsquared.bukkit.util.UUIDHandler;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
@ -155,11 +160,18 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final String gen_string = PS.get().config.getString("worlds." + world + "." + "generator.plugin");
|
final String gen_string = PS.get().config.getString("worlds." + world + "." + "generator.plugin");
|
||||||
PlotGenerator generator;
|
BukkitPlotGenerator generator;
|
||||||
if (gen_string == null) {
|
if (gen_string == null) {
|
||||||
generator = new HybridGen(world);
|
generator = new HybridGen(world);
|
||||||
} else {
|
} else {
|
||||||
generator = (PlotGenerator) PS.get().IMP.getGenerator(world, gen_string);
|
ChunkGenerator chunkgen = (ChunkGenerator) PS.get().IMP.getGenerator(world, gen_string).generator;
|
||||||
|
if (chunkgen instanceof BukkitPlotGenerator) {
|
||||||
|
generator = (BukkitPlotGenerator) chunkgen;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MainUtil.sendMessage(plr, C.SETUP_INVALID_GENERATOR, StringMan.join(SetupUtils.generators.keySet(), ","));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
new AugmentedPopulator(world, generator, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2);
|
new AugmentedPopulator(world, generator, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2);
|
||||||
}
|
}
|
||||||
|
@ -1,124 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
|
||||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
|
||||||
// /
|
|
||||||
// This program is free software; you can redistribute it and/or modify /
|
|
||||||
// it under the terms of the GNU General Public License as published by /
|
|
||||||
// the Free Software Foundation; either version 3 of the License, or /
|
|
||||||
// (at your option) any later version. /
|
|
||||||
// /
|
|
||||||
// This program is distributed in the hope that it will be useful, /
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
|
||||||
// GNU General Public License for more details. /
|
|
||||||
// /
|
|
||||||
// You should have received a copy of the GNU General Public License /
|
|
||||||
// along with this program; if not, write to the Free Software Foundation, /
|
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
|
||||||
// /
|
|
||||||
// You can contact us via: support@intellectualsites.com /
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
|
||||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
|
||||||
import com.intellectualsites.commands.CommandDeclaration;
|
|
||||||
import com.intellectualsites.commands.CommandCaller;
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
|
||||||
import com.plotsquared.bukkit.generator.HybridGen;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
|
||||||
|
|
||||||
@CommandDeclaration(
|
|
||||||
command = "setup",
|
|
||||||
permission = "plots.admin.command.setup",
|
|
||||||
description = "Plotworld setup command",
|
|
||||||
usage = "/plot setup",
|
|
||||||
aliases = {"create"},
|
|
||||||
category = CommandCategory.ACTIONS
|
|
||||||
)
|
|
||||||
public class DebugSetup extends SubCommand {
|
|
||||||
|
|
||||||
public void displayGenerators(PlotPlayer plr) {
|
|
||||||
StringBuffer message = new StringBuffer();
|
|
||||||
message.append("&6What generator do you want?");
|
|
||||||
for (Entry<String, ChunkGenerator> entry : SetupUtils.generators.entrySet()) {
|
|
||||||
if (entry.getKey().equals("PlotSquared")) {
|
|
||||||
message.append("\n&8 - &2" + entry.getKey() + " (Default Generator)");
|
|
||||||
}
|
|
||||||
else if (entry.getValue() instanceof HybridGen) {
|
|
||||||
message.append("\n&8 - &7" + entry.getKey() + " (Hybrid Generator)");
|
|
||||||
}
|
|
||||||
else if (entry.getValue() instanceof PlotGenerator) {
|
|
||||||
message.append("\n&8 - &7" + entry.getKey() + " (Plot Generator)");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
message.append("\n&8 - &7" + entry.getKey() + " (Unknown structure)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MainUtil.sendMessage(plr, message.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
|
||||||
final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
|
||||||
// going through setup
|
|
||||||
String name;
|
|
||||||
if (plr == null) {
|
|
||||||
name = "*";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
name = plr.getName();
|
|
||||||
}
|
|
||||||
if (!SetupUtils.setupMap.containsKey(name)) {
|
|
||||||
final SetupObject object = new SetupObject();
|
|
||||||
SetupUtils.setupMap.put(name, object);
|
|
||||||
SetupUtils.manager.updateGenerators();
|
|
||||||
sendMessage(plr, C.SETUP_INIT);
|
|
||||||
displayGenerators(plr);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
if (args[0].equalsIgnoreCase("cancel")) {
|
|
||||||
SetupUtils.setupMap.remove(name);
|
|
||||||
MainUtil.sendMessage(plr, "&aCancelled setup");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("back")) {
|
|
||||||
final SetupObject object = SetupUtils.setupMap.get(name);
|
|
||||||
if (object.setup_index > 0) {
|
|
||||||
object.setup_index--;
|
|
||||||
final ConfigurationNode node = object.step[object.setup_index];
|
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", node.getDescription(), node.getType().getType(), node.getDefaultValue() + "");
|
|
||||||
return false;
|
|
||||||
} else if (object.current > 0) {
|
|
||||||
object.current--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final SetupObject object = SetupUtils.setupMap.get(name);
|
|
||||||
final int index = object.current;
|
|
||||||
switch (index) {
|
|
||||||
case 0: { // choose plot manager // skip if 1 option
|
|
||||||
}
|
|
||||||
case 1: { // choose type (default, augmented, cluster)
|
|
||||||
}
|
|
||||||
case 2: { // Choose generator (vanilla, non plot generator) // skip if one option
|
|
||||||
}
|
|
||||||
case 3: { // world setup // skip if one option
|
|
||||||
}
|
|
||||||
case 4: { // world name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.config.Settings;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.intellectualsites.commands.Argument;
|
import com.intellectualsites.commands.Argument;
|
||||||
import com.intellectualsites.commands.Command;
|
import com.intellectualsites.commands.Command;
|
||||||
import com.intellectualsites.commands.CommandHandlingOutput;
|
import com.intellectualsites.commands.CommandHandlingOutput;
|
||||||
@ -93,9 +94,9 @@ public class MainCommand extends CommandManager {
|
|||||||
|
|
||||||
public static List<Command> getCommands(final CommandCategory category, final PlotPlayer player) {
|
public static List<Command> getCommands(final CommandCategory category, final PlotPlayer player) {
|
||||||
final List<Command> cmds = new ArrayList<>();
|
final List<Command> cmds = new ArrayList<>();
|
||||||
for (final Command c : instance.commands) {
|
for (final Command c : instance.commands.values()) {
|
||||||
if (!c.getRequiredType().equals(PlotPlayer.class)) {
|
if (c.getRequiredType().isInstance(PlotPlayer.class)) {
|
||||||
if ((c.getCategory().equals(category)) && player.hasPermission(c.getPermission())) {
|
if ((category == null || (c.getCategory().equals(category))) && player.hasPermission(c.getPermission())) {
|
||||||
cmds.add(c);
|
cmds.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,11 +106,7 @@ public class MainCommand extends CommandManager {
|
|||||||
|
|
||||||
public static List<String> helpMenu(final PlotPlayer player, final CommandCategory category, int page) {
|
public static List<String> helpMenu(final PlotPlayer player, final CommandCategory category, int page) {
|
||||||
List<Command> commands;
|
List<Command> commands;
|
||||||
if (category != null) {
|
|
||||||
commands = getCommands(category, player);
|
commands = getCommands(category, player);
|
||||||
} else {
|
|
||||||
commands = instance.commands;
|
|
||||||
}
|
|
||||||
// final int totalPages = ((int) Math.ceil(12 * (commands.size()) /
|
// final int totalPages = ((int) Math.ceil(12 * (commands.size()) /
|
||||||
// 100));
|
// 100));
|
||||||
final int perPage = 5;
|
final int perPage = 5;
|
||||||
@ -130,8 +127,8 @@ public class MainCommand extends CommandManager {
|
|||||||
for (int x = start; x < max; x++) {
|
for (int x = start; x < max; x++) {
|
||||||
cmd = commands.get(x);
|
cmd = commands.get(x);
|
||||||
String s = C.HELP_ITEM.s();
|
String s = C.HELP_ITEM.s();
|
||||||
if (cmd.getAliases().length > 0) {
|
if (cmd.getAliases().size() > 0) {
|
||||||
s = s.replace("%alias%", cmd.getAliases()[0]);
|
s = s.replace("%alias%", StringMan.join(cmd.getAliases(), "|"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
s = s.replace("%alias%", "");
|
s = s.replace("%alias%", "");
|
||||||
@ -255,12 +252,7 @@ public class MainCommand extends CommandManager {
|
|||||||
System.arraycopy(parts, 1, args, 0, args.length);
|
System.arraycopy(parts, 1, args, 0, args.length);
|
||||||
}
|
}
|
||||||
Command cmd = null;
|
Command cmd = null;
|
||||||
for (Command c1 : this.commands) {
|
cmd = this.commands.get(command);
|
||||||
if (c1.getCommand().equalsIgnoreCase(command) || c1.getAliases().contains(command)) {
|
|
||||||
cmd = c1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cmd == null) {
|
if (cmd == null) {
|
||||||
caller.message(C.NOT_VALID_SUBCOMMAND);
|
caller.message(C.NOT_VALID_SUBCOMMAND);
|
||||||
{
|
{
|
||||||
|
@ -26,17 +26,17 @@ import java.util.List;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
|
||||||
import com.intellectualsites.commands.CommandDeclaration;
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.CommandCaller;
|
import com.intellectualsites.commands.CommandCaller;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import com.plotsquared.bukkit.generator.HybridGen;
|
import com.plotsquared.bukkit.generator.HybridGen;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
@ -63,7 +63,7 @@ public class Setup extends SubCommand {
|
|||||||
else if (entry.getValue() instanceof HybridGen) {
|
else if (entry.getValue() instanceof HybridGen) {
|
||||||
message.append("\n&8 - &7" + entry.getKey() + " (Hybrid Generator)");
|
message.append("\n&8 - &7" + entry.getKey() + " (Hybrid Generator)");
|
||||||
}
|
}
|
||||||
else if (entry.getValue() instanceof PlotGenerator) {
|
else if (entry.getValue() instanceof BukkitPlotGenerator) {
|
||||||
message.append("\n&8 - &7" + entry.getKey() + " (Plot Generator)");
|
message.append("\n&8 - &7" + entry.getKey() + " (Plot Generator)");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -131,7 +131,7 @@ public class Setup extends SubCommand {
|
|||||||
List<String> allTypes = Arrays.asList(new String[] { "default", "augmented", "partial"});
|
List<String> allTypes = Arrays.asList(new String[] { "default", "augmented", "partial"});
|
||||||
List<String> allDesc = Arrays.asList(new String[] { "Standard plot generation", "Plot generation with vanilla terrain", "Vanilla with clusters of plots"});
|
List<String> allDesc = Arrays.asList(new String[] { "Standard plot generation", "Plot generation with vanilla terrain", "Vanilla with clusters of plots"});
|
||||||
ArrayList<String> types = new ArrayList<>();
|
ArrayList<String> types = new ArrayList<>();
|
||||||
if (SetupUtils.generators.get(object.setupGenerator) instanceof PlotGenerator) {
|
if (SetupUtils.generators.get(object.setupGenerator) instanceof BukkitPlotGenerator) {
|
||||||
types.add("default");
|
types.add("default");
|
||||||
}
|
}
|
||||||
types.add("augmented");
|
types.add("augmented");
|
||||||
@ -157,8 +157,8 @@ public class Setup extends SubCommand {
|
|||||||
object.current++;
|
object.current++;
|
||||||
if (object.step == null) {
|
if (object.step == null) {
|
||||||
object.plotManager = object.setupGenerator;
|
object.plotManager = object.setupGenerator;
|
||||||
object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
||||||
((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);
|
((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);
|
||||||
}
|
}
|
||||||
if (object.step.length == 0) {
|
if (object.step.length == 0) {
|
||||||
object.current = 4;
|
object.current = 4;
|
||||||
@ -169,17 +169,17 @@ public class Setup extends SubCommand {
|
|||||||
final ConfigurationNode step = object.step[object.setup_index];
|
final ConfigurationNode step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
} else {
|
} else {
|
||||||
if (gen instanceof PlotGenerator) {
|
if (gen instanceof BukkitPlotGenerator) {
|
||||||
object.plotManager = object.setupGenerator;
|
object.plotManager = object.setupGenerator;
|
||||||
object.setupGenerator = null;
|
object.setupGenerator = null;
|
||||||
object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
||||||
((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);
|
((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
object.plotManager = "PlotSquared";
|
object.plotManager = "PlotSquared";
|
||||||
MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as PlotGenerator");
|
MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as BukkitPlotGenerator");
|
||||||
MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin");
|
MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin");
|
||||||
object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ROAD&8 - &7Terrain seperated by roads" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ROAD&8 - &7Terrain seperated by roads" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ public class Setup extends SubCommand {
|
|||||||
object.terrain = terrain.indexOf(args[0].toLowerCase());
|
object.terrain = terrain.indexOf(args[0].toLowerCase());
|
||||||
object.current++;
|
object.current++;
|
||||||
if (object.step == null) {
|
if (object.step == null) {
|
||||||
object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
||||||
}
|
}
|
||||||
final ConfigurationNode step = object.step[object.setup_index];
|
final ConfigurationNode step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
|
@ -2,6 +2,8 @@ package com.intellectualsites.commands;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@ -46,8 +48,24 @@ public class CommandManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public Collection<Command> getCommands() {
|
final public ArrayList<Command> getCommands() {
|
||||||
return this.commands.values();
|
ArrayList<Command> result = new ArrayList<>(this.commands.values());
|
||||||
|
Collections.sort(result, new Comparator<Command>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Command a, Command b) {
|
||||||
|
if (a == b) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (a == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (b == null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return a.getCommand().compareTo(b.getCommand());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int handle(CommandCaller caller, String input) {
|
public int handle(CommandCaller caller, String input) {
|
||||||
|
@ -3,10 +3,13 @@ package com.plotsquared.bukkit.commands;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
import com.intellectualsites.commands.Command;
|
import com.intellectualsites.commands.Command;
|
||||||
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
@ -48,27 +51,30 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (!command.getLabel().equalsIgnoreCase("plots")) {
|
if (!command.getLabel().equalsIgnoreCase("plots")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final List<String> tabOptions = new ArrayList<>();
|
final Set<String> tabOptions = new HashSet<>();
|
||||||
final String[] commands = new String[MainCommand.instance.getCommands().size()];
|
ArrayList<Command> commands = MainCommand.instance.getCommands();
|
||||||
for (int x = 0; x < MainCommand.instance.getCommands().size(); x++) {
|
|
||||||
commands[x] = MainCommand.instance.getCommands().get(x).getCommand();
|
|
||||||
}
|
|
||||||
String best = new StringComparison(strings[0], commands).getBestMatch();
|
String best = new StringComparison(strings[0], commands).getBestMatch();
|
||||||
tabOptions.add(best);
|
tabOptions.add(best);
|
||||||
final String arg = strings[0].toLowerCase();
|
final String arg = strings[0].toLowerCase();
|
||||||
for (final Command cmd : MainCommand.instance.getCommands()) {
|
for (final Command cmd : MainCommand.instance.getCommands()) {
|
||||||
if (!cmd.getCommand().equalsIgnoreCase(best)) {
|
String label = cmd.getCommand();
|
||||||
|
if (!label.equalsIgnoreCase(best)) {
|
||||||
|
if (label.startsWith(arg)) {
|
||||||
if (player.hasPermission(cmd.getPermission())) {
|
if (player.hasPermission(cmd.getPermission())) {
|
||||||
if (cmd.getCommand().startsWith(arg)) {
|
|
||||||
tabOptions.add(cmd.getCommand());
|
tabOptions.add(cmd.getCommand());
|
||||||
} else if (cmd.getAliases().length > 0 && cmd.getAliases()[0].startsWith(arg)) {
|
} else if (cmd.getAliases().size() > 0) {
|
||||||
tabOptions.add(cmd.getAliases()[0]);
|
for (String alias : cmd.getAliases()) {
|
||||||
|
if (alias.startsWith(arg)) {
|
||||||
|
tabOptions.add(label);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tabOptions.size() > 0) {
|
if (tabOptions.size() > 0) {
|
||||||
return tabOptions;
|
return new ArrayList<>(tabOptions);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user