Several more progress

This commit is contained in:
dordsor21 2020-08-05 11:48:10 +01:00
parent 41a623a643
commit f1e3902fea
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
17 changed files with 142 additions and 92 deletions

View File

@ -194,16 +194,6 @@ public class PlotSquared {
this.captionMaps = new HashMap<>();
// Setup localization
CaptionMap captionMap;
if (Settings.Enabled_Components.PER_USER_LOCALE) {
captionMap = CaptionLoader.loadAll(Paths.get("lang"));
} else {
String fileName = "messages_" + Settings.Enabled_Components.DEFAULT_LOCALE + ".json";
captionMap = CaptionLoader.loadSingle(Paths.get("lang", fileName));
}
this.captionMaps.put(TranslatableCaption.DEFAULT_NAMESPACE, captionMap);
this.worldedit = WorldEdit.getInstance();
// Create Event utility class
@ -236,6 +226,18 @@ public class PlotSquared {
}
}
public void loadCaptionMap() throws IOException {
// Setup localization
CaptionMap captionMap;
if (Settings.Enabled_Components.PER_USER_LOCALE) {
captionMap = CaptionLoader.loadAll(Paths.get("lang"));
} else {
String fileName = "messages_" + Settings.Enabled_Components.DEFAULT_LOCALE + ".json";
captionMap = CaptionLoader.loadSingle(Paths.get("lang", fileName));
}
this.captionMaps.put(TranslatableCaption.DEFAULT_NAMESPACE, captionMap);
}
/**
* Get the platform specific {@link PlotAreaManager} instance
*

View File

@ -30,6 +30,7 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.configuration.file.YamlConfiguration;
@ -58,6 +59,7 @@ import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal3;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -584,14 +586,18 @@ public class Area extends SubCommand {
percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE;
region = "N/A";
}
String value =
"&r$1NAME: " + name + "\n$1Type: $2" + area.getType() + "\n$1Terrain: $2" + area
.getTerrain() + "\n$1Usage: $2" + String.format("%.2f", percent) + '%'
+ "\n$1Claimed: $2" + claimed + "\n$1Clusters: $2" + clusters
+ "\n$1Region: $2" + region + "\n$1Generator: $2" + generator;
MainUtil.sendMessage(player,
Captions.PLOT_INFO_HEADER.getTranslated() + '\n' + value + '\n'
+ Captions.PLOT_INFO_FOOTER.getTranslated(), false);
Template headerTemplate = Template.of("header", TranslatableCaption.of("info.plot_info_header").getComponent(player));
Template nameTemplate = Template.of("name", name);
Template typeTemplate = Template.of("type", area.getType().name());
Template terrainTemplate = Template.of("terrain", area.getTerrain().name());
Template usageTemplate = Template.of("usage", String.format("%.2f", percent));
Template claimedTemplate = Template.of("name", String.valueOf(claimed));
Template clustersTemplate = Template.of("name", String.valueOf(clusters));
Template regionTemplate = Template.of("name", region);
Template generatorTemplate = Template.of("name", generator);
Template footerTemplate = Template.of("name", TranslatableCaption.of("info.plot_info_footer").getComponent(player));
player.sendMessage(TranslatableCaption.of("info.area_format"), headerTemplate, nameTemplate, typeTemplate, terrainTemplate,
usageTemplate, claimedTemplate, clustersTemplate, regionTemplate, generatorTemplate, footerTemplate);
return true;
}
case "l":
@ -621,8 +627,8 @@ public class Area extends SubCommand {
}
final List<PlotArea> areas = new ArrayList<>(Arrays.asList(this.plotAreaManager.getAllPlotAreas()));
paginate(player, areas, 8, page,
new RunnableVal3<Integer, PlotArea, PlotMessage>() {
@Override public void run(Integer i, PlotArea area, PlotMessage message) {
new RunnableVal3<Integer, PlotArea, Caption>() {
@Override public void run(Integer i, PlotArea area, Caption message) {
String name;
double percent;
int claimed = area.getPlotCount();

View File

@ -28,6 +28,7 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.database.DBFunc;
@ -759,13 +760,13 @@ public class Cluster extends SubCommand {
String size = (cluster.getP2().getX() - cluster.getP1().getX() + 1) + "x" + (
cluster.getP2().getY() - cluster.getP1().getY() + 1);
String rights = cluster.isAdded(player.getUUID()) + "";
String message = Captions.CLUSTER_INFO.getTranslated();
message = message.replaceAll("%id%", id);
message = message.replaceAll("%owner%", owner);
message = message.replaceAll("%name%", name);
message = message.replaceAll("%size%", size);
message = message.replaceAll("%rights%", rights);
player.sendMessage(StaticCaption.of(message));
Caption message = TranslatableCaption.of("cluster.cluster_info");
Template idTemplate = Template.of("id", id);
Template ownerTemplate = Template.of("owner", owner);
Template nameTemplate = Template.of("name", name);
Template sizeTemplate = Template.of("size", size);
Template rightsTemplate = Template.of("rights", rights);
player.sendMessage(message, idTemplate, ownerTemplate, nameTemplate, sizeTemplate, rightsTemplate);
}
});
return true;

View File

@ -217,6 +217,7 @@ public class DatabaseCommand extends SubCommand {
break;
default:
player.sendMessage(StaticCaption.of("/plot database [sqlite/mysql]"));
return false;
}
try {
SQLManager manager = new SQLManager(implementation, prefix, this.eventDispatcher, this.plotListener, this.worldConfiguration);

View File

@ -42,6 +42,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
@ -60,6 +61,7 @@ public class Merge extends SubCommand {
public static final String[] values = new String[] {"north", "east", "south", "west"};
public static final String[] aliases = new String[] {"n", "e", "s", "w"};
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private final EventDispatcher eventDispatcher;
private final EconHandler econHandler;
@ -283,8 +285,9 @@ public class Merge extends SubCommand {
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
};
if (!force && hasConfirmation(player)) {
CmdConfirm.addPending(accepter, Captions.MERGE_REQUEST_CONFIRM.getTranslated()
.replaceAll("%s", player.getName()), run);
CmdConfirm.addPending(accepter, MINI_MESSAGE.serialize(MINI_MESSAGE
.parse(TranslatableCaption.of("merge.merge_request_confirm").getComponent(player), Template.of("player", player.getName()))),
run);
} else {
run.run();
}

View File

@ -68,7 +68,7 @@ public class Reload extends SubCommand {
// The following won't affect world generation, as that has to be
// loaded during startup unfortunately.
PlotSquared.get().setupConfigs();
Captions.load(PlotSquared.get().translationFile);
PlotSquared.get().loadCaptionMap();
this.plotAreaManager.forEachPlotArea(area -> {
ConfigurationSection worldSection = this.worldConfiguration
.getConfigurationSection("worlds." + area.getWorldName());

View File

@ -26,6 +26,7 @@
package com.plotsquared.core.configuration.caption;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.util.PlayerManager;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
@ -67,7 +68,7 @@ public final class Templates {
* @return Generated template
*/
@Nonnull public static Template of(@Nonnull final String key, @Nonnull final UUID uuid) {
final String username = MainUtil.getName(uuid);
final String username = PlayerManager.getName(uuid);
return Template.of(key, username);
}

