From 3fa532a3c0adff82e91b3c7470dc2bf6ec8da035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Wed, 8 Jul 2020 15:35:58 +0200 Subject: [PATCH] Move message sending into PlotPlayer to make it platform independent --- .../bukkit/player/BukkitPlayer.java | 44 +-------- .../com/plotsquared/core/command/Confirm.java | 7 +- .../core/player/ConsolePlayer.java | 5 ++ .../plotsquared/core/player/PlotPlayer.java | 89 ++++++++++++------- .../com/plotsquared/core/util/MainUtil.java | 77 ---------------- 5 files changed, 67 insertions(+), 155 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java index a5f3129f4..05db91ff2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -26,13 +26,10 @@ package com.plotsquared.bukkit.player; import com.google.common.base.Charsets; -import com.google.common.base.Objects; 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.TranslatableCaption; import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; @@ -45,10 +42,6 @@ import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemTypes; import io.papermc.lib.PaperLib; import net.kyori.adventure.audience.Audience; -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.bukkit.GameMode; import org.bukkit.Sound; import org.bukkit.WeatherType; @@ -60,10 +53,7 @@ import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.RegisteredListener; import org.jetbrains.annotations.NotNull; -import java.time.Duration; -import java.time.temporal.ChronoUnit; import java.util.Arrays; -import java.util.List; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -75,8 +65,6 @@ import static com.sk89q.worldedit.world.gamemode.GameModes.SURVIVAL; public class BukkitPlayer extends PlotPlayer { - private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build(); - private static boolean CHECK_EFFECTIVE = true; public final Player player; private boolean offline; @@ -232,34 +220,6 @@ public class BukkitPlayer extends PlotPlayer { return this.player.isPermissionSet(permission); } - @Override - public void sendTitle(@NotNull final Caption title, @NotNull final Caption subtitle, - final int fadeIn, final int stay, final int fadeOut, @NotNull final Template ... replacements) { - final Component titleComponent = MINI_MESSAGE.parse(title.getComponent(this), replacements); - final Component subtitleComponent = MINI_MESSAGE.parse(subtitle.getComponent(this), replacements); - final Audience audience = BukkitUtil.BUKKIT_AUDIENCES.player(this.player); - audience.showTitle(Title.of(titleComponent, subtitleComponent, Duration.of(fadeIn * 50, - ChronoUnit.MILLIS), Duration.of(stay * 50, ChronoUnit.MILLIS), Duration.of(fadeOut * 50, ChronoUnit.MILLIS))); - } - - @Override public void sendMessage(@NotNull final Caption caption, - @NotNull final Template... replacements) { - final String message = caption.getComponent(this); - if (message.isEmpty()) { - return; - } - // Create the template list, and add the prefix as a replacement - final List