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