mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-29 11:49:14 +00:00
3.0
This commit is contained in:
55
compatibility/build.gradle.kts
Normal file
55
compatibility/build.gradle.kts
Normal file
@@ -0,0 +1,55 @@
|
||||
plugins {
|
||||
id("io.github.goooler.shadow") version "8.1.8"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven("https://papermc.io/repo/repository/maven-public/") // paper
|
||||
maven("https://repo.william278.net/releases/") // husk
|
||||
maven("https://jitpack.io/")
|
||||
maven("https://repo.oraxen.com/releases/")
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // papi
|
||||
maven("https://repo.essentialsx.net/releases/") // ess
|
||||
maven("https://repo.md-5.net/content/groups/public/") // disguise
|
||||
maven("https://repo.opencollab.dev/main/") // geyser
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":api"))
|
||||
compileOnly(project(":common"))
|
||||
// Platform
|
||||
compileOnly("dev.folia:folia-api:${rootProject.properties["paper_version"]}-R0.1-SNAPSHOT")
|
||||
// Chat
|
||||
compileOnly(files("libs/VentureChat-3.7.1.jar"))
|
||||
compileOnly(files("libs/TrChat-2.0.11.jar"))
|
||||
compileOnly(files("libs/carbonchat-paper-3.0.0-beta.27.jar"))
|
||||
compileOnly(files("libs/AdvancedChat-1.3.7.jar"))
|
||||
compileOnly(files("libs/CMIAPI-9.7.4.1.jar"))
|
||||
compileOnly("net.william278.huskchat:huskchat-bukkit:3.0.4")
|
||||
compileOnly("net.essentialsx:EssentialsX:2.20.1")
|
||||
compileOnly("net.essentialsx:EssentialsXChat:2.20.1")
|
||||
// Emoji
|
||||
compileOnly("com.github.LoneDev6:api-itemsadder:3.6.3-beta-14")
|
||||
compileOnly("io.th0rgal:oraxen:1.182.0")
|
||||
// PAPI
|
||||
compileOnly("me.clip:placeholderapi:${rootProject.properties["placeholder_api_version"]}")
|
||||
// Disguise
|
||||
compileOnly("LibsDisguises:LibsDisguises:10.0.44")
|
||||
// Geyser
|
||||
compileOnly("org.geysermc.geyser:api:2.4.2-SNAPSHOT")
|
||||
// Floodgate
|
||||
compileOnly("org.geysermc.floodgate:api:2.2.3-SNAPSHOT")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
options.release.set(17)
|
||||
dependsOn(tasks.clean)
|
||||
}
|
||||
BIN
compatibility/libs/AdvancedChat-1.3.7.jar
Normal file
BIN
compatibility/libs/AdvancedChat-1.3.7.jar
Normal file
Binary file not shown.
BIN
compatibility/libs/CMIAPI-9.7.4.1.jar
Normal file
BIN
compatibility/libs/CMIAPI-9.7.4.1.jar
Normal file
Binary file not shown.
BIN
compatibility/libs/TrChat-2.0.11.jar
Normal file
BIN
compatibility/libs/TrChat-2.0.11.jar
Normal file
Binary file not shown.
BIN
compatibility/libs/VentureChat-3.7.1.jar
Normal file
BIN
compatibility/libs/VentureChat-3.7.1.jar
Normal file
Binary file not shown.
BIN
compatibility/libs/carbonchat-paper-3.0.0-beta.27.jar
Normal file
BIN
compatibility/libs/carbonchat-paper-3.0.0-beta.27.jar
Normal file
Binary file not shown.
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.expansion.Relational;
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.feature.TickStampData;
|
||||
import net.momirealms.customnameplates.api.placeholder.Placeholder;
|
||||
import net.momirealms.customnameplates.api.placeholder.PlayerPlaceholder;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class NameplatesExpansion extends PlaceholderExpansion implements Relational {
|
||||
|
||||
private final CustomNameplates plugin;
|
||||
|
||||
public NameplatesExpansion(CustomNameplates plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
return "nameplates";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
return "XiaoMoMi";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return "3.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||
Placeholder placeholder = plugin.getPlaceholderManager().getRegisteredPlaceholder("%np_" + params + "%");
|
||||
if (placeholder instanceof PlayerPlaceholder playerPlaceholder) {
|
||||
CNPlayer cnPlayer = player == null ? null : plugin.getPlayer(player.getUniqueId());
|
||||
if (placeholder.children().isEmpty()) {
|
||||
return playerPlaceholder.request(cnPlayer);
|
||||
}
|
||||
if (cnPlayer != null) {
|
||||
cnPlayer.forceUpdate(Set.of(placeholder), Collections.emptySet());
|
||||
return cnPlayer.getData(placeholder);
|
||||
} else {
|
||||
try {
|
||||
return playerPlaceholder.request(null);
|
||||
} catch (NullPointerException e) {
|
||||
plugin.getPluginLogger().warn("%nameplates_" + params + "% contains a placeholder that requires a player as the parameter");
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player p1, Player p2, String params) {
|
||||
CNPlayer cnPlayer1 = p1 == null ? null : plugin.getPlayer(p1.getUniqueId());
|
||||
CNPlayer cnPlayer2 = p2 == null ? null : plugin.getPlayer(p2.getUniqueId());
|
||||
if (p1 == null || p2 == null) {
|
||||
return null;
|
||||
}
|
||||
Placeholder placeholder = plugin.getPlaceholderManager().getRegisteredPlaceholder("%rel_np_" + params + "%");
|
||||
if (placeholder != null) {
|
||||
cnPlayer1.forceUpdate(Set.of(placeholder), Set.of(cnPlayer2));
|
||||
return Optional.ofNullable(cnPlayer1.getRelationalValue(placeholder, cnPlayer2)).map(TickStampData::data).orElse(placeholder.id());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.bedrock;
|
||||
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class FloodGateUtils {
|
||||
|
||||
public static boolean isBedrockPlayer(UUID uuid) {
|
||||
return FloodgateApi.getInstance().isFloodgatePlayer(uuid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.bedrock;
|
||||
|
||||
import org.geysermc.api.Geyser;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class GeyserUtils {
|
||||
|
||||
public static boolean isBedrockPlayer(UUID uuid) {
|
||||
return Geyser.api().isBedrockPlayer(uuid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.chat;
|
||||
|
||||
import net.advancedplugins.chat.api.AdvancedChannelChatEvent;
|
||||
import net.advancedplugins.chat.api.AdvancedChatAPI;
|
||||
import net.advancedplugins.chat.channel.ChatChannel;
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.AbstractChatMessageProvider;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.ChatManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class AdvancedChatProvider extends AbstractChatMessageProvider implements Listener {
|
||||
|
||||
public AdvancedChatProvider(CustomNameplates plugin, ChatManager manager) {
|
||||
super(plugin, manager);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onAdvancedChat(AdvancedChannelChatEvent event) {
|
||||
String channel = event.getChannel().getSectionName();
|
||||
if (event.getSender() instanceof Player player) {
|
||||
if (!player.isOnline()) return;
|
||||
CNPlayer cnPlayer = plugin.getPlayer(player.getUniqueId());
|
||||
if (cnPlayer == null) return;
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
manager.onChat(cnPlayer, event.getMessage(), channel);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasJoinedChannel(CNPlayer player, String channelID) {
|
||||
ChatChannel chatChannel = AdvancedChatAPI.getApi().getPlayerChatChannel(player.uuid());
|
||||
if (chatChannel == null) {
|
||||
return false;
|
||||
}
|
||||
return chatChannel.getSectionName().equals(channelID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canJoinChannel(CNPlayer player, String channelID) {
|
||||
ChatChannel chatChannel = AdvancedChatAPI.getApi().getPlayerChatChannel(player.uuid());
|
||||
if (chatChannel == null) {
|
||||
return false;
|
||||
}
|
||||
return chatChannel.getSectionName().equals(channelID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoring(CNPlayer sender, CNPlayer receiver) {
|
||||
return AdvancedChatAPI.getApi().getIgnoredPlayers((Player) receiver.player()).contains(sender.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("CustomNameplates")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.chat;
|
||||
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.ConfigManager;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.AbstractChatMessageProvider;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.ChatManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class AsyncChatProvider extends AbstractChatMessageProvider implements Listener {
|
||||
|
||||
public AsyncChatProvider(CustomNameplates plugin, ChatManager manager) {
|
||||
super(plugin, manager);
|
||||
}
|
||||
|
||||
// This event is not async sometimes
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
if (!ConfigManager.chatUnsafe() && event.isCancelled()) return;
|
||||
CNPlayer player = plugin.getPlayer(event.getPlayer().getUniqueId());
|
||||
if (player == null) return;
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
manager.onChat(player, event.getMessage(), "global");
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasJoinedChannel(CNPlayer player, String channelID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canJoinChannel(CNPlayer player, String channelID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoring(CNPlayer sender, CNPlayer receiver) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("CustomNameplates")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.chat;
|
||||
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.channels.ChannelRegistry;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.event.CarbonEventSubscription;
|
||||
import net.draycia.carbon.api.event.events.CarbonChatEvent;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.AbstractChatMessageProvider;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.ChatManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CarbonChatProvider extends AbstractChatMessageProvider {
|
||||
|
||||
private final CarbonChat api;
|
||||
private CarbonEventSubscription<CarbonChatEvent> subscription;
|
||||
private final Method originalMessageMethod;
|
||||
private final Method channelKeyMethod;
|
||||
private final Method getChannelByKeyMethod;
|
||||
private final Method getKeyAsStringMethod;
|
||||
private final Method getKeyFromStringMethod;
|
||||
private final Object miniMessageInstance;
|
||||
private final Method serializeComponentMethod;
|
||||
|
||||
public CarbonChatProvider(CustomNameplates plugin, ChatManager manager) {
|
||||
super(plugin, manager);
|
||||
this.api = net.draycia.carbon.api.CarbonChatProvider.carbonChat();
|
||||
try {
|
||||
this.originalMessageMethod = CarbonChatEvent.class.getMethod("originalMessage");
|
||||
this.channelKeyMethod = ChatChannel.class.getMethod("key");
|
||||
Class<?> keyClass = Class.forName("net{}kyori{}adventure{}key{}Key".replace("{}", "."));
|
||||
this.getKeyAsStringMethod = keyClass.getMethod("asString");
|
||||
this.getKeyFromStringMethod = keyClass.getMethod("key", String.class);
|
||||
this.getChannelByKeyMethod = ChannelRegistry.class.getMethod("channel", keyClass);
|
||||
Class<?> miniMessageClass = Class.forName("net{}kyori{}adventure{}text{}minimessage{}MiniMessage".replace("{}", "."));
|
||||
Method miniMessageInstanceGetMethod = miniMessageClass.getMethod("miniMessage");
|
||||
this.miniMessageInstance = miniMessageInstanceGetMethod.invoke(null);
|
||||
Class<?> componentClass = Class.forName("net{}kyori{}adventure{}text{}Component".replace("{}", "."));
|
||||
this.serializeComponentMethod = miniMessageClass.getMethod("serialize", componentClass);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
subscription = api.eventHandler().subscribe(CarbonChatEvent.class, event -> {
|
||||
if (event.cancelled())
|
||||
return;
|
||||
try {
|
||||
ChatChannel chatChannel = event.chatChannel();
|
||||
Object key = getChannelKey(chatChannel);
|
||||
if (key == null) return;
|
||||
String channel = (String) getKeyAsStringMethod.invoke(key);
|
||||
Player player = Bukkit.getPlayer(event.sender().uuid());
|
||||
if (player == null || !player.isOnline())
|
||||
return;
|
||||
CNPlayer cnPlayer = plugin.getPlayer(player.getUniqueId());
|
||||
if (cnPlayer == null) return;
|
||||
Object component = getComponentFromEvent(event);
|
||||
String message = (String) serializeComponentMethod.invoke(miniMessageInstance, component);
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
manager.onChat(cnPlayer, message, channel);
|
||||
});
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
if (subscription != null) {
|
||||
subscription.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private CarbonPlayer carbonPlayer(UUID uuid) {
|
||||
CarbonPlayer carbonPlayer = null;
|
||||
for (CarbonPlayer cPlayer : api.server().players()) {
|
||||
if (cPlayer.uuid().equals(uuid)) {
|
||||
carbonPlayer = cPlayer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return carbonPlayer;
|
||||
}
|
||||
|
||||
private Object getChannelKey(ChatChannel channel) {
|
||||
try {
|
||||
return this.channelKeyMethod.invoke(channel);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Object getComponentFromEvent(CarbonChatEvent event) {
|
||||
try {
|
||||
return this.originalMessageMethod.invoke(event);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasJoinedChannel(CNPlayer player, String channelID) {
|
||||
CarbonPlayer cPlayer = null;
|
||||
for (CarbonPlayer carbonPlayer : api.server().players()) {
|
||||
if (carbonPlayer.uuid().equals(player.uuid())) {
|
||||
cPlayer = carbonPlayer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
ChatChannel selectedChannel = cPlayer.selectedChannel();
|
||||
ChatChannel currentChannel = selectedChannel != null ? selectedChannel : api.channelRegistry().defaultChannel();
|
||||
Object key = getChannelKey(currentChannel);
|
||||
String str = (String) getKeyAsStringMethod.invoke(key);
|
||||
return str.equals(channelID);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canJoinChannel(CNPlayer player, String channelID) {
|
||||
ChannelRegistry registry = api.channelRegistry();
|
||||
Object key;
|
||||
try {
|
||||
key = getKeyFromStringMethod.invoke(null, channelID);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (key == null) {
|
||||
return false;
|
||||
}
|
||||
ChatChannel channel;
|
||||
try {
|
||||
channel = (ChatChannel) getChannelByKeyMethod.invoke(registry, key);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (channel == null) {
|
||||
return false;
|
||||
}
|
||||
String perm = channel.permission();
|
||||
if (perm == null) {
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoring(CNPlayer sender, CNPlayer receiver) {
|
||||
CarbonPlayer sPlayer = carbonPlayer(sender.uuid());
|
||||
CarbonPlayer rPlayer = carbonPlayer(receiver.uuid());
|
||||
if (sPlayer == null || rPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
return rPlayer.ignoring(sPlayer.uuid());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.chat;
|
||||
|
||||
import net.essentialsx.api.v2.events.chat.ChatEvent;
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.AbstractChatMessageProvider;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.ChatManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class EssentialsChatProvider extends AbstractChatMessageProvider implements Listener {
|
||||
|
||||
public EssentialsChatProvider(CustomNameplates plugin, ChatManager manager) {
|
||||
super(plugin, manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasJoinedChannel(CNPlayer player, String channelID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canJoinChannel(CNPlayer player, String channelID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoring(CNPlayer sender, CNPlayer receiver) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEssChat(ChatEvent event) {
|
||||
String channel = event.getChatType().key();
|
||||
Player player = Bukkit.getPlayer(event.getPlayer().getUniqueId());
|
||||
if (player == null || !player.isOnline())
|
||||
return;
|
||||
CNPlayer cnPlayer = plugin.getPlayer(player.getUniqueId());
|
||||
if (cnPlayer == null)
|
||||
return;
|
||||
plugin.getScheduler().async().execute(() -> manager.onChat(cnPlayer, event.getMessage(), channel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("CustomNameplates")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.chat;
|
||||
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.AbstractChatMessageProvider;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.ChatManager;
|
||||
import net.william278.huskchat.BukkitHuskChat;
|
||||
import net.william278.huskchat.api.BukkitHuskChatAPI;
|
||||
import net.william278.huskchat.channel.Channel;
|
||||
import net.william278.huskchat.event.ChatMessageEvent;
|
||||
import net.william278.huskchat.user.OnlineUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class HuskChatProvider extends AbstractChatMessageProvider implements Listener {
|
||||
|
||||
private final BukkitHuskChat huskChat;
|
||||
|
||||
public HuskChatProvider(CustomNameplates plugin, ChatManager manager) {
|
||||
super(plugin, manager);
|
||||
this.huskChat = (BukkitHuskChat) Bukkit.getPluginManager().getPlugin("HuskChat");
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onHuskChat(ChatMessageEvent event) {
|
||||
String channel = event.getChannelId();
|
||||
Player player = Bukkit.getPlayer(event.getSender().getUuid());
|
||||
if (player == null || !player.isOnline())
|
||||
return;
|
||||
CNPlayer cnPlayer = plugin.getPlayer(player.getUniqueId());
|
||||
if (cnPlayer == null) {
|
||||
return;
|
||||
}
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
manager.onChat(cnPlayer, event.getMessage(), channel);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasJoinedChannel(CNPlayer player, String channelID) {
|
||||
OnlineUser onlineUser = BukkitHuskChatAPI.getInstance().adaptPlayer((Player) player.player());
|
||||
Optional<String> channel = BukkitHuskChatAPI.getInstance().getPlayerChannel(onlineUser);
|
||||
return channel.map(s -> s.equals(channelID)).orElse(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canJoinChannel(CNPlayer player, String channelID) {
|
||||
Optional<Channel> channel = huskChat.getChannels().getChannel(channelID);
|
||||
if (channel.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Optional<String> optionalReceivePerm = channel.get().getPermissions().getReceive();
|
||||
return optionalReceivePerm.map(player::hasPermission).orElse(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoring(CNPlayer sender, CNPlayer receiver) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("CustomNameplates")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.chat;
|
||||
|
||||
import me.arasple.mc.trchat.TrChat;
|
||||
import me.arasple.mc.trchat.api.event.TrChatEvent;
|
||||
import me.arasple.mc.trchat.module.display.channel.Channel;
|
||||
import me.arasple.mc.trchat.module.internal.filter.FilteredObject;
|
||||
import me.arasple.mc.trchat.taboolib.platform.BukkitAdapter;
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.AbstractChatMessageProvider;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.ChatManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class TrChatProvider extends AbstractChatMessageProvider implements Listener {
|
||||
|
||||
private final BukkitAdapter adapter;
|
||||
|
||||
public TrChatProvider(CustomNameplates plugin, ChatManager manager) {
|
||||
super(plugin, manager);
|
||||
this.adapter = new BukkitAdapter();
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onTrChat(TrChatEvent event) {
|
||||
if (!event.getForward()) return;
|
||||
Channel channel = event.getChannel();
|
||||
String channelName = channel.getId();
|
||||
Player player = event.getSession().getPlayer();
|
||||
CNPlayer cnPlayer = plugin.getPlayer(player.getUniqueId());
|
||||
if (cnPlayer == null || !cnPlayer.isOnline()) {
|
||||
return;
|
||||
}
|
||||
FilteredObject object = TrChat.INSTANCE.api().getFilterManager().filter(event.getMessage(), adapter.adaptPlayer(event.getPlayer()), true);
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
manager.onChat(cnPlayer, object.getFiltered(), channelName);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasJoinedChannel(CNPlayer player, String channelID) {
|
||||
if (TrChat.INSTANCE.api().getChannelManager().getChannel(channelID) instanceof Channel channel) {
|
||||
return channel.getListeners().contains(player.name());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canJoinChannel(CNPlayer player, String channelID) {
|
||||
if (TrChat.INSTANCE.api().getChannelManager().getChannel(channelID) instanceof Channel channel) {
|
||||
String perm = channel.getSettings().getJoinPermission();
|
||||
return player.hasPermission(perm);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoring(CNPlayer sender, CNPlayer receiver) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("CustomNameplates")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.chat;
|
||||
|
||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||
import mineverse.Aust1n46.chat.api.events.VentureChatEvent;
|
||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.AbstractChatMessageProvider;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.chat.ChatManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class VentureChatProvider extends AbstractChatMessageProvider implements Listener {
|
||||
|
||||
public VentureChatProvider(CustomNameplates plugin, ChatManager manager) {
|
||||
super(plugin, manager);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVentureChat(VentureChatEvent event) {
|
||||
String channelName = event.getChannel().getName();
|
||||
final MineverseChatPlayer chatPlayer = event.getMineverseChatPlayer();
|
||||
if (chatPlayer == null) {
|
||||
return;
|
||||
}
|
||||
Player player = chatPlayer.getPlayer();
|
||||
CNPlayer cnPlayer = plugin.getPlayer(player.getUniqueId());
|
||||
if (cnPlayer == null) {
|
||||
return;
|
||||
}
|
||||
plugin.getScheduler().async().execute(() -> {
|
||||
manager.onChat(cnPlayer, event.getChat(), channelName);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasJoinedChannel(CNPlayer player, String channelID) {
|
||||
MineverseChatPlayer mcp = MineverseChatAPI.getOnlineMineverseChatPlayer((Player) player.player());
|
||||
return mcp.getCurrentChannel().getName().equals(channelID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canJoinChannel(CNPlayer player, String channelID) {
|
||||
ChatChannel channel = ChatChannel.getChannel(channelID);
|
||||
if (channel == null) {
|
||||
return false;
|
||||
}
|
||||
if (channel.hasPermission()) {
|
||||
return player.hasPermission(channel.getPermission());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoring(CNPlayer sender, CNPlayer receiver) {
|
||||
MineverseChatPlayer mcp = MineverseChatAPI.getOnlineMineverseChatPlayer((Player) receiver.player());
|
||||
return mcp.getIgnores().contains(sender.uuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("CustomNameplates")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.disguise;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class DisguiseUtils {
|
||||
|
||||
public static boolean isDisguised(Entity entity) {
|
||||
return DisguiseAPI.isDisguised(entity);
|
||||
}
|
||||
|
||||
public static double getDisguisedHeight(Entity entity) {
|
||||
Disguise disguise = DisguiseAPI.getDisguise(entity);
|
||||
return disguise.getHeight() + disguise.getWatcher().getYModifier() + disguise.getWatcher().getNameYModifier();
|
||||
}
|
||||
|
||||
public static EntityType getDisguisedType(Entity entity) {
|
||||
return DisguiseAPI.getDisguise(entity).getType().getEntityType();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.emoji;
|
||||
|
||||
import dev.lone.itemsadder.api.FontImages.FontImageWrapper;
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.emoji.EmojiProvider;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ItemsAdderEmojiProvider implements EmojiProvider {
|
||||
|
||||
@Override
|
||||
public String replace(CNPlayer player, String text) {
|
||||
try {
|
||||
return FontImageWrapper.replaceFontImages((Player) player.player(), text).replace("§f","<white><font:default>").replace("§r","</font></white>");
|
||||
} catch (NoSuchMethodError ignore) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bukkit.compatibility.emoji;
|
||||
|
||||
import io.th0rgal.oraxen.OraxenPlugin;
|
||||
import io.th0rgal.oraxen.font.FontManager;
|
||||
import io.th0rgal.oraxen.font.Glyph;
|
||||
import net.momirealms.customnameplates.api.CNPlayer;
|
||||
import net.momirealms.customnameplates.api.feature.bubble.emoji.EmojiProvider;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class OraxenEmojiProvider implements EmojiProvider {
|
||||
|
||||
private final FontManager fontManager;
|
||||
|
||||
public OraxenEmojiProvider() {
|
||||
this.fontManager = OraxenPlugin.get().getFontManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String replace(CNPlayer player, String text) {
|
||||
for (Map.Entry<String, Glyph> entry : this.fontManager.getGlyphByPlaceholderMap().entrySet()) {
|
||||
if (entry.getValue().hasPermission((Player) player.player())) {
|
||||
text = text.replace(entry.getKey(), "<white><font:default>" + entry.getValue().getCharacter() + "</font></white>");
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user