fix info for server-plots

This commit is contained in:
dordsor21 2020-12-10 21:05:50 +00:00
parent 8930ebe572
commit 540f4c0958
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 18 additions and 5 deletions

View File

@ -27,9 +27,11 @@ package com.plotsquared.core.listener;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; 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.StaticCaption;
import com.plotsquared.core.configuration.caption.Templates; import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.location.Location; 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.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; 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 net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -81,6 +85,8 @@ import java.util.function.Consumer;
public class PlotListener { public class PlotListener {
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private final HashMap<UUID, Interval> feedRunnable = new HashMap<>(); private final HashMap<UUID, Interval> feedRunnable = new HashMap<>();
private final HashMap<UUID, Interval> healRunnable = new HashMap<>(); private final HashMap<UUID, Interval> healRunnable = new HashMap<>();
@ -293,6 +299,8 @@ public class PlotListener {
UUID uuid = plot.getOwner(); UUID uuid = plot.getOwner();
if (uuid == null) { if (uuid == null) {
userConsumer.accept("Unknown"); userConsumer.accept("Unknown");
} else if (uuid.equals(DBFunc.SERVER)) {
userConsumer.accept(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.server").getComponent(player)));
} else { } else {
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(plot.getOwner(), (user, throwable) -> { PlotSquared.get().getImpromptuUUIDPipeline().getSingle(plot.getOwner(), (user, throwable) -> {
if (throwable == null) { if (throwable == null) {

View File

@ -89,7 +89,6 @@ import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -2707,9 +2706,8 @@ public class Plot {
} else { } else {
value = flag.toString(); value = flag.toString();
} }
Component snip = MINI_MESSAGE Component snip = MINI_MESSAGE.parse(prefix + CaptionUtility.format(player, TranslatableCaption.of("info.plot_flag_list").getComponent(player)),
.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())));
Template.of("flag", flag.getName()), Template.of("value", CaptionUtility.formatRaw(player, value.toString())));
if (flags != null) { if (flags != null) {
flags.append(snip); flags.append(snip);
} else { } else {
@ -2719,7 +2717,14 @@ public class Plot {
} }
} }
boolean build = this.isAdded(player.getUUID()); 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 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 footerTemplate = Template.of("footer", TranslatableCaption.of("info.plot_info_footer").getComponent(player));
Template areaTemplate; Template areaTemplate;