mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-26 02:34:42 +02:00
Pull Captions methods into a Caption interface.
This commit is contained in:
@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.api;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||||
@ -164,7 +165,7 @@ import java.util.UUID;
|
|||||||
* @see #sendConsoleMessage(String)
|
* @see #sendConsoleMessage(String)
|
||||||
* @see Captions
|
* @see Captions
|
||||||
*/
|
*/
|
||||||
public void sendConsoleMessage(Captions caption) {
|
public void sendConsoleMessage(Caption caption) {
|
||||||
sendConsoleMessage(caption.getTranslated());
|
sendConsoleMessage(caption.getTranslated());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import com.github.intellectualsites.plotsquared.configuration.MemorySection;
|
|||||||
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
||||||
import com.github.intellectualsites.plotsquared.configuration.serialization.ConfigurationSerialization;
|
import com.github.intellectualsites.plotsquared.configuration.serialization.ConfigurationSerialization;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.WE_Anywhere;
|
import com.github.intellectualsites.plotsquared.plot.commands.WE_Anywhere;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
@ -345,7 +346,8 @@ import java.util.zip.ZipInputStream;
|
|||||||
* @see IPlotMain#log(String)
|
* @see IPlotMain#log(String)
|
||||||
*/
|
*/
|
||||||
public static void log(Object message) {
|
public static void log(Object message) {
|
||||||
if (message == null || message.toString().isEmpty()) {
|
if (message == null || (message instanceof Caption ? ((Caption) message).getTranslated().isEmpty() :
|
||||||
|
message.toString().isEmpty())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PlotSquared.get() == null || PlotSquared.get().getLogger() == null) {
|
if (PlotSquared.get() == null || PlotSquared.get().getLogger() == null) {
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.config;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.commands.CommandCaller;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
|
|
||||||
|
public interface Caption {
|
||||||
|
|
||||||
|
String getTranslated();
|
||||||
|
|
||||||
|
default String formatted() {
|
||||||
|
return StringMan.replaceFromMap(getTranslated(), Captions.replacements);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void send(CommandCaller caller, String... args) {
|
||||||
|
send(caller, (Object[]) args);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void send(CommandCaller caller, Object... args) {
|
||||||
|
String msg = CaptionUtility.format(this, args);
|
||||||
|
if (caller == null) {
|
||||||
|
PlotSquared.log(msg);
|
||||||
|
} else {
|
||||||
|
caller.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean usePrefix();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.config;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class CaptionUtility {
|
||||||
|
|
||||||
|
public static String format(String message, Object... args) {
|
||||||
|
if (args.length == 0) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
Map<String, String> map = new LinkedHashMap<>();
|
||||||
|
for (int i = args.length - 1; i >= 0; i--) {
|
||||||
|
String arg = "" + args[i];
|
||||||
|
if (arg.isEmpty()) {
|
||||||
|
map.put("%s" + i, "");
|
||||||
|
} else {
|
||||||
|
arg = Captions.color(arg);
|
||||||
|
map.put("%s" + i, arg);
|
||||||
|
}
|
||||||
|
if (i == 0) {
|
||||||
|
map.put("%s", arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message = StringMan.replaceFromMap(message, map);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String format(Caption caption, Object... args) {
|
||||||
|
if (caption.usePrefix() && caption.getTranslated().length() > 0) {
|
||||||
|
return Captions.PREFIX.getTranslated() + format(caption.getTranslated(), args);
|
||||||
|
} else {
|
||||||
|
return format(caption.getTranslated(), args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.config;
|
package com.github.intellectualsites.plotsquared.plot.config;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.CommandCaller;
|
|
||||||
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
|
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
|
||||||
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
@ -11,14 +10,12 @@ import java.io.IOException;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Captions class.
|
* Captions class.
|
||||||
*/
|
*/
|
||||||
public enum Captions {
|
public enum Captions implements Caption {
|
||||||
|
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
//<editor-fold desc="Static Flags">
|
//<editor-fold desc="Static Flags">
|
||||||
@ -659,35 +656,6 @@ public enum Captions {
|
|||||||
this(defaultString, true, category.toLowerCase());
|
this(defaultString, true, category.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String format(String message, Object... args) {
|
|
||||||
if (args.length == 0) {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
Map<String, String> map = new LinkedHashMap<>();
|
|
||||||
for (int i = args.length - 1; i >= 0; i--) {
|
|
||||||
String arg = "" + args[i];
|
|
||||||
if (arg.isEmpty()) {
|
|
||||||
map.put("%s" + i, "");
|
|
||||||
} else {
|
|
||||||
arg = Captions.color(arg);
|
|
||||||
map.put("%s" + i, arg);
|
|
||||||
}
|
|
||||||
if (i == 0) {
|
|
||||||
map.put("%s", arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
message = StringMan.replaceFromMap(message, map);
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String format(Captions caption, Object... args) {
|
|
||||||
if (caption.usePrefix() && caption.translatedString.length() > 0) {
|
|
||||||
return Captions.PREFIX.getTranslated() + format(caption.translatedString, args);
|
|
||||||
} else {
|
|
||||||
return format(caption.translatedString, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String color(String string) {
|
public static String color(String string) {
|
||||||
return StringMan.replaceFromMap(string, replacements);
|
return StringMan.replaceFromMap(string, replacements);
|
||||||
}
|
}
|
||||||
@ -778,11 +746,7 @@ public enum Captions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String toString() {
|
@Override public String getTranslated() {
|
||||||
return this.translatedString;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTranslated() {
|
|
||||||
return this.translatedString;
|
return this.translatedString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,24 +754,8 @@ public enum Captions {
|
|||||||
return this.prefix;
|
return this.prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String formatted() {
|
|
||||||
return StringMan.replaceFromMap(getTranslated(), replacements);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCategory() {
|
public String getCategory() {
|
||||||
return this.category;
|
return this.category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(CommandCaller caller, String... args) {
|
|
||||||
send(caller, (Object[]) args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void send(CommandCaller caller, Object... args) {
|
|
||||||
String msg = format(this, args);
|
|
||||||
if (caller == null) {
|
|
||||||
PlotSquared.log(msg);
|
|
||||||
} else {
|
|
||||||
caller.sendMessage(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.config;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor public final class StaticCaption implements Caption {
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
private final boolean usePrefix;
|
||||||
|
|
||||||
|
public StaticCaption(final String value) {
|
||||||
|
this(value, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public String getTranslated() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean usePrefix() {
|
||||||
|
return this.usePrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.flags;
|
package com.github.intellectualsites.plotsquared.plot.flags;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
|
|
||||||
public class FlagParseException extends Exception {
|
public class FlagParseException extends Exception {
|
||||||
|
|
||||||
private final PlotFlag<?> flag;
|
private final PlotFlag<?, ?> flag;
|
||||||
private final String value;
|
private final String value;
|
||||||
private final Captions errorMessage;
|
private final Caption errorMessage;
|
||||||
|
|
||||||
public FlagParseException(final PlotFlag<?> flag, final String value, final Captions errorMessage) {
|
public FlagParseException(final PlotFlag<?, ?> flag, final String value, final Caption errorMessage) {
|
||||||
super(String.format("Failed to parse flag of type '%s'. Value '%s' was not accepted.",
|
super(String.format("Failed to parse flag of type '%s'. Value '%s' was not accepted.",
|
||||||
flag.getName(), value));
|
flag.getName(), value));
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
@ -30,11 +30,11 @@ public class FlagParseException extends Exception {
|
|||||||
*
|
*
|
||||||
* @return Flag that threw the exception
|
* @return Flag that threw the exception
|
||||||
*/
|
*/
|
||||||
public PlotFlag<?> getFlag() {
|
public PlotFlag<?, ?> getFlag() {
|
||||||
return this.flag;
|
return this.flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Captions getErrorMessage() {
|
public Caption getErrorMessage() {
|
||||||
return errorMessage;
|
return errorMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.flags;
|
package com.github.intellectualsites.plotsquared.plot.flags;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -17,16 +17,16 @@ import java.util.Locale;
|
|||||||
@EqualsAndHashCode(of = "value") public abstract class PlotFlag<T, F extends PlotFlag<T, F>> {
|
@EqualsAndHashCode(of = "value") public abstract class PlotFlag<T, F extends PlotFlag<T, F>> {
|
||||||
|
|
||||||
private final T value;
|
private final T value;
|
||||||
private final Captions flagCategory;
|
private final Caption flagCategory;
|
||||||
private final Captions flagDescription;
|
private final Caption flagDescription;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new flag instance.
|
* Construct a new flag instance.
|
||||||
*
|
*
|
||||||
* @param value Flag value
|
* @param value Flag value
|
||||||
*/
|
*/
|
||||||
protected PlotFlag(@NotNull final T value, @NotNull final Captions flagCategory,
|
protected PlotFlag(@NotNull final T value, @NotNull final Caption flagCategory,
|
||||||
@NotNull final Captions flagDescription) {
|
@NotNull final Caption flagDescription) {
|
||||||
this.value = Preconditions.checkNotNull(value, "flag value may not be null");
|
this.value = Preconditions.checkNotNull(value, "flag value may not be null");
|
||||||
this.flagCategory = Preconditions.checkNotNull(flagCategory, "flag category may not be null");
|
this.flagCategory = Preconditions.checkNotNull(flagCategory, "flag category may not be null");
|
||||||
this.flagDescription = Preconditions.checkNotNull(flagDescription, "flag description may not be null");
|
this.flagDescription = Preconditions.checkNotNull(flagDescription, "flag description may not be null");
|
||||||
@ -74,11 +74,11 @@ import java.util.Locale;
|
|||||||
return this.getClass().getSimpleName().toLowerCase(Locale.ENGLISH);
|
return this.getClass().getSimpleName().toLowerCase(Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Captions getFlagDescription() {
|
public Caption getFlagDescription() {
|
||||||
return this.flagDescription;
|
return this.flagDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Captions getFlagCategory() {
|
public Caption getFlagCategory() {
|
||||||
return this.flagCategory;
|
return this.flagCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.flags.types;
|
package com.github.intellectualsites.plotsquared.plot.flags.types;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
|
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
|
||||||
@ -12,7 +13,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class BlockTypeListFlag extends ListFlag<BlockType, BlockTypeListFlag> {
|
public class BlockTypeListFlag extends ListFlag<BlockType, BlockTypeListFlag> {
|
||||||
|
|
||||||
public BlockTypeListFlag(List<BlockType> blockTypeList, Captions description) {
|
public BlockTypeListFlag(List<BlockType> blockTypeList, Caption description) {
|
||||||
super(blockTypeList, Captions.FLAG_CATEGORY_BLOCK_LIST, description);
|
super(blockTypeList, Captions.FLAG_CATEGORY_BLOCK_LIST, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.flags.types;
|
package com.github.intellectualsites.plotsquared.plot.flags.types;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
|
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
@ -20,7 +21,7 @@ public abstract class BooleanFlag<F extends PlotFlag<Boolean, F>> extends PlotFl
|
|||||||
* @param value Flag value
|
* @param value Flag value
|
||||||
* @param description Flag description
|
* @param description Flag description
|
||||||
*/
|
*/
|
||||||
protected BooleanFlag(final boolean value, final Captions description) {
|
protected BooleanFlag(final boolean value, final Caption description) {
|
||||||
super(value, Captions.FLAG_CATEGORY_BOOLEAN, description);
|
super(value, Captions.FLAG_CATEGORY_BOOLEAN, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.flags.types;
|
package com.github.intellectualsites.plotsquared.plot.flags.types;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
|
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
@ -7,11 +8,11 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class IntegerFlag extends PlotFlag<Integer, IntegerFlag> {
|
public class IntegerFlag extends PlotFlag<Integer, IntegerFlag> {
|
||||||
|
|
||||||
protected IntegerFlag(final int value, @NotNull Captions flagDescription) {
|
protected IntegerFlag(final int value, @NotNull Caption flagDescription) {
|
||||||
super(value, Captions.FLAG_CATEGORY_INTEGERS, flagDescription);
|
super(value, Captions.FLAG_CATEGORY_INTEGERS, flagDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IntegerFlag(@NotNull Captions flagDescription) {
|
protected IntegerFlag(@NotNull Caption flagDescription) {
|
||||||
this(0, flagDescription);
|
this(0, flagDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.flags.types;
|
package com.github.intellectualsites.plotsquared.plot.flags.types;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
@ -10,7 +11,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public abstract class ListFlag<V, F extends PlotFlag<List<V>, F>> extends PlotFlag<List<V>, F> {
|
public abstract class ListFlag<V, F extends PlotFlag<List<V>, F>> extends PlotFlag<List<V>, F> {
|
||||||
|
|
||||||
public ListFlag(final List<V> valueList, final Captions category, final Captions description) {
|
public ListFlag(final List<V> valueList, final Captions category, final Caption description) {
|
||||||
super(valueList, category, description);
|
super(valueList, category, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ package com.github.intellectualsites.plotsquared.plot.util;
|
|||||||
import com.github.intellectualsites.plotsquared.commands.CommandCaller;
|
import com.github.intellectualsites.plotsquared.commands.CommandCaller;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.Like;
|
import com.github.intellectualsites.plotsquared.plot.commands.Like;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||||
@ -640,7 +642,7 @@ public class MainUtil {
|
|||||||
* @param caption the message to send
|
* @param caption the message to send
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
public static boolean sendMessage(CommandCaller player, Captions caption, String... args) {
|
public static boolean sendMessage(CommandCaller player, Caption caption, String... args) {
|
||||||
return sendMessage(player, caption, (Object[]) args);
|
return sendMessage(player, caption, (Object[]) args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,13 +653,13 @@ public class MainUtil {
|
|||||||
* @param caption the message to send
|
* @param caption the message to send
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
public static boolean sendMessage(final CommandCaller player, final Captions caption,
|
public static boolean sendMessage(final CommandCaller player, final Caption caption,
|
||||||
final Object... args) {
|
final Object... args) {
|
||||||
if (caption.getTranslated().isEmpty()) {
|
if (caption.getTranslated().isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
String m = Captions.format(caption, args);
|
String m = CaptionUtility.format(caption, args);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
PlotSquared.log(m);
|
PlotSquared.log(m);
|
||||||
} else {
|
} else {
|
||||||
@ -789,7 +791,7 @@ public class MainUtil {
|
|||||||
value = df.format(value);
|
value = df.format(value);
|
||||||
}
|
}
|
||||||
flags.append(prefix)
|
flags.append(prefix)
|
||||||
.append(Captions
|
.append(CaptionUtility
|
||||||
.format(Captions.PLOT_FLAG_LIST.getTranslated(), entry.getKey().getName(),
|
.format(Captions.PLOT_FLAG_LIST.getTranslated(), entry.getKey().getName(),
|
||||||
value));
|
value));
|
||||||
prefix = ", ";
|
prefix = ", ";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util;
|
package com.github.intellectualsites.plotsquared.plot.util;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
@ -51,6 +52,9 @@ public class StringMan {
|
|||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
return (String) obj;
|
return (String) obj;
|
||||||
}
|
}
|
||||||
|
if (obj instanceof Caption) {
|
||||||
|
return ((Caption) obj).getTranslated();
|
||||||
|
}
|
||||||
if (obj.getClass().isArray()) {
|
if (obj.getClass().isArray()) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
|
Reference in New Issue
Block a user