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

View file

@ -233,12 +233,14 @@ public class ChatProcessing {
val channelHover = (ChatUtils.MCORIGIN.equals(origin) ? "" : "From " + origin + "\n") + "Copy message";
json.append(text(channelidentifier)
.hoverEvent(hoverEvent(SHOW_TEXT, text(channelHover).color(BLUE))).clickEvent(suggestCommand(message)));
if (player != null) {
if (PluginMain.permission.has(player, "tbmc.badge.diamond")) // TODO: Cross-platform permissions
json.append(text("[P]").color(AQUA).decorate(TextDecoration.BOLD)
.hoverEvent(hoverEvent(SHOW_TEXT, text("Diamond Patreon supporter"))));
else if (PluginMain.permission.has(player, "tbmc.badge.gold"))
json.append(text("[P]").color(GOLD).decorate(TextDecoration.BOLD)
.hoverEvent(hoverEvent(SHOW_TEXT, text("Gold Patreon supporter"))));
}
json.append(text(" <"));
json.append(text(user.getName()).hoverEvent(hoverEvent(SHOW_TEXT, text(user.getInfo(ChromaGamerBase.InfoTarget.MCHover)))));
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.FormatSettings;
import buttondevteam.chat.components.formatter.formatting.MatchProviderBase;
import buttondevteam.core.TestPrepare;
import buttondevteam.core.MainPlugin;
import buttondevteam.core.component.channel.Channel;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.player.ChromaGamerBase;
import buttondevteam.lib.player.TBMCPlayer;
import buttondevteam.lib.player.TBMCPlayerBase;
import buttondevteam.lib.test.TestPermissions;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.milkbowl.vault.permission.Permission;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
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.event.ClickEvent.Action.OPEN_URL;
import static net.kyori.adventure.text.event.ClickEvent.clickEvent;
@ -39,11 +38,11 @@ import static net.kyori.adventure.text.format.TextDecoration.*;
public class ChatFormatIT {
@Objects
public static List<Object> data() {
TestPrepare.PrepareServer();
var sender = ChromaGamerBase.getUser("test", ChatPlayer.class);
mock();
load(MainPlugin.class, true);
var sender = ChromaGamerBase.getUser(UUID.randomUUID().toString(), ChatPlayer.class);
DebugCommand.DebugMode = true;
PluginMain.permission = Mockito.mock(Permission.class);
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class, TBMCPlayer::new);
PluginMain.permission = new TestPermissions();
List<Object> list = new ArrayList<>();