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-02-02 03:08:10 +08:00
parent c69735ea2b
commit 180b34f4c8
29 changed files with 594 additions and 67 deletions

View File

@@ -2,4 +2,11 @@ dependencies {
implementation(project(":common"))
compileOnly("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.11.5")
implementation("net.kyori:adventure-api:4.15.0")
}
tasks {
shadowJar {
relocate ("net.kyori", "net.momirealms.customnameplates.libraries")
}
}

View File

@@ -82,6 +82,10 @@ public class OnlineUser {
return CustomNameplatesPlugin.get().getNameplateManager().getNameplate(temp);
}
/**
* This value might be inconsistent with the key get by "getBubbleKey()"
* Because if a player doesn't have a bubble, his bubble would be the default one
*/
@Nullable
public Bubble getBubble() {
String temp = nameplate;

View File

@@ -23,6 +23,9 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.jetbrains.annotations.NotNull;
/**
* An event triggered when player sends a message
*/
public class BubblesSpawnEvent extends PlayerEvent implements Cancellable {
private boolean cancelled;
@@ -57,18 +60,34 @@ public class BubblesSpawnEvent extends PlayerEvent implements Cancellable {
return getHandlerList();
}
/**
* Get the bubble's key
*/
public String getBubble() {
return bubble;
}
/**
* Set the bubble
*
* @param bubble bubble's key
*/
public void setBubble(String bubble) {
this.bubble = bubble;
}
/**
* Get the bubble text content
*/
public String getText() {
return text;
}
/**
* Set the bubble text content
*
* @param text text
*/
public void setText(String text) {
this.text = text;
}

View File

@@ -22,6 +22,9 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Plugin reload event
*/
public class CustomNameplatesReloadEvent extends Event {
private static final HandlerList handlerList = new HandlerList();

View File

@@ -24,6 +24,9 @@ import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Player data loaded event
*/
public class NameplateDataLoadEvent extends Event {
private static final HandlerList handlerList = new HandlerList();
@@ -36,10 +39,20 @@ public class NameplateDataLoadEvent extends Event {
this.onlineUser = onlineUser;
}
/**
* Get the UUID
*
* @return uuid
*/
public UUID getUUID() {
return uuid;
}
/**
* Get the online user
*
* @return online user
*/
public OnlineUser getOnlineUser() {
return onlineUser;
}

View File

@@ -149,6 +149,12 @@ public interface AdventureManager {
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
boolean isColorCode(char c);
/**
* Convert a color into decimal
*
* @param color color
* @return decimal
*/
int colorToDecimal(ChatColor color);
/**
@@ -175,5 +181,11 @@ public interface AdventureManager {
*/
String getMiniMessageFormat(Component component);
/**
* Get IChatComponent from Json
*
* @param json json
* @return component
*/
Object getIChatComponent(String json);
}

View File

@@ -34,6 +34,11 @@ public interface BackGroundManager {
@Nullable
BackGround getBackGround(@NotNull String key);
/**
* Get all the backgrounds
*
* @return backgrounds
*/
Collection<BackGround> getBackGrounds();
/**

View File

@@ -26,29 +26,102 @@ import java.util.List;
public interface BubbleManager {
/**
* Register a bubble into map
*
* @param key key
* @param bubble bubble
* @return success or not
*/
boolean registerBubble(String key, Bubble bubble);
/**
* Unregister a bubble from map
*
* @param key key
* @return success or not
*/
boolean unregisterBubble(String key);
/**
* Get a bubble from map
*
* @param bubble key
* @return bubble
*/
@Nullable Bubble getBubble(String bubble);
/**
* If a player has a certain bubble
*
* @param player player
* @param bubble key
* @return
*/
boolean hasBubble(Player player, String bubble);
/**
* Get a list of the bubbles that a player has
*
* @param player player
* @return bubbles' keys
*/
List<String> getAvailableBubbles(Player player);
/**
* Get a list of the bubbles' display names that a player has
*
* @param player player
* @return bubbles' display names
*/
List<String> getAvailableBubblesDisplayNames(Player player);
/**
* Get blacklist chat channels
*
* @return channels
*/
String[] getBlacklistChannels();
/**
* Get all the bubbles
*
* @return bubbles
*/
Collection<Bubble> getBubbles();
/**
* Whether a bubble exists
*/
boolean containsBubble(String key);
/**
* Equip a bubble for a player
*
* @param player player
* @param bubble bubble
* @return success or not
*/
boolean equipBubble(Player player, String bubble);
/**
* Unequip a bubble for a player
*
* @param player player
*/
void unEquipBubble(Player player);
/**
* Get the default bubble key
*
* @return bubble key
*/
String getDefaultBubble();
/**
* Get all the bubbles' keys
*
* @return keys
*/
Collection<String> getBubbleKeys();
}

View File

@@ -34,6 +34,11 @@ public interface ImageManager {
@Nullable
ConfiguredChar getImage(@NotNull String key);
/**
* Get all the images
*
* @return images
*/
Collection<ConfiguredChar> getImages();
/**

View File

@@ -48,7 +48,7 @@ public interface NameplateManager {
* @param entityID entityID
* @param entity entity
*/
boolean putEntityIDToMap(int entityID, Entity entity);
boolean putEntityIDToMap(int entityID, @NotNull Entity entity);
/**
* Remove the entity from map
@@ -66,7 +66,7 @@ public interface NameplateManager {
* @param uuid player uuid
* @param nameplate cached nameplate
*/
boolean putCachedNameplateToMap(UUID uuid, CachedNameplate nameplate);
boolean putCachedNameplateToMap(@NotNull UUID uuid, @NotNull CachedNameplate nameplate);
/**
* Remove CachedNameplate from map
@@ -75,7 +75,7 @@ public interface NameplateManager {
* @return removed CachedNameplate
*/
@Nullable
CachedNameplate removeCachedNameplateFromMap(UUID uuid);
CachedNameplate removeCachedNameplateFromMap(@NotNull UUID uuid);
/**
* Get player by entityID from the cache
@@ -102,7 +102,7 @@ public interface NameplateManager {
* @param player player
* @return if the nameplate is updated
*/
boolean updateCachedNameplate(Player player);
boolean updateCachedNameplate(@NotNull Player player);
/**
* Update a player's cached nameplate
@@ -111,7 +111,7 @@ public interface NameplateManager {
* @param player player
* @return if the nameplate is updated
*/
boolean updateCachedNameplate(Player player, Nameplate nameplate);
boolean updateCachedNameplate(@NotNull Player player, @Nullable Nameplate nameplate);
/**
* This should not be null when player's data is loaded (async process)
@@ -120,61 +120,192 @@ public interface NameplateManager {
* @return cached nameplate
*/
@Nullable
CachedNameplate getCacheNameplate(Player player);
CachedNameplate getCacheNameplate(@NotNull Player player);
/**
* Create a name tag for a player, the tag type is decided by the mode in nameplate.yml
* If mode is DISABLE, this method would return null
* The tag would be put into map automatically and you can get it by getNameplatePlayer(uuid)
*
* @param player player
*/
void createNameTag(Player player);
@Nullable
NameplatePlayer createNameTag(@NotNull Player player);
void putNameplatePlayerToMap(NameplatePlayer player);
/**
* Put a nameplater player to map
*
* @param player player
*/
void putNameplatePlayerToMap(@NotNull NameplatePlayer player);
NameplatePlayer getNameplatePlayer(UUID uuid);
/**
* Get a nameplate player from map
*
* @param uuid uuid
* @return nameplate player
*/
@Nullable
NameplatePlayer getNameplatePlayer(@NotNull UUID uuid);
NameplatePlayer removeNameplatePlayerFromMap(UUID uuid);
/**
* Remove nameplate player from map
*
* @param uuid uuid
* @return removed nameplate player
*/
@Nullable
NameplatePlayer removeNameplatePlayerFromMap(@NotNull UUID uuid);
String getNameplatePrefix(Player player);
/**
* Get the nameplate's prefix with text tags
*
* @param player player
* @return prefix with text tags
*/
@NotNull
String getNameplatePrefix(@NotNull Player player);
String getNameplateSuffix(Player player);
/**
* Get the nameplate's suffix with text tags
*
* @param player player
* @return suffix with text tags
*/
@NotNull
String getNameplateSuffix(@NotNull Player player);
String getFullNameTag(Player player);
/**
* Get the full nameplate tag
*
* @param player player
* @return nameplate tag
*/
@NotNull
String getFullNameTag(@NotNull Player player);
boolean registerNameplate(String key, Nameplate nameplate);
/**
* Register a custom nameplate into map
*
* @param key key
* @param nameplate nameplate
* @return success or not
*/
boolean registerNameplate(@NotNull String key, @NotNull Nameplate nameplate);
boolean equipNameplate(Player player, String nameplateKey, boolean temp);
/**
* Unregister a nameplate from map
*
* @param key key
* @return success or not
*/
boolean unregisterNameplate(@NotNull String key);
/**
* Equip a nameplate for a player
*
* @param player player
* @param nameplateKey key
* @param temp whether save to storage
* @return success or not
*/
boolean equipNameplate(@NotNull Player player, @NotNull String nameplateKey, boolean temp);
/**
* Remove a nameplate for a player
*
* @param player player
* @param temp whether save to storage
*/
void unEquipNameplate(Player player, boolean temp);
boolean unregisterNameplate(String key);
/**
* Is team managed on proxy side
*/
boolean isProxyMode();
/**
* Get preview duration
*/
int getPreviewDuration();
/**
* Get the tag mode
*/
@NotNull
TagMode getTagMode();
Nameplate getNameplate(String key);
/**
* Get a nameplate by key
*
* @param key key
* @return nameplate
*/
@NotNull
Nameplate getNameplate(@NotNull String key);
/**
* Get all the nameplates
*
* @return nameplates
*/
@NotNull
Collection<Nameplate> getNameplates();
/**
* Get all the nameplates' keys
*
* @return keys
*/
@NotNull
Collection<String> getNameplateKeys();
boolean containsNameplate(String key);
/**
* Whether a nameplate key exists
*/
boolean containsNameplate(@NotNull String key);
List<String> getAvailableNameplates(Player player);
/**
* Get all the nameplates that the player has
*
* @param player player
* @return nameplates' keys
*/
@NotNull
List<String> getAvailableNameplates(@NotNull Player player);
/**
* If player has permission for a certain nameplate
*/
boolean hasNameplate(Player player, String nameplate);
boolean hasNameplate(@NotNull Player player, @NotNull String nameplate);
List<String> getAvailableNameplateDisplayNames(Player player);
/**
* Get all the nameplates' display names that the player has
*
* @param player player
* @return nameplates' display names
*/
@NotNull
List<String> getAvailableNameplateDisplayNames(@NotNull Player player);
TeamColor getTeamColor(Player player);
/**
* Get the nameplate's team color
*
* @param player player
* @return team color
*/
@NotNull
TeamColor getTeamColor(@NotNull Player player);
/**
* Get team tag manager
*/
@NotNull
TeamTagManager getTeamTagManager();
/**
* Get unlimited tag manager
*/
@NotNull
UnlimitedTagManager getUnlimitedTagManager();
}

View File

@@ -44,6 +44,11 @@ public interface PlaceholderManager {
@Nullable
StaticText getStaticText(String key);
/**
* Get all the static texts
*
* @return static texts
*/
Collection<StaticText> getStaticTexts();
/**
@@ -55,6 +60,11 @@ public interface PlaceholderManager {
@Nullable
SwitchText getSwitchText(String key);
/**
* Get all the switch texts
*
* @return switch texts
*/
Collection<SwitchText> getSwitchTexts();
/**
@@ -66,6 +76,11 @@ public interface PlaceholderManager {
@Nullable
DescentText getDescentText(String key);
/**
* Get all the descent texts
*
* @return descent texts
*/
Collection<DescentText> getDescentTexts();
/**
@@ -77,6 +92,11 @@ public interface PlaceholderManager {
@Nullable
ConditionalText getConditionalText(String key);
/**
* Get all the conditional texts
*
* @return conditional texts
*/
Collection<ConditionalText> getConditionalTexts();
/**
@@ -88,6 +108,11 @@ public interface PlaceholderManager {
@Nullable
NameplateText getNameplateText(String key);
/**
* Get all the nameplate texts
*
* @return nameplate texts
*/
Collection<NameplateText> getNameplateTexts();
/**
@@ -99,9 +124,25 @@ public interface PlaceholderManager {
@Nullable
BackGroundText getBackGroundText(String key);
/**
* Get all the background texts
*
* @return background texts
*/
Collection<BackGroundText> getBackGroundTexts();
/**
* Get a vanilla hud
*
* @param key key
* @return vanilla hud
*/
VanillaHud getVanillaHud(String key);
/**
* Get all the vanilla huds
*
* @return vanilla huds
*/
Collection<VanillaHud> getVanillaHuds();
}

View File

@@ -26,5 +26,10 @@ public interface ResourcePackManager {
*/
void generateResourcePack();
/**
* Delete a directory
*
* @param file file
*/
void deleteDirectory(File file);
}

View File

@@ -46,7 +46,7 @@ public interface TeamManager {
* Get the team player in
*
* @param player player
* @param viewer
* @param viewer viewer
* @return team name
*/
String getTeamName(Player player, Player viewer);

View File

@@ -24,6 +24,14 @@ import org.jetbrains.annotations.NotNull;
public interface UnlimitedTagManager {
/**
* Create a named entity (ArmorStand) for an entity
* To apply the changes, you should add it to the EntityTagEntity
*
* @param entity entity
* @param setting setting
* @return named entity
*/
@NotNull StaticTextEntity createNamedEntity(EntityTagEntity entity, StaticTextTagSetting setting);
/**
@@ -37,7 +45,19 @@ public interface UnlimitedTagManager {
@NotNull
DynamicTextEntity createNamedEntity(EntityTagPlayer player, DynamicTextTagSetting setting);
/**
* Create or get a tag instance
*
* @param entity entity
* @return entity tag instance
*/
EntityTagEntity createOrGetTagForEntity(Entity entity);
/**
* Create or get a tag instance
*
* @param player player
* @return entity tag instance
*/
EntityTagPlayer createOrGetTagForPlayer(Player player);
}

View File

@@ -17,16 +17,53 @@
package net.momirealms.customnameplates.api.manager;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.CompletionStage;
public interface VersionManager {
/**
* Is folia scheduler implemented
*/
boolean isFolia();
/**
* Get bukkit version
*
* @return version
*/
String getServerVersion();
/**
* Check update
*
* @return return true if plugin needs update
*/
CompletionStage<Boolean> checkUpdate();
/**
* Get plugin version
*
* @return version
*/
@NotNull
String getPluginVersion();
/**
* Is the plugin the latest version
*
* @return latest or not
*/
boolean isLatest();
/**
* Get pack format
*
* @return pack format
*/
int getPackFormat();
boolean isVersionNewerThan1_19();
boolean isVersionNewerThan1_19_R2();
@@ -36,11 +73,4 @@ public interface VersionManager {
boolean isVersionNewerThan1_20();
boolean isVersionNewerThan1_20_R2();
String getPluginVersion();
boolean isLatest();
int getPackFormat();
}

View File

@@ -19,15 +19,43 @@ package net.momirealms.customnameplates.api.manager;
import net.momirealms.customnameplates.api.mechanic.font.FontData;
import net.momirealms.customnameplates.common.Key;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface WidthManager {
boolean registerFontData(Key key, FontData fontData);
/**
* Register a font data into the plugin
* If there already exists one, it would fail
*
* @param key key
* @param fontData data
* @return success or not
*/
boolean registerFontData(@NotNull Key key, @NotNull FontData fontData);
boolean unregisterFontData(Key key);
/**
* Unregister a font data from map
*
* @param key key
* @return success or not
*/
boolean unregisterFontData(@NotNull Key key);
@Nullable FontData getFontData(Key key);
/**
* Get font data by key
*
* @param key key
* @return font data
*/
@Nullable
FontData getFontData(@NotNull Key key);
int getTextWidth(String textWithTags);
/**
* Get text's width (MiniMessage format text)
*
* @param textWithTags text
* @return width
*/
int getTextWidth(@NotNull String textWithTags);
}

View File

@@ -25,17 +25,32 @@ public class CharacterArranger {
currentChar = (char) (currentChar + '\u0001');
}
/**
* Get and increase the char arranged automatically by the plugin
*
* @return char
*/
public static char getAndIncrease() {
char temp = currentChar;
increase();
return temp;
}
/**
* Increase and get the char arranged automatically by the plugin
*
* @return char
*/
public static char increaseAndGet() {
increase();
return currentChar;
}
/**
* Reset the initial char
*
* @param c char
*/
public static void reset(char c) {
currentChar = c;
}

View File

@@ -29,18 +29,40 @@ public class FontData {
this.defaultWidth = defaultWidth;
}
/**
* Register a char's width
*
* @param codePoint code point
* @param width width
*/
public void registerCharWidth(int codePoint, int width) {
widthData.put(codePoint, width);
}
/**
* Get a character's width
*
* @param codePoint code point
* @return width
*/
public int getWidth(int codePoint) {
return widthData.getOrDefault(codePoint, defaultWidth);
}
/**
* Get the data map
*
* @return map
*/
public HashMap<Integer, Integer> getWidthData() {
return widthData;
}
/**
* Override the data with another one
*
* @param fontData font data
*/
public void overrideWith(FontData fontData) {
if (fontData == null) return;
widthData.putAll(fontData.getWidthData());

View File

@@ -66,6 +66,12 @@ public enum OffsetFont {
return this.height;
}
/**
* Get offset characters
*
* @param offset offset
* @return chars
*/
public static String getOffsetChars(int offset) {
if (offset >= 0) {
return getShortestPosChars(offset);
@@ -74,6 +80,12 @@ public enum OffsetFont {
}
}
/**
* get negative characters
*
* @param n n > 0
* @return chars
*/
public static String getShortestNegChars(int n) {
StringBuilder stringBuilder = new StringBuilder();
while (n >= 128) {
@@ -126,6 +138,12 @@ public enum OffsetFont {
return stringBuilder.toString();
}
/**
* get positive characters
*
* @param n n > 0
* @return chars
*/
public static String getShortestPosChars(int n) {
StringBuilder stringBuilder = new StringBuilder();
while (n >= 128) {

View File

@@ -21,13 +21,37 @@ import net.momirealms.customnameplates.api.mechanic.misc.ViewerText;
import net.momirealms.customnameplates.api.mechanic.tag.NameplatePlayer;
public interface TeamTagPlayer extends NameplatePlayer {
/**
* Set a player's prefix
*
* @param prefix prefix
*/
void setPrefix(String prefix);
/**
* Set a player's suffix
*
* @param suffix suffix
*/
void setSuffix(String suffix);
/**
* Get a player's prefix
*
* @return prefix
*/
ViewerText getPrefix();
/**
* Get a player's suffix
*
* @return suffix
*/
ViewerText getSuffix();
/**
* Destroy the tag
*/
void destroy();
}

View File

@@ -21,7 +21,11 @@ import org.bukkit.OfflinePlayer;
public class Condition {
private final OfflinePlayer player;
private OfflinePlayer player;
public Condition() {
this.player = null;
}
public Condition(OfflinePlayer player) {
this.player = player;
@@ -30,4 +34,26 @@ public class Condition {
public OfflinePlayer getOfflinePlayer() {
return player;
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private final Condition condition;
public Builder() {
this.condition = new Condition();
}
public Builder player(OfflinePlayer player) {
condition.player = player;
return this;
}
public Condition build() {
return condition;
}
}
}

View File

@@ -22,6 +22,13 @@ import org.bukkit.entity.Entity;
public class LocationUtils {
/**
* Get distance by two entities
*
* @param e1 entity
* @param e2 entity
* @return distance
*/
public static double getDistance(Entity e1, Entity e2) {
Location loc1 = e1.getLocation();
Location loc2 = e2.getLocation();

View File

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

View File

@@ -17,6 +17,7 @@
package net.momirealms.customnameplates.paper.mechanic.bubble.listener;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.paper.mechanic.bubble.BubbleManagerImpl;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerChatEvent;
@@ -30,6 +31,6 @@ public class AsyncChatListener extends AbstractChatListener {
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
if (event.isCancelled()) return;
chatBubblesManager.onChat(event.getPlayer(), event.getMessage());
CustomNameplatesPlugin.get().getScheduler().runTaskAsync(() -> chatBubblesManager.onChat(event.getPlayer(), event.getMessage()));
}
}

View File

@@ -30,7 +30,7 @@ import java.util.Arrays;
public class TrChatListener extends AbstractChatListener {
private BukkitAdapter adapter;
private final BukkitAdapter adapter;
public TrChatListener(BubbleManagerImpl chatBubblesManager) {
super(chatBubblesManager);

View File

@@ -859,7 +859,7 @@ public class WidthManagerImpl implements WidthManager {
}
@Override
public boolean registerFontData(Key key, FontData fontData) {
public boolean registerFontData(@NotNull Key key, @NotNull FontData fontData) {
if (fontDataMap.containsKey(key)) {
return false;
}
@@ -868,18 +868,18 @@ public class WidthManagerImpl implements WidthManager {
}
@Override
public boolean unregisterFontData(Key key) {
public boolean unregisterFontData(@NotNull Key key) {
return fontDataMap.remove(key) != null;
}
@Nullable
@Override
public FontData getFontData(Key key) {
public FontData getFontData(@NotNull Key key) {
return fontDataMap.get(key);
}
@Override
public int getTextWidth(String textWithTags) {
public int getTextWidth(@NotNull String textWithTags) {
return cacheSystem.getWidthFromCache(textWithTags);
}

View File

@@ -26,6 +26,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.jetbrains.annotations.NotNull;
import java.io.BufferedReader;
import java.io.InputStream;
@@ -97,6 +98,7 @@ public class VersionManagerImpl implements VersionManager, Listener {
return isNewerThan1_20_R2;
}
@NotNull
@Override
public String getPluginVersion() {
return pluginVersion;

View File

@@ -333,7 +333,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
}
@Override
public boolean putEntityIDToMap(int entityID, Entity entity) {
public boolean putEntityIDToMap(int entityID, @NotNull Entity entity) {
if (this.entityID2EntityMap.containsKey(entityID))
return false;
this.entityID2EntityMap.put(entityID, entity);
@@ -346,7 +346,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
}
@Override
public boolean putCachedNameplateToMap(UUID uuid, CachedNameplate nameplate) {
public boolean putCachedNameplateToMap(@NotNull UUID uuid, @NotNull CachedNameplate nameplate) {
if (this.cachedNameplateMap.containsKey(uuid)) {
return false;
}
@@ -355,7 +355,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
}
@Override
public CachedNameplate removeCachedNameplateFromMap(UUID uuid) {
public CachedNameplate removeCachedNameplateFromMap(@NotNull UUID uuid) {
return this.cachedNameplateMap.remove(uuid);
}
@@ -374,7 +374,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
}
@Override
public boolean updateCachedNameplate(Player player) {
public boolean updateCachedNameplate(@NotNull Player player) {
Optional<OnlineUser> onlineUser = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
if (onlineUser.isEmpty()) return false;
Nameplate nameplate = onlineUser.get().getNameplate();
@@ -382,45 +382,49 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
}
@Override
public boolean updateCachedNameplate(Player player, Nameplate nameplate) {
public boolean updateCachedNameplate(@NotNull Player player, Nameplate nameplate) {
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
if (cachedNameplate == null) return false;
return updateCachedNameplate(cachedNameplate, player, nameplate);
}
@Override
public CachedNameplate getCacheNameplate(Player player) {
public CachedNameplate getCacheNameplate(@NotNull Player player) {
return cachedNameplateMap.get(player.getUniqueId());
}
@Override
public void createNameTag(Player player) {
public NameplatePlayer createNameTag(@NotNull Player player) {
if (tagMode == TagMode.TEAM) {
putNameplatePlayerToMap(this.teamTagManager.createTagForPlayer(player, teamPrefix, teamSuffix));
NameplatePlayer nameplatePlayer = this.teamTagManager.createTagForPlayer(player, teamPrefix, teamSuffix);
putNameplatePlayerToMap(nameplatePlayer);
this.unlimitedTagManager.createOrGetTagForPlayer(player);
return nameplatePlayer;
} else if (tagMode == TagMode.UNLIMITED) {
EntityTagPlayer tagPlayer = this.unlimitedTagManager.createOrGetTagForPlayer(player);
for (DynamicTextTagSetting setting : tagSettings) {
tagPlayer.addTag(setting);
}
putNameplatePlayerToMap(tagPlayer);
return tagPlayer;
} else {
this.unlimitedTagManager.createOrGetTagForPlayer(player);
return null;
}
}
@Override
public void putNameplatePlayerToMap(NameplatePlayer player) {
public void putNameplatePlayerToMap(@NotNull NameplatePlayer player) {
this.nameplatePlayerMap.put(player.getPlayer().getUniqueId(), player);
}
@Override
public NameplatePlayer getNameplatePlayer(UUID uuid) {
public NameplatePlayer getNameplatePlayer(@NotNull UUID uuid) {
return this.nameplatePlayerMap.get(uuid);
}
@Override
public NameplatePlayer removeNameplatePlayerFromMap(UUID uuid) {
public NameplatePlayer removeNameplatePlayerFromMap(@NotNull UUID uuid) {
return this.nameplatePlayerMap.remove(uuid);
}
@@ -453,22 +457,25 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
return true;
}
@NotNull
@Override
public String getNameplatePrefix(Player player) {
public String getNameplatePrefix(@NotNull Player player) {
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
if (cachedNameplate == null) return "";
return cachedNameplate.getTagPrefix();
}
@NotNull
@Override
public String getNameplateSuffix(Player player) {
public String getNameplateSuffix(@NotNull Player player) {
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
if (cachedNameplate == null) return "";
return cachedNameplate.getTagSuffix();
}
@NotNull
@Override
public String getFullNameTag(Player player) {
public String getFullNameTag(@NotNull Player player) {
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
if (cachedNameplate == null) {
return player.getName();
@@ -481,8 +488,9 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
+ cachedNameplate.getNameSuffix();
}
@NotNull
@Override
public List<String> getAvailableNameplates(Player player) {
public List<String> getAvailableNameplates(@NotNull Player player) {
List<String> nameplates = new ArrayList<>();
for (String nameplate : nameplateMap.keySet()) {
if (hasNameplate(player, nameplate)) {
@@ -492,8 +500,9 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
return nameplates;
}
@NotNull
@Override
public List<String> getAvailableNameplateDisplayNames(Player player) {
public List<String> getAvailableNameplateDisplayNames(@NotNull Player player) {
List<String> nameplates = new ArrayList<>();
for (Map.Entry<String, Nameplate> entry : nameplateMap.entrySet()) {
if (hasNameplate(player, entry.getKey())) {
@@ -504,7 +513,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
}
@Override
public boolean equipNameplate(Player player, String nameplateKey, boolean temp) {
public boolean equipNameplate(@NotNull Player player, @NotNull String nameplateKey, boolean temp) {
Nameplate nameplate = getNameplate(nameplateKey);
if (nameplate == null && nameplateKey.equals("none")) {
return false;
@@ -555,14 +564,14 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
}
@Override
public boolean registerNameplate(String key, Nameplate nameplate) {
public boolean registerNameplate(@NotNull String key, @NotNull Nameplate nameplate) {
if (this.nameplateMap.containsKey(key)) return false;
this.nameplateMap.put(key, nameplate);
return true;
}
@Override
public boolean unregisterNameplate(String key) {
public boolean unregisterNameplate(@NotNull String key) {
return this.nameplateMap.remove(key) != null;
}
@@ -576,39 +585,43 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
return previewDuration;
}
@NotNull
@Override
public TagMode getTagMode() {
return tagMode;
}
@NotNull
@Override
@Nullable
public Nameplate getNameplate(String key) {
public Nameplate getNameplate(@NotNull String key) {
return nameplateMap.get(key);
}
@NotNull
@Override
public Collection<Nameplate> getNameplates() {
return nameplateMap.values();
}
@NotNull
@Override
public Collection<String> getNameplateKeys() {
return nameplateMap.keySet();
}
@Override
public boolean containsNameplate(String key) {
public boolean containsNameplate(@NotNull String key) {
return nameplateMap.containsKey(key);
}
@Override
public boolean hasNameplate(Player player, String nameplate) {
public boolean hasNameplate(@NotNull Player player, @NotNull String nameplate) {
return player.hasPermission("nameplates.equip." + nameplate);
}
@NotNull
@Override
public TeamColor getTeamColor(Player player) {
public TeamColor getTeamColor(@NotNull Player player) {
CachedNameplate nameplate = getCacheNameplate(player);
return nameplate == null ? TeamColor.WHITE : nameplate.getTeamColor();
}
@@ -619,11 +632,13 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
return defaultNameplate;
}
@NotNull
@Override
public TeamTagManager getTeamTagManager() {
return teamTagManager;
}
@NotNull
@Override
public UnlimitedTagManager getUnlimitedTagManager() {
return unlimitedTagManager;

View File

@@ -17,6 +17,7 @@
package net.momirealms.customnameplates.paper.mechanic.placeholder;
import me.clip.placeholderapi.PlaceholderAPI;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.manager.PlaceholderManager;
import net.momirealms.customnameplates.api.mechanic.character.ConfiguredChar;