i broke it this will need fixing

This commit is contained in:
Telesphoreo 2022-08-02 20:06:38 -05:00
parent 5e4cb5cd52
commit edaa8f7614
3 changed files with 8 additions and 17 deletions

View File

@ -21,7 +21,6 @@ dependencies {
compileOnly("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT")
implementation("org.apache.commons:commons-lang3:3.12.0") implementation("org.apache.commons:commons-lang3:3.12.0")
compileOnly("dev.plex:server:1.2-SNAPSHOT") compileOnly("dev.plex:server:1.2-SNAPSHOT")
compileOnly("dev.plex:api:1.2-SNAPSHOT")
compileOnly("dev.morphia.morphia:morphia-core:2.2.7") compileOnly("dev.morphia.morphia:morphia-core:2.2.7")
compileOnly("org.json:json:20220320") compileOnly("org.json:json:20220320")
implementation("org.jetbrains:annotations:23.0.0") implementation("org.jetbrains:annotations:23.0.0")

View File

@ -6,16 +6,11 @@ import dev.plex.data.SQLGuildManager;
import dev.plex.data.SQLManager; import dev.plex.data.SQLManager;
import dev.plex.guild.Guild; import dev.plex.guild.Guild;
import dev.plex.guild.GuildHolder; import dev.plex.guild.GuildHolder;
import dev.plex.handler.ChatHandlerImpl;
import dev.plex.listener.impl.ChatListener;
import dev.plex.module.PlexModule; import dev.plex.module.PlexModule;
import dev.plex.storage.StorageType; import dev.plex.storage.StorageType;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import io.papermc.paper.event.player.AsyncChatEvent;
import lombok.Getter; import lombok.Getter;
import java.util.Arrays;
//TODO: Implement mongodb //TODO: Implement mongodb
@Getter @Getter
public class Guilds extends PlexModule public class Guilds extends PlexModule
@ -55,7 +50,7 @@ public class Guilds extends PlexModule
}); });
} }
Plex.get().setChatHandler(new ChatHandlerImpl()); //Plex.get().setChat(new ChatHandlerImpl());
addDefaultMessage("guildsHelpCommand", "<gradient:gold:yellow>======</gradient>Guild Menu<gradient:gold:yellow>======</gradient><newline><newline>{0}", "0 - The commands list"); addDefaultMessage("guildsHelpCommand", "<gradient:gold:yellow>======</gradient>Guild Menu<gradient:gold:yellow>======</gradient><newline><newline>{0}", "0 - The commands list");
addDefaultMessage("guildsCommandDisplay", "<gold>{0} <yellow>{1}", "0 - The command name", "1 - The command description"); addDefaultMessage("guildsCommandDisplay", "<gold>{0} <yellow>{1}", "0 - The command name", "1 - The command description");
@ -99,7 +94,7 @@ public class Guilds extends PlexModule
{ {
// Unregistering listeners / commands is handled by Plex // Unregistering listeners / commands is handled by Plex
this.getGuildHolder().getGuilds().forEach(sqlGuildManager::updateGuild); this.getGuildHolder().getGuilds().forEach(sqlGuildManager::updateGuild);
this.getPlex().setChatHandler(new ChatListener.ChatHandlerImpl()); //this.getPlex().setChat(new ChatListener.PlexChatRenderer());
} }
public static Guilds get() public static Guilds get()

View File

@ -2,14 +2,15 @@ package dev.plex.handler;
import dev.plex.Guilds; import dev.plex.Guilds;
import dev.plex.Plex; import dev.plex.Plex;
import dev.plex.api.chat.IChatHandler;
import dev.plex.cache.PlayerCache;
import dev.plex.guild.data.Member; import dev.plex.guild.data.Member;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
import dev.plex.util.PlexUtils; import dev.plex.util.PlexUtils;
import dev.plex.util.minimessage.SafeMiniMessage; import dev.plex.util.minimessage.SafeMiniMessage;
import io.papermc.paper.chat.ChatRenderer; import io.papermc.paper.chat.ChatRenderer;
import io.papermc.paper.event.player.AsyncChatEvent; import io.papermc.paper.event.player.AsyncChatEvent;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextReplacementConfig; import net.kyori.adventure.text.TextReplacementConfig;
@ -19,21 +20,17 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags; import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Objects; public class ChatHandlerImpl
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
public class ChatHandlerImpl implements IChatHandler
{ {
private final static TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig.builder().match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]").replacement((matchResult, builder) -> Component.empty().content(matchResult.group()).clickEvent(ClickEvent.openUrl(matchResult.group()))).build(); private final static TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig.builder().match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]").replacement((matchResult, builder) -> Component.empty().content(matchResult.group()).clickEvent(ClickEvent.openUrl(matchResult.group()))).build();
private final PlexChatRenderer renderer = new PlexChatRenderer(); private final PlexChatRenderer renderer = new PlexChatRenderer();
@Override @EventHandler
public void doChat(AsyncChatEvent event) public void doChat(AsyncChatEvent event)
{ {
event.renderer(renderer); event.renderer(renderer);