9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2026-01-04 15:31:47 +00:00

velocity module

This commit is contained in:
XiaoMoMi
2024-01-21 18:03:00 +08:00
parent d6ac11e8b3
commit b2f329332d
44 changed files with 352 additions and 81 deletions

View File

@@ -70,7 +70,7 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin {
public void onDisable() {
((SchedulerImpl) this.scheduler).shutdown();
((ActionBarManagerImpl) actionBarManager).unload();
((NameplateManagerImpl) this.nameplateManager).unload();
((NameplateManagerImpl) this.nameplateManager).disable();
((TeamManagerImpl) this.teamManager).unload();
((BossBarManagerImpl) this.bossBarManager).unload();
((ImageManagerImpl) this.imageManager).unload();

View File

@@ -75,12 +75,12 @@ public class AdventureManagerImpl implements AdventureManager {
}
@Override
public net.momirealms.customnameplates.api.common.Key keyToKey(Key key) {
return net.momirealms.customnameplates.api.common.Key.of(key.namespace(), key.value());
public net.momirealms.customnameplates.common.Key keyToKey(Key key) {
return net.momirealms.customnameplates.common.Key.of(key.namespace(), key.value());
}
@Override
public Key keyToKey(net.momirealms.customnameplates.api.common.Key key) {
public Key keyToKey(net.momirealms.customnameplates.common.Key key) {
return Key.key(key.namespace(), key.value());
}

View File

@@ -1,7 +1,7 @@
package net.momirealms.customnameplates.paper.mechanic.bossbar;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.common.Pair;
import net.momirealms.customnameplates.common.Pair;
import net.momirealms.customnameplates.api.manager.BossBarManager;
import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.paper.mechanic.misc.DisplayController;

View File

@@ -1,7 +1,7 @@
package net.momirealms.customnameplates.paper.mechanic.bossbar;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.common.Pair;
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;

View File

@@ -13,15 +13,14 @@ 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.api.common.Key;
import net.momirealms.customnameplates.api.common.Tuple;
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;
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.FontUtils;
import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
import net.momirealms.customnameplates.paper.setting.CNConfig;
@@ -80,8 +79,7 @@ public class WidthManagerImpl implements WidthManager {
private void loadInternalConfigs() {
FontData fontData = new FontData(8);
ArrayList<ConfiguredChar> chars = new ArrayList<>();
chars.addAll(plugin.getImageManager().getImages());
ArrayList<ConfiguredChar> chars = new ArrayList<>(plugin.getImageManager().getImages());
for (Nameplate nameplate : plugin.getNameplateManager().getNameplates()) {
chars.add(nameplate.getLeft());
chars.add(nameplate.getMiddle());
@@ -241,7 +239,6 @@ public class WidthManagerImpl implements WidthManager {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(zipFile.getInputStream(entry)))) {
YamlConfiguration yml = new YamlConfiguration();
String line;
loop:
while ((line = reader.readLine()) != null) {
String[] parts = line.split(":");
if (parts.length > 1) {
@@ -263,7 +260,8 @@ public class WidthManagerImpl implements WidthManager {
int x;
int n;
outer: {
outer:
{
for (x = 0; x < splitInterval; x++) {
inner:
for (int y = 0; y < 16; y++) {

View File

@@ -15,7 +15,7 @@ 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.api.mechanic.team.TeamColor;
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;
@@ -120,6 +120,11 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
ProtocolLibrary.getProtocolManager().removePacketListener(entityTeleportListener);
}
public void disable() {
this.proxyMode = false;
unload();
}
public void load() {
if (!CNConfig.nameplateModule) return;
this.loadConfig();
@@ -411,7 +416,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
public String getNameplatePrefix(Player player) {
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
if (cachedNameplate == null) return "";
return "<#FEFEFE>" + cachedNameplate.getTagPrefix() + "</#FEFEFE>";
return cachedNameplate.getTagPrefix();
}
@Override
@@ -428,7 +433,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
return player.getName();
}
return "<#FEFEFE>" + cachedNameplate.getTagPrefix() + "</#FEFEFE>"
return cachedNameplate.getTagPrefix()
+ cachedNameplate.getNamePrefix()
+ cachedNameplate.getPlayerName()
+ cachedNameplate.getNameSuffix()

View File

@@ -184,7 +184,6 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
image.setRGB(i, j, 0);
}
}
ImageIO.write(image, "png", inputFile);
} catch (IOException e) {
e.printStackTrace();
@@ -389,12 +388,16 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
public static final String Nameplates_Shader =
"if (Color.xyz == vec3(255., 254., 253.) / 255.) {\n" +
" vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);\n" +
" vertex.y+= 1;\n" +
" vertex.x+= 1;\n" +
" vertex.y += 1;\n" +
" vertex.x += 1;\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" } else if (Color.xyz == vec3(254., 254., 254.) / 255.) {\n" +
" vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);\n" +
" vertex.z-= 0.01;\n" +
" vertex.z -= 0.001;\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" } else if (Color.xyz == vec3(253., 254., 254.) / 255.) {\n" +
" vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);\n" +
" vertex.z -= 0.0011;\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" } else {\n" +
" vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);\n" +

View File

@@ -1,7 +1,7 @@
package net.momirealms.customnameplates.paper.mechanic.placeholder;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.common.Pair;
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;

View File

@@ -19,7 +19,7 @@ package net.momirealms.customnameplates.paper.mechanic.requirement;
import me.clip.placeholderapi.PlaceholderAPI;
import net.momirealms.biomeapi.BiomeAPI;
import net.momirealms.customnameplates.api.common.Pair;
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;

View File

@@ -5,9 +5,13 @@ 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.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;
@@ -75,7 +79,10 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
@Override
public void createProxyTeam(Player player) {
sendPluginMessage(
MessageType.CREATE,
player.getUniqueId().toString()
);
}
@Override
@@ -94,7 +101,8 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
@Override
public void removeProxyTeam(Player player) {
this.sendPluginMessage(MessageType.REMOVE,
this.sendPluginMessage(
MessageType.REMOVE,
player.getName()
);
}
@@ -103,16 +111,28 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
public void updateTeam(Player owner, Player viewer, Component prefix, Component suffix, TeamColor color, TeamTagVisibility visibility) {
if (color == TeamColor.NONE || color == TeamColor.CUSTOM)
color = TeamColor.WHITE;
PacketContainer packet = teamPacketAdaptor.getTeamUpdatePacket(
TeamUpdatePacket.builder()
.teamName(teamProvider.getTeam(owner))
.color(color)
.prefix(prefix)
.suffix(suffix)
.tagVisibility(visibility)
.build()
);
PacketManager.getInstance().send(viewer, packet);
if (plugin.getNameplateManager().isProxyMode()) {
this.sendPluginMessage(
MessageType.UPDATE,
owner.getName(),
viewer.getName(),
GsonComponentSerializer.gson().serialize(prefix),
GsonComponentSerializer.gson().serialize(suffix),
color.name(),
visibility.name()
);
} else {
PacketContainer packet = teamPacketAdaptor.getTeamUpdatePacket(
TeamUpdatePacket.builder()
.teamName(teamProvider.getTeam(owner))
.color(color)
.prefix(prefix)
.suffix(suffix)
.tagVisibility(visibility)
.build()
);
PacketManager.getInstance().send(viewer, packet);
}
}
public void reload() {
@@ -159,16 +179,11 @@ 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 -> {
player.sendPluginMessage(plugin, CHANNEL, dataOutput.toByteArray());
});
}
public static class MessageType {
public static final String CREATE = "create";
public static final String REMOVE = "remove";
}
}

View File

@@ -6,7 +6,7 @@ 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.api.mechanic.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;

View File

@@ -1,7 +1,7 @@
package net.momirealms.customnameplates.paper.util;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.common.Pair;
import net.momirealms.customnameplates.common.Pair;
import net.momirealms.customnameplates.api.requirement.Requirement;
import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.paper.mechanic.misc.TimeLimitText;

View File

@@ -1,7 +1,9 @@
# Team / Unlimited / Disable
mode: TEAM
# If you are using BungeeCord/Velocity, it's advised to install CustomNameplates on proxy too and enable this option.
# 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.

View File

@@ -4,4 +4,5 @@ main: net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl
api-version: 1.17
authors: [ XiaoMoMi ]
folia-supported: true
depend: [ ProtocolLib ,PlaceholderAPI ]
depend: [ ProtocolLib ,PlaceholderAPI ]
softdepend: [ MagicCosmetics, TAB, CMI, TrChat, ItemsAdder, Oraxen ]