mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-23 08:59:30 +00:00
2.3.1
This commit is contained in:
@@ -2,4 +2,11 @@ dependencies {
|
|||||||
implementation(project(":common"))
|
implementation(project(":common"))
|
||||||
compileOnly("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT")
|
compileOnly("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.5")
|
compileOnly("me.clip:placeholderapi:2.11.5")
|
||||||
|
implementation("net.kyori:adventure-api:4.15.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
shadowJar {
|
||||||
|
relocate ("net.kyori", "net.momirealms.customnameplates.libraries")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -82,6 +82,10 @@ public class OnlineUser {
|
|||||||
return CustomNameplatesPlugin.get().getNameplateManager().getNameplate(temp);
|
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
|
@Nullable
|
||||||
public Bubble getBubble() {
|
public Bubble getBubble() {
|
||||||
String temp = nameplate;
|
String temp = nameplate;
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An event triggered when player sends a message
|
||||||
|
*/
|
||||||
public class BubblesSpawnEvent extends PlayerEvent implements Cancellable {
|
public class BubblesSpawnEvent extends PlayerEvent implements Cancellable {
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
@@ -57,18 +60,34 @@ public class BubblesSpawnEvent extends PlayerEvent implements Cancellable {
|
|||||||
return getHandlerList();
|
return getHandlerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the bubble's key
|
||||||
|
*/
|
||||||
public String getBubble() {
|
public String getBubble() {
|
||||||
return bubble;
|
return bubble;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bubble
|
||||||
|
*
|
||||||
|
* @param bubble bubble's key
|
||||||
|
*/
|
||||||
public void setBubble(String bubble) {
|
public void setBubble(String bubble) {
|
||||||
this.bubble = bubble;
|
this.bubble = bubble;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the bubble text content
|
||||||
|
*/
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bubble text content
|
||||||
|
*
|
||||||
|
* @param text text
|
||||||
|
*/
|
||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin reload event
|
||||||
|
*/
|
||||||
public class CustomNameplatesReloadEvent extends Event {
|
public class CustomNameplatesReloadEvent extends Event {
|
||||||
|
|
||||||
private static final HandlerList handlerList = new HandlerList();
|
private static final HandlerList handlerList = new HandlerList();
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Player data loaded event
|
||||||
|
*/
|
||||||
public class NameplateDataLoadEvent extends Event {
|
public class NameplateDataLoadEvent extends Event {
|
||||||
|
|
||||||
private static final HandlerList handlerList = new HandlerList();
|
private static final HandlerList handlerList = new HandlerList();
|
||||||
@@ -36,10 +39,20 @@ public class NameplateDataLoadEvent extends Event {
|
|||||||
this.onlineUser = onlineUser;
|
this.onlineUser = onlineUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the UUID
|
||||||
|
*
|
||||||
|
* @return uuid
|
||||||
|
*/
|
||||||
public UUID getUUID() {
|
public UUID getUUID() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the online user
|
||||||
|
*
|
||||||
|
* @return online user
|
||||||
|
*/
|
||||||
public OnlineUser getOnlineUser() {
|
public OnlineUser getOnlineUser() {
|
||||||
return onlineUser;
|
return onlineUser;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,6 +149,12 @@ public interface AdventureManager {
|
|||||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||||
boolean isColorCode(char c);
|
boolean isColorCode(char c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a color into decimal
|
||||||
|
*
|
||||||
|
* @param color color
|
||||||
|
* @return decimal
|
||||||
|
*/
|
||||||
int colorToDecimal(ChatColor color);
|
int colorToDecimal(ChatColor color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -175,5 +181,11 @@ public interface AdventureManager {
|
|||||||
*/
|
*/
|
||||||
String getMiniMessageFormat(Component component);
|
String getMiniMessageFormat(Component component);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get IChatComponent from Json
|
||||||
|
*
|
||||||
|
* @param json json
|
||||||
|
* @return component
|
||||||
|
*/
|
||||||
Object getIChatComponent(String json);
|
Object getIChatComponent(String json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ public interface BackGroundManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
BackGround getBackGround(@NotNull String key);
|
BackGround getBackGround(@NotNull String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the backgrounds
|
||||||
|
*
|
||||||
|
* @return backgrounds
|
||||||
|
*/
|
||||||
Collection<BackGround> getBackGrounds();
|
Collection<BackGround> getBackGrounds();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,29 +26,102 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface BubbleManager {
|
public interface BubbleManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a bubble into map
|
||||||
|
*
|
||||||
|
* @param key key
|
||||||
|
* @param bubble bubble
|
||||||
|
* @return success or not
|
||||||
|
*/
|
||||||
boolean registerBubble(String key, Bubble bubble);
|
boolean registerBubble(String key, Bubble bubble);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister a bubble from map
|
||||||
|
*
|
||||||
|
* @param key key
|
||||||
|
* @return success or not
|
||||||
|
*/
|
||||||
boolean unregisterBubble(String key);
|
boolean unregisterBubble(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a bubble from map
|
||||||
|
*
|
||||||
|
* @param bubble key
|
||||||
|
* @return bubble
|
||||||
|
*/
|
||||||
@Nullable Bubble getBubble(String 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);
|
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);
|
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);
|
List<String> getAvailableBubblesDisplayNames(Player player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get blacklist chat channels
|
||||||
|
*
|
||||||
|
* @return channels
|
||||||
|
*/
|
||||||
String[] getBlacklistChannels();
|
String[] getBlacklistChannels();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the bubbles
|
||||||
|
*
|
||||||
|
* @return bubbles
|
||||||
|
*/
|
||||||
Collection<Bubble> getBubbles();
|
Collection<Bubble> getBubbles();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a bubble exists
|
||||||
|
*/
|
||||||
boolean containsBubble(String key);
|
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);
|
boolean equipBubble(Player player, String bubble);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unequip a bubble for a player
|
||||||
|
*
|
||||||
|
* @param player player
|
||||||
|
*/
|
||||||
void unEquipBubble(Player player);
|
void unEquipBubble(Player player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default bubble key
|
||||||
|
*
|
||||||
|
* @return bubble key
|
||||||
|
*/
|
||||||
String getDefaultBubble();
|
String getDefaultBubble();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the bubbles' keys
|
||||||
|
*
|
||||||
|
* @return keys
|
||||||
|
*/
|
||||||
Collection<String> getBubbleKeys();
|
Collection<String> getBubbleKeys();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ public interface ImageManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
ConfiguredChar getImage(@NotNull String key);
|
ConfiguredChar getImage(@NotNull String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the images
|
||||||
|
*
|
||||||
|
* @return images
|
||||||
|
*/
|
||||||
Collection<ConfiguredChar> getImages();
|
Collection<ConfiguredChar> getImages();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public interface NameplateManager {
|
|||||||
* @param entityID entityID
|
* @param entityID entityID
|
||||||
* @param entity entity
|
* @param entity entity
|
||||||
*/
|
*/
|
||||||
boolean putEntityIDToMap(int entityID, Entity entity);
|
boolean putEntityIDToMap(int entityID, @NotNull Entity entity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the entity from map
|
* Remove the entity from map
|
||||||
@@ -66,7 +66,7 @@ public interface NameplateManager {
|
|||||||
* @param uuid player uuid
|
* @param uuid player uuid
|
||||||
* @param nameplate cached nameplate
|
* @param nameplate cached nameplate
|
||||||
*/
|
*/
|
||||||
boolean putCachedNameplateToMap(UUID uuid, CachedNameplate nameplate);
|
boolean putCachedNameplateToMap(@NotNull UUID uuid, @NotNull CachedNameplate nameplate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove CachedNameplate from map
|
* Remove CachedNameplate from map
|
||||||
@@ -75,7 +75,7 @@ public interface NameplateManager {
|
|||||||
* @return removed CachedNameplate
|
* @return removed CachedNameplate
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
CachedNameplate removeCachedNameplateFromMap(UUID uuid);
|
CachedNameplate removeCachedNameplateFromMap(@NotNull UUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get player by entityID from the cache
|
* Get player by entityID from the cache
|
||||||
@@ -102,7 +102,7 @@ public interface NameplateManager {
|
|||||||
* @param player player
|
* @param player player
|
||||||
* @return if the nameplate is updated
|
* @return if the nameplate is updated
|
||||||
*/
|
*/
|
||||||
boolean updateCachedNameplate(Player player);
|
boolean updateCachedNameplate(@NotNull Player player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a player's cached nameplate
|
* Update a player's cached nameplate
|
||||||
@@ -111,7 +111,7 @@ public interface NameplateManager {
|
|||||||
* @param player player
|
* @param player player
|
||||||
* @return if the nameplate is updated
|
* @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)
|
* This should not be null when player's data is loaded (async process)
|
||||||
@@ -120,61 +120,192 @@ public interface NameplateManager {
|
|||||||
* @return cached nameplate
|
* @return cached nameplate
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@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
|
* 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
|
* @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);
|
void unEquipNameplate(Player player, boolean temp);
|
||||||
|
|
||||||
boolean unregisterNameplate(String key);
|
/**
|
||||||
|
* Is team managed on proxy side
|
||||||
|
*/
|
||||||
boolean isProxyMode();
|
boolean isProxyMode();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get preview duration
|
||||||
|
*/
|
||||||
int getPreviewDuration();
|
int getPreviewDuration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tag mode
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
TagMode getTagMode();
|
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();
|
Collection<Nameplate> getNameplates();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the nameplates' keys
|
||||||
|
*
|
||||||
|
* @return keys
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
Collection<String> getNameplateKeys();
|
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
|
* 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();
|
TeamTagManager getTeamTagManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get unlimited tag manager
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
UnlimitedTagManager getUnlimitedTagManager();
|
UnlimitedTagManager getUnlimitedTagManager();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ public interface PlaceholderManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
StaticText getStaticText(String key);
|
StaticText getStaticText(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the static texts
|
||||||
|
*
|
||||||
|
* @return static texts
|
||||||
|
*/
|
||||||
Collection<StaticText> getStaticTexts();
|
Collection<StaticText> getStaticTexts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,6 +60,11 @@ public interface PlaceholderManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
SwitchText getSwitchText(String key);
|
SwitchText getSwitchText(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the switch texts
|
||||||
|
*
|
||||||
|
* @return switch texts
|
||||||
|
*/
|
||||||
Collection<SwitchText> getSwitchTexts();
|
Collection<SwitchText> getSwitchTexts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,6 +76,11 @@ public interface PlaceholderManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
DescentText getDescentText(String key);
|
DescentText getDescentText(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the descent texts
|
||||||
|
*
|
||||||
|
* @return descent texts
|
||||||
|
*/
|
||||||
Collection<DescentText> getDescentTexts();
|
Collection<DescentText> getDescentTexts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,6 +92,11 @@ public interface PlaceholderManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
ConditionalText getConditionalText(String key);
|
ConditionalText getConditionalText(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the conditional texts
|
||||||
|
*
|
||||||
|
* @return conditional texts
|
||||||
|
*/
|
||||||
Collection<ConditionalText> getConditionalTexts();
|
Collection<ConditionalText> getConditionalTexts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,6 +108,11 @@ public interface PlaceholderManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
NameplateText getNameplateText(String key);
|
NameplateText getNameplateText(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the nameplate texts
|
||||||
|
*
|
||||||
|
* @return nameplate texts
|
||||||
|
*/
|
||||||
Collection<NameplateText> getNameplateTexts();
|
Collection<NameplateText> getNameplateTexts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,9 +124,25 @@ public interface PlaceholderManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
BackGroundText getBackGroundText(String key);
|
BackGroundText getBackGroundText(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the background texts
|
||||||
|
*
|
||||||
|
* @return background texts
|
||||||
|
*/
|
||||||
Collection<BackGroundText> getBackGroundTexts();
|
Collection<BackGroundText> getBackGroundTexts();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a vanilla hud
|
||||||
|
*
|
||||||
|
* @param key key
|
||||||
|
* @return vanilla hud
|
||||||
|
*/
|
||||||
VanillaHud getVanillaHud(String key);
|
VanillaHud getVanillaHud(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the vanilla huds
|
||||||
|
*
|
||||||
|
* @return vanilla huds
|
||||||
|
*/
|
||||||
Collection<VanillaHud> getVanillaHuds();
|
Collection<VanillaHud> getVanillaHuds();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,5 +26,10 @@ public interface ResourcePackManager {
|
|||||||
*/
|
*/
|
||||||
void generateResourcePack();
|
void generateResourcePack();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a directory
|
||||||
|
*
|
||||||
|
* @param file file
|
||||||
|
*/
|
||||||
void deleteDirectory(File file);
|
void deleteDirectory(File file);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public interface TeamManager {
|
|||||||
* Get the team player in
|
* Get the team player in
|
||||||
*
|
*
|
||||||
* @param player player
|
* @param player player
|
||||||
* @param viewer
|
* @param viewer viewer
|
||||||
* @return team name
|
* @return team name
|
||||||
*/
|
*/
|
||||||
String getTeamName(Player player, Player viewer);
|
String getTeamName(Player player, Player viewer);
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public interface UnlimitedTagManager {
|
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);
|
@NotNull StaticTextEntity createNamedEntity(EntityTagEntity entity, StaticTextTagSetting setting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +45,19 @@ public interface UnlimitedTagManager {
|
|||||||
@NotNull
|
@NotNull
|
||||||
DynamicTextEntity createNamedEntity(EntityTagPlayer player, DynamicTextTagSetting setting);
|
DynamicTextEntity createNamedEntity(EntityTagPlayer player, DynamicTextTagSetting setting);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create or get a tag instance
|
||||||
|
*
|
||||||
|
* @param entity entity
|
||||||
|
* @return entity tag instance
|
||||||
|
*/
|
||||||
EntityTagEntity createOrGetTagForEntity(Entity entity);
|
EntityTagEntity createOrGetTagForEntity(Entity entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create or get a tag instance
|
||||||
|
*
|
||||||
|
* @param player player
|
||||||
|
* @return entity tag instance
|
||||||
|
*/
|
||||||
EntityTagPlayer createOrGetTagForPlayer(Player player);
|
EntityTagPlayer createOrGetTagForPlayer(Player player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,16 +17,53 @@
|
|||||||
|
|
||||||
package net.momirealms.customnameplates.api.manager;
|
package net.momirealms.customnameplates.api.manager;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.concurrent.CompletionStage;
|
import java.util.concurrent.CompletionStage;
|
||||||
|
|
||||||
public interface VersionManager {
|
public interface VersionManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is folia scheduler implemented
|
||||||
|
*/
|
||||||
boolean isFolia();
|
boolean isFolia();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get bukkit version
|
||||||
|
*
|
||||||
|
* @return version
|
||||||
|
*/
|
||||||
String getServerVersion();
|
String getServerVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check update
|
||||||
|
*
|
||||||
|
* @return return true if plugin needs update
|
||||||
|
*/
|
||||||
CompletionStage<Boolean> checkUpdate();
|
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();
|
||||||
|
|
||||||
boolean isVersionNewerThan1_19_R2();
|
boolean isVersionNewerThan1_19_R2();
|
||||||
@@ -36,11 +73,4 @@ public interface VersionManager {
|
|||||||
boolean isVersionNewerThan1_20();
|
boolean isVersionNewerThan1_20();
|
||||||
|
|
||||||
boolean isVersionNewerThan1_20_R2();
|
boolean isVersionNewerThan1_20_R2();
|
||||||
|
|
||||||
String getPluginVersion();
|
|
||||||
|
|
||||||
boolean isLatest();
|
|
||||||
|
|
||||||
int getPackFormat();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,15 +19,43 @@ package net.momirealms.customnameplates.api.manager;
|
|||||||
|
|
||||||
import net.momirealms.customnameplates.api.mechanic.font.FontData;
|
import net.momirealms.customnameplates.api.mechanic.font.FontData;
|
||||||
import net.momirealms.customnameplates.common.Key;
|
import net.momirealms.customnameplates.common.Key;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public interface WidthManager {
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,32 @@ public class CharacterArranger {
|
|||||||
currentChar = (char) (currentChar + '\u0001');
|
currentChar = (char) (currentChar + '\u0001');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get and increase the char arranged automatically by the plugin
|
||||||
|
*
|
||||||
|
* @return char
|
||||||
|
*/
|
||||||
public static char getAndIncrease() {
|
public static char getAndIncrease() {
|
||||||
char temp = currentChar;
|
char temp = currentChar;
|
||||||
increase();
|
increase();
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increase and get the char arranged automatically by the plugin
|
||||||
|
*
|
||||||
|
* @return char
|
||||||
|
*/
|
||||||
public static char increaseAndGet() {
|
public static char increaseAndGet() {
|
||||||
increase();
|
increase();
|
||||||
return currentChar;
|
return currentChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the initial char
|
||||||
|
*
|
||||||
|
* @param c char
|
||||||
|
*/
|
||||||
public static void reset(char c) {
|
public static void reset(char c) {
|
||||||
currentChar = c;
|
currentChar = c;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,18 +29,40 @@ public class FontData {
|
|||||||
this.defaultWidth = defaultWidth;
|
this.defaultWidth = defaultWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a char's width
|
||||||
|
*
|
||||||
|
* @param codePoint code point
|
||||||
|
* @param width width
|
||||||
|
*/
|
||||||
public void registerCharWidth(int codePoint, int width) {
|
public void registerCharWidth(int codePoint, int width) {
|
||||||
widthData.put(codePoint, width);
|
widthData.put(codePoint, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a character's width
|
||||||
|
*
|
||||||
|
* @param codePoint code point
|
||||||
|
* @return width
|
||||||
|
*/
|
||||||
public int getWidth(int codePoint) {
|
public int getWidth(int codePoint) {
|
||||||
return widthData.getOrDefault(codePoint, defaultWidth);
|
return widthData.getOrDefault(codePoint, defaultWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data map
|
||||||
|
*
|
||||||
|
* @return map
|
||||||
|
*/
|
||||||
public HashMap<Integer, Integer> getWidthData() {
|
public HashMap<Integer, Integer> getWidthData() {
|
||||||
return widthData;
|
return widthData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the data with another one
|
||||||
|
*
|
||||||
|
* @param fontData font data
|
||||||
|
*/
|
||||||
public void overrideWith(FontData fontData) {
|
public void overrideWith(FontData fontData) {
|
||||||
if (fontData == null) return;
|
if (fontData == null) return;
|
||||||
widthData.putAll(fontData.getWidthData());
|
widthData.putAll(fontData.getWidthData());
|
||||||
|
|||||||
@@ -66,6 +66,12 @@ public enum OffsetFont {
|
|||||||
return this.height;
|
return this.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get offset characters
|
||||||
|
*
|
||||||
|
* @param offset offset
|
||||||
|
* @return chars
|
||||||
|
*/
|
||||||
public static String getOffsetChars(int offset) {
|
public static String getOffsetChars(int offset) {
|
||||||
if (offset >= 0) {
|
if (offset >= 0) {
|
||||||
return getShortestPosChars(offset);
|
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) {
|
public static String getShortestNegChars(int n) {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
while (n >= 128) {
|
while (n >= 128) {
|
||||||
@@ -126,6 +138,12 @@ public enum OffsetFont {
|
|||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get positive characters
|
||||||
|
*
|
||||||
|
* @param n n > 0
|
||||||
|
* @return chars
|
||||||
|
*/
|
||||||
public static String getShortestPosChars(int n) {
|
public static String getShortestPosChars(int n) {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
while (n >= 128) {
|
while (n >= 128) {
|
||||||
|
|||||||
@@ -21,13 +21,37 @@ import net.momirealms.customnameplates.api.mechanic.misc.ViewerText;
|
|||||||
import net.momirealms.customnameplates.api.mechanic.tag.NameplatePlayer;
|
import net.momirealms.customnameplates.api.mechanic.tag.NameplatePlayer;
|
||||||
|
|
||||||
public interface TeamTagPlayer extends NameplatePlayer {
|
public interface TeamTagPlayer extends NameplatePlayer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a player's prefix
|
||||||
|
*
|
||||||
|
* @param prefix prefix
|
||||||
|
*/
|
||||||
void setPrefix(String prefix);
|
void setPrefix(String prefix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a player's suffix
|
||||||
|
*
|
||||||
|
* @param suffix suffix
|
||||||
|
*/
|
||||||
void setSuffix(String suffix);
|
void setSuffix(String suffix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a player's prefix
|
||||||
|
*
|
||||||
|
* @return prefix
|
||||||
|
*/
|
||||||
ViewerText getPrefix();
|
ViewerText getPrefix();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a player's suffix
|
||||||
|
*
|
||||||
|
* @return suffix
|
||||||
|
*/
|
||||||
ViewerText getSuffix();
|
ViewerText getSuffix();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy the tag
|
||||||
|
*/
|
||||||
void destroy();
|
void destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ import org.bukkit.OfflinePlayer;
|
|||||||
|
|
||||||
public class Condition {
|
public class Condition {
|
||||||
|
|
||||||
private final OfflinePlayer player;
|
private OfflinePlayer player;
|
||||||
|
|
||||||
|
public Condition() {
|
||||||
|
this.player = null;
|
||||||
|
}
|
||||||
|
|
||||||
public Condition(OfflinePlayer player) {
|
public Condition(OfflinePlayer player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@@ -30,4 +34,26 @@ public class Condition {
|
|||||||
public OfflinePlayer getOfflinePlayer() {
|
public OfflinePlayer getOfflinePlayer() {
|
||||||
return player;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ import org.bukkit.entity.Entity;
|
|||||||
|
|
||||||
public class LocationUtils {
|
public class LocationUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get distance by two entities
|
||||||
|
*
|
||||||
|
* @param e1 entity
|
||||||
|
* @param e2 entity
|
||||||
|
* @return distance
|
||||||
|
*/
|
||||||
public static double getDistance(Entity e1, Entity e2) {
|
public static double getDistance(Entity e1, Entity e2) {
|
||||||
Location loc1 = e1.getLocation();
|
Location loc1 = e1.getLocation();
|
||||||
Location loc2 = e2.getLocation();
|
Location loc2 = e2.getLocation();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ plugins {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|
||||||
version = "2.3.0.6"
|
version = "2.3.1.0"
|
||||||
|
|
||||||
apply<JavaPlugin>()
|
apply<JavaPlugin>()
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package net.momirealms.customnameplates.paper.mechanic.bubble.listener;
|
package net.momirealms.customnameplates.paper.mechanic.bubble.listener;
|
||||||
|
|
||||||
|
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||||
import net.momirealms.customnameplates.paper.mechanic.bubble.BubbleManagerImpl;
|
import net.momirealms.customnameplates.paper.mechanic.bubble.BubbleManagerImpl;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
@@ -30,6 +31,6 @@ public class AsyncChatListener extends AbstractChatListener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onChat(AsyncPlayerChatEvent event) {
|
public void onChat(AsyncPlayerChatEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
chatBubblesManager.onChat(event.getPlayer(), event.getMessage());
|
CustomNameplatesPlugin.get().getScheduler().runTaskAsync(() -> chatBubblesManager.onChat(event.getPlayer(), event.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
public class TrChatListener extends AbstractChatListener {
|
public class TrChatListener extends AbstractChatListener {
|
||||||
|
|
||||||
private BukkitAdapter adapter;
|
private final BukkitAdapter adapter;
|
||||||
|
|
||||||
public TrChatListener(BubbleManagerImpl chatBubblesManager) {
|
public TrChatListener(BubbleManagerImpl chatBubblesManager) {
|
||||||
super(chatBubblesManager);
|
super(chatBubblesManager);
|
||||||
|
|||||||
@@ -859,7 +859,7 @@ public class WidthManagerImpl implements WidthManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean registerFontData(Key key, FontData fontData) {
|
public boolean registerFontData(@NotNull Key key, @NotNull FontData fontData) {
|
||||||
if (fontDataMap.containsKey(key)) {
|
if (fontDataMap.containsKey(key)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -868,18 +868,18 @@ public class WidthManagerImpl implements WidthManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean unregisterFontData(Key key) {
|
public boolean unregisterFontData(@NotNull Key key) {
|
||||||
return fontDataMap.remove(key) != null;
|
return fontDataMap.remove(key) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public FontData getFontData(Key key) {
|
public FontData getFontData(@NotNull Key key) {
|
||||||
return fontDataMap.get(key);
|
return fontDataMap.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTextWidth(String textWithTags) {
|
public int getTextWidth(@NotNull String textWithTags) {
|
||||||
return cacheSystem.getWidthFromCache(textWithTags);
|
return cacheSystem.getWidthFromCache(textWithTags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -97,6 +98,7 @@ public class VersionManagerImpl implements VersionManager, Listener {
|
|||||||
return isNewerThan1_20_R2;
|
return isNewerThan1_20_R2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getPluginVersion() {
|
public String getPluginVersion() {
|
||||||
return pluginVersion;
|
return pluginVersion;
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean putEntityIDToMap(int entityID, Entity entity) {
|
public boolean putEntityIDToMap(int entityID, @NotNull Entity entity) {
|
||||||
if (this.entityID2EntityMap.containsKey(entityID))
|
if (this.entityID2EntityMap.containsKey(entityID))
|
||||||
return false;
|
return false;
|
||||||
this.entityID2EntityMap.put(entityID, entity);
|
this.entityID2EntityMap.put(entityID, entity);
|
||||||
@@ -346,7 +346,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean putCachedNameplateToMap(UUID uuid, CachedNameplate nameplate) {
|
public boolean putCachedNameplateToMap(@NotNull UUID uuid, @NotNull CachedNameplate nameplate) {
|
||||||
if (this.cachedNameplateMap.containsKey(uuid)) {
|
if (this.cachedNameplateMap.containsKey(uuid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -355,7 +355,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CachedNameplate removeCachedNameplateFromMap(UUID uuid) {
|
public CachedNameplate removeCachedNameplateFromMap(@NotNull UUID uuid) {
|
||||||
return this.cachedNameplateMap.remove(uuid);
|
return this.cachedNameplateMap.remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateCachedNameplate(Player player) {
|
public boolean updateCachedNameplate(@NotNull Player player) {
|
||||||
Optional<OnlineUser> onlineUser = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
Optional<OnlineUser> onlineUser = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||||
if (onlineUser.isEmpty()) return false;
|
if (onlineUser.isEmpty()) return false;
|
||||||
Nameplate nameplate = onlineUser.get().getNameplate();
|
Nameplate nameplate = onlineUser.get().getNameplate();
|
||||||
@@ -382,45 +382,49 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateCachedNameplate(Player player, Nameplate nameplate) {
|
public boolean updateCachedNameplate(@NotNull Player player, Nameplate nameplate) {
|
||||||
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
|
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
|
||||||
if (cachedNameplate == null) return false;
|
if (cachedNameplate == null) return false;
|
||||||
return updateCachedNameplate(cachedNameplate, player, nameplate);
|
return updateCachedNameplate(cachedNameplate, player, nameplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CachedNameplate getCacheNameplate(Player player) {
|
public CachedNameplate getCacheNameplate(@NotNull Player player) {
|
||||||
return cachedNameplateMap.get(player.getUniqueId());
|
return cachedNameplateMap.get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createNameTag(Player player) {
|
public NameplatePlayer createNameTag(@NotNull Player player) {
|
||||||
if (tagMode == TagMode.TEAM) {
|
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);
|
this.unlimitedTagManager.createOrGetTagForPlayer(player);
|
||||||
|
return nameplatePlayer;
|
||||||
} else if (tagMode == TagMode.UNLIMITED) {
|
} else if (tagMode == TagMode.UNLIMITED) {
|
||||||
EntityTagPlayer tagPlayer = this.unlimitedTagManager.createOrGetTagForPlayer(player);
|
EntityTagPlayer tagPlayer = this.unlimitedTagManager.createOrGetTagForPlayer(player);
|
||||||
for (DynamicTextTagSetting setting : tagSettings) {
|
for (DynamicTextTagSetting setting : tagSettings) {
|
||||||
tagPlayer.addTag(setting);
|
tagPlayer.addTag(setting);
|
||||||
}
|
}
|
||||||
putNameplatePlayerToMap(tagPlayer);
|
putNameplatePlayerToMap(tagPlayer);
|
||||||
|
return tagPlayer;
|
||||||
} else {
|
} else {
|
||||||
this.unlimitedTagManager.createOrGetTagForPlayer(player);
|
this.unlimitedTagManager.createOrGetTagForPlayer(player);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putNameplatePlayerToMap(NameplatePlayer player) {
|
public void putNameplatePlayerToMap(@NotNull NameplatePlayer player) {
|
||||||
this.nameplatePlayerMap.put(player.getPlayer().getUniqueId(), player);
|
this.nameplatePlayerMap.put(player.getPlayer().getUniqueId(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NameplatePlayer getNameplatePlayer(UUID uuid) {
|
public NameplatePlayer getNameplatePlayer(@NotNull UUID uuid) {
|
||||||
return this.nameplatePlayerMap.get(uuid);
|
return this.nameplatePlayerMap.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NameplatePlayer removeNameplatePlayerFromMap(UUID uuid) {
|
public NameplatePlayer removeNameplatePlayerFromMap(@NotNull UUID uuid) {
|
||||||
return this.nameplatePlayerMap.remove(uuid);
|
return this.nameplatePlayerMap.remove(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,22 +457,25 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getNameplatePrefix(Player player) {
|
public String getNameplatePrefix(@NotNull Player player) {
|
||||||
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
|
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
|
||||||
if (cachedNameplate == null) return "";
|
if (cachedNameplate == null) return "";
|
||||||
return cachedNameplate.getTagPrefix();
|
return cachedNameplate.getTagPrefix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getNameplateSuffix(Player player) {
|
public String getNameplateSuffix(@NotNull Player player) {
|
||||||
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
|
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
|
||||||
if (cachedNameplate == null) return "";
|
if (cachedNameplate == null) return "";
|
||||||
return cachedNameplate.getTagSuffix();
|
return cachedNameplate.getTagSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getFullNameTag(Player player) {
|
public String getFullNameTag(@NotNull Player player) {
|
||||||
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
|
CachedNameplate cachedNameplate = cachedNameplateMap.get(player.getUniqueId());
|
||||||
if (cachedNameplate == null) {
|
if (cachedNameplate == null) {
|
||||||
return player.getName();
|
return player.getName();
|
||||||
@@ -481,8 +488,9 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
+ cachedNameplate.getNameSuffix();
|
+ cachedNameplate.getNameSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<String> getAvailableNameplates(Player player) {
|
public List<String> getAvailableNameplates(@NotNull Player player) {
|
||||||
List<String> nameplates = new ArrayList<>();
|
List<String> nameplates = new ArrayList<>();
|
||||||
for (String nameplate : nameplateMap.keySet()) {
|
for (String nameplate : nameplateMap.keySet()) {
|
||||||
if (hasNameplate(player, nameplate)) {
|
if (hasNameplate(player, nameplate)) {
|
||||||
@@ -492,8 +500,9 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
return nameplates;
|
return nameplates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<String> getAvailableNameplateDisplayNames(Player player) {
|
public List<String> getAvailableNameplateDisplayNames(@NotNull Player player) {
|
||||||
List<String> nameplates = new ArrayList<>();
|
List<String> nameplates = new ArrayList<>();
|
||||||
for (Map.Entry<String, Nameplate> entry : nameplateMap.entrySet()) {
|
for (Map.Entry<String, Nameplate> entry : nameplateMap.entrySet()) {
|
||||||
if (hasNameplate(player, entry.getKey())) {
|
if (hasNameplate(player, entry.getKey())) {
|
||||||
@@ -504,7 +513,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
Nameplate nameplate = getNameplate(nameplateKey);
|
||||||
if (nameplate == null && nameplateKey.equals("none")) {
|
if (nameplate == null && nameplateKey.equals("none")) {
|
||||||
return false;
|
return false;
|
||||||
@@ -555,14 +564,14 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean registerNameplate(String key, Nameplate nameplate) {
|
public boolean registerNameplate(@NotNull String key, @NotNull Nameplate nameplate) {
|
||||||
if (this.nameplateMap.containsKey(key)) return false;
|
if (this.nameplateMap.containsKey(key)) return false;
|
||||||
this.nameplateMap.put(key, nameplate);
|
this.nameplateMap.put(key, nameplate);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean unregisterNameplate(String key) {
|
public boolean unregisterNameplate(@NotNull String key) {
|
||||||
return this.nameplateMap.remove(key) != null;
|
return this.nameplateMap.remove(key) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,39 +585,43 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
return previewDuration;
|
return previewDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public TagMode getTagMode() {
|
public TagMode getTagMode() {
|
||||||
return tagMode;
|
return tagMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public Nameplate getNameplate(@NotNull String key) {
|
||||||
public Nameplate getNameplate(String key) {
|
|
||||||
return nameplateMap.get(key);
|
return nameplateMap.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<Nameplate> getNameplates() {
|
public Collection<Nameplate> getNameplates() {
|
||||||
return nameplateMap.values();
|
return nameplateMap.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getNameplateKeys() {
|
public Collection<String> getNameplateKeys() {
|
||||||
return nameplateMap.keySet();
|
return nameplateMap.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsNameplate(String key) {
|
public boolean containsNameplate(@NotNull String key) {
|
||||||
return nameplateMap.containsKey(key);
|
return nameplateMap.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNameplate(Player player, String nameplate) {
|
public boolean hasNameplate(@NotNull Player player, @NotNull String nameplate) {
|
||||||
return player.hasPermission("nameplates.equip." + nameplate);
|
return player.hasPermission("nameplates.equip." + nameplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public TeamColor getTeamColor(Player player) {
|
public TeamColor getTeamColor(@NotNull Player player) {
|
||||||
CachedNameplate nameplate = getCacheNameplate(player);
|
CachedNameplate nameplate = getCacheNameplate(player);
|
||||||
return nameplate == null ? TeamColor.WHITE : nameplate.getTeamColor();
|
return nameplate == null ? TeamColor.WHITE : nameplate.getTeamColor();
|
||||||
}
|
}
|
||||||
@@ -619,11 +632,13 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
return defaultNameplate;
|
return defaultNameplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public TeamTagManager getTeamTagManager() {
|
public TeamTagManager getTeamTagManager() {
|
||||||
return teamTagManager;
|
return teamTagManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public UnlimitedTagManager getUnlimitedTagManager() {
|
public UnlimitedTagManager getUnlimitedTagManager() {
|
||||||
return unlimitedTagManager;
|
return unlimitedTagManager;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
package net.momirealms.customnameplates.paper.mechanic.placeholder;
|
package net.momirealms.customnameplates.paper.mechanic.placeholder;
|
||||||
|
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
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.character.ConfiguredChar;
|
import net.momirealms.customnameplates.api.mechanic.character.ConfiguredChar;
|
||||||
|
|||||||
Reference in New Issue
Block a user