9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-19 15:09:23 +00:00
This commit is contained in:
XiaoMoMi
2024-01-26 23:56:49 +08:00
parent dc149dbb05
commit 8ff48ad395
9 changed files with 52 additions and 39 deletions

View File

@@ -18,6 +18,7 @@
package net.momirealms.customnameplates.api.mechanic.placeholder;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.HashMap;
@@ -41,9 +42,9 @@ public class SwitchText {
this.toParse = toParse;
}
public String getValue(Player player) {
public String getValue(OfflinePlayer player) {
String parsed = PlaceholderAPI.setPlaceholders(player, toParse);
return valueMap.getOrDefault(parsed, defaultValue);
return PlaceholderAPI.setPlaceholders(player, valueMap.getOrDefault(parsed, defaultValue));
}
public static class Builder {

View File

@@ -18,12 +18,10 @@
package net.momirealms.customnameplates.api.mechanic.placeholder;
import me.clip.placeholderapi.PlaceholderAPI;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.mechanic.font.OffsetFont;
import net.momirealms.customnameplates.api.util.FontUtils;
import net.momirealms.customnameplates.api.util.LogUtils;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
public class VanillaHud {

View File

@@ -7,7 +7,7 @@ plugins {
allprojects {
version = "2.3.0.2"
version = "2.3.0.3"
apply<JavaPlugin>()
apply(plugin = "java")

View File

@@ -107,7 +107,7 @@ public class CommandManager {
public static CommandAPICommand getListCommand() {
return new CommandAPICommand("list")
.withPermission("bubbles.list")
.withPermission("bubbles.command.list")
.executesPlayer((player, args) -> {
if (!CNConfig.bubbleModule) return;
List<String> bubbles = CustomNameplatesPlugin.get().getBubbleManager().getAvailableBubblesDisplayNames(player);
@@ -125,15 +125,22 @@ public class CommandManager {
public static CommandAPICommand getEquipCommand() {
return new CommandAPICommand("equip")
.withPermission("bubbles.equip")
.withPermission("bubbles.command.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)) {
if (!CustomNameplatesPlugin.get().getBubbleManager().containsBubble(bubble)) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_BUBBLE_NOT_EXIST);
return;
}
if (!CustomNameplatesPlugin.get().getBubbleManager().hasBubble(player, bubble)) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_BUBBLE_NOT_AVAILABLE);
return;
}
CustomNameplatesPlugin.get().getBubbleManager().equipBubble(player, bubble);
Bubble bubbleInstance = CustomNameplatesPlugin.get().getBubbleManager().getBubble(bubble);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_EQUIP_BUBBLE.replace("{Bubble}", bubbleInstance.getDisplayName()));
});
@@ -141,7 +148,7 @@ public class CommandManager {
public static CommandAPICommand getUnEquipCommand() {
return new CommandAPICommand("unequip")
.withPermission("bubbles.unequip")
.withPermission("bubbles.command.unequip")
.executesPlayer((player, args) -> {
if (!CNConfig.bubbleModule) return;
CustomNameplatesPlugin.get().getBubbleManager().unEquipBubble(player);
@@ -218,7 +225,7 @@ public class CommandManager {
public static CommandAPICommand getPreviewCommand() {
return new CommandAPICommand("preview")
.withPermission("nameplates.preview")
.withPermission("nameplates.command.preview")
.executesPlayer((player, args) -> {
if (!CNConfig.nameplateModule) return;
NameplatePlayer nameplatePlayer = CustomNameplatesPlugin.get().getNameplateManager().getNameplatePlayer(player.getUniqueId());
@@ -290,15 +297,23 @@ public class CommandManager {
public static CommandAPICommand getEquipCommand() {
return new CommandAPICommand("equip")
.withPermission("nameplates.equip")
.withPermission("nameplates.command.equip")
.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");
if (!CustomNameplatesPlugin.get().getNameplateManager().equipNameplate(player, nameplate, false)) {
if (!CustomNameplatesPlugin.get().getNameplateManager().containsNameplate(nameplate)) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_NAMEPLATE_NOT_EXISTS);
return;
}
if (!CustomNameplatesPlugin.get().getNameplateManager().hasNameplate(player, nameplate)) {
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_NAMEPLATE_NOT_AVAILABLE);
return;
}
CustomNameplatesPlugin.get().getNameplateManager().equipNameplate(player, nameplate, false);
Nameplate nameplateInstance = CustomNameplatesPlugin.get().getNameplateManager().getNameplate(nameplate);
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_EQUIP_NAMEPLATE.replace("{Nameplate}", nameplateInstance.getDisplayName()));
});
@@ -306,7 +321,7 @@ public class CommandManager {
public static CommandAPICommand getUnEquipCommand() {
return new CommandAPICommand("unequip")
.withPermission("nameplates.unequip")
.withPermission("nameplates.command.unequip")
.executesPlayer((player, args) -> {
if (!CNConfig.nameplateModule) return;
CustomNameplatesPlugin.get().getNameplateManager().unEquipNameplate(player, false);
@@ -316,7 +331,7 @@ public class CommandManager {
public static CommandAPICommand getListCommand() {
return new CommandAPICommand("list")
.withPermission("nameplates.list")
.withPermission("nameplates.command.list")
.executesPlayer((player, args) -> {
if (!CNConfig.nameplateModule) return;
List<String> nameplates = CustomNameplatesPlugin.get().getNameplateManager().getAvailableNameplateDisplayNames(player);
@@ -383,7 +398,7 @@ public class CommandManager {
public static CommandAPICommand getAboutCommand() {
return new CommandAPICommand("about")
.withPermission("customnameplates.about")
.withPermission("customnameplates.admin")
.executes((sender, args) -> {
AdventureManagerImpl.getInstance().sendMessage(sender, "<#3CB371>⚓ CustomNameplates <gray>- <#98FB98>" + CustomNameplatesPlugin.getInstance().getVersionManager().getPluginVersion());
AdventureManagerImpl.getInstance().sendMessage(sender, "<#7FFFAA>A plugin that provides adjustable images for texts");

View File

@@ -26,9 +26,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.destroystokyo.paper.profile.PlayerProfile;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.paper.mechanic.nameplate.NameplateManagerImpl;
import net.momirealms.customnameplates.paper.mechanic.nameplate.tag.team.TeamTagManagerImpl;
import java.util.ArrayList;

View File

@@ -119,6 +119,11 @@ public class PluginPlaceholders extends PlaceholderExpansion {
if (vanillaHud == null) return "Vanilla text not exists: " + mainArg;
return vanillaHud.getValue(offlinePlayer);
}
case "switch" -> {
SwitchText switchText = placeholderManager.getSwitchText(mainArg);
if (switchText == null) return "Switch text not exists: " + mainArg;
return switchText.getValue(offlinePlayer);
}
}
Player onlinePlayer = offlinePlayer.getPlayer();

View File

@@ -18,10 +18,11 @@
package net.momirealms.customnameplates.paper.mechanic.team.provider;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.*;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.common.team.TeamColor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -32,7 +33,6 @@ import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class UnknownProvider extends PacketAdapter implements TeamProvider, Listener {

View File

@@ -17,17 +17,13 @@
package net.momirealms.customnameplates.paper.util;
import com.comphenix.protocol.utility.MinecraftFields;
import com.comphenix.protocol.utility.MinecraftMethods;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import net.momirealms.customnameplates.api.util.LogUtils;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.UUID;
public class ReflectionUtils {

View File

@@ -7,34 +7,34 @@ folia-supported: true
depend: [ ProtocolLib ,PlaceholderAPI ]
softdepend: [ MagicCosmetics, TAB, CMI, TrChat, ItemsAdder, Oraxen ]
permissions:
nameplates.*:
nameplates.command.*:
description: Gives access to all nameplate user commands
children:
nameplates.equip: true
nameplates.unequip: true
nameplates.preview: true
nameplates.list: true
nameplates.equip:
nameplates.command.equip: true
nameplates.command.unequip: true
nameplates.command.preview: true
nameplates.command.list: true
nameplates.command.equip:
default: true
nameplates.unequip:
nameplates.command.unequip:
default: true
nameplates.preview:
nameplates.command.preview:
default: true
nameplates.list:
nameplates.command.list:
default: true
customnameplates.admin:
default: op
bubbles.*:
bubbles.command.*:
description: Gives access to bubble all user commands
children:
bubbles.equip: true
bubbles.unequip: true
bubbles.list: true
bubbles.equip:
bubbles.command.equip:
default: true
bubbles.unequip:
bubbles.command.unequip:
default: true
bubbles.list:
bubbles.command.list:
default: true
bubbles.use:
default: false
default: true