9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-19 15:09:23 +00:00

2.3-beta-1

This commit is contained in:
XiaoMoMi
2024-01-22 10:58:17 +08:00
parent 3975a1192e
commit 90c5da446a
17 changed files with 344 additions and 160 deletions

View File

@@ -1,8 +1,11 @@
package net.momirealms.customnameplates.api.data; package net.momirealms.customnameplates.api.data;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin; import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.mechanic.bubble.Bubble;
import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate; import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.UUID; import java.util.UUID;
@@ -36,6 +39,7 @@ public class OnlineUser {
/** /**
* Get the original nameplate key from data * Get the original nameplate key from data
*/ */
@NotNull
public String getNameplateKey() { public String getNameplateKey() {
return nameplate; return nameplate;
} }
@@ -43,6 +47,7 @@ public class OnlineUser {
/** /**
* Get the original bubble key from data * Get the original bubble key from data
*/ */
@NotNull
public String getBubbleKey() { public String getBubbleKey() {
return bubble; return bubble;
} }
@@ -51,6 +56,7 @@ public class OnlineUser {
* This value might be inconsistent with the key get by "getNameplateKey()" * This value might be inconsistent with the key get by "getNameplateKey()"
* Because if a player doesn't have a nameplate, his nameplate would be the default one * Because if a player doesn't have a nameplate, his nameplate would be the default one
*/ */
@Nullable
public Nameplate getNameplate() { public Nameplate getNameplate() {
String temp = nameplate; String temp = nameplate;
if (temp.equals("none")) { if (temp.equals("none")) {
@@ -59,6 +65,15 @@ public class OnlineUser {
return CustomNameplatesPlugin.get().getNameplateManager().getNameplate(temp); return CustomNameplatesPlugin.get().getNameplateManager().getNameplate(temp);
} }
@Nullable
public Bubble getBubble() {
String temp = nameplate;
if (temp.equals("none")) {
temp = CustomNameplatesPlugin.get().getBubbleManager().getDefaultBubble();
}
return CustomNameplatesPlugin.get().getBubbleManager().getBubble(temp);
}
/** /**
* Set nameplate for a player * Set nameplate for a player
* *

View File

@@ -9,7 +9,6 @@ import java.util.List;
public interface BubbleManager { public interface BubbleManager {
boolean registerBubble(String key, Bubble bubble); boolean registerBubble(String key, Bubble bubble);
boolean unregisterBubble(String key); boolean unregisterBubble(String key);
@@ -25,4 +24,12 @@ public interface BubbleManager {
String[] getBlacklistChannels(); String[] getBlacklistChannels();
Collection<Bubble> getBubbles(); Collection<Bubble> getBubbles();
boolean equipBubble(Player player, String bubble);
void unEquipBubble(Player player);
String getDefaultBubble();
Collection<String> getBubbleKeys();
} }

View File

@@ -7,7 +7,7 @@ plugins {
allprojects { allprojects {
version = "2.3.0.0" version = "2.3.0.0-beta-1"
apply<JavaPlugin>() apply<JavaPlugin>()
apply(plugin = "java") apply(plugin = "java")

View File

@@ -60,8 +60,8 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin {
this.actionBarManager = new ActionBarManagerImpl(this); this.actionBarManager = new ActionBarManagerImpl(this);
this.coolDownManager = new CoolDownManager(this); this.coolDownManager = new CoolDownManager(this);
this.packetManager = new PacketManager(this); this.packetManager = new PacketManager(this);
new CommandManager(this).load();
this.reload(CNConfig.generatePackOnStart); this.reload(CNConfig.generatePackOnStart);
new CommandManager(this).load();
this.versionManager.checkUpdate().thenAccept(outDated -> { this.versionManager.checkUpdate().thenAccept(outDated -> {
if (!outDated) this.getAdventure().sendConsoleMessage("[CustomNameplates] You are using the latest version."); if (!outDated) this.getAdventure().sendConsoleMessage("[CustomNameplates] You are using the latest version.");
else this.getAdventure().sendConsoleMessage("[CustomNameplates] Update is available: <u>https://polymart.org/resource/2543<!u>"); else this.getAdventure().sendConsoleMessage("[CustomNameplates] Update is available: <u>https://polymart.org/resource/2543<!u>");

View File

@@ -26,11 +26,13 @@ import dev.jorel.commandapi.arguments.PlayerArgument;
import dev.jorel.commandapi.arguments.StringArgument; import dev.jorel.commandapi.arguments.StringArgument;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin; import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.data.OnlineUser; import net.momirealms.customnameplates.api.data.OnlineUser;
import net.momirealms.customnameplates.api.mechanic.bubble.Bubble;
import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate; import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
import net.momirealms.customnameplates.api.mechanic.tag.NameplatePlayer; import net.momirealms.customnameplates.api.mechanic.tag.NameplatePlayer;
import net.momirealms.customnameplates.api.util.LogUtils; import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl; import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl;
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.CNLocale; import net.momirealms.customnameplates.paper.setting.CNLocale;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -51,57 +53,155 @@ public class CommandManager {
} }
public void load() { public void load() {
new CommandAPICommand("customnameplates") var command1 = new CommandAPICommand("customnameplates")
.withAliases("nameplates", "cnameplates") .withAliases("nameplates", "cnameplates")
.withSubcommands( .withSubcommands(
getReloadCommand(), NameplatesCommands.getReloadCommand(),
getAboutCommand(), NameplatesCommands.getAboutCommand()
getEquipCommand(), );
getUnEquipCommand(), if (CNConfig.nameplateModule) {
getPreviewCommand(), command1.withSubcommands(
getListCommand(), NameplatesCommands.getEquipCommand(),
getForceEquipCommand(), NameplatesCommands.getUnEquipCommand(),
getForceUnEquipCommand(), NameplatesCommands.getPreviewCommand(),
getForcePreviewCommand() NameplatesCommands.getListCommand(),
NameplatesCommands.getForceEquipCommand(),
NameplatesCommands.getForceUnEquipCommand(),
NameplatesCommands.getForcePreviewCommand()
);
}
command1.register();
if (CNConfig.bubbleModule)
new CommandAPICommand("bubbles")
.withSubcommands(
BubblesCommands.getListCommand(),
BubblesCommands.getEquipCommand(),
BubblesCommands.getUnEquipCommand(),
BubblesCommands.getForceEquipCommand(),
BubblesCommands.getForceUnEquipCommand()
) )
.register(); .register();
} }
private CommandAPICommand getForceEquipCommand() { public static class BubblesCommands {
return new CommandAPICommand("force-equip")
.withPermission("customnameplates.admin") public static CommandAPICommand getListCommand() {
.withArguments(new PlayerArgument("player")) return new CommandAPICommand("list")
.withArguments(new StringArgument("nameplate").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> plugin.getNameplateManager().getNameplateKeys().toArray(new String[0])))) .withPermission("bubbles.list")
.executes((sender, args) -> { .executesPlayer((player, args) -> {
Player player = (Player) args.get("player"); if (!CNConfig.bubbleModule) return;
String nameplate = (String) args.get("nameplate"); List<String> bubbles = CustomNameplatesPlugin.get().getBubbleManager().getAvailableBubblesDisplayNames(player);
if (player == null) return; if (bubbles.size() != 0) {
if (!plugin.getNameplateManager().equipNameplate(player, nameplate, false)) { StringJoiner stringJoiner = new StringJoiner(", ");
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_NAMEPLATE_NOT_EXISTS); for (String availableBubble : bubbles) {
return; stringJoiner.add(availableBubble);
}
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_AVAILABLE_BUBBLE.replace("{Bubble}", stringJoiner.toString()));
} else {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_HAVE_NO_BUBBLE);
} }
Nameplate nameplateInstance = plugin.getNameplateManager().getNameplate(nameplate);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_FORCE_EQUIP_NAMEPLATE.replace("{Nameplate}", nameplateInstance.getDisplayName()).replace("{Player}", player.getName()));
}); });
} }
private CommandAPICommand getForceUnEquipCommand() { public static CommandAPICommand getEquipCommand() {
return new CommandAPICommand("equip")
.withPermission("bubbles.equip")
.withArguments(new StringArgument("bubble").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> CustomNameplatesPlugin.get().getBubbleManager().getAvailableBubbles((Player) commandSenderSuggestionInfo.sender()).toArray(new String[0]))))
.executesPlayer((player, args) -> {
if (!CNConfig.bubbleModule) return;
String bubble = (String) args.get("bubble");
if (!CustomNameplatesPlugin.get().getBubbleManager().equipBubble(player, bubble)) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_BUBBLE_NOT_EXIST);
return;
}
Bubble bubbleInstance = CustomNameplatesPlugin.get().getBubbleManager().getBubble(bubble);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_EQUIP_BUBBLE.replace("{Bubble}", bubbleInstance.getDisplayName()));
});
}
public static CommandAPICommand getUnEquipCommand() {
return new CommandAPICommand("unequip")
.withPermission("bubbles.unequip")
.executesPlayer((player, args) -> {
if (!CNConfig.bubbleModule) return;
CustomNameplatesPlugin.get().getBubbleManager().unEquipBubble(player);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_UNEQUIP_BUBBLE);
});
}
public static CommandAPICommand getForceEquipCommand() {
return new CommandAPICommand("force-equip")
.withPermission("customnameplates.admin")
.withArguments(new PlayerArgument("player"))
.withArguments(new StringArgument("bubble").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> CustomNameplatesPlugin.get().getBubbleManager().getBubbleKeys().toArray(new String[0]))))
.executes((sender, args) -> {
if (!CNConfig.bubbleModule) return;
Player player = (Player) args.get("player");
String bubble = (String) args.get("bubble");
if (player == null) return;
if (!CustomNameplatesPlugin.get().getBubbleManager().equipBubble(player, bubble)) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_BUBBLE_NOT_EXIST);
return;
}
Bubble bubbleInstance = CustomNameplatesPlugin.get().getBubbleManager().getBubble(bubble);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_FORCE_EQUIP_BUBBLE.replace("{Bubble}", bubbleInstance.getDisplayName()).replace("{Player}", player.getName()));
});
}
public static CommandAPICommand getForceUnEquipCommand() {
return new CommandAPICommand("force-unequip") return new CommandAPICommand("force-unequip")
.withPermission("customnameplates.admin") .withPermission("customnameplates.admin")
.withArguments(new PlayerArgument("player")) .withArguments(new PlayerArgument("player"))
.executes((sender, args) -> { .executes((sender, args) -> {
if (!CNConfig.bubbleModule) return;
Player player = (Player) args.get("player"); Player player = (Player) args.get("player");
if (player == null) return; if (player == null) return;
plugin.getNameplateManager().unEquipNameplate(player, false); CustomNameplatesPlugin.get().getBubbleManager().unEquipBubble(player);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_FORCE_UNEQUIP_BUBBLE.replace("{Player}", player.getName()));
});
}
}
public static class NameplatesCommands {
public static CommandAPICommand getForceEquipCommand() {
return new CommandAPICommand("force-equip")
.withPermission("customnameplates.admin")
.withArguments(new PlayerArgument("player"))
.withArguments(new StringArgument("nameplate").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> CustomNameplatesPlugin.get().getNameplateManager().getNameplateKeys().toArray(new String[0]))))
.executes((sender, args) -> {
if (!CNConfig.nameplateModule) return;
Player player = (Player) args.get("player");
String nameplate = (String) args.get("nameplate");
if (player == null) return;
if (!CustomNameplatesPlugin.get().getNameplateManager().equipNameplate(player, nameplate, false)) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_NAMEPLATE_NOT_EXISTS);
return;
}
Nameplate nameplateInstance = CustomNameplatesPlugin.get().getNameplateManager().getNameplate(nameplate);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_FORCE_EQUIP_NAMEPLATE.replace("{Nameplate}", nameplateInstance.getDisplayName()).replace("{Player}", player.getName()));
});
}
public static CommandAPICommand getForceUnEquipCommand() {
return new CommandAPICommand("force-unequip")
.withPermission("customnameplates.admin")
.withArguments(new PlayerArgument("player"))
.executes((sender, args) -> {
if (!CNConfig.nameplateModule) return;
Player player = (Player) args.get("player");
if (player == null) return;
CustomNameplatesPlugin.get().getNameplateManager().unEquipNameplate(player, false);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_FORCE_UNEQUIP_NAMEPLATE.replace("{Player}", player.getName())); AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_FORCE_UNEQUIP_NAMEPLATE.replace("{Player}", player.getName()));
}); });
} }
private CommandAPICommand getPreviewCommand() { public static CommandAPICommand getPreviewCommand() {
return new CommandAPICommand("preview") return new CommandAPICommand("preview")
.withPermission("nameplates.preview") .withPermission("nameplates.preview")
.executesPlayer((player, args) -> { .executesPlayer((player, args) -> {
NameplatePlayer nameplatePlayer = plugin.getNameplateManager().getNameplatePlayer(player.getUniqueId()); if (!CNConfig.nameplateModule) return;
NameplatePlayer nameplatePlayer = CustomNameplatesPlugin.get().getNameplateManager().getNameplatePlayer(player.getUniqueId());
if (nameplatePlayer == null) { if (nameplatePlayer == null) {
LogUtils.warn(player.getName() + " failed to preview because no tag is created"); LogUtils.warn(player.getName() + " failed to preview because no tag is created");
return; return;
@@ -112,22 +212,23 @@ public class CommandManager {
} }
nameplatePlayer.setPreview(true); nameplatePlayer.setPreview(true);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_PREVIEW_START); AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_PREVIEW_START);
plugin.getScheduler().runTaskAsyncLater(() -> { CustomNameplatesPlugin.get().getScheduler().runTaskAsyncLater(() -> {
nameplatePlayer.setPreview(false); nameplatePlayer.setPreview(false);
}, plugin.getNameplateManager().getPreviewDuration(), TimeUnit.SECONDS); }, CustomNameplatesPlugin.get().getNameplateManager().getPreviewDuration(), TimeUnit.SECONDS);
}); });
} }
private CommandAPICommand getForcePreviewCommand() { public static CommandAPICommand getForcePreviewCommand() {
return new CommandAPICommand("force-preview") return new CommandAPICommand("force-preview")
.withPermission("customnameplates.admin") .withPermission("customnameplates.admin")
.withArguments(new PlayerArgument("player")) .withArguments(new PlayerArgument("player"))
.withOptionalArguments(new StringArgument("nameplate").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> plugin.getNameplateManager().getNameplateKeys().toArray(new String[0])))) .withOptionalArguments(new StringArgument("nameplate").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> CustomNameplatesPlugin.get().getNameplateManager().getNameplateKeys().toArray(new String[0]))))
.executes((sender, args) -> { .executes((sender, args) -> {
if (!CNConfig.nameplateModule) return;
Player player = (Player) args.get("player"); Player player = (Player) args.get("player");
String nameplate = (String) args.getOrDefault("nameplate", ""); String nameplate = (String) args.getOrDefault("nameplate", "");
if (player == null) return; if (player == null) return;
NameplatePlayer nameplatePlayer = plugin.getNameplateManager().getNameplatePlayer(player.getUniqueId()); NameplatePlayer nameplatePlayer = CustomNameplatesPlugin.get().getNameplateManager().getNameplatePlayer(player.getUniqueId());
if (nameplatePlayer == null) { if (nameplatePlayer == null) {
LogUtils.warn(player.getName() + " failed to preview because no tag is created"); LogUtils.warn(player.getName() + " failed to preview because no tag is created");
return; return;
@@ -136,58 +237,61 @@ public class CommandManager {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_PREVIEW_COOLDOWN); AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_PREVIEW_COOLDOWN);
return; return;
} }
Optional<OnlineUser> user = plugin.getStorageManager().getOnlineUser(player.getUniqueId()); Optional<OnlineUser> user = CustomNameplatesPlugin.get().getStorageManager().getOnlineUser(player.getUniqueId());
if (user.isEmpty()) { if (user.isEmpty()) {
LogUtils.warn(player.getName() + " failed to preview because data not loaded"); LogUtils.warn(player.getName() + " failed to preview because data not loaded");
return; return;
} }
String previous = user.get().getNameplateKey(); String previous = user.get().getNameplateKey();
if (!plugin.getNameplateManager().equipNameplate(player, nameplate, true)) { if (!CustomNameplatesPlugin.get().getNameplateManager().equipNameplate(player, nameplate, true)) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_NAMEPLATE_NOT_EXISTS); AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_NAMEPLATE_NOT_EXISTS);
return; return;
} }
nameplatePlayer.setPreview(true); nameplatePlayer.setPreview(true);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_FORCE_PREVIEW.replace("{Player}", player.getName())); AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_FORCE_PREVIEW.replace("{Player}", player.getName()));
plugin.getScheduler().runTaskAsyncLater(() -> { CustomNameplatesPlugin.get().getScheduler().runTaskAsyncLater(() -> {
nameplatePlayer.setPreview(false); nameplatePlayer.setPreview(false);
plugin.getNameplateManager().equipNameplate(player, previous, true); if (previous.equals("none")) {
}, plugin.getNameplateManager().getPreviewDuration(), TimeUnit.SECONDS); CustomNameplatesPlugin.get().getNameplateManager().unEquipNameplate(player, true);
} else {
CustomNameplatesPlugin.get().getNameplateManager().equipNameplate(player, previous, true);
}
}, CustomNameplatesPlugin.get().getNameplateManager().getPreviewDuration(), TimeUnit.SECONDS);
}); });
} }
private CommandAPICommand getEquipCommand() { public static CommandAPICommand getEquipCommand() {
return new CommandAPICommand("equip") return new CommandAPICommand("equip")
.withPermission("nameplates.equip") .withPermission("nameplates.equip")
.withArguments(new StringArgument("nameplate").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> plugin.getNameplateManager().getAvailableNameplates((Player) commandSenderSuggestionInfo.sender()).toArray(new String[0])))) .withArguments(new StringArgument("nameplate").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> CustomNameplatesPlugin.get().getNameplateManager().getAvailableNameplates((Player) commandSenderSuggestionInfo.sender()).toArray(new String[0]))))
.executesPlayer((player, args) -> { .executesPlayer((player, args) -> {
if (!CNConfig.nameplateModule) return;
String nameplate = (String) args.get("nameplate"); String nameplate = (String) args.get("nameplate");
Nameplate nameplateInstance = plugin.getNameplateManager().getNameplate(nameplate); if (!CustomNameplatesPlugin.get().getNameplateManager().equipNameplate(player, nameplate, false)) {
if (nameplateInstance == null) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_NAMEPLATE_NOT_AVAILABLE);
return;
}
if (!plugin.getNameplateManager().equipNameplate(player, nameplate, false)) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_NAMEPLATE_NOT_EXISTS); AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_NAMEPLATE_NOT_EXISTS);
return; return;
} }
Nameplate nameplateInstance = CustomNameplatesPlugin.get().getNameplateManager().getNameplate(nameplate);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_EQUIP_NAMEPLATE.replace("{Nameplate}", nameplateInstance.getDisplayName())); AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_EQUIP_NAMEPLATE.replace("{Nameplate}", nameplateInstance.getDisplayName()));
}); });
} }
private CommandAPICommand getUnEquipCommand() { public static CommandAPICommand getUnEquipCommand() {
return new CommandAPICommand("unequip") return new CommandAPICommand("unequip")
.withPermission("nameplates.unequip") .withPermission("nameplates.unequip")
.executesPlayer((player, args) -> { .executesPlayer((player, args) -> {
plugin.getNameplateManager().unEquipNameplate(player, false); if (!CNConfig.nameplateModule) return;
CustomNameplatesPlugin.get().getNameplateManager().unEquipNameplate(player, false);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_UNEQUIP_NAMEPLATE); AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_UNEQUIP_NAMEPLATE);
}); });
} }
private CommandAPICommand getListCommand() { public static CommandAPICommand getListCommand() {
return new CommandAPICommand("list") return new CommandAPICommand("list")
.withPermission("nameplates.list") .withPermission("nameplates.list")
.executesPlayer((player, args) -> { .executesPlayer((player, args) -> {
List<String> nameplates = plugin.getNameplateManager().getAvailableNameplateDisplayNames(player); if (!CNConfig.nameplateModule) return;
List<String> nameplates = CustomNameplatesPlugin.get().getNameplateManager().getAvailableNameplateDisplayNames(player);
if (nameplates.size() != 0) { if (nameplates.size() != 0) {
StringJoiner stringJoiner = new StringJoiner(", "); StringJoiner stringJoiner = new StringJoiner(", ");
for (String availableNameplate : nameplates) { for (String availableNameplate : nameplates) {
@@ -200,24 +304,24 @@ public class CommandManager {
}); });
} }
private CommandAPICommand getReloadCommand() { public static CommandAPICommand getReloadCommand() {
return new CommandAPICommand("reload") return new CommandAPICommand("reload")
.withPermission("customnameplates.admin") .withPermission("customnameplates.admin")
.withOptionalArguments(new BooleanArgument("generate pack")) .withOptionalArguments(new BooleanArgument("generate pack"))
.executes((sender, args) -> { .executes((sender, args) -> {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
plugin.reload(false); CustomNameplatesPlugin.get().reload(false);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_RELOAD.replace("{time}", String.valueOf(System.currentTimeMillis()-time))); AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_RELOAD.replace("{time}", String.valueOf(System.currentTimeMillis()-time)));
boolean generate = (boolean) args.getOrDefault("generate pack", true); boolean generate = (boolean) args.getOrDefault("generate pack", true);
if (generate) { if (generate) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_GENERATING); AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_GENERATING);
plugin.getResourcePackManager().generateResourcePack(); CustomNameplatesPlugin.get().getResourcePackManager().generateResourcePack();
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_PACK_GENERATED); AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_PACK_GENERATED);
} }
}); });
} }
private CommandAPICommand getAboutCommand() { public static CommandAPICommand getAboutCommand() {
return new CommandAPICommand("about") return new CommandAPICommand("about")
.withPermission("customnameplates.about") .withPermission("customnameplates.about")
.executes((sender, args) -> { .executes((sender, args) -> {
@@ -228,4 +332,5 @@ public class CommandManager {
AdventureManagerImpl.getInstance().sendMessage(sender, "<#FFD700>⭐ <click:open_url:https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates>Document</click> <#A9A9A9>| <#FAFAD2>⛏ <click:open_url:https://github.com/Xiao-MoMi/Custom-Nameplates>Github</click> <#A9A9A9>| <#48D1CC>\uD83D\uDD14 <click:open_url:https://polymart.org/resource/customnameplates.2543>Polymart</click>"); AdventureManagerImpl.getInstance().sendMessage(sender, "<#FFD700>⭐ <click:open_url:https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates>Document</click> <#A9A9A9>| <#FAFAD2>⛏ <click:open_url:https://github.com/Xiao-MoMi/Custom-Nameplates>Github</click> <#A9A9A9>| <#48D1CC>\uD83D\uDD14 <click:open_url:https://polymart.org/resource/customnameplates.2543>Polymart</click>");
}); });
} }
}
} }

View File

@@ -24,6 +24,8 @@ import net.momirealms.customnameplates.api.manager.BubbleManager;
import net.momirealms.customnameplates.api.mechanic.bubble.Bubble; import net.momirealms.customnameplates.api.mechanic.bubble.Bubble;
import net.momirealms.customnameplates.api.mechanic.character.CharacterArranger; import net.momirealms.customnameplates.api.mechanic.character.CharacterArranger;
import net.momirealms.customnameplates.api.mechanic.character.ConfiguredChar; import net.momirealms.customnameplates.api.mechanic.character.ConfiguredChar;
import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
import net.momirealms.customnameplates.api.mechanic.tag.NameplatePlayer;
import net.momirealms.customnameplates.api.mechanic.tag.unlimited.EntityTagPlayer; import net.momirealms.customnameplates.api.mechanic.tag.unlimited.EntityTagPlayer;
import net.momirealms.customnameplates.api.mechanic.tag.unlimited.StaticTextEntity; import net.momirealms.customnameplates.api.mechanic.tag.unlimited.StaticTextEntity;
import net.momirealms.customnameplates.api.mechanic.tag.unlimited.StaticTextTagSetting; import net.momirealms.customnameplates.api.mechanic.tag.unlimited.StaticTextTagSetting;
@@ -306,6 +308,11 @@ public class BubbleManagerImpl implements BubbleManager {
return result; return result;
} }
@Override
public Collection<String> getBubbleKeys() {
return bubbleMap.keySet();
}
@Nullable @Nullable
@Override @Override
public Bubble getBubble(String bubble) { public Bubble getBubble(String bubble) {
@@ -349,6 +356,42 @@ public class BubbleManagerImpl implements BubbleManager {
return bubbleMap.values(); return bubbleMap.values();
} }
@Override
public boolean equipBubble(Player player, String bubbleKey) {
Bubble bubble = getBubble(bubbleKey);
if (bubble == null && bubbleKey.equals("none")) {
return false;
}
plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresentOrElse(it -> {
if (it.getBubbleKey().equals(bubbleKey)) {
return;
}
it.setBubble(bubbleKey);
plugin.getStorageManager().saveOnlinePlayerData(player.getUniqueId());
}, () -> {
LogUtils.severe("Player " + player.getName() + "'s data is not loaded.");
});
return true;
}
@Override
public void unEquipBubble(Player player) {
plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresentOrElse(it -> {
if (it.getBubbleKey().equals("none")) {
return;
}
it.setNameplate("none");
plugin.getStorageManager().saveOnlinePlayerData(player.getUniqueId());
}, () -> {
LogUtils.severe("Player " + player.getName() + "'s data is not loaded.");
});
}
@Override
public String getDefaultBubble() {
return defaultBubble;
}
private void saveDefaultBubbles() { private void saveDefaultBubbles() {
String[] png_list = new String[]{"chat"}; String[] png_list = new String[]{"chat"};
String[] part_list = new String[]{"_left.png", "_middle.png", "_right.png", "_tail.png", ".yml"}; String[] part_list = new String[]{"_left.png", "_middle.png", "_right.png", "_tail.png", ".yml"};

View File

@@ -479,7 +479,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
@Override @Override
public boolean equipNameplate(Player player, String nameplateKey, boolean temp) { public boolean equipNameplate(Player player, String nameplateKey, boolean temp) {
Nameplate nameplate = getNameplate(nameplateKey); Nameplate nameplate = getNameplate(nameplateKey);
if (nameplate == null && !nameplateKey.equals("none")) { if (nameplate == null && nameplateKey.equals("none")) {
return false; return false;
} }
plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresentOrElse(it -> { plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresentOrElse(it -> {
@@ -502,6 +502,9 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
@Override @Override
public void unEquipNameplate(Player player, boolean temp) { public void unEquipNameplate(Player player, boolean temp) {
plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresentOrElse(it -> { plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresentOrElse(it -> {
if (it.getNameplateKey().equals("none")) {
return;
}
it.setNameplate("none"); it.setNameplate("none");
this.updateCachedNameplate(player, getNameplate(getDefaultNameplate())); this.updateCachedNameplate(player, getNameplate(getDefaultNameplate()));
NameplatePlayer nameplatePlayer = getNameplatePlayer(player.getUniqueId()); NameplatePlayer nameplatePlayer = getNameplatePlayer(player.getUniqueId());

View File

@@ -3,6 +3,7 @@ package net.momirealms.customnameplates.paper.mechanic.placeholder;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin; import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.manager.PlaceholderManager; import net.momirealms.customnameplates.api.manager.PlaceholderManager;
import net.momirealms.customnameplates.api.mechanic.bubble.Bubble;
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.api.mechanic.nameplate.Nameplate; import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
@@ -134,10 +135,20 @@ public class PluginPlaceholders extends PlaceholderExpansion {
case "nameplate-name" -> { case "nameplate-name" -> {
Nameplate nameplate = optPlayer.get().getNameplate(); Nameplate nameplate = optPlayer.get().getNameplate();
if (nameplate == null) { if (nameplate == null) {
return CNLocale.MSG_NO_NAMEPLATE; return "";
} }
return nameplate.getDisplayName(); return nameplate.getDisplayName();
} }
case "bubble" -> {
return optPlayer.get().getBubbleKey();
}
case "bubble-name" -> {
Bubble bubble = optPlayer.get().getBubble();
if (bubble == null) {
return "";
}
return bubble.getDisplayName();
}
} }
} }
} }

View File

@@ -33,14 +33,14 @@ public class CNLocale {
public static String MSG_AVAILABLE_NAMEPLATE; public static String MSG_AVAILABLE_NAMEPLATE;
public static String MSG_HAVE_NO_NAMEPLATE; public static String MSG_HAVE_NO_NAMEPLATE;
public static String MSG_FORCE_PREVIEW; public static String MSG_FORCE_PREVIEW;
public static String bb_equip; public static String MSG_EQUIP_BUBBLE;
public static String bb_unEquip; public static String MSG_UNEQUIP_BUBBLE;
public static String bb_force_equip; public static String MSG_FORCE_EQUIP_BUBBLE;
public static String bb_force_unEquip; public static String MSG_FORCE_UNEQUIP_BUBBLE;
public static String bb_not_exist; public static String MSG_BUBBLE_NOT_EXIST;
public static String bb_notAvailable; public static String MSG_BUBBLE_NOT_AVAILABLE;
public static String bb_available; public static String MSG_AVAILABLE_BUBBLE;
public static String bb_haveNone; public static String MSG_HAVE_NO_BUBBLE;
public static void load() { public static void load() {
try { try {
@@ -83,14 +83,14 @@ public class CNLocale {
MSG_AVAILABLE_NAMEPLATE = config.getString("messages.available-nameplates"); MSG_AVAILABLE_NAMEPLATE = config.getString("messages.available-nameplates");
MSG_HAVE_NO_NAMEPLATE = config.getString("messages.have-no-nameplates"); MSG_HAVE_NO_NAMEPLATE = config.getString("messages.have-no-nameplates");
MSG_FORCE_PREVIEW = config.getString("messages.force-preview"); MSG_FORCE_PREVIEW = config.getString("messages.force-preview");
bb_equip = config.getString("messages.equip-bubbles"); MSG_EQUIP_BUBBLE = config.getString("messages.equip-bubbles");
bb_unEquip = config.getString("messages.unequip-bubbles"); MSG_UNEQUIP_BUBBLE = config.getString("messages.unequip-bubbles");
bb_force_equip = config.getString("messages.force-equip-bubbles"); MSG_FORCE_EQUIP_BUBBLE = config.getString("messages.force-equip-bubbles");
bb_force_unEquip = config.getString("messages.force-unequip-bubbles"); MSG_FORCE_UNEQUIP_BUBBLE = config.getString("messages.force-unequip-bubbles");
bb_not_exist = config.getString("messages.not-exist-bubbles"); MSG_BUBBLE_NOT_EXIST = config.getString("messages.not-exist-bubbles");
bb_notAvailable = config.getString("messages.not-available-bubbles"); MSG_BUBBLE_NOT_AVAILABLE = config.getString("messages.not-available-bubbles");
bb_available = config.getString("messages.available-bubbles"); MSG_AVAILABLE_BUBBLE = config.getString("messages.available-bubbles");
bb_haveNone = config.getString("messages.have-no-bubbles"); MSG_HAVE_NO_BUBBLE = config.getString("messages.have-no-bubbles");
} }
} }
} }

View File

@@ -3,7 +3,7 @@ blacklist-channels:
- Private - Private
- Staff - Staff
# Player's default chatting bubbles # Default bubble to display if player's bubble is "none"
default-bubbles: 'chat' default-bubbles: 'chat'
# Text format when bubble is "none" # Text format when bubble is "none"

View File

@@ -4,7 +4,7 @@ mode: TEAM
# 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
# Default nameplate to display if player doesn't equip any # Default nameplate to display if player's nameplate is "none"
default-nameplate: 'none' default-nameplate: 'none'
# This decides what %nameplates_prefix/suffix% would return # This decides what %nameplates_prefix/suffix% would return

View File

@@ -21,8 +21,8 @@ messages:
equip-bubbles: '<white>你已佩戴聊天气泡 {Bubble}</white>' equip-bubbles: '<white>你已佩戴聊天气泡 {Bubble}</white>'
unequip-bubbles: '<white>你已卸下聊天气泡</white>' unequip-bubbles: '<white>你已卸下聊天气泡</white>'
available-bubbles: '<white>可用聊天气泡: {Bubbles}</white>' available-bubbles: '<white>可用聊天气泡: {Bubble}</white>'
force-equip-bubbles: '<white>成功使用聊天气泡 {Bubbles}</white>' force-equip-bubbles: '<white>成功使用聊天气泡 {Bubble}</white>'
force-unequip-bubbles: '<white>你移除了 {Player} 的聊天气泡</white>' force-unequip-bubbles: '<white>你移除了 {Player} 的聊天气泡</white>'
not-exist-bubbles: '<white>那个聊天气泡不存在!</white>' not-exist-bubbles: '<white>那个聊天气泡不存在!</white>'
not-available-bubbles: '<white>你还未拥有这个气泡!</white>' not-available-bubbles: '<white>你还未拥有这个气泡!</white>'

View File

@@ -20,10 +20,10 @@ messages:
force-preview: '<white>Forced {Player} to preview the nameplate</white>' force-preview: '<white>Forced {Player} to preview the nameplate</white>'
equip-bubbles: '<white>Successfully equipped chatting bubbles {Bubble}</white>' equip-bubbles: '<white>Successfully equipped chatting bubbles {Bubble}</white>'
force-equip-bubbles: '<white>Successfully equipped chatting bubbles {Bubbles}</white>' force-equip-bubbles: '<white>Successfully equipped chatting bubbles {Bubble}</white>'
unequip-bubbles: '<white>You removed your chatting bubbles</white>' unequip-bubbles: '<white>You removed your chatting bubbles</white>'
force-unequip-bubbles: '<white>Successfully removed {Player}''s bubbles!</white>' force-unequip-bubbles: '<white>Successfully removed {Player}''s bubbles!</white>'
not-exist-bubbles: '<white>This bubble does not exist!</white>' not-exist-bubbles: '<white>This bubble does not exist!</white>'
not-available-bubbles: '<white>This bubble is currently not available!</white>' not-available-bubbles: '<white>This bubble is currently not available!</white>'
available-bubbles: '<white>Available bubbles: {Bubbles}</white>' available-bubbles: '<white>Available bubbles: {Bubble}</white>'
have-no-bubbles: '<white>You don''t have any bubble yet' have-no-bubbles: '<white>You don''t have any bubble yet'

View File

@@ -20,10 +20,10 @@ messages:
force-preview: '<white>Forced {Player} to preview the nameplate</white>' force-preview: '<white>Forced {Player} to preview the nameplate</white>'
equip-bubbles: '<white>Bulles de discussion {Bubble} équipées avec succès</white>' equip-bubbles: '<white>Bulles de discussion {Bubble} équipées avec succès</white>'
force-equip-bubbles: '<white>Bulles de discussion {Bubbles} équipées avec succès</white>' force-equip-bubbles: '<white>Bulles de discussion {Bubble} équipées avec succès</white>'
unequip-bubbles: '<white>Vous avez retiré vos bulles de discussion</white>' unequip-bubbles: '<white>Vous avez retiré vos bulles de discussion</white>'
force-unequip-bubbles: '<white>Les bulles de discussion de {Player} ont été retirées avec succès !</white>' force-unequip-bubbles: '<white>Les bulles de discussion de {Player} ont été retirées avec succès !</white>'
not-exist-bubbles: '<white>Cette bulle de discussion n'existe pas !</white>' not-exist-bubbles: '<white>Cette bulle de discussion n'existe pas !</white>'
not-available-bubbles: '<white>Cette bulle de discussion n'est actuellement pas disponible !</white>' not-available-bubbles: '<white>Cette bulle de discussion n'est actuellement pas disponible !</white>'
available-bubbles: '<white>Bulles de discussion disponibles : {Bubbles}.</white>' available-bubbles: '<white>Bulles de discussion disponibles : {Bubble}.</white>'
have-no-bubbles: '<white>Vous n'avez pas encore de bulles de discussion</white>' have-no-bubbles: '<white>Vous n'avez pas encore de bulles de discussion</white>'

View File

@@ -20,10 +20,10 @@ messages:
force-preview: '<white>Forced {Player} to preview the nameplate</white>' force-preview: '<white>Forced {Player} to preview the nameplate</white>'
equip-bubbles: '<white>Успешно установлен стиль чата над головой: {Bubble}</white>' equip-bubbles: '<white>Успешно установлен стиль чата над головой: {Bubble}</white>'
force-equip-bubbles: '<white>Успешно установлен стиль чата над головой: {Bubbles}</white>' force-equip-bubbles: '<white>Успешно установлен стиль чата над головой: {Bubble}</white>'
unequip-bubbles: '<white>Вы сняли стиль чата над головой.</white>' unequip-bubbles: '<white>Вы сняли стиль чата над головой.</white>'
force-unequip-bubbles: '<white>Успешно снят стиль чата над головой у {Player}!</white>' force-unequip-bubbles: '<white>Успешно снят стиль чата над головой у {Player}!</white>'
not-exist-bubbles: '<white>Такого стиля чата над головой не существует!</white>' not-exist-bubbles: '<white>Такого стиля чата над головой не существует!</white>'
not-available-bubbles: '<white>Этот стиль чата над головой сейчас недоступен!</white>' not-available-bubbles: '<white>Этот стиль чата над головой сейчас недоступен!</white>'
available-bubbles: '<white>Доступные стили чата над головой: {Bubbles}</white>' available-bubbles: '<white>Доступные стили чата над головой: {Bubble}</white>'
have-no-bubbles: '<white>У вас еще нет никаких стилей чата над головой.' have-no-bubbles: '<white>У вас еще нет никаких стилей чата над головой.'

View File

@@ -20,10 +20,10 @@ messages:
force-preview: '<white>Forced {Player} to preview the nameplate</white>' force-preview: '<white>Forced {Player} to preview the nameplate</white>'
equip-bubbles: '<white>Correctamente equipado chatting bubbles {Bubble}</white>' equip-bubbles: '<white>Correctamente equipado chatting bubbles {Bubble}</white>'
force-equip-bubbles: '<white>Correctamente equipdo chatting bubbles {Bubbles}</white>' force-equip-bubbles: '<white>Correctamente equipdo chatting bubbles {Bubble}</white>'
unequip-bubbles: '<white>Se ha removido tu chatting bubbles</white>' unequip-bubbles: '<white>Se ha removido tu chatting bubbles</white>'
force-unequip-bubbles: '<white>Se ha removido tu chatting bubbles</white>' force-unequip-bubbles: '<white>Se ha removido tu chatting bubbles</white>'
not-exist-bubbles: '<white>Este bubble no existe</white>' not-exist-bubbles: '<white>Este bubble no existe</white>'
not-available-bubbles: '<white>Este bubble no esta actualmente disponible!</white>' not-available-bubbles: '<white>Este bubble no esta actualmente disponible!</white>'
available-bubbles: '<white>Bubbles Disponibles: {Bubbles}</white>' available-bubbles: '<white>Bubbles Disponibles: {Bubble}</white>'
have-no-bubbles: '<white>Todavía no tienes ningun bubble' have-no-bubbles: '<white>Todavía no tienes ningun bubble'

View File

@@ -21,10 +21,10 @@ messages:
force-preview: '<white>Forced {Player} to preview the nameplate</white>' force-preview: '<white>Forced {Player} to preview the nameplate</white>'
equip-bubbles: '<white>Sohbet balonlarınız başarıyla eklendi {Bubble}</white>' equip-bubbles: '<white>Sohbet balonlarınız başarıyla eklendi {Bubble}</white>'
force-equip-bubbles: '<white>{Bubbles} sohbet balonları başarıyla eklendi.</white>' force-equip-bubbles: '<white>{Bubble} sohbet balonları başarıyla eklendi.</white>'
unequip-bubbles: '<white>Sohbet balonlarınızı kaldırdınız</white>' unequip-bubbles: '<white>Sohbet balonlarınızı kaldırdınız</white>'
force-unequip-bubbles: '<white>{Player} oyuncusunun sohbet balonları başarıyla kaldırıldı!</white>' force-unequip-bubbles: '<white>{Player} oyuncusunun sohbet balonları başarıyla kaldırıldı!</white>'
not-exist-bubbles: '<white>Bu balon mevcut değil!</white>' not-exist-bubbles: '<white>Bu balon mevcut değil!</white>'
not-available-bubbles: '<white>Bu balon şu anda kullanılabilir değil!</white>' not-available-bubbles: '<white>Bu balon şu anda kullanılabilir değil!</white>'
available-bubbles: '<white>Mevcut sohbet balonları: {Bubbles}.</white>' available-bubbles: '<white>Mevcut sohbet balonları: {Bubble}.</white>'
have-no-bubbles: '<white>Henüz hiç sohbet balonunuz yok</white>' have-no-bubbles: '<white>Henüz hiç sohbet balonunuz yok</white>'