mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Component progress. The plugin is **very** broken right now.
This commit is contained in:
parent
d061f728bd
commit
c8a8806e7d
@ -14,6 +14,7 @@ repositories {
|
||||
maven { url = "https://ci.ender.zone/plugin/repository/everything/" }
|
||||
maven { url = "https://mvn.intellectualsites.com/content/repositories/snapshots" }
|
||||
maven { url = "https://repo.wea-ondara.net/repository/public/" }
|
||||
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
@ -35,7 +36,8 @@ dependencies {
|
||||
implementation("net.luckperms:api:5.1")
|
||||
implementation("net.ess3:EssentialsX:2.17.2")
|
||||
implementation("net.alpenblock:BungeePerms:4.0-dev-106")
|
||||
implementation("net.kyori:adventure-text-platform-bukkit:4.0.0-SNAPSHOT")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT")
|
||||
implementation('net.kyori:adventure-text-minimessage:3.0.0-SNAPSHOT')
|
||||
compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false }
|
||||
compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false }
|
||||
}
|
||||
@ -92,7 +94,8 @@ shadowJar {
|
||||
dependencies {
|
||||
include(dependency(":PlotSquared-Core"))
|
||||
include(dependency("io.papermc:paperlib:1.0.2"))
|
||||
include(dependency("net.kyori:adventure-text-platform-bukkit:4.0.0-SNAPSHOT"))
|
||||
include(dependency("net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT"))
|
||||
include(dependency("net.kyori:adventure-text-minimessage:3.0.0-SNAPSHOT"))
|
||||
include(dependency("org.bstats:bstats-bukkit:1.7"))
|
||||
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
|
||||
include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT"))
|
||||
|
@ -26,24 +26,28 @@
|
||||
package com.plotsquared.bukkit.player;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Objects;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Caption;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.configuration.caption.VariableReplacement;
|
||||
import com.plotsquared.core.events.TeleportCause;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.PlotWeather;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
import com.plotsquared.core.util.MathMan;
|
||||
import com.plotsquared.core.util.StringMan;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.WeatherType;
|
||||
@ -67,6 +71,9 @@ import static com.sk89q.worldedit.world.gamemode.GameModes.SURVIVAL;
|
||||
|
||||
public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
|
||||
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
|
||||
private static final BukkitAudiences BUKKIT_AUDIENCES = BukkitAudiences.create(BukkitMain.getPlugin(BukkitMain.class));
|
||||
|
||||
private static boolean CHECK_EFFECTIVE = true;
|
||||
public final Player player;
|
||||
private boolean offline;
|
||||
@ -228,17 +235,13 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
}
|
||||
|
||||
@Override public void sendMessage(@NotNull final Caption caption,
|
||||
@NotNull final VariableReplacement... replacements) {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated @Override public void sendMessage(String message) {
|
||||
message = message.replace('\u2010', '%').replace('\u2020', '&').replace('\u2030', '&');
|
||||
if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (
|
||||
System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
|
||||
setMeta("lastMessage", message);
|
||||
@NotNull final Template... replacements) {
|
||||
// TODO: Inject the prefix here
|
||||
final Component component = MINI_MESSAGE.parse(caption.getComponent(this), replacements);
|
||||
if (!Objects.equal(component, this.getMeta("lastMessage")) || System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000) {
|
||||
setMeta("lastMessage", component);
|
||||
setMeta("lastMessageTime", System.currentTimeMillis());
|
||||
this.player.sendMessage(message);
|
||||
BUKKIT_AUDIENCES.player(player).sendMessage(component);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
repositories {
|
||||
maven { url = "https://jitpack.io" }
|
||||
maven { url = "https://mvn.intellectualsites.com/content/repositories/snapshots" }
|
||||
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
}
|
||||
def textVersion = "3.0.2"
|
||||
|
||||
|
@ -33,7 +33,6 @@ import com.plotsquared.core.configuration.CaptionUtility;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||
import com.plotsquared.core.configuration.caption.LegacyCaptionMap;
|
||||
import com.plotsquared.core.configuration.MemorySection;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.configuration.Storage;
|
||||
@ -234,13 +233,6 @@ public class PlotSquared {
|
||||
String fileName = "messages_" + Settings.Enabled_Components.DEFAULT_LOCALE + ".json";
|
||||
captionMap = CaptionLoader.loadSingle(Paths.get("lang", fileName));
|
||||
}
|
||||
if (Settings.Enabled_Components.LEGACY_MESSAGES) {
|
||||
this.translationFile = MainUtil.getFile(this.IMP.getDirectory(),
|
||||
Settings.Paths.TRANSLATIONS + File.separator + IMP.getPluginName()
|
||||
+ ".use_THIS.yml");
|
||||
Captions.load(this.translationFile);
|
||||
captionMap = new LegacyCaptionMap(captionMap);
|
||||
}
|
||||
this.captionMap = captionMap;
|
||||
|
||||
// Setup plotAreaManager
|
||||
|
@ -26,26 +26,18 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.configuration.Caption;
|
||||
import com.plotsquared.core.configuration.caption.VariableReplacement;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface CommandCaller {
|
||||
|
||||
/**
|
||||
* Send the player a message.
|
||||
*
|
||||
* @param message the message to send
|
||||
* @deprecated Use static captions instead
|
||||
*/
|
||||
@Deprecated void sendMessage(String message);
|
||||
|
||||
/**
|
||||
* Send a message to the command caller
|
||||
*
|
||||
* @param caption Caption to send
|
||||
* @param replacements Variable replacements
|
||||
*/
|
||||
void sendMessage(@NotNull Caption caption, @NotNull VariableReplacement... replacements);
|
||||
void sendMessage(@NotNull Caption caption, @NotNull Template... replacements);
|
||||
|
||||
/**
|
||||
* Check the player's permissions. <i>Will be cached if permission caching is enabled.</i>
|
||||
|
@ -25,32 +25,20 @@
|
||||
*/
|
||||
package com.plotsquared.core.configuration;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.util.StringMan;
|
||||
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Any message that can be sent to a player, the console, etc.
|
||||
*/
|
||||
public interface Caption {
|
||||
|
||||
String getTranslated();
|
||||
|
||||
@Deprecated default String formatted() {
|
||||
return StringMan.replaceFromMap(getTranslated(), Captions.replacements);
|
||||
}
|
||||
|
||||
default boolean send(PlotPlayer caller, String... args) {
|
||||
return send(caller, (Object[]) args);
|
||||
}
|
||||
|
||||
default boolean send(PlotPlayer caller, Object... args) {
|
||||
String msg = CaptionUtility.format(caller, this, args);
|
||||
if (caller == null) {
|
||||
PlotSquared.log(msg);
|
||||
} else {
|
||||
caller.sendMessage(msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean usePrefix();
|
||||
/**
|
||||
* Get the message that should be sent to the recipient
|
||||
*
|
||||
* @param localeHolder Locale holder
|
||||
* @return Message
|
||||
*/
|
||||
@NotNull String getComponent(@NotNull LocaleHolder localeHolder);
|
||||
|
||||
}
|
||||
|
@ -573,8 +573,6 @@ public class Settings extends Config {
|
||||
PERSISTENT_ROAD_REGEN = false;
|
||||
@Comment({"Enable the `/plot component` preset GUI",
|
||||
"Read more about components here: https://wiki.intellectualsites.com/en/plotsquared/installation/plot-components"}) public static boolean COMPONENT_PRESETS = true;
|
||||
@Comment({"Use legacy messages (will be removed in future)",
|
||||
"It is recommended to use the new message system"}) public static boolean LEGACY_MESSAGES = true;
|
||||
@Comment("Enable per user locale") public static boolean PER_USER_LOCALE = false;
|
||||
@Comment("The default locale") public static String DEFAULT_LOCALE = "en";
|
||||
@Comment("Use UUID cache to complete usernames")
|
||||
|
@ -78,7 +78,7 @@ public final class CaptionLoader {
|
||||
JsonObject.class);
|
||||
Map<TranslatableCaption, String> captions = new HashMap<>();
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
TranslatableCaption key = TranslatableCaption.of(entry.getKey());
|
||||
TranslatableCaption key = TranslatableCaption.keyed(entry.getKey());
|
||||
captions.put(key, entry.getValue().getAsString());
|
||||
}
|
||||
return new LocalizedCaptionMap(locale, captions);
|
||||
|
@ -25,17 +25,57 @@
|
||||
*/
|
||||
package com.plotsquared.core.configuration.caption;
|
||||
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import net.kyori.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Map containing mappings between {@link TranslatableCaption captions} and
|
||||
* {@link Component components}
|
||||
*/
|
||||
public interface CaptionMap {
|
||||
|
||||
String getMessage(TranslatableCaption caption);
|
||||
/**
|
||||
* Get a message using the server locale
|
||||
*
|
||||
* @param caption Caption containing the caption key
|
||||
* @return Component
|
||||
* @throws NoSuchCaptionException if no caption with the given key exists
|
||||
*/
|
||||
@NotNull String getMessage(@NotNull TranslatableCaption caption) throws NoSuchCaptionException;
|
||||
|
||||
String getMessage(TranslatableCaption caption, PlotPlayer<?> context);
|
||||
/**
|
||||
* Get a message using a specific locale
|
||||
*
|
||||
* @param caption Caption containing the caption key
|
||||
* @param localeHolder Holder that determines the message locale
|
||||
* @return Component
|
||||
* @throws NoSuchCaptionException if no caption with the given key exists
|
||||
*/
|
||||
String getMessage(@NotNull TranslatableCaption caption, @NotNull LocaleHolder localeHolder) throws NoSuchCaptionException;
|
||||
|
||||
boolean supportsLocale(Locale locale);
|
||||
/**
|
||||
* Check if the map supports a given locale
|
||||
*
|
||||
* @param locale Locale
|
||||
* @return True if the map supports the locale
|
||||
*/
|
||||
boolean supportsLocale(@NotNull Locale locale);
|
||||
|
||||
/**
|
||||
* Get the locale of the messages stored in the map
|
||||
*
|
||||
* @return Message locale
|
||||
*/
|
||||
@NotNull Locale getLocale();
|
||||
|
||||
class NoSuchCaptionException extends IllegalArgumentException {
|
||||
|
||||
public NoSuchCaptionException(@NotNull final KeyedCaption caption) {
|
||||
super(String.format("No caption with the key '%s' exists in the map", caption.getKey()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Locale getLocale();
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.plotsquared.core.configuration.caption;
|
||||
|
||||
import com.plotsquared.core.configuration.Caption;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A {@link com.plotsquared.core.configuration.Caption} that can be identified by a key
|
||||
*/
|
||||
public interface KeyedCaption extends Caption {
|
||||
|
||||
/**
|
||||
* Get the key that identifies this caption
|
||||
*
|
||||
* @return Caption key
|
||||
*/
|
||||
@NotNull String getKey();
|
||||
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2020 IntellectualSites
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.configuration.caption;
|
||||
|
||||
import com.plotsquared.core.configuration.Caption;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@Deprecated
|
||||
public class LegacyCaptionMap implements CaptionMap {
|
||||
private final CaptionMap parent;
|
||||
private final Map<String, Caption> legacyMap;
|
||||
|
||||
public LegacyCaptionMap(CaptionMap parent) {
|
||||
this.parent = parent;
|
||||
this.legacyMap = new HashMap<>();
|
||||
// add here custom mappings
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(TranslatableCaption caption) {
|
||||
Caption legacy = this.legacyMap.computeIfAbsent(caption.getKey(), key -> {
|
||||
String captionsName = key.substring(key.indexOf('.') + 1).toUpperCase(Locale.ROOT);
|
||||
try {
|
||||
return Captions.valueOf(captionsName);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
if (legacy == null) {
|
||||
return this.parent.getMessage(caption);
|
||||
}
|
||||
return legacy.getTranslated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(TranslatableCaption caption, PlotPlayer<?> context) {
|
||||
return getMessage(caption); // Captions does not allow per player locale
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLocale(Locale locale) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return Locale.ROOT;
|
||||
}
|
||||
}
|
@ -25,55 +25,27 @@
|
||||
*/
|
||||
package com.plotsquared.core.configuration.caption;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Key-value pair used as replacement of variables in {@link com.plotsquared.core.configuration.Caption captions}
|
||||
* Any entity that has a locale
|
||||
*/
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public final class VariableReplacement {
|
||||
|
||||
private final String key;
|
||||
private final String value;
|
||||
|
||||
private VariableReplacement(@NotNull final String key, @NotNull final String value) {
|
||||
this.key = Objects.requireNonNull(key, "Key may not be null");
|
||||
this.value = Objects.requireNonNull(value, "Value may not be null");
|
||||
}
|
||||
public interface LocaleHolder {
|
||||
|
||||
/**
|
||||
* Create a new variable replacement from a key-value pair
|
||||
* Get the locale used by the holder
|
||||
*
|
||||
* @param key Replacement key
|
||||
* @param value Replacement value
|
||||
* @return Replacement instance
|
||||
* @return Locale
|
||||
*/
|
||||
@NotNull public static VariableReplacement keyed(@NotNull final String key,
|
||||
@NotNull final String value) {
|
||||
return new VariableReplacement(key, value);
|
||||
}
|
||||
@NotNull Locale getLocale();
|
||||
|
||||
/**
|
||||
* Get the replacement key
|
||||
* Set the locale for the holder
|
||||
*
|
||||
* @return Replacement key
|
||||
* @param locale New locale
|
||||
*/
|
||||
@NotNull public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the replacement value
|
||||
*
|
||||
* @return Replacement value
|
||||
*/
|
||||
@NotNull public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
void setLocale(@NotNull Locale locale);
|
||||
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.configuration.caption;
|
||||
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -40,19 +40,19 @@ public class LocalizedCaptionMap implements CaptionMap {
|
||||
this.captions = captions;
|
||||
}
|
||||
|
||||
@Override public String getMessage(TranslatableCaption caption) {
|
||||
@Override @NotNull public String getMessage(@NotNull final TranslatableCaption caption) {
|
||||
return this.captions.get(caption);
|
||||
}
|
||||
|
||||
@Override public String getMessage(TranslatableCaption caption, PlotPlayer<?> context) {
|
||||
@Override @NotNull public String getMessage(@NotNull final TranslatableCaption caption, @NotNull final LocaleHolder localeHolder) {
|
||||
return getMessage(caption); // use the translation of this locale
|
||||
}
|
||||
|
||||
@Override public boolean supportsLocale(Locale locale) {
|
||||
@Override public boolean supportsLocale(@NotNull final Locale locale) {
|
||||
return this.locale.equals(locale);
|
||||
}
|
||||
|
||||
@Override public Locale getLocale() {
|
||||
@Override @NotNull public Locale getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.configuration.caption;
|
||||
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
@ -40,13 +40,14 @@ public class PerUserLocaleCaptionMap extends LocalizedCaptionMap {
|
||||
this.localeMap = localeMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(TranslatableCaption caption, PlotPlayer<?> context) {
|
||||
return this.localeMap.get(context.getLocale()).getMessage(caption);
|
||||
@Override @NotNull public String getMessage(@NotNull final TranslatableCaption caption,
|
||||
@NotNull final LocaleHolder localeHolder) throws NoSuchCaptionException {
|
||||
return this.localeMap.get(localeHolder.getLocale()).getMessage(caption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLocale(Locale locale) {
|
||||
public boolean supportsLocale(@NotNull final Locale locale) {
|
||||
return this.localeMap.containsKey(locale);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,31 +26,34 @@
|
||||
package com.plotsquared.core.configuration.caption;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Caption;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class TranslatableCaption implements Caption {
|
||||
import java.util.Locale;
|
||||
|
||||
@NotNull private final String key;
|
||||
/**
|
||||
* Caption that is user modifiable
|
||||
*/
|
||||
public final class TranslatableCaption implements KeyedCaption {
|
||||
|
||||
private TranslatableCaption(@NotNull String key) {
|
||||
@Getter private final String key;
|
||||
|
||||
private TranslatableCaption(@NotNull final String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public static TranslatableCaption of(@NotNull final String key) {
|
||||
return new TranslatableCaption(key);
|
||||
/**
|
||||
* Get a new {@link TranslatableCaption} instance
|
||||
*
|
||||
* @param key Caption key
|
||||
* @return Caption instance
|
||||
*/
|
||||
@NotNull public static TranslatableCaption keyed(@NotNull final String key) {
|
||||
return new TranslatableCaption(key.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
@Override public String getTranslated() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public boolean usePrefix() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull public String getKey() {
|
||||
return this.key;
|
||||
@Override @NotNull public String getComponent(@NotNull final LocaleHolder localeHolder) {
|
||||
return PlotSquared.get().getCaptionMap().getMessage(this, localeHolder);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import com.plotsquared.core.command.RequiredType;
|
||||
import com.plotsquared.core.configuration.CaptionUtility;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
||||
import com.plotsquared.core.database.DBFunc;
|
||||
import com.plotsquared.core.events.TeleportCause;
|
||||
import com.plotsquared.core.location.Location;
|
||||
@ -72,7 +73,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* The abstract class supporting {@code BukkitPlayer} and {@code SpongePlayer}.
|
||||
*/
|
||||
public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer {
|
||||
public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer, LocaleHolder {
|
||||
|
||||
public static final String META_LAST_PLOT = "lastplot";
|
||||
public static final String META_LOCATION = "location";
|
||||
@ -739,14 +740,14 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
return this.getAttribute("debug");
|
||||
}
|
||||
|
||||
@NotNull public Locale getLocale() {
|
||||
@NotNull @Override public Locale getLocale() {
|
||||
if (this.locale == null) {
|
||||
this.locale = Locale.forLanguageTag(Settings.Enabled_Components.DEFAULT_LOCALE);
|
||||
}
|
||||
return this.locale;
|
||||
}
|
||||
|
||||
public void setLocale(@NotNull final Locale locale) {
|
||||
@Override public void setLocale(@NotNull final Locale locale) {
|
||||
if (!PlotSquared.get().getCaptionMap().supportsLocale(locale)) {
|
||||
this.locale = Locale.forLanguageTag(Settings.Enabled_Components.DEFAULT_LOCALE);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user