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:
@@ -1,8 +1,11 @@
|
||||
package net.momirealms.customnameplates.api.data;
|
||||
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.api.mechanic.bubble.Bubble;
|
||||
import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -36,6 +39,7 @@ public class OnlineUser {
|
||||
/**
|
||||
* Get the original nameplate key from data
|
||||
*/
|
||||
@NotNull
|
||||
public String getNameplateKey() {
|
||||
return nameplate;
|
||||
}
|
||||
@@ -43,6 +47,7 @@ public class OnlineUser {
|
||||
/**
|
||||
* Get the original bubble key from data
|
||||
*/
|
||||
@NotNull
|
||||
public String getBubbleKey() {
|
||||
return bubble;
|
||||
}
|
||||
@@ -51,6 +56,7 @@ public class OnlineUser {
|
||||
* 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
|
||||
*/
|
||||
@Nullable
|
||||
public Nameplate getNameplate() {
|
||||
String temp = nameplate;
|
||||
if (temp.equals("none")) {
|
||||
@@ -59,6 +65,15 @@ public class OnlineUser {
|
||||
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
|
||||
*
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.List;
|
||||
|
||||
public interface BubbleManager {
|
||||
|
||||
|
||||
boolean registerBubble(String key, Bubble bubble);
|
||||
|
||||
boolean unregisterBubble(String key);
|
||||
@@ -25,4 +24,12 @@ public interface BubbleManager {
|
||||
String[] getBlacklistChannels();
|
||||
|
||||
Collection<Bubble> getBubbles();
|
||||
|
||||
boolean equipBubble(Player player, String bubble);
|
||||
|
||||
void unEquipBubble(Player player);
|
||||
|
||||
String getDefaultBubble();
|
||||
|
||||
Collection<String> getBubbleKeys();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
|
||||
version = "2.3.0.0"
|
||||
version = "2.3.0.0-beta-1"
|
||||
|
||||
apply<JavaPlugin>()
|
||||
apply(plugin = "java")
|
||||
|
||||
@@ -60,8 +60,8 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin {
|
||||
this.actionBarManager = new ActionBarManagerImpl(this);
|
||||
this.coolDownManager = new CoolDownManager(this);
|
||||
this.packetManager = new PacketManager(this);
|
||||
new CommandManager(this).load();
|
||||
this.reload(CNConfig.generatePackOnStart);
|
||||
new CommandManager(this).load();
|
||||
this.versionManager.checkUpdate().thenAccept(outDated -> {
|
||||
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>");
|
||||
|
||||
@@ -26,11 +26,13 @@ import dev.jorel.commandapi.arguments.PlayerArgument;
|
||||
import dev.jorel.commandapi.arguments.StringArgument;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
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.tag.NameplatePlayer;
|
||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||
import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl;
|
||||
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
|
||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||
import net.momirealms.customnameplates.paper.setting.CNLocale;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -51,57 +53,155 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
public void load() {
|
||||
new CommandAPICommand("customnameplates")
|
||||
var command1 = new CommandAPICommand("customnameplates")
|
||||
.withAliases("nameplates", "cnameplates")
|
||||
.withSubcommands(
|
||||
getReloadCommand(),
|
||||
getAboutCommand(),
|
||||
getEquipCommand(),
|
||||
getUnEquipCommand(),
|
||||
getPreviewCommand(),
|
||||
getListCommand(),
|
||||
getForceEquipCommand(),
|
||||
getForceUnEquipCommand(),
|
||||
getForcePreviewCommand()
|
||||
NameplatesCommands.getReloadCommand(),
|
||||
NameplatesCommands.getAboutCommand()
|
||||
);
|
||||
if (CNConfig.nameplateModule) {
|
||||
command1.withSubcommands(
|
||||
NameplatesCommands.getEquipCommand(),
|
||||
NameplatesCommands.getUnEquipCommand(),
|
||||
NameplatesCommands.getPreviewCommand(),
|
||||
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();
|
||||
}
|
||||
|
||||
private CommandAPICommand getForceEquipCommand() {
|
||||
return new CommandAPICommand("force-equip")
|
||||
.withPermission("customnameplates.admin")
|
||||
.withArguments(new PlayerArgument("player"))
|
||||
.withArguments(new StringArgument("nameplate").replaceSuggestions(ArgumentSuggestions.strings(commandSenderSuggestionInfo -> plugin.getNameplateManager().getNameplateKeys().toArray(new String[0]))))
|
||||
.executes((sender, args) -> {
|
||||
Player player = (Player) args.get("player");
|
||||
String nameplate = (String) args.get("nameplate");
|
||||
if (player == null) return;
|
||||
if (!plugin.getNameplateManager().equipNameplate(player, nameplate, false)) {
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_NAMEPLATE_NOT_EXISTS);
|
||||
return;
|
||||
public static class BubblesCommands {
|
||||
|
||||
public static CommandAPICommand getListCommand() {
|
||||
return new CommandAPICommand("list")
|
||||
.withPermission("bubbles.list")
|
||||
.executesPlayer((player, args) -> {
|
||||
if (!CNConfig.bubbleModule) return;
|
||||
List<String> bubbles = CustomNameplatesPlugin.get().getBubbleManager().getAvailableBubblesDisplayNames(player);
|
||||
if (bubbles.size() != 0) {
|
||||
StringJoiner stringJoiner = new StringJoiner(", ");
|
||||
for (String availableBubble : bubbles) {
|
||||
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")
|
||||
.withPermission("customnameplates.admin")
|
||||
.withArguments(new PlayerArgument("player"))
|
||||
.executes((sender, args) -> {
|
||||
if (!CNConfig.bubbleModule) return;
|
||||
Player player = (Player) args.get("player");
|
||||
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()));
|
||||
});
|
||||
}
|
||||
|
||||
private CommandAPICommand getPreviewCommand() {
|
||||
public static CommandAPICommand getPreviewCommand() {
|
||||
return new CommandAPICommand("preview")
|
||||
.withPermission("nameplates.preview")
|
||||
.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) {
|
||||
LogUtils.warn(player.getName() + " failed to preview because no tag is created");
|
||||
return;
|
||||
@@ -112,22 +212,23 @@ public class CommandManager {
|
||||
}
|
||||
nameplatePlayer.setPreview(true);
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_PREVIEW_START);
|
||||
plugin.getScheduler().runTaskAsyncLater(() -> {
|
||||
CustomNameplatesPlugin.get().getScheduler().runTaskAsyncLater(() -> {
|
||||
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")
|
||||
.withPermission("customnameplates.admin")
|
||||
.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) -> {
|
||||
if (!CNConfig.nameplateModule) return;
|
||||
Player player = (Player) args.get("player");
|
||||
String nameplate = (String) args.getOrDefault("nameplate", "");
|
||||
if (player == null) return;
|
||||
NameplatePlayer nameplatePlayer = plugin.getNameplateManager().getNameplatePlayer(player.getUniqueId());
|
||||
NameplatePlayer nameplatePlayer = CustomNameplatesPlugin.get().getNameplateManager().getNameplatePlayer(player.getUniqueId());
|
||||
if (nameplatePlayer == null) {
|
||||
LogUtils.warn(player.getName() + " failed to preview because no tag is created");
|
||||
return;
|
||||
@@ -136,58 +237,61 @@ public class CommandManager {
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_PREVIEW_COOLDOWN);
|
||||
return;
|
||||
}
|
||||
Optional<OnlineUser> user = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
Optional<OnlineUser> user = CustomNameplatesPlugin.get().getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
if (user.isEmpty()) {
|
||||
LogUtils.warn(player.getName() + " failed to preview because data not loaded");
|
||||
return;
|
||||
}
|
||||
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);
|
||||
return;
|
||||
}
|
||||
nameplatePlayer.setPreview(true);
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_FORCE_PREVIEW.replace("{Player}", player.getName()));
|
||||
plugin.getScheduler().runTaskAsyncLater(() -> {
|
||||
CustomNameplatesPlugin.get().getScheduler().runTaskAsyncLater(() -> {
|
||||
nameplatePlayer.setPreview(false);
|
||||
plugin.getNameplateManager().equipNameplate(player, previous, true);
|
||||
}, plugin.getNameplateManager().getPreviewDuration(), TimeUnit.SECONDS);
|
||||
if (previous.equals("none")) {
|
||||
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")
|
||||
.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) -> {
|
||||
if (!CNConfig.nameplateModule) return;
|
||||
String nameplate = (String) args.get("nameplate");
|
||||
Nameplate nameplateInstance = plugin.getNameplateManager().getNameplate(nameplate);
|
||||
if (nameplateInstance == null) {
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_NAMEPLATE_NOT_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
if (!plugin.getNameplateManager().equipNameplate(player, nameplate, false)) {
|
||||
if (!CustomNameplatesPlugin.get().getNameplateManager().equipNameplate(player, nameplate, false)) {
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_NAMEPLATE_NOT_EXISTS);
|
||||
return;
|
||||
}
|
||||
Nameplate nameplateInstance = CustomNameplatesPlugin.get().getNameplateManager().getNameplate(nameplate);
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_EQUIP_NAMEPLATE.replace("{Nameplate}", nameplateInstance.getDisplayName()));
|
||||
});
|
||||
}
|
||||
|
||||
private CommandAPICommand getUnEquipCommand() {
|
||||
public static CommandAPICommand getUnEquipCommand() {
|
||||
return new CommandAPICommand("unequip")
|
||||
.withPermission("nameplates.unequip")
|
||||
.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);
|
||||
});
|
||||
}
|
||||
|
||||
private CommandAPICommand getListCommand() {
|
||||
public static CommandAPICommand getListCommand() {
|
||||
return new CommandAPICommand("list")
|
||||
.withPermission("nameplates.list")
|
||||
.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) {
|
||||
StringJoiner stringJoiner = new StringJoiner(", ");
|
||||
for (String availableNameplate : nameplates) {
|
||||
@@ -200,24 +304,24 @@ public class CommandManager {
|
||||
});
|
||||
}
|
||||
|
||||
private CommandAPICommand getReloadCommand() {
|
||||
public static CommandAPICommand getReloadCommand() {
|
||||
return new CommandAPICommand("reload")
|
||||
.withPermission("customnameplates.admin")
|
||||
.withOptionalArguments(new BooleanArgument("generate pack"))
|
||||
.executes((sender, args) -> {
|
||||
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)));
|
||||
boolean generate = (boolean) args.getOrDefault("generate pack", true);
|
||||
if (generate) {
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_GENERATING);
|
||||
plugin.getResourcePackManager().generateResourcePack();
|
||||
CustomNameplatesPlugin.get().getResourcePackManager().generateResourcePack();
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(sender, CNLocale.MSG_PACK_GENERATED);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private CommandAPICommand getAboutCommand() {
|
||||
public static CommandAPICommand getAboutCommand() {
|
||||
return new CommandAPICommand("about")
|
||||
.withPermission("customnameplates.about")
|
||||
.executes((sender, args) -> {
|
||||
@@ -229,3 +333,4 @@ public class CommandManager {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.character.CharacterArranger;
|
||||
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.StaticTextEntity;
|
||||
import net.momirealms.customnameplates.api.mechanic.tag.unlimited.StaticTextTagSetting;
|
||||
@@ -306,6 +308,11 @@ public class BubbleManagerImpl implements BubbleManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getBubbleKeys() {
|
||||
return bubbleMap.keySet();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Bubble getBubble(String bubble) {
|
||||
@@ -349,6 +356,42 @@ public class BubbleManagerImpl implements BubbleManager {
|
||||
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() {
|
||||
String[] png_list = new String[]{"chat"};
|
||||
String[] part_list = new String[]{"_left.png", "_middle.png", "_right.png", "_tail.png", ".yml"};
|
||||
|
||||
@@ -479,7 +479,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
@Override
|
||||
public boolean equipNameplate(Player player, String nameplateKey, boolean temp) {
|
||||
Nameplate nameplate = getNameplate(nameplateKey);
|
||||
if (nameplate == null && !nameplateKey.equals("none")) {
|
||||
if (nameplate == null && nameplateKey.equals("none")) {
|
||||
return false;
|
||||
}
|
||||
plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresentOrElse(it -> {
|
||||
@@ -502,6 +502,9 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
@Override
|
||||
public void unEquipNameplate(Player player, boolean temp) {
|
||||
plugin.getStorageManager().getOnlineUser(player.getUniqueId()).ifPresentOrElse(it -> {
|
||||
if (it.getNameplateKey().equals("none")) {
|
||||
return;
|
||||
}
|
||||
it.setNameplate("none");
|
||||
this.updateCachedNameplate(player, getNameplate(getDefaultNameplate()));
|
||||
NameplatePlayer nameplatePlayer = getNameplatePlayer(player.getUniqueId());
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.momirealms.customnameplates.paper.mechanic.placeholder;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
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.font.OffsetFont;
|
||||
import net.momirealms.customnameplates.api.mechanic.nameplate.Nameplate;
|
||||
@@ -134,10 +135,20 @@ public class PluginPlaceholders extends PlaceholderExpansion {
|
||||
case "nameplate-name" -> {
|
||||
Nameplate nameplate = optPlayer.get().getNameplate();
|
||||
if (nameplate == null) {
|
||||
return CNLocale.MSG_NO_NAMEPLATE;
|
||||
return "";
|
||||
}
|
||||
return nameplate.getDisplayName();
|
||||
}
|
||||
case "bubble" -> {
|
||||
return optPlayer.get().getBubbleKey();
|
||||
}
|
||||
case "bubble-name" -> {
|
||||
Bubble bubble = optPlayer.get().getBubble();
|
||||
if (bubble == null) {
|
||||
return "";
|
||||
}
|
||||
return bubble.getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,14 +33,14 @@ public class CNLocale {
|
||||
public static String MSG_AVAILABLE_NAMEPLATE;
|
||||
public static String MSG_HAVE_NO_NAMEPLATE;
|
||||
public static String MSG_FORCE_PREVIEW;
|
||||
public static String bb_equip;
|
||||
public static String bb_unEquip;
|
||||
public static String bb_force_equip;
|
||||
public static String bb_force_unEquip;
|
||||
public static String bb_not_exist;
|
||||
public static String bb_notAvailable;
|
||||
public static String bb_available;
|
||||
public static String bb_haveNone;
|
||||
public static String MSG_EQUIP_BUBBLE;
|
||||
public static String MSG_UNEQUIP_BUBBLE;
|
||||
public static String MSG_FORCE_EQUIP_BUBBLE;
|
||||
public static String MSG_FORCE_UNEQUIP_BUBBLE;
|
||||
public static String MSG_BUBBLE_NOT_EXIST;
|
||||
public static String MSG_BUBBLE_NOT_AVAILABLE;
|
||||
public static String MSG_AVAILABLE_BUBBLE;
|
||||
public static String MSG_HAVE_NO_BUBBLE;
|
||||
|
||||
public static void load() {
|
||||
try {
|
||||
@@ -83,14 +83,14 @@ public class CNLocale {
|
||||
MSG_AVAILABLE_NAMEPLATE = config.getString("messages.available-nameplates");
|
||||
MSG_HAVE_NO_NAMEPLATE = config.getString("messages.have-no-nameplates");
|
||||
MSG_FORCE_PREVIEW = config.getString("messages.force-preview");
|
||||
bb_equip = config.getString("messages.equip-bubbles");
|
||||
bb_unEquip = config.getString("messages.unequip-bubbles");
|
||||
bb_force_equip = config.getString("messages.force-equip-bubbles");
|
||||
bb_force_unEquip = config.getString("messages.force-unequip-bubbles");
|
||||
bb_not_exist = config.getString("messages.not-exist-bubbles");
|
||||
bb_notAvailable = config.getString("messages.not-available-bubbles");
|
||||
bb_available = config.getString("messages.available-bubbles");
|
||||
bb_haveNone = config.getString("messages.have-no-bubbles");
|
||||
MSG_EQUIP_BUBBLE = config.getString("messages.equip-bubbles");
|
||||
MSG_UNEQUIP_BUBBLE = config.getString("messages.unequip-bubbles");
|
||||
MSG_FORCE_EQUIP_BUBBLE = config.getString("messages.force-equip-bubbles");
|
||||
MSG_FORCE_UNEQUIP_BUBBLE = config.getString("messages.force-unequip-bubbles");
|
||||
MSG_BUBBLE_NOT_EXIST = config.getString("messages.not-exist-bubbles");
|
||||
MSG_BUBBLE_NOT_AVAILABLE = config.getString("messages.not-available-bubbles");
|
||||
MSG_AVAILABLE_BUBBLE = config.getString("messages.available-bubbles");
|
||||
MSG_HAVE_NO_BUBBLE = config.getString("messages.have-no-bubbles");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ blacklist-channels:
|
||||
- Private
|
||||
- Staff
|
||||
|
||||
# Player's default chatting bubbles
|
||||
# Default bubble to display if player's bubble is "none"
|
||||
default-bubbles: 'chat'
|
||||
|
||||
# Text format when bubble is "none"
|
||||
|
||||
@@ -4,7 +4,7 @@ mode: TEAM
|
||||
# The duration (in seconds) that the nameplate preview will last for.
|
||||
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'
|
||||
|
||||
# This decides what %nameplates_prefix/suffix% would return
|
||||
|
||||
@@ -21,8 +21,8 @@ messages:
|
||||
|
||||
equip-bubbles: '<white>你已佩戴聊天气泡 {Bubble}</white>'
|
||||
unequip-bubbles: '<white>你已卸下聊天气泡</white>'
|
||||
available-bubbles: '<white>可用聊天气泡: {Bubbles}</white>'
|
||||
force-equip-bubbles: '<white>成功使用聊天气泡 {Bubbles}</white>'
|
||||
available-bubbles: '<white>可用聊天气泡: {Bubble}</white>'
|
||||
force-equip-bubbles: '<white>成功使用聊天气泡 {Bubble}</white>'
|
||||
force-unequip-bubbles: '<white>你移除了 {Player} 的聊天气泡</white>'
|
||||
not-exist-bubbles: '<white>那个聊天气泡不存在!</white>'
|
||||
not-available-bubbles: '<white>你还未拥有这个气泡!</white>'
|
||||
|
||||
@@ -20,10 +20,10 @@ messages:
|
||||
force-preview: '<white>Forced {Player} to preview the nameplate</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>'
|
||||
force-unequip-bubbles: '<white>Successfully removed {Player}''s bubbles!</white>'
|
||||
not-exist-bubbles: '<white>This bubble does not exist!</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'
|
||||
@@ -20,10 +20,10 @@ messages:
|
||||
force-preview: '<white>Forced {Player} to preview the nameplate</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>'
|
||||
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-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>'
|
||||
|
||||
@@ -20,10 +20,10 @@ messages:
|
||||
force-preview: '<white>Forced {Player} to preview the nameplate</white>'
|
||||
|
||||
equip-bubbles: '<white>Успешно установлен стиль чата над головой: {Bubble}</white>'
|
||||
force-equip-bubbles: '<white>Успешно установлен стиль чата над головой: {Bubbles}</white>'
|
||||
force-equip-bubbles: '<white>Успешно установлен стиль чата над головой: {Bubble}</white>'
|
||||
unequip-bubbles: '<white>Вы сняли стиль чата над головой.</white>'
|
||||
force-unequip-bubbles: '<white>Успешно снят стиль чата над головой у {Player}!</white>'
|
||||
not-exist-bubbles: '<white>Такого стиля чата над головой не существует!</white>'
|
||||
not-available-bubbles: '<white>Этот стиль чата над головой сейчас недоступен!</white>'
|
||||
available-bubbles: '<white>Доступные стили чата над головой: {Bubbles}</white>'
|
||||
available-bubbles: '<white>Доступные стили чата над головой: {Bubble}</white>'
|
||||
have-no-bubbles: '<white>У вас еще нет никаких стилей чата над головой.'
|
||||
|
||||
@@ -20,10 +20,10 @@ messages:
|
||||
force-preview: '<white>Forced {Player} to preview the nameplate</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>'
|
||||
force-unequip-bubbles: '<white>Se ha removido tu chatting bubbles</white>'
|
||||
not-exist-bubbles: '<white>Este bubble no existe</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'
|
||||
@@ -21,10 +21,10 @@ messages:
|
||||
force-preview: '<white>Forced {Player} to preview the nameplate</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>'
|
||||
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-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>'
|
||||
Reference in New Issue
Block a user