Fix chat tests with MockBukkit and fix Paper version

#130
This commit is contained in:
Norbi Peti 2023-06-27 01:39:35 +02:00
parent e35e94e87c
commit b5fd834dc7
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 24 additions and 17 deletions

View file

@ -109,7 +109,7 @@
<dependency> <dependency>
<groupId>io.papermc.paper</groupId> <groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version> <version>1.19.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -189,6 +189,12 @@
<version>1.0.500</version> <version>1.0.500</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.19</artifactId>
<version>2.29.0</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<artifactId>Chroma-Chat</artifactId> <artifactId>Chroma-Chat</artifactId>
<organization> <organization>

View file

@ -233,12 +233,14 @@ public class ChatProcessing {
val channelHover = (ChatUtils.MCORIGIN.equals(origin) ? "" : "From " + origin + "\n") + "Copy message"; val channelHover = (ChatUtils.MCORIGIN.equals(origin) ? "" : "From " + origin + "\n") + "Copy message";
json.append(text(channelidentifier) json.append(text(channelidentifier)
.hoverEvent(hoverEvent(SHOW_TEXT, text(channelHover).color(BLUE))).clickEvent(suggestCommand(message))); .hoverEvent(hoverEvent(SHOW_TEXT, text(channelHover).color(BLUE))).clickEvent(suggestCommand(message)));
if (PluginMain.permission.has(player, "tbmc.badge.diamond")) // TODO: Cross-platform permissions if (player != null) {
json.append(text("[P]").color(AQUA).decorate(TextDecoration.BOLD) if (PluginMain.permission.has(player, "tbmc.badge.diamond")) // TODO: Cross-platform permissions
.hoverEvent(hoverEvent(SHOW_TEXT, text("Diamond Patreon supporter")))); json.append(text("[P]").color(AQUA).decorate(TextDecoration.BOLD)
else if (PluginMain.permission.has(player, "tbmc.badge.gold")) .hoverEvent(hoverEvent(SHOW_TEXT, text("Diamond Patreon supporter"))));
json.append(text("[P]").color(GOLD).decorate(TextDecoration.BOLD) else if (PluginMain.permission.has(player, "tbmc.badge.gold"))
.hoverEvent(hoverEvent(SHOW_TEXT, text("Gold Patreon supporter")))); json.append(text("[P]").color(GOLD).decorate(TextDecoration.BOLD)
.hoverEvent(hoverEvent(SHOW_TEXT, text("Gold Patreon supporter"))));
}
json.append(text(" <")); json.append(text(" <"));
json.append(text(user.getName()).hoverEvent(hoverEvent(SHOW_TEXT, text(user.getInfo(ChromaGamerBase.InfoTarget.MCHover))))); json.append(text(user.getName()).hoverEvent(hoverEvent(SHOW_TEXT, text(user.getInfo(ChromaGamerBase.InfoTarget.MCHover)))));
json.append(text("> ")); json.append(text("> "));

View file

@ -9,24 +9,23 @@ import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
import buttondevteam.chat.components.formatter.formatting.ChatFormatter; import buttondevteam.chat.components.formatter.formatting.ChatFormatter;
import buttondevteam.chat.components.formatter.formatting.FormatSettings; import buttondevteam.chat.components.formatter.formatting.FormatSettings;
import buttondevteam.chat.components.formatter.formatting.MatchProviderBase; import buttondevteam.chat.components.formatter.formatting.MatchProviderBase;
import buttondevteam.core.TestPrepare; import buttondevteam.core.MainPlugin;
import buttondevteam.core.component.channel.Channel; import buttondevteam.core.component.channel.Channel;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.player.ChromaGamerBase; import buttondevteam.lib.player.ChromaGamerBase;
import buttondevteam.lib.player.TBMCPlayer; import buttondevteam.lib.test.TestPermissions;
import buttondevteam.lib.player.TBMCPlayerBase;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.milkbowl.vault.permission.Permission;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mockito;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.function.Function; import java.util.function.Function;
import static be.seeseemelk.mockbukkit.MockBukkit.load;
import static be.seeseemelk.mockbukkit.MockBukkit.mock;
import static net.kyori.adventure.text.Component.text; import static net.kyori.adventure.text.Component.text;
import static net.kyori.adventure.text.event.ClickEvent.Action.OPEN_URL; import static net.kyori.adventure.text.event.ClickEvent.Action.OPEN_URL;
import static net.kyori.adventure.text.event.ClickEvent.clickEvent; import static net.kyori.adventure.text.event.ClickEvent.clickEvent;
@ -39,11 +38,11 @@ import static net.kyori.adventure.text.format.TextDecoration.*;
public class ChatFormatIT { public class ChatFormatIT {
@Objects @Objects
public static List<Object> data() { public static List<Object> data() {
TestPrepare.PrepareServer(); mock();
var sender = ChromaGamerBase.getUser("test", ChatPlayer.class); load(MainPlugin.class, true);
var sender = ChromaGamerBase.getUser(UUID.randomUUID().toString(), ChatPlayer.class);
DebugCommand.DebugMode = true; DebugCommand.DebugMode = true;
PluginMain.permission = Mockito.mock(Permission.class); PluginMain.permission = new TestPermissions();
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class, TBMCPlayer::new);
List<Object> list = new ArrayList<>(); List<Object> list = new ArrayList<>();