diff --git a/Core/src/main/java/com/plotsquared/core/command/Debug.java b/Core/src/main/java/com/plotsquared/core/command/Debug.java index 3d847247b..2223db91f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Debug.java +++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java @@ -28,9 +28,9 @@ package com.plotsquared.core.command; import com.google.inject.Inject; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.caption.Caption; +import com.plotsquared.core.configuration.caption.LocaleHolder; import com.plotsquared.core.configuration.caption.StaticCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption; -import com.plotsquared.core.player.ConsolePlayer; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.StringMan; @@ -88,6 +88,7 @@ public class Debug extends SubCommand { .getValue() .toString() + " , ")); } + return true; } } if (args.length > 0 && "loadedchunks".equalsIgnoreCase(args[0])) { @@ -151,12 +152,12 @@ public class Debug extends SubCommand { Set captions = PlotSquared .get() .getCaptionMap(TranslatableCaption.DEFAULT_NAMESPACE) - .getCaptions() - .keySet(); + .getCaptions(); if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) { StringBuilder msg = new StringBuilder(); + LocaleHolder localeHolder = args.length > 1 && "own".equalsIgnoreCase(args[1]) ? player : LocaleHolder.console(); for (Caption caption : captions) { - msg.append(caption.getComponent(ConsolePlayer.getConsole())).append("\n"); + msg.append(caption.getComponent(localeHolder)).append("\n"); } player.sendMessage(StaticCaption.of(msg.toString())); return true; @@ -190,7 +191,7 @@ public class Debug extends SubCommand { Template.of("var", "View all captions"), Template.of("val", "/plot debug msg") )); - player.sendMessage(StaticCaption.of(information.toString())); + player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(information.build()))); return true; } diff --git a/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionMap.java b/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionMap.java index ef7729e88..1151dad9d 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionMap.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionMap.java @@ -28,7 +28,7 @@ package com.plotsquared.core.configuration.caption; import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Locale; -import java.util.Map; +import java.util.Set; /** * Map containing mappings between {@link TranslatableCaption captions} and @@ -43,7 +43,7 @@ public interface CaptionMap { * @return Component * @throws NoSuchCaptionException if no caption with the given key exists */ - @NonNull String getMessage(@NonNull TranslatableCaption caption) throws NoSuchCaptionException; + @NonNull String getMessage(final @NonNull TranslatableCaption caption) throws NoSuchCaptionException; /** * Get a message using a specific locale @@ -53,7 +53,7 @@ public interface CaptionMap { * @return Component * @throws NoSuchCaptionException if no caption with the given key exists */ - @NonNull String getMessage(@NonNull TranslatableCaption caption, @NonNull LocaleHolder localeHolder) throws + @NonNull String getMessage(final @NonNull TranslatableCaption caption, final @NonNull LocaleHolder localeHolder) throws NoSuchCaptionException; /** @@ -62,7 +62,7 @@ public interface CaptionMap { * @param locale Locale * @return True if the map supports the locale */ - boolean supportsLocale(@NonNull Locale locale); + boolean supportsLocale(final @NonNull Locale locale); /** * Get the locale of the messages stored in the map @@ -72,11 +72,11 @@ public interface CaptionMap { @NonNull Locale getLocale(); /** - * Gets a copy of the map of captions stored in the CaptionMap + * Gets a copy of the set of captions stored in the CaptionMap * - * @return ImmutableMap of TranslatableCaption, String captionMap + * @return An immutable set of TranslatableCaption */ - @NonNull Map getCaptions(); + @NonNull Set getCaptions(); class NoSuchCaptionException extends IllegalArgumentException { diff --git a/Core/src/main/java/com/plotsquared/core/configuration/caption/DummyCaptionMap.java b/Core/src/main/java/com/plotsquared/core/configuration/caption/DummyCaptionMap.java index c4d8bf0a6..36c62083d 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/caption/DummyCaptionMap.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/caption/DummyCaptionMap.java @@ -27,9 +27,9 @@ package com.plotsquared.core.configuration.caption; import org.checkerframework.checker.nullness.qual.NonNull; -import java.util.HashMap; +import java.util.Collections; import java.util.Locale; -import java.util.Map; +import java.util.Set; /** * {@link CaptionMap} implementation that throws exception on all getters @@ -60,10 +60,9 @@ public class DummyCaptionMap implements CaptionMap { throw new UnsupportedOperationException("Cannot get locale of DummyCaptionMap"); } - @NonNull @Override - public Map getCaptions() { - return new HashMap<>(); + public @NonNull Set getCaptions() { + return Collections.emptySet(); } } diff --git a/Core/src/main/java/com/plotsquared/core/configuration/caption/LocalizedCaptionMap.java b/Core/src/main/java/com/plotsquared/core/configuration/caption/LocalizedCaptionMap.java index 3e2ac0544..207715766 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/caption/LocalizedCaptionMap.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/caption/LocalizedCaptionMap.java @@ -25,11 +25,12 @@ */ package com.plotsquared.core.configuration.caption; -import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Locale; import java.util.Map; +import java.util.Set; public class LocalizedCaptionMap implements CaptionMap { @@ -68,10 +69,9 @@ public class LocalizedCaptionMap implements CaptionMap { return this.locale; } - @NonNull @Override - public Map getCaptions() { - return ImmutableMap.copyOf(captions); + public @NonNull Set getCaptions() { + return ImmutableSet.copyOf(this.captions.keySet()); } } diff --git a/Core/src/main/java/com/plotsquared/core/configuration/caption/PerUserLocaleCaptionMap.java b/Core/src/main/java/com/plotsquared/core/configuration/caption/PerUserLocaleCaptionMap.java index 8b5a97bf8..4b1686473 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/caption/PerUserLocaleCaptionMap.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/caption/PerUserLocaleCaptionMap.java @@ -25,11 +25,13 @@ */ package com.plotsquared.core.configuration.caption; +import com.google.common.collect.ImmutableSet; import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Collections; import java.util.Locale; import java.util.Map; +import java.util.Set; public class PerUserLocaleCaptionMap extends LocalizedCaptionMap { @@ -53,4 +55,9 @@ public class PerUserLocaleCaptionMap extends LocalizedCaptionMap { return this.localeMap.containsKey(locale); } + @Override + public @NonNull Set getCaptions() { + return ImmutableSet.copyOf(this.localeMap.get(LocaleHolder.console().getLocale()).getCaptions()); + } + }