Add plot debugging and make tab completable aliases configurable

This commit is contained in:
Alexander Söderberg
2020-06-23 11:39:45 +02:00
parent 2d6e6ceaeb
commit 2b4e2fc793
8 changed files with 78 additions and 19 deletions

View File

@ -72,6 +72,13 @@ public class Debug extends SubCommand {
MainUtil.sendMessage(player, String.format("There are %d cached UUIDs", mappings.size()));
return true;
}
if (args.length > 0 && "debug-players".equalsIgnoreCase(args[0])) {
MainUtil.sendMessage(player, "Player in debug mode: " );
for (final PlotPlayer<?> pp : PlotPlayer.getDebugModePlayers()) {
MainUtil.sendMessage(player, "- " + pp.getName());
}
return true;
}
if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) {
EntityCategories.init();
player.sendMessage(Captions.PREFIX.getTranslated() + "§cEntity Categories: ");

View File

@ -129,7 +129,7 @@ public class Toggle extends Command {
public void debug(Command command, PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) {
if (toggle(player, "debug")) {
if (!toggle(player, "debug")) {
MainUtil.sendMessage(player, Captions.TOGGLE_ENABLED, command.toString());
} else {
MainUtil.sendMessage(player, Captions.TOGGLE_DISABLED, command.toString());

View File

@ -805,7 +805,7 @@ public enum Captions implements Caption {
//</editor-fold>
//<editor-fold desc="Debug">
PLOT_DEBUG("$1Plot Debug ($2%plot%$1): %message%", "Plot-Debug"),
PLOT_DEBUG("$2Plot Debug ($1%plot%$2): %message%", "Plot-Debug"),
//</editor-fold>
/**

View File

@ -568,6 +568,8 @@ public class Settings extends Config {
"Read more about components here: https://wiki.intellectualsites.com/en/plotsquared/installation/plot-components"}) public static boolean COMPONENT_PRESETS = true;
@Comment("Use UUID cache to complete usernames")
public static boolean EXTENDED_USERNAME_COMPLETION = true;
@Comment("Command aliases that will be tab completed")
public static List<String> TAB_COMPLETED_ALIASES = Arrays.asList("plot", "plots", "p", "plotsquared", "plot2", "p2", "ps", "2", "plotme", "plotz", "ap");
}
}

View File

@ -87,7 +87,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
private ConcurrentHashMap<String, Object> meta;
private int hash;
public static <T> PlotPlayer from(@NonNull final T object) {
public static <T> PlotPlayer<T> from(@NonNull final T object) {
if (!converters.containsKey(object.getClass())) {
throw new IllegalArgumentException(String
.format("There is no registered PlotPlayer converter for type %s",
@ -101,7 +101,11 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
converters.put(clazz, converter);
}
public static Collection<PlotPlayer<?>> getDebugModePlayerInPlot(@NotNull final Plot plot) {
public static Collection<PlotPlayer<?>> getDebugModePlayers() {
return Collections.unmodifiableCollection(debugModeEnabled);
}
public static Collection<PlotPlayer<?>> getDebugModePlayersInPlot(@NotNull final Plot plot) {
if (debugModeEnabled.isEmpty()) {
return Collections.emptyList();
}

View File

@ -2925,7 +2925,7 @@ public class Plot {
}
public void debug(@NotNull final String message) {
final Collection<PlotPlayer<?>> players = PlotPlayer.getDebugModePlayerInPlot(this);
final Collection<PlotPlayer<?>> players = PlotPlayer.getDebugModePlayersInPlot(this);
if (players.isEmpty()) {
return;
}