mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 11:45:19 +01:00
Fix several issues with debug command
This commit is contained in:
parent
46fbc05040
commit
1172e02f1b
@ -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<TranslatableCaption> 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;
|
||||
}
|
||||
|
||||
|
@ -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<TranslatableCaption, String> getCaptions();
|
||||
@NonNull Set<TranslatableCaption> getCaptions();
|
||||
|
||||
class NoSuchCaptionException extends IllegalArgumentException {
|
||||
|
||||
|
@ -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<TranslatableCaption, String> getCaptions() {
|
||||
return new HashMap<>();
|
||||
public @NonNull Set<TranslatableCaption> getCaptions() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<TranslatableCaption, String> getCaptions() {
|
||||
return ImmutableMap.copyOf(captions);
|
||||
public @NonNull Set<TranslatableCaption> getCaptions() {
|
||||
return ImmutableSet.copyOf(this.captions.keySet());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<TranslatableCaption> getCaptions() {
|
||||
return ImmutableSet.copyOf(this.localeMap.get(LocaleHolder.console().getLocale()).getCaptions());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user