View File

@ -28,11 +28,13 @@ package com.plotsquared.core.listener;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.MetaDataAccess;
import com.plotsquared.core.player.PlayerMetaDataKeys;
import com.plotsquared.core.player.PlotPlayer;
@ -159,7 +161,7 @@ public class PlotListener {
final String greeting = plot.getFlag(GreetingFlag.class);
if (!greeting.isEmpty()) {
plot.format(greeting, player, false).thenAcceptAsync(player::sendMessage);
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage);
}
if (plot.getFlag(NotifyEnterFlag.class)) {
@ -270,8 +272,8 @@ public class PlotListener {
CommentManager.sendTitle(player, plot);
if (titles && !player.getAttribute("disabletitles")) {
if (!Captions.TITLE_ENTERED_PLOT.getTranslated().isEmpty()
|| !Captions.TITLE_ENTERED_PLOT_SUB.getTranslated().isEmpty()) {
if (!TranslatableCaption.of("titles.title_entered_plot").getComponent(ConsolePlayer.getConsole()).isEmpty()
|| !TranslatableCaption.of("titles.title_entered_plot_sub").getComponent(ConsolePlayer.getConsole()).isEmpty()) {
TaskManager.runTaskLaterAsync(() -> {
Plot lastPlot = null;
try (final MetaDataAccess<Plot> lastPlotAccess =
@ -346,7 +348,7 @@ public class PlotListener {
final String farewell = plot.getFlag(FarewellFlag.class);
if (!farewell.isEmpty()) {
plot.format(farewell, player, false).thenAcceptAsync(player::sendMessage);
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage);
}
if (plot.getFlag(NotifyLeaveFlag.class)) {

View File

@ -70,6 +70,7 @@ import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.title.Title;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -866,6 +867,11 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
}
}
// Redefine from PermissionHolder as it's required from CommandCaller
@Override public boolean hasPermission(@NotNull String permission) {
return hasPermission(null, permission);
}
boolean hasPersistentMeta(String key) {
return this.metaMap.containsKey(key);
}
@ -884,7 +890,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
}
@Override public void setLocale(@Nonnull final Locale locale) {
if (!PlotSquared.get().getCaptionMap().supportsLocale(locale)) {
if (!PlotSquared.get().getCaptionMap(TranslatableCaption.DEFAULT_NAMESPACE).supportsLocale(locale)) {
this.locale = Locale.forLanguageTag(Settings.Enabled_Components.DEFAULT_LOCALE);
} else {
this.locale = locale;

View File

@ -142,13 +142,12 @@ public class Plot {
private static final Logger logger = LoggerFactory.getLogger("P2/" + Plot.class.getSimpleName());
private static final DecimalFormat FLAG_DECIMAL_FORMAT = new DecimalFormat("0");
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
static {
FLAG_DECIMAL_FORMAT.setMaximumFractionDigits(340);
}
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private static Set<Plot> connected_cache;
private static Set<CuboidRegion> regions_cache;
@ -1893,6 +1892,7 @@ public class Plot {
return true;
}
/**
* Register a plot and create it in the database<br>
* - The plot will not be created if the owner is null<br>

View File

@ -29,12 +29,13 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.plotsquared.core.collection.QuadMap;
import com.plotsquared.core.configuration.caption.CaptionUtility;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.CaptionUtility;
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.configuration.file.YamlConfiguration;
import com.plotsquared.core.generator.GridPlotWorld;
@ -43,6 +44,7 @@ import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.location.Direction;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.location.PlotLoc;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.MetaDataAccess;
import com.plotsquared.core.player.PlayerMetaDataKeys;
import com.plotsquared.core.player.PlotPlayer;
@ -51,6 +53,7 @@ import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.types.DoubleFlag;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.util.EconHandler;
@ -65,11 +68,15 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -89,6 +96,11 @@ import java.util.function.Consumer;
public abstract class PlotArea {
private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotArea.class.getSimpleName());
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private static final DecimalFormat FLAG_DECIMAL_FORMAT = new DecimalFormat("0");
static {
FLAG_DECIMAL_FORMAT.setMaximumFractionDigits(340);
}
protected final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>();
@Nonnull private final String worldName;
@ -369,20 +381,10 @@ public abstract class PlotArea {
}
this.getFlagContainer().addAll(parseFlags(flags));
StringBuilder flagBuilder = new StringBuilder();
Component flagsComponent = null;
Collection<PlotFlag<?, ?>> flagCollection = this.getFlagContainer().getFlagMap().values();
if (flagCollection.isEmpty()) {
flagBuilder.append(TranslatableCaption.of("info.none"));
} else {
String prefix = " ";
for (final PlotFlag<?, ?> flag : flagCollection) {
Object value = flag.toString();
flagBuilder.append(prefix).append(CaptionUtility
.format(null, Captions.PLOT_FLAG_LIST.getTranslated(), flag.getName(),
CaptionUtility.formatRaw(null, value.toString(), "")));
prefix = ", ";
}
}
flagsComponent = getFlagsComponent(flagsComponent, flagCollection);
ConsolePlayer.getConsole().sendMessage(StaticCaption.of("[P2] - area flags: <flags>"), Template.of("flags", flagsComponent));
this.spawnEggs = config.getBoolean("event.spawn.egg");
this.spawnCustom = config.getBoolean("event.spawn.custom");
@ -404,25 +406,39 @@ public abstract class PlotArea {
}
this.getRoadFlagContainer().addAll(parseFlags(roadflags));
StringBuilder roadFlagBuilder = new StringBuilder();
Collection<PlotFlag<?, ?>> roadFlagCollection = this.getFlagContainer().getFlagMap().values();
if (roadFlagCollection.isEmpty()) {
roadFlagBuilder.append(TranslatableCaption.of("info.none"));
Component roadFlagsComponent = null;
Collection<PlotFlag<?, ?>> roadFlagCollection = this.getRoadFlagContainer().getFlagMap().values();
roadFlagsComponent = getFlagsComponent(roadFlagsComponent, roadFlagCollection);
ConsolePlayer.getConsole().sendMessage(StaticCaption.of("[P2] - road flags: <flags>"), Template.of("flags", roadFlagsComponent));
loadConfiguration(config);
}
private Component getFlagsComponent(Component flagsComponent, Collection<PlotFlag<?, ?>> flagCollection) {
if (flagCollection.isEmpty()) {
flagsComponent = MINI_MESSAGE.parse(TranslatableCaption.of("info.none").getComponent(LocaleHolder.console()));
} else {
roadFlags = true;
String prefix = " ";
for (final PlotFlag<?, ?> flag : roadFlagCollection) {
Object value = flag.toString();
roadFlagBuilder.append(prefix).append(CaptionUtility
.format(null, Captions.PLOT_FLAG_LIST.getTranslated(), flag.getName(),
CaptionUtility.formatRaw(null, value.toString(), "")));
for (final PlotFlag<?, ?> flag : flagCollection) {
Object value;
if (flag instanceof DoubleFlag && !Settings.General.SCIENTIFIC) {
value = FLAG_DECIMAL_FORMAT.format(flag.getValue());
} else {
value = flag.toString();
}
Component snip = MINI_MESSAGE.parse(prefix + CaptionUtility
.format(ConsolePlayer.getConsole(), TranslatableCaption.of("info.plot_flag_list").getComponent(LocaleHolder.console())),
Template.of("flag", flag.getName()),
Template.of("value", CaptionUtility.formatRaw(ConsolePlayer.getConsole(), value.toString())));
if (flagsComponent != null) {
flagsComponent.append(snip);
} else {
flagsComponent = snip;
}
prefix = ", ";
}
}
logger.info("[P2] - road flags: {}", roadFlagBuilder.toString());
loadConfiguration(config);
return flagsComponent;
}
public abstract void loadConfiguration(ConfigurationSection config);

View File

@ -59,7 +59,7 @@ public abstract class BooleanFlag<F extends PlotFlag<Boolean, F>> extends PlotFl
*
* @param description Flag description
*/
protected BooleanFlag(final Captions description) {
protected BooleanFlag(final Caption description) {
this(false, description);
}

View File

@ -37,7 +37,7 @@ import java.util.List;
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 Caption description) {
public ListFlag(final List<V> valueList, final Caption category, final Caption description) {
super(Collections.unmodifiableList(valueList), category, description);
}

View File

@ -30,9 +30,13 @@ import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -54,6 +58,8 @@ import java.util.function.BiConsumer;
*/
public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private final Map<UUID, P> playerMap = new HashMap<>();
private final Object playerLock = new Object();
@ -116,11 +122,11 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
final List<String> users = new LinkedList<>();
for (final UUID uuid : uuids) {
if (uuid == null) {
users.add(Captions.NONE.getTranslated());
users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.none").getComponent(ConsolePlayer.getConsole())));
} else if (DBFunc.EVERYONE.equals(uuid)) {
users.add(Captions.EVERYONE.getTranslated());
users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.everyone").getComponent(ConsolePlayer.getConsole())));
} else if (DBFunc.SERVER.equals(uuid)) {
users.add(Captions.SERVER.getTranslated());
users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.console").getComponent(ConsolePlayer.getConsole())));
} else {
players.add(uuid);
}
@ -135,13 +141,13 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
e.printStackTrace();
}
String c = Captions.PLOT_USER_LIST.getTranslated();
StringBuilder list = new StringBuilder();
String c = TranslatableCaption.of("info.plot_user_list").getComponent(ConsolePlayer.getConsole());
Component list = MINI_MESSAGE.deserialize("");
for (int x = 0; x < users.size(); x++) {
if (x + 1 == uuids.size()) {
list.append(c.replace("%user%", users.get(x)).replace(",", ""));
list.append(MINI_MESSAGE.parse(c, Template.of("user", users.get(x))));
} else {
list.append(c.replace("%user%", users.get(x)));
list.append(MINI_MESSAGE.parse(c + ", ", Template.of("user", users.get(x))));
}
}
return list.toString();

View File

@ -26,11 +26,11 @@
package com.plotsquared.core.util.helpmenu;
import com.plotsquared.core.command.CommandCategory;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.StringMan;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import java.util.ArrayList;
@ -38,27 +38,29 @@ import java.util.List;
public class HelpPage {
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private final List<HelpObject> helpObjects;
private final String header;
private final Template catTemplate;
private final Template curTemplate;
private final Template maxTemplate;
public HelpPage(CommandCategory category, int currentPage, int maxPages) {
this.helpObjects = new ArrayList<>();
this.header = Captions.HELP_PAGE_HEADER.getTranslated()
.replace("%category%", category == null ? "ALL" : category.toString())
.replace("%current%", (currentPage + 1) + "").replace("%max%", (maxPages + 1) + "");
this.catTemplate = Template.of("category", category == null ? "ALL" : category.name());
this.curTemplate = Template.of("current", String.valueOf(currentPage + 1));
this.maxTemplate = Template.of("max", String.valueOf(maxPages + 1));
}
public void render(PlotPlayer player) {
if (this.helpObjects.size() < 1) {
player.sendMessage(
TranslatableCaption.of("invalid.not_valid_number"),
Template.of("value", "(0)")
);
player.sendMessage(TranslatableCaption.of("invalid.not_valid_number"), Template.of("value", "(0)"));
} else {
String message =
Captions.HELP_HEADER.getTranslated() + "\n" + this.header + "\n" + StringMan
.join(this.helpObjects, "\n") + "\n" + Captions.HELP_FOOTER.getTranslated();
player.sendMessage(StaticCaption.of(message));
Template header = Template.of("header", TranslatableCaption.of("help.help_header").getComponent(player));
Template page_header = Template.of("page_header",
MINI_MESSAGE.parse(TranslatableCaption.of("help.help_page_header").getComponent(player), catTemplate, curTemplate, maxTemplate));
Template help_objects = Template.of("help_objects", StringMan.join(this.helpObjects, "\n"));
Template footer = Template.of("footer", TranslatableCaption.of("help.help_footer").getComponent(player));
player.sendMessage(StaticCaption.of("<header>\n<page_header>\n<help_objects>\n<footer>"), header, page_header, help_objects, footer);
}
}

View File

@ -27,11 +27,12 @@ package com.plotsquared.core.uuid;
import com.google.common.collect.Lists;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.util.ThreadUtils;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -66,6 +67,7 @@ import java.util.function.Function;
public class UUIDPipeline {
private static final Logger logger = LoggerFactory.getLogger("P2/" + UUIDPipeline.class.getSimpleName());
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private final Executor executor;
private final List<UUIDService> serviceList;
@ -331,7 +333,8 @@ public class UUIDPipeline {
if (Settings.UUID.UNKNOWN_AS_DEFAULT) {
for (final UUID uuid : remainingRequests) {
mappings.add(new UUIDMapping(uuid, TranslatableCaption.of("info.unknown")));
mappings.add(new UUIDMapping(uuid,
MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.unknown").getComponent(ConsolePlayer.getConsole()))));
}
return mappings;
} else {

View File

@ -375,6 +375,7 @@
"info.plot_no_description": "<prefix><gray>No description set.</gray>",
"info.plot_caps_header": "<dark_gray><strikethrough>--------- <reset><gold>CAPS </gold><dark_gray><strikethrough>---------<reset>",
"info.plot_caps_format": "<prefix><gray>- Cap Type: </gray><gold><cap> </gold><gray>| Status: </gray><gold><current></gold><gray>/</gray><gold><limit> </gold><gray>(</gray><gold><percentage>%</gold><gray>)</gray>",
"info.area_format": "<header>\n<reset><gold>NAME: </gold><grey><name></grey>\n<gold>Type: </gold><grey><type></grey>\n<gold>Terrain: </gold><grey><terrain></grey>\n<gold>Usage: </gold><grey><usage>%</grey>\n<gold>Claimed: </gold><grey><claimed></grey>\n<gold>Clusters: </gold><grey><clusters></grey>\n<gold>Region: </gold><grey><region></grey>\n<gold>Generator: </gold><grey><generator></grey>\n<footer>",
"working.generating_component": "<prefix><gold>Started generating component from your settings.</gold>",
"working.clearing_done": "<prefix><dark_aqua>Clear completed! Took <amount>ms.</dark_aqua>",