From 540f4c0958149fd713352adfe0da18692f3b8e7d Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 10 Dec 2020 21:05:50 +0000 Subject: [PATCH] fix info for server-plots --- .../plotsquared/core/listener/PlotListener.java | 8 ++++++++ .../main/java/com/plotsquared/core/plot/Plot.java | 15 ++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java index 27a5b6c40..c33ce1746 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java @@ -27,9 +27,11 @@ package com.plotsquared.core.listener; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.LocaleHolder; 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.database.DBFunc; import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.Result; import com.plotsquared.core.location.Location; @@ -68,6 +70,8 @@ import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nullable; @@ -81,6 +85,8 @@ import java.util.function.Consumer; public class PlotListener { + private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build(); + private final HashMap feedRunnable = new HashMap<>(); private final HashMap healRunnable = new HashMap<>(); @@ -293,6 +299,8 @@ public class PlotListener { UUID uuid = plot.getOwner(); if (uuid == null) { userConsumer.accept("Unknown"); + } else if (uuid.equals(DBFunc.SERVER)) { + userConsumer.accept(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.server").getComponent(player))); } else { PlotSquared.get().getImpromptuUUIDPipeline().getSingle(plot.getOwner(), (user, throwable) -> { if (throwable == null) { diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 2cc25e5cd..40efa215f 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -89,7 +89,6 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -2707,9 +2706,8 @@ public class Plot { } else { value = flag.toString(); } - Component snip = MINI_MESSAGE - .parse(prefix + CaptionUtility.format(player, TranslatableCaption.of("info.plot_flag_list").getComponent(player)), - Template.of("flag", flag.getName()), Template.of("value", CaptionUtility.formatRaw(player, value.toString()))); + Component snip = MINI_MESSAGE.parse(prefix + CaptionUtility.format(player, TranslatableCaption.of("info.plot_flag_list").getComponent(player)), + Template.of("flag", flag.getName()), Template.of("value", CaptionUtility.formatRaw(player, value.toString()))); if (flags != null) { flags.append(snip); } else { @@ -2719,7 +2717,14 @@ public class Plot { } } boolean build = this.isAdded(player.getUUID()); - Component owner = this.getOwners().isEmpty() ? Component.text("unowned") : PlayerManager.getPlayerList(this.getOwners()); + Component owner; + if (this.getOwner() == null) { + owner = Component.text("unowned"); + } else if (this.getOwner().equals(DBFunc.SERVER)) { + owner = Component.text(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.server").getComponent(player))); + } else { + owner = PlayerManager.getPlayerList(this.getOwners()); + } Template headerTemplate = Template.of("header", TranslatableCaption.of("info.plot_info_header").getComponent(player)); Template footerTemplate = Template.of("footer", TranslatableCaption.of("info.plot_info_footer").getComponent(player)); Template areaTemplate;