mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-19 15:09:23 +00:00
improve team management
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package net.momirealms.customnameplates.api.manager;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,13 +13,6 @@ public interface TeamManager {
|
||||
*/
|
||||
void createTeam(Player player);
|
||||
|
||||
/**
|
||||
* Create a team for a player on proxy
|
||||
*
|
||||
* @param player player
|
||||
*/
|
||||
void createProxyTeam(Player player);
|
||||
|
||||
/**
|
||||
* Remove a team for a player
|
||||
*
|
||||
@@ -29,13 +21,9 @@ public interface TeamManager {
|
||||
void removeTeam(Player player);
|
||||
|
||||
/**
|
||||
* Remove a team for a player on proxy
|
||||
*
|
||||
* @param player player
|
||||
* Update a player's team for a viewer
|
||||
*/
|
||||
void removeProxyTeam(Player player);
|
||||
|
||||
void updateTeam(Player owner, Player viewer, Component prefix, Component suffix, TeamColor color, TeamTagVisibility visibility);
|
||||
void updateTeam(Player owner, Player viewer, String prefix, String suffix, TeamColor color, TeamTagVisibility visibility);
|
||||
|
||||
/**
|
||||
* Get the team player in
|
||||
|
||||
@@ -2,8 +2,8 @@ package net.momirealms.customnameplates.api.mechanic.nameplate;
|
||||
|
||||
import net.momirealms.customnameplates.api.mechanic.character.ConfiguredChar;
|
||||
import net.momirealms.customnameplates.api.mechanic.font.OffsetFont;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.api.util.FontUtils;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
|
||||
public class Nameplate {
|
||||
|
||||
@@ -98,13 +98,13 @@ public class Nameplate {
|
||||
}
|
||||
stringBuilder.append(OffsetFont.getShortestNegChars(middle.getWidth() - (textWidth+2) % middle.getWidth() + 1)); // +1
|
||||
}
|
||||
stringBuilder.append("</#FEFEFE>");
|
||||
stringBuilder.append("<#FDFEFE>");
|
||||
stringBuilder.append(middle.getCharacter());
|
||||
stringBuilder.append("</#FDFEFE>");
|
||||
stringBuilder.append(OffsetFont.NEG_1.getCharacter());
|
||||
stringBuilder.append(right.getCharacter());
|
||||
stringBuilder.append("</#FEFEFE>");
|
||||
stringBuilder.append(OffsetFont.getShortestNegChars(textWidth + right.getWidth() + 1)); // -1;
|
||||
stringBuilder.append("</#FDFEFE>");
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package net.momirealms.customnameplates.api.mechanic.placeholder;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.api.manager.RequirementManager;
|
||||
import net.momirealms.customnameplates.api.requirement.Condition;
|
||||
import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.momirealms.customnameplates.api.mechanic.tag.team;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.api.manager.TeamTagManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.misc.ViewerText;
|
||||
@@ -70,8 +69,8 @@ public class TeamPlayer implements NameplatePlayer {
|
||||
CustomNameplatesPlugin.get().getTeamManager().updateTeam(
|
||||
owner,
|
||||
viewer,
|
||||
CustomNameplatesPlugin.get().getAdventure().getComponentFromMiniMessage(prefix.getLatestValue(viewer)),
|
||||
CustomNameplatesPlugin.get().getAdventure().getComponentFromMiniMessage(suffix.getLatestValue(viewer)),
|
||||
prefix.getLatestValue(viewer),
|
||||
suffix.getLatestValue(viewer),
|
||||
CustomNameplatesPlugin.get().getNameplateManager().getTeamColor(owner),
|
||||
TeamTagVisibility.ALWAYS
|
||||
);
|
||||
@@ -85,8 +84,8 @@ public class TeamPlayer implements NameplatePlayer {
|
||||
CustomNameplatesPlugin.get().getTeamManager().updateTeam(
|
||||
owner,
|
||||
viewer,
|
||||
Component.text(""),
|
||||
Component.text(""),
|
||||
"",
|
||||
"",
|
||||
TeamColor.WHITE,
|
||||
TeamTagVisibility.ALWAYS
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.momirealms.customnameplates.api.mechanic.tag.unlimited;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.api.manager.UnlimitedTagManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
|
||||
@@ -175,8 +174,8 @@ public class UnlimitedPlayer extends UnlimitedObject implements NameplatePlayer
|
||||
CustomNameplatesPlugin.get().getTeamManager().updateTeam(
|
||||
owner,
|
||||
viewer,
|
||||
Component.text(""),
|
||||
Component.text(""),
|
||||
"",
|
||||
"",
|
||||
TeamColor.WHITE,
|
||||
TeamTagVisibility.NEVER
|
||||
);
|
||||
@@ -186,8 +185,8 @@ public class UnlimitedPlayer extends UnlimitedObject implements NameplatePlayer
|
||||
CustomNameplatesPlugin.get().getTeamManager().updateTeam(
|
||||
owner,
|
||||
viewer,
|
||||
Component.text(""),
|
||||
Component.text(""),
|
||||
"",
|
||||
"",
|
||||
TeamColor.WHITE,
|
||||
TeamTagVisibility.ALWAYS
|
||||
);
|
||||
|
||||
@@ -41,7 +41,8 @@ allprojects {
|
||||
maven("https://repo.minebench.de/")
|
||||
maven("https://repo.xenondevs.xyz/releases/")
|
||||
maven("https://repo.kryptonmc.org/releases")
|
||||
maven("https://repo.oraxen.com/releases")
|
||||
maven("https://repo.oraxen.com/releases/")
|
||||
maven("https://nexus.codecrafter47.de/content/repositories/public/")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +54,9 @@ subprojects {
|
||||
filesMatching("*plugin.yml") {
|
||||
expand(props)
|
||||
}
|
||||
filesMatching("bungee.yml") {
|
||||
expand(props)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
dependencies {
|
||||
implementation(project(":common"))
|
||||
// TAB
|
||||
compileOnly("me.neznamy:tab-api:4.0.2")
|
||||
// BungeeTabListPlus
|
||||
compileOnly("codecrafter47.bungeetablistplus:bungeetablistplus-api-bungee:3.6.4")
|
||||
// BungeeCord
|
||||
compileOnly("net.md-5:bungeecord-api:1.20-R0.2-SNAPSHOT")
|
||||
compileOnly("net.md-5:bungeecord-protocol:1.20-R0.2-SNAPSHOT")
|
||||
compileOnly("net.md-5:bungeecord-event:1.20-R0.2-SNAPSHOT")
|
||||
compileOnly("net.md-5:bungeecord-proxy:1.20-R0.2-SNAPSHOT")
|
||||
|
||||
implementation("net.kyori:adventure-api:4.15.0")
|
||||
implementation("net.kyori:adventure-platform-bungeecord:4.3.2")
|
||||
implementation("net.kyori:adventure-text-minimessage:4.15.0")
|
||||
implementation("net.kyori:adventure-text-serializer-legacy:4.15.0")
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
relocate ("net.kyori", "net.momirealms.customnameplates.libraries")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.momirealms.customnameplates.bungeecord;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
public class CustomNameplatesBungeeCord extends Plugin implements Listener {
|
||||
|
||||
private static final String CHANNEL = "customnameplates:cnp";
|
||||
private static CustomNameplatesBungeeCord instance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
this.getProxy().registerChannel(CHANNEL);
|
||||
this.getProxy().getPluginManager().registerListener(this, this);
|
||||
this.getLogger().warning("It's not necessary to install the plugin on BungeeCord now!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.getProxy().unregisterChannel(CHANNEL);
|
||||
this.getProxy().getPluginManager().unregisterListener(this);
|
||||
}
|
||||
|
||||
public static CustomNameplatesBungeeCord getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static CustomNameplatesBungeeCord get() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
5
bungeecord/src/main/resources/bungee.yml
Normal file
5
bungeecord/src/main/resources/bungee.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
name: CustomNameplates
|
||||
main: net.momirealms.customnameplates.bungeecord.CustomNameplatesBungeeCord
|
||||
version: '${version}'
|
||||
author: XiaoMoMi
|
||||
softDepends: [TAB, BungeeTabListPlus]
|
||||
@@ -1,9 +0,0 @@
|
||||
name: CustomNameplates
|
||||
version: '${version}'
|
||||
main: net.momirealms.customnameplates.paper.Main
|
||||
api-version: 1.17
|
||||
authors: [ XiaoMoMi ]
|
||||
folia-supported: true
|
||||
depend:
|
||||
- ProtocolLib
|
||||
- PlaceholderAPI
|
||||
@@ -4,7 +4,6 @@ import java.util.Locale;
|
||||
|
||||
public enum TeamColor {
|
||||
|
||||
NONE,
|
||||
BLACK,
|
||||
DARK_BLUE,
|
||||
DARK_GREEN,
|
||||
@@ -21,6 +20,7 @@ public enum TeamColor {
|
||||
LIGHT_PURPLE,
|
||||
YELLOW,
|
||||
WHITE,
|
||||
NONE,
|
||||
CUSTOM;
|
||||
|
||||
public TeamColor getById(String id) throws IllegalArgumentException {
|
||||
|
||||
@@ -43,7 +43,7 @@ dependencies {
|
||||
|
||||
// adventure
|
||||
implementation("net.kyori:adventure-api:4.15.0")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.3.1")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.3.2")
|
||||
implementation("net.kyori:adventure-text-minimessage:4.15.0")
|
||||
implementation("net.kyori:adventure-text-serializer-legacy:4.15.0")
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package net.momirealms.customnameplates.paper.mechanic.bossbar;
|
||||
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.api.manager.BossBarManager;
|
||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.paper.mechanic.misc.DisplayController;
|
||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||
import net.momirealms.customnameplates.paper.util.ConfigUtils;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package net.momirealms.customnameplates.paper.mechanic.bossbar;
|
||||
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.api.requirement.Condition;
|
||||
import net.momirealms.customnameplates.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.paper.mechanic.misc.DisplayController;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ import net.kyori.adventure.text.minimessage.internal.parser.node.TagNode;
|
||||
import net.kyori.adventure.text.minimessage.internal.parser.node.ValueNode;
|
||||
import net.kyori.adventure.text.minimessage.tag.Inserting;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.common.Key;
|
||||
import net.momirealms.customnameplates.common.Tuple;
|
||||
import net.momirealms.customnameplates.api.manager.WidthManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.background.BackGround;
|
||||
import net.momirealms.customnameplates.api.mechanic.character.ConfiguredChar;
|
||||
@@ -22,6 +20,8 @@ import net.momirealms.customnameplates.api.mechanic.font.FontData;
|
||||
import net.momirealms.customnameplates.api.mechanic.font.OffsetFont;
|
||||
import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
|
||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||
import net.momirealms.customnameplates.common.Key;
|
||||
import net.momirealms.customnameplates.common.Tuple;
|
||||
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
|
||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||
import net.momirealms.customnameplates.paper.util.ConfigUtils;
|
||||
@@ -32,7 +32,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.customnameplates.paper.mechanic.misc;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
@@ -30,4 +31,15 @@ public class PacketManager {
|
||||
this.plugin.debug("Packet sent: " + packet.getType() + " to " + player.getName());
|
||||
this.protocolManager.sendServerPacket(player, packet);
|
||||
}
|
||||
|
||||
public void send(Player player, PacketContainer... packets) {
|
||||
if (plugin.getVersionManager().isVersionNewerThan1_20()) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BUNDLE);
|
||||
|
||||
} else {
|
||||
for (PacketContainer packet : packets) {
|
||||
send(player, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
|
||||
import net.momirealms.customnameplates.api.mechanic.nameplate.TagMode;
|
||||
import net.momirealms.customnameplates.api.mechanic.tag.NameplatePlayer;
|
||||
import net.momirealms.customnameplates.api.mechanic.tag.unlimited.UnlimitedTagSetting;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.api.scheduler.CancellableTask;
|
||||
import net.momirealms.customnameplates.api.util.FontUtils;
|
||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.paper.mechanic.nameplate.tag.listener.*;
|
||||
import net.momirealms.customnameplates.paper.mechanic.nameplate.tag.team.TeamTagManagerImpl;
|
||||
import net.momirealms.customnameplates.paper.mechanic.nameplate.tag.unlimited.UnlimitedTagManagerImpl;
|
||||
@@ -36,6 +36,7 @@ import org.bukkit.event.entity.EntityPoseChangeEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
@@ -270,10 +271,12 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
var player = event.getPlayer();
|
||||
this.putEntityIDToMap(player.getEntityId(), player);
|
||||
if (!CNConfig.isOtherTeamPluginHooked())
|
||||
if (!proxyMode) plugin.getTeamManager().createTeam(player);
|
||||
else plugin.getTeamManager().createProxyTeam(player);
|
||||
this.createNameTag(player);
|
||||
if (!CNConfig.isOtherTeamPluginHooked() && !isProxyMode())
|
||||
plugin.getTeamManager().createTeam(player);
|
||||
plugin.getScheduler().runTaskAsyncLater(() -> {
|
||||
if (player.isOnline())
|
||||
this.createNameTag(player);
|
||||
}, 200, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -285,7 +288,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
this.teamTagManager.handlePlayerQuit(player);
|
||||
this.unlimitedTagManager.handlePlayerQuit(player);
|
||||
|
||||
if (!proxyMode && !CNConfig.isOtherTeamPluginHooked()) {
|
||||
if (!CNConfig.isOtherTeamPluginHooked() && !isProxyMode()) {
|
||||
plugin.getTeamManager().removeTeam(player);
|
||||
}
|
||||
}
|
||||
@@ -500,7 +503,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
|
||||
@Override
|
||||
public boolean isProxyMode() {
|
||||
return proxyMode;
|
||||
return CNConfig.velocitab;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -535,6 +538,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
return nameplate == null ? TeamColor.WHITE : nameplate.getTeamColor();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDefaultNameplate() {
|
||||
return defaultNameplate;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package net.momirealms.customnameplates.paper.mechanic.placeholder;
|
||||
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.api.manager.PlaceholderManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.placeholder.*;
|
||||
import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -19,12 +19,12 @@ package net.momirealms.customnameplates.paper.mechanic.requirement;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.momirealms.biomeapi.BiomeAPI;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.api.manager.RequirementManager;
|
||||
import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||
import net.momirealms.customnameplates.api.requirement.RequirementExpansion;
|
||||
import net.momirealms.customnameplates.api.requirement.RequirementFactory;
|
||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl;
|
||||
import net.momirealms.customnameplates.paper.util.ClassUtils;
|
||||
import net.momirealms.customnameplates.paper.util.ConfigUtils;
|
||||
|
||||
@@ -4,17 +4,14 @@ import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.api.manager.TeamManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.team.*;
|
||||
import net.momirealms.customnameplates.common.message.MessageType;
|
||||
import net.momirealms.customnameplates.common.team.TeamCollisionRule;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
||||
import net.momirealms.customnameplates.paper.mechanic.misc.PacketManager;
|
||||
import net.momirealms.customnameplates.paper.mechanic.team.packet.TeamPacketAdaptor;
|
||||
import net.momirealms.customnameplates.paper.mechanic.team.packet.TeamPacket_1_17;
|
||||
import net.momirealms.customnameplates.paper.mechanic.team.packet.*;
|
||||
import net.momirealms.customnameplates.paper.mechanic.team.provider.CMIProvider;
|
||||
import net.momirealms.customnameplates.paper.mechanic.team.provider.DefaultProvider;
|
||||
import net.momirealms.customnameplates.paper.mechanic.team.provider.TABProvider;
|
||||
@@ -32,64 +29,53 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||
|
||||
private final CustomNameplatesPlugin plugin;
|
||||
private final TeamPacketAdaptor teamPacketAdaptor;
|
||||
private final TeamProvider teamProvider;
|
||||
private TeamProvider teamProvider;
|
||||
private static final String CHANNEL = "customnameplates:cnp";
|
||||
|
||||
public TeamManagerImpl(CustomNameplatesPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.teamPacketAdaptor = new TeamPacket_1_17();
|
||||
if (CNConfig.tabTeam) {
|
||||
teamProvider = new TABProvider();
|
||||
} else if (CNConfig.cmiTeam) {
|
||||
teamProvider = new CMIProvider();
|
||||
} else {
|
||||
teamProvider = new DefaultProvider();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTeam(Player player) {
|
||||
if (CNConfig.isOtherTeamPluginHooked()) {
|
||||
return;
|
||||
}
|
||||
if (CNConfig.disableTeamManage) return;
|
||||
PacketContainer createOwner = teamPacketAdaptor.getTeamCreatePacket(
|
||||
TeamCreatePacket.builder()
|
||||
TeamCreate.builder()
|
||||
.teamName(teamProvider.getTeam(player))
|
||||
.color(TeamColor.WHITE)
|
||||
.prefix(Component.text(""))
|
||||
.suffix(Component.text(""))
|
||||
.display("")
|
||||
.prefix("")
|
||||
.suffix("")
|
||||
.members(Collections.singletonList(player.getName()))
|
||||
.collisionRule(TeamCollisionRule.ALWAYS)
|
||||
.tagVisibility(TeamTagVisibility.ALWAYS)
|
||||
.build()
|
||||
);
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
PacketManager.getInstance().send(online, createOwner);
|
||||
if (online == player) continue;
|
||||
PacketContainer createOther = teamPacketAdaptor.getTeamCreatePacket(
|
||||
TeamCreatePacket.builder()
|
||||
TeamCreate.builder()
|
||||
.teamName(teamProvider.getTeam(online))
|
||||
.color(TeamColor.WHITE)
|
||||
.prefix(Component.text(""))
|
||||
.suffix(Component.text(""))
|
||||
.display("")
|
||||
.prefix("")
|
||||
.suffix("")
|
||||
.members(Collections.singletonList(online.getName()))
|
||||
.collisionRule(TeamCollisionRule.ALWAYS)
|
||||
.tagVisibility(TeamTagVisibility.ALWAYS)
|
||||
.build()
|
||||
);
|
||||
PacketManager.getInstance().send(player, createOther);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createProxyTeam(Player player) {
|
||||
sendPluginMessage(
|
||||
MessageType.CREATE,
|
||||
player.getUniqueId().toString()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTeam(Player player) {
|
||||
if (CNConfig.isOtherTeamPluginHooked()) return;
|
||||
if (CNConfig.disableTeamManage) return;
|
||||
PacketContainer packet = teamPacketAdaptor.getTeamRemovePacket(
|
||||
TeamRemovePacket.builder()
|
||||
TeamRemove.builder()
|
||||
.teamName(teamProvider.getTeam(player))
|
||||
.build()
|
||||
);
|
||||
@@ -100,15 +86,8 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeProxyTeam(Player player) {
|
||||
this.sendPluginMessage(
|
||||
MessageType.REMOVE,
|
||||
player.getName()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTeam(Player owner, Player viewer, Component prefix, Component suffix, TeamColor color, TeamTagVisibility visibility) {
|
||||
public void updateTeam(Player owner, Player viewer, String prefix, String suffix, TeamColor color, TeamTagVisibility visibility) {
|
||||
if (CNConfig.disableTeamManage) return;
|
||||
if (color == TeamColor.NONE || color == TeamColor.CUSTOM)
|
||||
color = TeamColor.WHITE;
|
||||
if (plugin.getNameplateManager().isProxyMode()) {
|
||||
@@ -116,19 +95,21 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||
MessageType.UPDATE,
|
||||
owner.getName(),
|
||||
viewer.getName(),
|
||||
GsonComponentSerializer.gson().serialize(prefix),
|
||||
GsonComponentSerializer.gson().serialize(suffix),
|
||||
prefix,
|
||||
suffix,
|
||||
color.name(),
|
||||
visibility.name()
|
||||
);
|
||||
} else {
|
||||
PacketContainer packet = teamPacketAdaptor.getTeamUpdatePacket(
|
||||
TeamUpdatePacket.builder()
|
||||
TeamUpdate.builder()
|
||||
.teamName(teamProvider.getTeam(owner))
|
||||
.color(color)
|
||||
.display("")
|
||||
.prefix(prefix)
|
||||
.suffix(suffix)
|
||||
.tagVisibility(visibility)
|
||||
.collisionRule(TeamCollisionRule.ALWAYS)
|
||||
.build()
|
||||
);
|
||||
PacketManager.getInstance().send(viewer, packet);
|
||||
@@ -146,6 +127,13 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (CNConfig.tabTeam) {
|
||||
teamProvider = new TABProvider();
|
||||
} else if (CNConfig.cmiTeam) {
|
||||
teamProvider = new CMIProvider();
|
||||
} else {
|
||||
teamProvider = new DefaultProvider();
|
||||
}
|
||||
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(plugin, CHANNEL);
|
||||
Bukkit.getServer().getMessenger().registerIncomingPluginChannel(plugin, CHANNEL, this);
|
||||
}
|
||||
@@ -179,7 +167,6 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||
ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
|
||||
dataOutput.writeByte(messages.length);
|
||||
for (String message : messages) {
|
||||
plugin.debug(message);
|
||||
dataOutput.writeUTF(message);
|
||||
}
|
||||
Bukkit.getOnlinePlayers().stream().findAny().ifPresent(player -> {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package net.momirealms.customnameplates.api.mechanic.team;
|
||||
package net.momirealms.customnameplates.paper.mechanic.team.packet;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customnameplates.common.team.TeamCollisionRule;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
||||
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class TeamCreatePacket {
|
||||
public class TeamCreate {
|
||||
|
||||
// String i
|
||||
private String teamName;
|
||||
@@ -19,11 +19,11 @@ public class TeamCreatePacket {
|
||||
Optional<b> k
|
||||
*/
|
||||
// IChatBaseComponent a
|
||||
private Component teamDisplay;
|
||||
private Object teamDisplay;
|
||||
// IChatBaseComponent b
|
||||
private Component teamPrefix;
|
||||
private Object teamPrefix;
|
||||
// IChatBaseComponent c
|
||||
private Component teamSuffix;
|
||||
private Object teamSuffix;
|
||||
// String d
|
||||
private TeamTagVisibility tagVisibility;
|
||||
// String e
|
||||
@@ -31,18 +31,10 @@ public class TeamCreatePacket {
|
||||
// Enum f
|
||||
private TeamColor teamColor;
|
||||
|
||||
private TeamCreatePacket() {
|
||||
this.teamName = "";
|
||||
this.members = Collections.singleton("");
|
||||
this.teamDisplay = Component.text("");
|
||||
this.teamPrefix = Component.text("");
|
||||
this.teamSuffix = Component.text("");
|
||||
this.tagVisibility = TeamTagVisibility.ALWAYS;
|
||||
this.collisionRule = TeamCollisionRule.ALWAYS;
|
||||
this.teamColor = TeamColor.WHITE;
|
||||
private TeamCreate() {
|
||||
}
|
||||
|
||||
public TeamCreatePacket(
|
||||
public TeamCreate(
|
||||
String teamName,
|
||||
Collection<String> members,
|
||||
Component teamDisplay,
|
||||
@@ -70,15 +62,15 @@ public class TeamCreatePacket {
|
||||
return members;
|
||||
}
|
||||
|
||||
public Component getTeamDisplay() {
|
||||
public Object getTeamDisplay() {
|
||||
return teamDisplay;
|
||||
}
|
||||
|
||||
public Component getTeamPrefix() {
|
||||
public Object getTeamPrefix() {
|
||||
return teamPrefix;
|
||||
}
|
||||
|
||||
public Component getTeamSuffix() {
|
||||
public Object getTeamSuffix() {
|
||||
return teamSuffix;
|
||||
}
|
||||
|
||||
@@ -100,10 +92,10 @@ public class TeamCreatePacket {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private final TeamCreatePacket packet;
|
||||
private final TeamCreate packet;
|
||||
|
||||
public Builder() {
|
||||
this.packet = new TeamCreatePacket();
|
||||
this.packet = new TeamCreate();
|
||||
}
|
||||
|
||||
public static Builder of() {
|
||||
@@ -120,18 +112,18 @@ public class TeamCreatePacket {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder display(Component display) {
|
||||
packet.teamDisplay = display;
|
||||
public Builder display(String display) {
|
||||
packet.teamDisplay = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(display);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder prefix(Component prefix) {
|
||||
packet.teamPrefix = prefix;
|
||||
public Builder prefix(String prefix) {
|
||||
packet.teamPrefix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(prefix);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder suffix(Component suffix) {
|
||||
packet.teamSuffix = suffix;
|
||||
public Builder suffix(String suffix) {
|
||||
packet.teamSuffix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(suffix);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -150,7 +142,7 @@ public class TeamCreatePacket {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TeamCreatePacket build() {
|
||||
public TeamCreate build() {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
package net.momirealms.customnameplates.paper.mechanic.team.packet;
|
||||
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import net.momirealms.customnameplates.api.mechanic.team.TeamCreatePacket;
|
||||
import net.momirealms.customnameplates.api.mechanic.team.TeamRemovePacket;
|
||||
import net.momirealms.customnameplates.api.mechanic.team.TeamUpdatePacket;
|
||||
|
||||
public interface TeamPacketAdaptor {
|
||||
|
||||
PacketContainer getTeamCreatePacket(TeamCreatePacket teamCreatePacket);
|
||||
PacketContainer getTeamCreatePacket(TeamCreate teamCreate);
|
||||
|
||||
PacketContainer getTeamUpdatePacket(TeamUpdatePacket teamUpdatePacket);
|
||||
PacketContainer getTeamUpdatePacket(TeamUpdate teamUpdate);
|
||||
|
||||
PacketContainer getTeamRemovePacket(TeamRemovePacket teamRemovePacket);
|
||||
PacketContainer getTeamRemovePacket(TeamRemove teamRemove);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,7 @@ import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.InternalStructure;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.api.mechanic.team.TeamCreatePacket;
|
||||
import net.momirealms.customnameplates.api.mechanic.team.TeamRemovePacket;
|
||||
import net.momirealms.customnameplates.api.mechanic.team.TeamUpdatePacket;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -17,52 +12,52 @@ import java.util.Optional;
|
||||
public class TeamPacket_1_17 implements TeamPacketAdaptor {
|
||||
|
||||
@Override
|
||||
public PacketContainer getTeamCreatePacket(TeamCreatePacket teamCreatePacket) {
|
||||
public PacketContainer getTeamCreatePacket(TeamCreate teamCreate) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
|
||||
// 0 = create team
|
||||
packet.getModifier().write(0,0);
|
||||
packet.getModifier().write(1, teamCreatePacket.getTeamName());
|
||||
packet.getModifier().write(2, teamCreatePacket.getMembers());
|
||||
packet.getModifier().write(1, teamCreate.getTeamName());
|
||||
packet.getModifier().write(2, teamCreate.getMembers());
|
||||
Optional<InternalStructure> optionalInternalStructure = packet.getOptionalStructures().read(0);
|
||||
if (optionalInternalStructure.isPresent()) {
|
||||
InternalStructure is = optionalInternalStructure.get();
|
||||
// Team
|
||||
is.getChatComponents().write(0, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(teamCreatePacket.getTeamDisplay())));
|
||||
is.getChatComponents().write(1, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(teamCreatePacket.getTeamPrefix())));
|
||||
is.getChatComponents().write(2, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(teamCreatePacket.getTeamSuffix())));
|
||||
is.getModifier().write(3, teamCreatePacket.getTagVisibility().getId());
|
||||
is.getModifier().write(4, teamCreatePacket.getCollisionRule().getId());
|
||||
is.getEnumModifier(TeamColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0, teamCreatePacket.getTeamColor());
|
||||
is.getModifier().write(6, teamCreatePacket.getMembers().size());
|
||||
is.getModifier().write(0, teamCreate.getTeamDisplay());
|
||||
is.getModifier().write(1, teamCreate.getTeamPrefix());
|
||||
is.getModifier().write(2, teamCreate.getTeamSuffix());
|
||||
is.getModifier().write(3, teamCreate.getTagVisibility().getId());
|
||||
is.getModifier().write(4, teamCreate.getCollisionRule().getId());
|
||||
is.getEnumModifier(TeamColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0, teamCreate.getTeamColor());
|
||||
is.getModifier().write(6, teamCreate.getMembers().size());
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketContainer getTeamRemovePacket(TeamRemovePacket teamRemovePacket) {
|
||||
public PacketContainer getTeamRemovePacket(TeamRemove teamRemove) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
|
||||
// 1 = remove team
|
||||
packet.getModifier().write(0,1);
|
||||
packet.getStrings().write(0, teamRemovePacket.getTeamName());
|
||||
packet.getStrings().write(0, teamRemove.getTeamName());
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketContainer getTeamUpdatePacket(TeamUpdatePacket teamUpdatePacket) {
|
||||
public PacketContainer getTeamUpdatePacket(TeamUpdate teamUpdate) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
|
||||
// 2 = update team
|
||||
packet.getModifier().write(0,2);
|
||||
packet.getModifier().write(1, teamUpdatePacket.getTeamName());
|
||||
packet.getModifier().write(1, teamUpdate.getTeamName());
|
||||
Optional<InternalStructure> optionalInternalStructure = packet.getOptionalStructures().read(0);
|
||||
if (optionalInternalStructure.isPresent()) {
|
||||
InternalStructure is = optionalInternalStructure.get();
|
||||
// Team
|
||||
is.getChatComponents().write(0, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(teamUpdatePacket.getTeamDisplay())));
|
||||
is.getChatComponents().write(1, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(teamUpdatePacket.getTeamPrefix())));
|
||||
is.getChatComponents().write(2, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(teamUpdatePacket.getTeamSuffix())));
|
||||
is.getModifier().write(3, teamUpdatePacket.getTagVisibility().getId());
|
||||
is.getModifier().write(4, teamUpdatePacket.getCollisionRule().getId());
|
||||
is.getEnumModifier(TeamColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0, teamUpdatePacket.getTeamColor());
|
||||
is.getModifier().write(0, teamUpdate.getTeamDisplay());
|
||||
is.getModifier().write(1, teamUpdate.getTeamPrefix());
|
||||
is.getModifier().write(2, teamUpdate.getTeamSuffix());
|
||||
is.getModifier().write(3, teamUpdate.getTagVisibility().getId());
|
||||
is.getModifier().write(4, teamUpdate.getCollisionRule().getId());
|
||||
is.getEnumModifier(TeamColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0, teamUpdate.getTeamColor());
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package net.momirealms.customnameplates.api.mechanic.team;
|
||||
package net.momirealms.customnameplates.paper.mechanic.team.packet;
|
||||
|
||||
public class TeamRemovePacket {
|
||||
public class TeamRemove {
|
||||
|
||||
private String teamName;
|
||||
|
||||
private TeamRemovePacket() {
|
||||
private TeamRemove() {
|
||||
}
|
||||
|
||||
public TeamRemovePacket(String teamName) {
|
||||
public TeamRemove(String teamName) {
|
||||
this.teamName = teamName;
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ public class TeamRemovePacket {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private final TeamRemovePacket packet;
|
||||
private final TeamRemove packet;
|
||||
|
||||
public Builder() {
|
||||
this.packet = new TeamRemovePacket();
|
||||
this.packet = new TeamRemove();
|
||||
}
|
||||
|
||||
public Builder teamName(String teamName) {
|
||||
@@ -32,7 +32,7 @@ public class TeamRemovePacket {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TeamRemovePacket build() {
|
||||
public TeamRemove build() {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package net.momirealms.customnameplates.api.mechanic.team;
|
||||
package net.momirealms.customnameplates.paper.mechanic.team.packet;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customnameplates.common.team.TeamCollisionRule;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
||||
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
|
||||
|
||||
public class TeamUpdatePacket {
|
||||
public class TeamUpdate {
|
||||
|
||||
private String teamName;
|
||||
|
||||
@@ -13,11 +13,11 @@ public class TeamUpdatePacket {
|
||||
Optional<b> k
|
||||
*/
|
||||
// IChatBaseComponent a
|
||||
private Component teamDisplay;
|
||||
private Object teamDisplay;
|
||||
// IChatBaseComponent b
|
||||
private Component teamPrefix;
|
||||
private Object teamPrefix;
|
||||
// IChatBaseComponent c
|
||||
private Component teamSuffix;
|
||||
private Object teamSuffix;
|
||||
// String d
|
||||
private TeamTagVisibility tagVisibility;
|
||||
// String e
|
||||
@@ -25,21 +25,14 @@ public class TeamUpdatePacket {
|
||||
// Enum f
|
||||
private TeamColor teamColor;
|
||||
|
||||
private TeamUpdatePacket() {
|
||||
this.teamName = "";
|
||||
this.teamDisplay = Component.text("");
|
||||
this.teamPrefix = Component.text("");
|
||||
this.teamSuffix = Component.text("");
|
||||
this.tagVisibility = TeamTagVisibility.ALWAYS;
|
||||
this.collisionRule = TeamCollisionRule.ALWAYS;
|
||||
this.teamColor = TeamColor.WHITE;
|
||||
private TeamUpdate() {
|
||||
}
|
||||
|
||||
public TeamUpdatePacket(
|
||||
public TeamUpdate(
|
||||
String teamName,
|
||||
Component teamDisplay,
|
||||
Component teamPrefix,
|
||||
Component teamSuffix,
|
||||
Object teamDisplay,
|
||||
Object teamPrefix,
|
||||
Object teamSuffix,
|
||||
TeamTagVisibility tagVisibility,
|
||||
TeamCollisionRule collisionRule,
|
||||
TeamColor teamColor
|
||||
@@ -57,15 +50,15 @@ public class TeamUpdatePacket {
|
||||
return teamName;
|
||||
}
|
||||
|
||||
public Component getTeamDisplay() {
|
||||
public Object getTeamDisplay() {
|
||||
return teamDisplay;
|
||||
}
|
||||
|
||||
public Component getTeamPrefix() {
|
||||
public Object getTeamPrefix() {
|
||||
return teamPrefix;
|
||||
}
|
||||
|
||||
public Component getTeamSuffix() {
|
||||
public Object getTeamSuffix() {
|
||||
return teamSuffix;
|
||||
}
|
||||
|
||||
@@ -87,10 +80,10 @@ public class TeamUpdatePacket {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private final TeamUpdatePacket packet;
|
||||
private final TeamUpdate packet;
|
||||
|
||||
public Builder() {
|
||||
this.packet = new TeamUpdatePacket();
|
||||
this.packet = new TeamUpdate();
|
||||
}
|
||||
|
||||
public static Builder of() {
|
||||
@@ -102,18 +95,18 @@ public class TeamUpdatePacket {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder display(Component display) {
|
||||
packet.teamDisplay = display;
|
||||
public Builder display(String display) {
|
||||
packet.teamDisplay = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(display);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder prefix(Component prefix) {
|
||||
packet.teamPrefix = prefix;
|
||||
public Builder prefix(String prefix) {
|
||||
packet.teamPrefix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(prefix);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder suffix(Component suffix) {
|
||||
packet.teamSuffix = suffix;
|
||||
public Builder suffix(String suffix) {
|
||||
packet.teamSuffix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(suffix);;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -132,7 +125,7 @@ public class TeamUpdatePacket {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TeamUpdatePacket build() {
|
||||
public TeamUpdate build() {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,12 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class TABProvider implements TeamProvider {
|
||||
|
||||
private final TabAPI api;
|
||||
private final SortingManager sortingManager;
|
||||
|
||||
public TABProvider() {
|
||||
this.sortingManager = TabAPI.getInstance().getSortingManager();
|
||||
this.api = TabAPI.getInstance();
|
||||
this.sortingManager = api.getSortingManager();
|
||||
if (sortingManager == null) {
|
||||
LogUtils.warn("Detected that team management is disabled in TAB. Using player name as team name.");
|
||||
}
|
||||
@@ -19,8 +21,14 @@ public class TABProvider implements TeamProvider {
|
||||
|
||||
@Override
|
||||
public String getTeam(Player player) {
|
||||
TabPlayer tabPlayer = TabAPI.getInstance().getPlayer(player.getUniqueId());
|
||||
if (tabPlayer == null || sortingManager == null) return player.getName();
|
||||
TabPlayer tabPlayer = api.getPlayer(player.getUniqueId());
|
||||
if (tabPlayer == null) {
|
||||
return null;
|
||||
}
|
||||
String forced = sortingManager.getForcedTeamName(tabPlayer);
|
||||
if (forced != null) {
|
||||
return forced;
|
||||
}
|
||||
return sortingManager.getOriginalTeamName(tabPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ public class CNConfig {
|
||||
public static boolean hideScoreboardNumber;
|
||||
public static boolean animatedImage;
|
||||
public static boolean textEffects;
|
||||
public static boolean disableTeamManage;
|
||||
public static boolean velocitab;
|
||||
|
||||
public static void load() {
|
||||
try {
|
||||
@@ -108,6 +110,7 @@ public class CNConfig {
|
||||
ventureChatChannel = integrationSection.getBoolean("chat.VentureChat", false);
|
||||
tabTeam = integrationSection.getBoolean("team.TAB", false);
|
||||
cmiTeam = integrationSection.getBoolean("team.CMI", false);
|
||||
velocitab = integrationSection.getBoolean("team.Velocitab", false);
|
||||
}
|
||||
|
||||
ConfigurationSection packSection = config.getConfigurationSection("resource-pack");
|
||||
@@ -137,6 +140,7 @@ public class CNConfig {
|
||||
textEffects = packSection.getBoolean("shader.ItemsAdder-text-effects", false);
|
||||
}
|
||||
|
||||
disableTeamManage = config.getBoolean("other-settings.disable-team-management", false);
|
||||
corePoolSize = config.getInt("other-settings.thread-pool-settings.corePoolSize", 10);
|
||||
maximumPoolSize = config.getInt("other-settings.thread-pool-settings.maximumPoolSize", 10);
|
||||
keepAliveTime = config.getInt("other-settings.thread-pool-settings.keepAliveTime", 30);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package net.momirealms.customnameplates.paper.util;
|
||||
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.paper.mechanic.misc.TimeLimitText;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -26,20 +26,14 @@ modules:
|
||||
# Integrations
|
||||
integrations:
|
||||
resource-pack:
|
||||
# If enabled, CustomNameplates will automatically place the generated resource pack into ItemsAdder/Oraxen.
|
||||
# To apply this change, run "/nameplates reload" & "/iazip" or "/oraxen reload all"
|
||||
ItemsAdder: false
|
||||
Oraxen: false
|
||||
# Require a restart to apply this
|
||||
team:
|
||||
# When enabled, CustomNameplates will hook into TAB's team management
|
||||
TAB: false
|
||||
# When enabled, CustomNameplates will hook into CMI's team management
|
||||
CMI: false
|
||||
Velocitab: false
|
||||
chat:
|
||||
# TrChat channels
|
||||
TrChat: false
|
||||
# VentureChat channels
|
||||
VentureChat: false
|
||||
|
||||
resource-pack:
|
||||
@@ -82,6 +76,9 @@ resource-pack:
|
||||
legacy-unicodes: true
|
||||
|
||||
other-settings:
|
||||
# Disable CustomNameplates' team management
|
||||
disable-team-management: false
|
||||
|
||||
# It's recommended to use MiniMessage format. If you insist on using legacy color code "&", enable the support below.
|
||||
legacy-color-code-support: false
|
||||
|
||||
@@ -95,8 +92,6 @@ other-settings:
|
||||
# If a thread is idle for more than this attribute value, it will exit due to timeout
|
||||
keepAliveTime: 30
|
||||
|
||||
# default width
|
||||
default-character-width: 8
|
||||
# delay x ticks before actionbar/bossbar is sent to players
|
||||
send-delay: 0
|
||||
# Set the size for the cache system. This is useful and would bring huge performance if you keep it to a reasonable value
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
# Team / Unlimited / Disable
|
||||
mode: TEAM
|
||||
|
||||
# You should enable this when you are
|
||||
# ① using Velocitab by William278 on Velocity
|
||||
# ② using TAB by NEZNAMY on BungeeCord
|
||||
proxy: false
|
||||
|
||||
# The duration (in seconds) that the nameplate preview will last for.
|
||||
preview-duration: 5
|
||||
|
||||
|
||||
@@ -13,9 +13,12 @@ import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.momirealms.customnameplates.common.message.MessageType;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
||||
import net.momirealms.customnameplates.velocity.team.VelocitabManager;
|
||||
import net.momirealms.customnameplates.velocity.team.VelocityTeamManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.time.Duration;
|
||||
@@ -83,31 +86,32 @@ public class CustomNameplatesVelocity {
|
||||
if (optionalOwner.isEmpty()) return;
|
||||
Player owner = optionalOwner.get();
|
||||
|
||||
String team = teamManager.getTeamName(owner);
|
||||
|
||||
Optional<Player> optionalViewer = server.getPlayer(dataInput.readUTF());
|
||||
if (optionalViewer.isEmpty()) return;
|
||||
Player viewer = optionalViewer.get();
|
||||
|
||||
String prefixJson = dataInput.readUTF();
|
||||
String suffixJson = dataInput.readUTF();
|
||||
String prefix = dataInput.readUTF();
|
||||
String suffix = dataInput.readUTF();
|
||||
|
||||
TeamColor teamColor = TeamColor.valueOf(dataInput.readUTF());
|
||||
TeamTagVisibility visibility = TeamTagVisibility.valueOf(dataInput.readUTF());
|
||||
|
||||
// delay 500ms because Velocitab delays 300ms
|
||||
if (teamManager instanceof VelocitabManager) {
|
||||
server.getScheduler().buildTask(this, () -> {
|
||||
if (!owner.isActive() || !viewer.isActive()) {
|
||||
return;
|
||||
}
|
||||
String teamNameRetry = teamManager.getTeamName(owner);
|
||||
if (teamNameRetry != null)
|
||||
teamManager.sendTeamUpdatePacket(viewer, teamNameRetry, teamColor, visibility, prefixJson, suffixJson);
|
||||
if (teamNameRetry != null) {
|
||||
teamManager.sendTeamUpdatePacket(viewer, teamNameRetry, teamColor, visibility,
|
||||
MiniMessage.miniMessage().deserialize(prefix),
|
||||
MiniMessage.miniMessage().deserialize(suffix)
|
||||
);
|
||||
}
|
||||
else
|
||||
logger.warn("Failed to get player " + owner.getUsername() + "'s team name.");
|
||||
}).delay(Duration.ofMillis(500)).schedule();
|
||||
} else {
|
||||
teamManager.sendTeamUpdatePacket(viewer, team, teamColor, visibility, prefixJson, suffixJson);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package net.momirealms.customnameplates.velocity;
|
||||
package net.momirealms.customnameplates.velocity.team;
|
||||
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
||||
import net.william278.velocitab.Velocitab;
|
||||
@@ -34,7 +33,7 @@ public class VelocitabManager implements VelocityTeamManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTeamUpdatePacket(Player receiver, String team, TeamColor color, TeamTagVisibility visibility, String prefix, String suffix) {
|
||||
public void sendTeamUpdatePacket(Player receiver, String team, TeamColor color, TeamTagVisibility visibility, Component prefix, Component suffix) {
|
||||
UpdateTeamsPacket packet = new UpdateTeamsPacket(velocitab)
|
||||
.teamName(team.length() > 16 ? team.substring(0, 16) : team)
|
||||
.mode(UpdateTeamsPacket.UpdateMode.UPDATE_INFO)
|
||||
@@ -43,8 +42,8 @@ public class VelocitabManager implements VelocityTeamManager {
|
||||
.nametagVisibility(UpdateTeamsPacket.NametagVisibility.valueOf(visibility.name()))
|
||||
.collisionRule(UpdateTeamsPacket.CollisionRule.ALWAYS)
|
||||
.color(UpdateTeamsPacket.TeamColor.valueOf(color.name()).ordinal())
|
||||
.prefix(GsonComponentSerializer.gson().deserialize(prefix))
|
||||
.suffix(GsonComponentSerializer.gson().deserialize(suffix));
|
||||
.prefix(prefix)
|
||||
.suffix(suffix);
|
||||
|
||||
ConnectedPlayer connectedPlayer = (ConnectedPlayer) receiver;
|
||||
connectedPlayer.getConnection().write(packet);
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.momirealms.customnameplates.velocity;
|
||||
package net.momirealms.customnameplates.velocity.team;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -10,5 +11,5 @@ public interface VelocityTeamManager {
|
||||
@Nullable
|
||||
String getTeamName(Player player);
|
||||
|
||||
void sendTeamUpdatePacket(Player receiver, String team, TeamColor color, TeamTagVisibility visibility, String prefix, String suffix);
|
||||
void sendTeamUpdatePacket(Player receiver, String team, TeamColor color, TeamTagVisibility visibility, Component prefix, Component suffix);
|
||||
}
|
||||
Reference in New Issue
Block a user