mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2026-11-06 17:32:43 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22a440ae23 | ||
|
|
c279c9a74d | ||
|
|
a6b11d1fe7 | ||
|
|
180b34f4c8 | ||
|
|
c69735ea2b | ||
|
|
f7628c2db9 | ||
|
|
4c0df8288b | ||
|
|
bd0abb3463 | ||
|
|
65b70a639b | ||
|
|
8ff48ad395 | ||
|
|
dc149dbb05 | ||
|
|
f70918befd | ||
|
|
53f9a9a85d |
No files matched your search
@@ -1,21 +1,79 @@
|
||||
# This project is currently under recoding
|
||||
# Custom-Nameplates
|
||||
|
||||
### Custom-Nameplates
|
||||
A unique way to customize nametags
|
||||

|
||||

|
||||

|
||||

|
||||
[](https://jitpack.io/#Xiao-MoMi/Custom-Nameplates)
|
||||
<a href="https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/" alt="GitBook">
|
||||
<img src="https://img.shields.io/badge/docs-gitbook-brightgreen" alt="Gitbook"/>
|
||||
</a>
|
||||
|
||||
### How to support the developer
|
||||
CustomNameplates is a Paper plugin that provides unlimited customization for nametags, bossbars, actionbars and chat bubbles.
|
||||
|
||||
https://afdian.net/@xiaomomi
|
||||
## How to build
|
||||
|
||||
https://polymart.org/resource/customnameplates.2543
|
||||
### Windows
|
||||
|
||||
### How to compile
|
||||
Open the project with your IDE and execute gradle build. Finally you will get the jar at /project/build/libs/CustomNameplates-xxx-all.jar.
|
||||
|
||||
### I don't know how to build with IDE
|
||||
#### Command Line
|
||||
Install JDK 17 and set the JDK installation path to JAVA_HOME as an environment variable.\
|
||||
Start powershell and change directory to the project folder.\
|
||||
Execute ".\gradlew build" and get the jar at /project/build/libs/CustomNameplates-xxx-all.jar.
|
||||
Execute ".\gradlew build" and get the jar at /target/CustomNameplates-universe-version.jar.
|
||||
|
||||
### API
|
||||
Plugin is scheduled to be recoded on December. At that time API would be available. For the moment you can use the jar as local library.
|
||||
#### IDE
|
||||
Import the project and execute gradle build action.
|
||||
|
||||
##### About Proxy
|
||||
If you are using a proxy, configurate the proxy in gradle.properties. Otherwise comment the lines in gradle.properties.
|
||||
|
||||
## Support the developer
|
||||
|
||||
Polymart: https://polymart.org/resource/customnameplates.2543 \
|
||||
Afdian: https://afdian.net/@xiaomomi
|
||||
|
||||
## Use CustomNameplates API
|
||||
|
||||
### Maven
|
||||
|
||||
```
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack</id>
|
||||
<url>https://jitpack.io/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
```
|
||||
```
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.Xiao-MoMi</groupId>
|
||||
<artifactId>Custom-Nameplates</artifactId>
|
||||
<version>{LATEST}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
### Gradle (Groovy)
|
||||
|
||||
```
|
||||
repositories {
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
```
|
||||
```
|
||||
dependencies {
|
||||
compileOnly 'com.github.Xiao-MoMi:Custom-Nameplates:{LATEST}'
|
||||
}
|
||||
```
|
||||
### Gradle (Kotlin)
|
||||
|
||||
```
|
||||
repositories {
|
||||
maven("https://jitpack.io/")
|
||||
}
|
||||
```
|
||||
```
|
||||
dependencies {
|
||||
compileOnly("com.github.Xiao-MoMi:Custom-Nameplates:{LATEST}")
|
||||
}
|
||||
```
|
||||
@@ -1,5 +1,12 @@
|
||||
dependencies {
|
||||
implementation(project(":common"))
|
||||
compileOnly("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT")
|
||||
compileOnly("me.clip:placeholderapi:2.11.5")
|
||||
implementation(project(":common"))
|
||||
implementation("net.kyori:adventure-api:4.15.0")
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
relocate ("net.kyori", "net.momirealms.customnameplates.libraries")
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,13 @@ public interface DataStorageInterface {
|
||||
*/
|
||||
StorageType getStorageType();
|
||||
|
||||
/**
|
||||
* Get a player's data by uuid
|
||||
* This player can be an offline one
|
||||
*
|
||||
* @param uuid uuid
|
||||
* @return player data
|
||||
*/
|
||||
CompletableFuture<Optional<PlayerData>> getPlayerData(UUID uuid);
|
||||
|
||||
CompletableFuture<Boolean> updatePlayerData(UUID uuid, PlayerData playerData);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+3
@@ -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();
|
||||
|
||||
+13
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -34,6 +34,11 @@ public interface BackGroundManager {
|
||||
@Nullable
|
||||
BackGround getBackGround(@NotNull String key);
|
||||
|
||||
/**
|
||||
* Get all the backgrounds
|
||||
*
|
||||
* @return backgrounds
|
||||
*/
|
||||
Collection<BackGround> getBackGrounds();
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,29 +26,110 @@ 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();
|
||||
|
||||
/**
|
||||
* Trigger chat
|
||||
*
|
||||
* @param player player
|
||||
* @param text text
|
||||
*/
|
||||
void onChat(Player player, String text);
|
||||
}
|
||||
@@ -34,6 +34,11 @@ public interface ImageManager {
|
||||
@Nullable
|
||||
ConfiguredChar getImage(@NotNull String key);
|
||||
|
||||
/**
|
||||
* Get all the images
|
||||
*
|
||||
* @return images
|
||||
*/
|
||||
Collection<ConfiguredChar> getImages();
|
||||
|
||||
/**
|
||||
|
||||
+154
-23
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -26,5 +26,10 @@ public interface ResourcePackManager {
|
||||
*/
|
||||
void generateResourcePack();
|
||||
|
||||
/**
|
||||
* Delete a directory
|
||||
*
|
||||
* @param file file
|
||||
*/
|
||||
void deleteDirectory(File file);
|
||||
}
|
||||
@@ -46,7 +46,8 @@ public interface TeamManager {
|
||||
* Get the team player in
|
||||
*
|
||||
* @param player player
|
||||
* @param viewer viewer
|
||||
* @return team name
|
||||
*/
|
||||
String getTeamName(Player player);
|
||||
String getTeamName(Player player, Player viewer);
|
||||
}
|
||||
+20
-2
@@ -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,9 +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);
|
||||
|
||||
EntityTagPlayer createOrGetTagForPlayer(Player player, boolean manageTeam);
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
+8
-4
@@ -15,16 +15,20 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.paper.mechanic.bubble.listener;
|
||||
package net.momirealms.customnameplates.api.mechanic.bubble.listener;
|
||||
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.BubbleManagerImpl;
|
||||
import net.momirealms.customnameplates.api.manager.BubbleManager;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public abstract class AbstractChatListener implements Listener {
|
||||
|
||||
protected BubbleManagerImpl chatBubblesManager;
|
||||
protected BubbleManager chatBubblesManager;
|
||||
|
||||
public AbstractChatListener(BubbleManagerImpl chatBubblesManager) {
|
||||
public AbstractChatListener(BubbleManager chatBubblesManager) {
|
||||
this.chatBubblesManager = chatBubblesManager;
|
||||
}
|
||||
|
||||
public abstract void register();
|
||||
|
||||
public abstract void unregister();
|
||||
}
|
||||
+15
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@
|
||||
package net.momirealms.customnameplates.api.mechanic.placeholder;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -41,9 +41,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 {
|
||||
|
||||
-2
@@ -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 {
|
||||
|
||||
|
||||
+24
@@ -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();
|
||||
}
|
||||
-2
@@ -41,8 +41,6 @@ public interface EntityTagPlayer extends NameplatePlayer {
|
||||
|
||||
void setHatOffset(double hatOffset);
|
||||
|
||||
void setManageTeams(boolean manageTeams);
|
||||
|
||||
double getHatOffset();
|
||||
|
||||
void destroy();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
+2
-1
@@ -7,7 +7,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
|
||||
version = "2.3.0.0"
|
||||
version = "2.3.2.0"
|
||||
|
||||
apply<JavaPlugin>()
|
||||
apply(plugin = "java")
|
||||
@@ -43,6 +43,7 @@ allprojects {
|
||||
maven("https://repo.kryptonmc.org/releases")
|
||||
maven("https://repo.oraxen.com/releases/")
|
||||
maven("https://nexus.codecrafter47.de/content/repositories/public/")
|
||||
maven("https://repo.opencollab.dev/main/")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -30,7 +30,6 @@ public class CustomNameplatesBungeeCord extends Plugin implements Listener {
|
||||
instance = this;
|
||||
this.getProxy().registerChannel(CHANNEL);
|
||||
this.getProxy().getPluginManager().registerListener(this, this);
|
||||
this.getLogger().warning("It's not necessary to install the plugin on BungeeCord now!");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.bungeecord.team;
|
||||
|
||||
import me.neznamy.tab.api.TabAPI;
|
||||
import me.neznamy.tab.api.TabPlayer;
|
||||
import me.neznamy.tab.api.tablist.SortingManager;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public class TABProvider implements TeamProvider {
|
||||
|
||||
private final TabAPI api;
|
||||
private final SortingManager sortingManager;
|
||||
|
||||
public TABProvider() {
|
||||
this.api = TabAPI.getInstance();
|
||||
this.sortingManager = api.getSortingManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeam(ProxiedPlayer player, ProxiedPlayer ignore) {
|
||||
TabPlayer tabPlayer = api.getPlayer(player.getUniqueId());
|
||||
if (tabPlayer == null) {
|
||||
return null;
|
||||
}
|
||||
String forced = sortingManager.getForcedTeamName(tabPlayer);
|
||||
if (forced != null) {
|
||||
return forced;
|
||||
}
|
||||
return sortingManager.getOriginalTeamName(tabPlayer);
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -15,9 +15,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.paper.mechanic.team;
|
||||
package net.momirealms.customnameplates.bungeecord.team;
|
||||
|
||||
public interface Team {
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public interface TeamProvider {
|
||||
|
||||
String getTeam(ProxiedPlayer player, ProxiedPlayer viewer);
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package net.momirealms.customnameplates.bungeecord.team;
|
||||
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.packet.Team;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class UnknownProvider extends PacketHandler implements Listener, TeamProvider {
|
||||
|
||||
private final ConcurrentHashMap<UUID, PlayerTeamView> teamViewMap;
|
||||
|
||||
public UnknownProvider() {
|
||||
this.teamViewMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Team team) {
|
||||
switch (team.getMode()) {
|
||||
case 0, 3 -> {
|
||||
}
|
||||
case 1 -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
teamViewMap.put(event.getPlayer().getUniqueId(), new PlayerTeamView());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisConnect(PlayerDisconnectEvent event) {
|
||||
teamViewMap.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeam(ProxiedPlayer player, ProxiedPlayer viewer) {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class PlayerTeamView {
|
||||
|
||||
private final HashMap<String, String> playerToTeamMap;
|
||||
private final HashMap<String, String[]> teamToPlayerMap;
|
||||
|
||||
public PlayerTeamView() {
|
||||
this.playerToTeamMap = new HashMap<>();
|
||||
this.teamToPlayerMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public String getTeam(ProxiedPlayer player) {
|
||||
return playerToTeamMap.get(player.getName());
|
||||
}
|
||||
|
||||
public void removeTeam(String team) {
|
||||
String[] removedMembers = teamToPlayerMap.remove(team);
|
||||
if (removedMembers != null) {
|
||||
for (String member : removedMembers) {
|
||||
playerToTeamMap.remove(member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addMembers(String team, Collection<String> members) {
|
||||
String[] oldMembers = teamToPlayerMap.remove(team);
|
||||
if (oldMembers != null) {
|
||||
String[] newMembers = new String[members.size() + oldMembers.length];
|
||||
int i = 0;
|
||||
for (String m : oldMembers) {
|
||||
newMembers[i] = m;
|
||||
i++;
|
||||
}
|
||||
for (String m : members) {
|
||||
newMembers[i] = m;
|
||||
i++;
|
||||
}
|
||||
teamToPlayerMap.put(team, newMembers);
|
||||
for (String member : newMembers) {
|
||||
playerToTeamMap.put(member, team);
|
||||
}
|
||||
} else {
|
||||
teamToPlayerMap.put(team, members.toArray(new String[0]));
|
||||
for (String member : members) {
|
||||
playerToTeamMap.put(member, team);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeMembers(String team, Collection<String> members) {
|
||||
String[] oldMembers = teamToPlayerMap.remove(team);
|
||||
if (oldMembers != null) {
|
||||
ArrayList<String> newMembers = new ArrayList<>(Arrays.asList(oldMembers));
|
||||
for (String member : members) {
|
||||
playerToTeamMap.remove(member);
|
||||
newMembers.remove(member);
|
||||
}
|
||||
teamToPlayerMap.put(team, newMembers.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -1,8 +1,8 @@
|
||||
#systemProp.socks.proxyHost=127.0.0.1
|
||||
#systemProp.socks.proxyPort=7890
|
||||
#
|
||||
#systemProp.http.proxyHost=127.0.0.1
|
||||
#systemProp.http.proxyPort=7890
|
||||
#
|
||||
#systemProp.https.proxyHost=127.0.0.1
|
||||
#systemProp.https.proxyPort=7890
|
||||
systemProp.socks.proxyHost=127.0.0.1
|
||||
systemProp.socks.proxyPort=7890
|
||||
|
||||
systemProp.http.proxyHost=127.0.0.1
|
||||
systemProp.http.proxyPort=7890
|
||||
|
||||
systemProp.https.proxyHost=127.0.0.1
|
||||
systemProp.https.proxyPort=7890
|
||||
@@ -33,11 +33,13 @@ dependencies {
|
||||
compileOnly("io.th0rgal:oraxen:1.165.0")
|
||||
compileOnly("com.github.FrancoBM12:API-MagicCosmetics:2.2.5")
|
||||
compileOnly("commons-io:commons-io:2.15.1")
|
||||
|
||||
compileOnly("org.geysermc.geyser:api:2.2.0-SNAPSHOT")
|
||||
|
||||
// chat channels
|
||||
compileOnly(files("libs/VentureChat-3.7.1.jar"))
|
||||
compileOnly(files("libs/TrChat-2.0.11.jar"))
|
||||
compileOnly(files("libs/carbonchat-paper-3.0.0-beta.26.jar"))
|
||||
compileOnly("net.william278:huskchat:2.7.1")
|
||||
|
||||
// api module
|
||||
implementation(project(":api"))
|
||||
|
||||
Binary file not shown.
+6
-1
@@ -43,6 +43,7 @@ import net.momirealms.customnameplates.paper.setting.CNLocale;
|
||||
import net.momirealms.customnameplates.paper.storage.StorageManagerImpl;
|
||||
import net.momirealms.customnameplates.paper.util.Migration;
|
||||
import net.momirealms.customnameplates.paper.util.ReflectionUtils;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -93,6 +94,10 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin implement
|
||||
else this.getAdventure().sendConsoleMessage("[CustomNameplates] Update is available: <u>https://polymart.org/resource/2543<!u>");
|
||||
});
|
||||
this.getServer().getPluginManager().registerEvents((VersionManagerImpl) versionManager, this);
|
||||
if (CNConfig.generatePackOnStart)
|
||||
this.resourcePackManager.generateResourcePack();
|
||||
if (CNConfig.metrics)
|
||||
new Metrics(this, 16649);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,7 +105,7 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin implement
|
||||
if (scheduler != null) ((SchedulerImpl) this.scheduler).shutdown();
|
||||
if (actionBarManager != null) ((ActionBarManagerImpl) actionBarManager).unload();
|
||||
if (nameplateManager != null) ((NameplateManagerImpl) this.nameplateManager).disable();
|
||||
if (teamManager != null) ((TeamManagerImpl) this.teamManager).unload();
|
||||
if (teamManager != null) ((TeamManagerImpl) this.teamManager).disable();
|
||||
if (bossBarManager != null) ((BossBarManagerImpl) this.bossBarManager).unload();
|
||||
if (imageManager != null) ((ImageManagerImpl) this.imageManager).unload();
|
||||
if (backGroundManager != null) ((BackGroundManagerImpl) this.backGroundManager).unload();
|
||||
|
||||
+27
-12
@@ -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);
|
||||
@@ -116,7 +116,7 @@ public class CommandManager {
|
||||
for (String availableBubble : bubbles) {
|
||||
stringJoiner.add(availableBubble);
|
||||
}
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_AVAILABLE_BUBBLE.replace("{Bubble}", stringJoiner.toString()));
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_AVAILABLE_BUBBLE.replace("{Bubble}", stringJoiner.toString()).replace("{Bubbles}", stringJoiner.toString()));
|
||||
} else {
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_HAVE_NO_BUBBLE);
|
||||
}
|
||||
@@ -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);
|
||||
@@ -325,7 +340,7 @@ public class CommandManager {
|
||||
for (String availableNameplate : nameplates) {
|
||||
stringJoiner.add(availableNameplate);
|
||||
}
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_AVAILABLE_NAMEPLATE.replace("{Nameplates}", stringJoiner.toString()));
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_AVAILABLE_NAMEPLATE.replace("{Nameplates}", stringJoiner.toString()).replace("{Nameplate}", stringJoiner.toString()));
|
||||
} else {
|
||||
AdventureManagerImpl.getInstance().sendMessageWithPrefix(player, CNLocale.MSG_HAVE_NO_NAMEPLATE);
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class ActionBarReceiver {
|
||||
}
|
||||
case UPDATE -> {
|
||||
if (controller.isShown()) {
|
||||
controller.initialize();
|
||||
controller.initialize(condition);
|
||||
AdventureManagerImpl.getInstance().sendActionbar(player, controller.getLatestContent());
|
||||
} else {
|
||||
AdventureManagerImpl.getInstance().sendActionbar(player, "");
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ public class BossBarReceiver {
|
||||
if (this.bossBars[j].left().isShown())
|
||||
this.bossBars[j].right().hide();
|
||||
|
||||
controller.initialize();
|
||||
controller.initialize(condition);
|
||||
pair.right().setMiniMessageText(pair.left().getLatestContent());
|
||||
pair.right().show();
|
||||
|
||||
|
||||
+21
-9
@@ -19,11 +19,13 @@ package net.momirealms.customnameplates.paper.mechanic.bubble;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.api.data.OnlineUser;
|
||||
import net.momirealms.customnameplates.api.event.BubblesSpawnEvent;
|
||||
import net.momirealms.customnameplates.api.event.NameplateDataLoadEvent;
|
||||
import net.momirealms.customnameplates.api.manager.BubbleManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.bubble.Bubble;
|
||||
import net.momirealms.customnameplates.api.mechanic.bubble.listener.AbstractChatListener;
|
||||
import net.momirealms.customnameplates.api.mechanic.character.CharacterArranger;
|
||||
import net.momirealms.customnameplates.api.mechanic.character.ConfiguredChar;
|
||||
import net.momirealms.customnameplates.api.mechanic.tag.unlimited.EntityTagPlayer;
|
||||
@@ -36,10 +38,7 @@ import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.image.ImageParser;
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.image.ItemsAdderImageImpl;
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.image.OraxenImageImpl;
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.listener.AbstractChatListener;
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.listener.AsyncChatListener;
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.listener.TrChatListener;
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.listener.VentureChatListener;
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.listener.*;
|
||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -47,7 +46,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -97,7 +95,7 @@ public class BubbleManagerImpl implements BubbleManager {
|
||||
public void unload() {
|
||||
this.imageParser = null;
|
||||
this.bubbleMap.clear();
|
||||
if (chatListener != null) HandlerList.unregisterAll(chatListener);
|
||||
if (chatListener != null) chatListener.unregister();
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
@@ -127,15 +125,23 @@ public class BubbleManagerImpl implements BubbleManager {
|
||||
}
|
||||
|
||||
private void registerListener() {
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
if (CNConfig.trChatChannel) {
|
||||
this.chatListener = new TrChatListener(this);
|
||||
} else if (CNConfig.ventureChatChannel) {
|
||||
this.chatListener = new VentureChatListener(this);
|
||||
} else if (CNConfig.huskChatChannel) {
|
||||
this.chatListener = new HuskChatListener(this);
|
||||
} else if (CNConfig.carbonChatChannel) {
|
||||
this.chatListener = new CarbonChatListener(this);
|
||||
} else {
|
||||
this.chatListener = new AsyncChatListener(this);
|
||||
try {
|
||||
Class.forName("io.papermc.paper.event.player.AsyncChatEvent");
|
||||
this.chatListener = new PaperAsyncChatListener(this);
|
||||
} catch (ClassNotFoundException e) {
|
||||
this.chatListener = new AsyncChatListener(this);
|
||||
}
|
||||
}
|
||||
pluginManager.registerEvents(chatListener, plugin);
|
||||
this.chatListener.register();
|
||||
}
|
||||
|
||||
private void loadBubbles() {
|
||||
@@ -214,6 +220,12 @@ public class BubbleManagerImpl implements BubbleManager {
|
||||
|| !player.hasPermission("bubbles.use")
|
||||
) return;
|
||||
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
String finalText = text;
|
||||
CustomNameplatesPlugin.get().getScheduler().runTaskAsync(() -> onChat(player, finalText));
|
||||
return;
|
||||
}
|
||||
|
||||
var optionalUser = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
if (optionalUser.isEmpty()) {
|
||||
return;
|
||||
|
||||
+18
-5
@@ -17,19 +17,32 @@
|
||||
|
||||
package net.momirealms.customnameplates.paper.mechanic.bubble.listener;
|
||||
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.BubbleManagerImpl;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.api.manager.BubbleManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.bubble.listener.AbstractChatListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
public class AsyncChatListener extends AbstractChatListener {
|
||||
|
||||
public AsyncChatListener(BubbleManagerImpl chatBubblesManager) {
|
||||
public AsyncChatListener(BubbleManager chatBubblesManager) {
|
||||
super(chatBubblesManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, CustomNameplatesPlugin.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
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()));
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.paper.mechanic.bubble.listener;
|
||||
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.event.CarbonEventSubscription;
|
||||
import net.draycia.carbon.api.event.events.CarbonChatEvent;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.api.manager.BubbleManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.bubble.listener.AbstractChatListener;
|
||||
import net.momirealms.customnameplates.paper.util.ReflectionUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class CarbonChatListener extends AbstractChatListener {
|
||||
|
||||
private final CarbonChat api;
|
||||
private CarbonEventSubscription<CarbonChatEvent> subscription;
|
||||
private Method originalMessageMethod;
|
||||
private Method channelKeyMethod;
|
||||
|
||||
public CarbonChatListener(BubbleManager chatBubblesManager) {
|
||||
super(chatBubblesManager);
|
||||
this.api = CarbonChatProvider.carbonChat();
|
||||
try {
|
||||
this.originalMessageMethod = CarbonChatEvent.class.getMethod("originalMessage");
|
||||
this.channelKeyMethod = ChatChannel.class.getMethod("key");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
subscription = api.eventHandler().subscribe(CarbonChatEvent.class, event -> {
|
||||
if (event.cancelled())
|
||||
return;
|
||||
ChatChannel chatChannel = event.chatChannel();
|
||||
Object key = getChannelKey(chatChannel);
|
||||
if (key == null) return;
|
||||
String channel = ReflectionUtils.getKeyAsString(key);
|
||||
for (String black : chatBubblesManager.getBlacklistChannels()) {
|
||||
if (channel.equals(black)) return;
|
||||
}
|
||||
Player player = Bukkit.getPlayer(event.sender().uuid());
|
||||
if (player == null || !player.isOnline())
|
||||
return;
|
||||
Object component = getComponentFromEvent(event);
|
||||
String message = ReflectionUtils.getMiniMessageTextFromNonShadedComponent(component);
|
||||
CustomNameplatesPlugin.get().getScheduler().runTaskAsync(() -> chatBubblesManager.onChat(player, message));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
if (subscription != null) {
|
||||
subscription.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private Object getChannelKey(ChatChannel channel) {
|
||||
try {
|
||||
return this.channelKeyMethod.invoke(channel);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Object getComponentFromEvent(CarbonChatEvent event) {
|
||||
try {
|
||||
return this.originalMessageMethod.invoke(event);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ReflectionUtils.getEmptyComponent();
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.paper.mechanic.bubble.listener;
|
||||
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.api.manager.BubbleManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.bubble.listener.AbstractChatListener;
|
||||
import net.william278.huskchat.bukkit.event.ChatMessageEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class HuskChatListener extends AbstractChatListener {
|
||||
|
||||
public HuskChatListener(BubbleManager chatBubblesManager) {
|
||||
super(chatBubblesManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, CustomNameplatesPlugin.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onHuskChat(ChatMessageEvent event) {
|
||||
String channel = event.getChannelId();
|
||||
for (String black : chatBubblesManager.getBlacklistChannels()) {
|
||||
if (channel.equals(black)) return;
|
||||
}
|
||||
Player player = Bukkit.getPlayer(event.getSender().getUuid());
|
||||
if (player == null || !player.isOnline())
|
||||
return;
|
||||
CustomNameplatesPlugin.get().getScheduler().runTaskAsync(() -> {
|
||||
chatBubblesManager.onChat(player, event.getMessage());
|
||||
});
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.paper.mechanic.bubble.listener;
|
||||
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.api.manager.BubbleManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.bubble.listener.AbstractChatListener;
|
||||
import net.momirealms.customnameplates.paper.util.ReflectionUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class PaperAsyncChatListener extends AbstractChatListener {
|
||||
|
||||
private Method messageMethod;
|
||||
|
||||
public PaperAsyncChatListener(BubbleManager chatBubblesManager) {
|
||||
super(chatBubblesManager);
|
||||
try {
|
||||
this.messageMethod = AsyncChatEvent.class.getMethod("message");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, CustomNameplatesPlugin.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onChat(AsyncChatEvent event) {
|
||||
Object component = getComponentFromEvent(event);
|
||||
String message = ReflectionUtils.getMiniMessageTextFromNonShadedComponent(component);
|
||||
CustomNameplatesPlugin.get().getScheduler().runTaskAsync(() -> chatBubblesManager.onChat(event.getPlayer(), message));
|
||||
}
|
||||
|
||||
private Object getComponentFromEvent(AsyncChatEvent event) {
|
||||
try {
|
||||
return this.messageMethod.invoke(event);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ReflectionUtils.getEmptyComponent();
|
||||
}
|
||||
}
|
||||
+27
-6
@@ -17,27 +17,48 @@
|
||||
|
||||
package net.momirealms.customnameplates.paper.mechanic.bubble.listener;
|
||||
|
||||
import me.arasple.mc.trchat.TrChat;
|
||||
import me.arasple.mc.trchat.api.event.TrChatEvent;
|
||||
import me.arasple.mc.trchat.module.display.channel.Channel;
|
||||
import me.arasple.mc.trchat.module.internal.filter.FilteredObject;
|
||||
import me.arasple.mc.trchat.taboolib.platform.BukkitAdapter;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.BubbleManagerImpl;
|
||||
import net.momirealms.customnameplates.api.manager.BubbleManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.bubble.listener.AbstractChatListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class TrChatListener extends AbstractChatListener {
|
||||
|
||||
public TrChatListener(BubbleManagerImpl chatBubblesManager) {
|
||||
private final BukkitAdapter adapter;
|
||||
|
||||
public TrChatListener(BubbleManager chatBubblesManager) {
|
||||
super(chatBubblesManager);
|
||||
this.adapter = new BukkitAdapter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, CustomNameplatesPlugin.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onTrChat(TrChatEvent event) {
|
||||
if (!event.getForward()) return;
|
||||
Channel channelName = event.getChannel();
|
||||
for (String channel : chatBubblesManager.getBlacklistChannels()) {
|
||||
if (channelName.equals(channel)) return;
|
||||
Channel channel = event.getChannel();
|
||||
String channelName = channel.getId();
|
||||
for (String black : chatBubblesManager.getBlacklistChannels()) {
|
||||
if (channelName.equals(black)) return;
|
||||
}
|
||||
FilteredObject object = TrChat.INSTANCE.api().getFilterManager().filter(event.getMessage(), adapter.adaptPlayer(event.getPlayer()), true);
|
||||
CustomNameplatesPlugin.get().getScheduler().runTaskAsync(() -> {
|
||||
chatBubblesManager.onChat(event.getSession().getPlayer(), event.getMessage());
|
||||
chatBubblesManager.onChat(event.getSession().getPlayer(), object.getFiltered());
|
||||
});
|
||||
}
|
||||
}
|
||||
+16
-3
@@ -20,16 +20,29 @@ package net.momirealms.customnameplates.paper.mechanic.bubble.listener;
|
||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||
import mineverse.Aust1n46.chat.api.events.VentureChatEvent;
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.paper.mechanic.bubble.BubbleManagerImpl;
|
||||
import net.momirealms.customnameplates.api.manager.BubbleManager;
|
||||
import net.momirealms.customnameplates.api.mechanic.bubble.listener.AbstractChatListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class VentureChatListener extends AbstractChatListener {
|
||||
|
||||
public VentureChatListener(BubbleManagerImpl chatBubblesManager) {
|
||||
public VentureChatListener(BubbleManager chatBubblesManager) {
|
||||
super(chatBubblesManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@Override
|
||||
public void register() {
|
||||
Bukkit.getPluginManager().registerEvents(this, CustomNameplatesPlugin.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler (ignoreCancelled = true)
|
||||
public void onVentureChat(VentureChatEvent event) {
|
||||
String channelName = event.getChannel().getName();
|
||||
for (String channel : chatBubblesManager.getBlacklistChannels()) {
|
||||
|
||||
+22
-10
@@ -442,7 +442,9 @@ public class WidthManagerImpl implements WidthManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
int charWidth = (int) (((double) (x_final - i * single) / single * 8) + 1);
|
||||
int pixels = x_final - i * single + 1;
|
||||
double times = (double) width / 128;
|
||||
int charWidth = (int) (pixels / times);
|
||||
yml.set(ConfigUtils.native2ascii(c), charWidth);
|
||||
i++;
|
||||
}
|
||||
@@ -501,7 +503,9 @@ public class WidthManagerImpl implements WidthManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
int charWidth = (int) (((double) (x_final - i * single) / single * 8) + 1);
|
||||
int pixels = x_final - i * single + 1;
|
||||
double times = (double) width / 128;
|
||||
int charWidth = (int) (pixels / times);
|
||||
yml.set(ConfigUtils.native2ascii(c), charWidth);
|
||||
i++;
|
||||
}
|
||||
@@ -548,7 +552,10 @@ public class WidthManagerImpl implements WidthManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
int charWidth = (int) (((double) (x_final - i * single) / single * 8) + 1);
|
||||
|
||||
int pixels = x_final - i * single + 1;
|
||||
double times = (double) width / 128;
|
||||
int charWidth = (int) (pixels / times);
|
||||
yml.set(ConfigUtils.native2ascii(c), charWidth);
|
||||
i++;
|
||||
}
|
||||
@@ -652,11 +659,12 @@ public class WidthManagerImpl implements WidthManager {
|
||||
char[] chars = ConfigUtils.convertUnicodeStringToChars(line);
|
||||
for (char c : chars) {
|
||||
int width = bufferedImage.getWidth();
|
||||
double times = (double) width / 144;
|
||||
int single = width / 16;
|
||||
int x_final = i * single;
|
||||
outer:
|
||||
for (int x = i * single; x < (i+1) * single; x++) {
|
||||
for (int y = j * single; y < (j+1) * single; y++) {
|
||||
for (int y = (int) (j * 12 * times); y < (j+1) * 12 * times; y++) {
|
||||
int rgb = bufferedImage.getRGB(x, y);
|
||||
int alpha = (rgb >> 24) & 0xff;
|
||||
if (alpha != 0) {
|
||||
@@ -665,7 +673,9 @@ public class WidthManagerImpl implements WidthManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
int charWidth = (int) (((double) (x_final - i * single) / single * 8) + 1);
|
||||
|
||||
int pixels = x_final - i * single + 1;
|
||||
int charWidth = (int) (pixels / times);
|
||||
yml.set(ConfigUtils.native2ascii(c), charWidth);
|
||||
i++;
|
||||
}
|
||||
@@ -786,7 +796,9 @@ public class WidthManagerImpl implements WidthManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
int charWidth = (int) (((double) (x_final - i * single) / single * 8) + 1);
|
||||
int pixels = x_final - i * single + 1;
|
||||
double times = (double) width / 128;
|
||||
int charWidth = (int) (pixels / times);
|
||||
yml.set(unicode, charWidth);
|
||||
i++;
|
||||
}
|
||||
@@ -847,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;
|
||||
}
|
||||
@@ -856,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);
|
||||
}
|
||||
|
||||
|
||||
+23
-8
@@ -21,6 +21,7 @@ import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.momirealms.customnameplates.api.manager.RequirementManager;
|
||||
import net.momirealms.customnameplates.api.requirement.Condition;
|
||||
import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DisplayController {
|
||||
@@ -35,6 +36,7 @@ public class DisplayController {
|
||||
private int timeLeft;
|
||||
private int index;
|
||||
private final TimeLimitText[] texts;
|
||||
private boolean metAnyCondition;
|
||||
|
||||
public DisplayController(
|
||||
Player player,
|
||||
@@ -44,10 +46,10 @@ public class DisplayController {
|
||||
) {
|
||||
this.owner = player;
|
||||
this.checkFrequency = checkFrequency;
|
||||
this.checkTimer = 0;
|
||||
this.refreshTimer = 0;
|
||||
this.requirements = requirements;
|
||||
this.texts = texts;
|
||||
this.checkTimer = checkFrequency - 1;
|
||||
}
|
||||
|
||||
public NextStage stateCheck(Condition condition) {
|
||||
@@ -78,21 +80,33 @@ public class DisplayController {
|
||||
}
|
||||
|
||||
public boolean updateText(Condition condition) {
|
||||
timeLeft--;
|
||||
if (timeLeft <= 0) {
|
||||
if (timeLeft > 0)
|
||||
timeLeft--;
|
||||
|
||||
// Definitely goto "if" on init
|
||||
if (timeLeft == 0) {
|
||||
int triedTimes = 0;
|
||||
do {
|
||||
index++;
|
||||
if (index >= texts.length) {
|
||||
index = 0;
|
||||
}
|
||||
if (triedTimes == texts.length) {
|
||||
timeLeft = Math.max(checkFrequency, 1);
|
||||
metAnyCondition = false;
|
||||
LogUtils.warn("No text is available for player " + owner.getName() + ". Please check your conditions.");
|
||||
return updateText("");
|
||||
}
|
||||
triedTimes++;
|
||||
} while (!RequirementManager.isRequirementMet(condition, texts[index].getRequirements()));
|
||||
|
||||
metAnyCondition = true;
|
||||
timeLeft = texts[index].getDuration();
|
||||
refreshTimer = 0;
|
||||
return updateText(texts[index].getText());
|
||||
}
|
||||
|
||||
if (texts[index].getRefreshFrequency() <= 0) {
|
||||
if (!metAnyCondition || texts[index].getRefreshFrequency() <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -114,12 +128,13 @@ public class DisplayController {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
index = 0;
|
||||
public void initialize(Condition condition) {
|
||||
index = texts.length - 1;
|
||||
checkTimer = 0;
|
||||
refreshTimer = 0;
|
||||
timeLeft = texts[0].getDuration();
|
||||
latestValue = PlaceholderAPI.setPlaceholders(owner, texts[0].getText());
|
||||
timeLeft = 1;
|
||||
// The text would definitely be refreshed
|
||||
updateText(condition);
|
||||
}
|
||||
|
||||
public String getLatestContent() {
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package net.momirealms.customnameplates.paper.mechanic.misc;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class MessageManager implements Listener {
|
||||
|
||||
|
||||
|
||||
}
|
||||
+2
@@ -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;
|
||||
|
||||
+69
-45
@@ -55,7 +55,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@@ -145,6 +144,12 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
|
||||
public void load() {
|
||||
this.unlimitedTagManager.load();
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(entityDestroyListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(entitySpawnListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(entityLookListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(entityMoveListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(entityTeleportListener);
|
||||
|
||||
if (!CNConfig.nameplateModule) return;
|
||||
this.loadConfig();
|
||||
@@ -160,13 +165,6 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
createNameTag(online);
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(entityDestroyListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(entitySpawnListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(entityLookListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(entityMoveListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(entityTeleportListener);
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
@@ -259,6 +257,8 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
|
||||
@EventHandler (ignoreCancelled = true, priority = EventPriority.LOW)
|
||||
public void onDataLoaded(NameplateDataLoadEvent event) {
|
||||
if (!CNConfig.nameplateModule) return;
|
||||
|
||||
OnlineUser data = event.getOnlineUser();
|
||||
String nameplate = data.getNameplateKey();
|
||||
if (nameplate.equals("none")) {
|
||||
@@ -285,27 +285,36 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
// unlimited part
|
||||
var player = event.getPlayer();
|
||||
this.putEntityIDToMap(player.getEntityId(), player);
|
||||
if (!CNConfig.isOtherTeamPluginHooked() && !isProxyMode())
|
||||
plugin.getTeamManager().createTeam(player);
|
||||
plugin.getScheduler().runTaskAsyncLater(() -> {
|
||||
if (player.isOnline())
|
||||
this.createNameTag(player);
|
||||
}, 200, TimeUnit.MILLISECONDS);
|
||||
|
||||
// nameplate module part
|
||||
if (CNConfig.nameplateModule) {
|
||||
if (!CNConfig.isOtherTeamPluginHooked() && !isProxyMode()) {
|
||||
plugin.getTeamManager().createTeam(player);
|
||||
}
|
||||
plugin.getScheduler().runTaskAsyncLater(() -> {
|
||||
if (player.isOnline())
|
||||
this.createNameTag(player);
|
||||
}, 200, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
// unlimited part
|
||||
var player = event.getPlayer();
|
||||
this.removeCachedNameplateFromMap(player.getUniqueId());
|
||||
this.removeEntityIDFromMap(player.getEntityId());
|
||||
|
||||
this.teamTagManager.handlePlayerQuit(player);
|
||||
this.unlimitedTagManager.handlePlayerQuit(player);
|
||||
|
||||
if (!CNConfig.isOtherTeamPluginHooked() && !isProxyMode()) {
|
||||
plugin.getTeamManager().removeTeam(player);
|
||||
// nameplate module part
|
||||
if (CNConfig.nameplateModule) {
|
||||
this.removeCachedNameplateFromMap(player.getUniqueId());
|
||||
if (!CNConfig.isOtherTeamPluginHooked() && !isProxyMode()) {
|
||||
plugin.getTeamManager().removeTeam(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +332,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);
|
||||
@@ -336,7 +345,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;
|
||||
}
|
||||
@@ -345,7 +354,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CachedNameplate removeCachedNameplateFromMap(UUID uuid) {
|
||||
public CachedNameplate removeCachedNameplateFromMap(@NotNull UUID uuid) {
|
||||
return this.cachedNameplateMap.remove(uuid);
|
||||
}
|
||||
|
||||
@@ -364,7 +373,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();
|
||||
@@ -372,45 +381,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));
|
||||
EntityTagPlayer tagPlayer = this.unlimitedTagManager.createOrGetTagForPlayer(player, false);
|
||||
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, true);
|
||||
EntityTagPlayer tagPlayer = this.unlimitedTagManager.createOrGetTagForPlayer(player);
|
||||
for (DynamicTextTagSetting setting : tagSettings) {
|
||||
tagPlayer.addTag(setting);
|
||||
}
|
||||
putNameplatePlayerToMap(tagPlayer);
|
||||
return tagPlayer;
|
||||
} else {
|
||||
EntityTagPlayer tagPlayer = this.unlimitedTagManager.createOrGetTagForPlayer(player, false);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -443,22 +456,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();
|
||||
@@ -471,8 +487,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)) {
|
||||
@@ -482,8 +499,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())) {
|
||||
@@ -494,7 +512,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;
|
||||
@@ -545,14 +563,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;
|
||||
}
|
||||
|
||||
@@ -566,39 +584,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();
|
||||
}
|
||||
@@ -609,11 +631,13 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
||||
return defaultNameplate;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TeamTagManager getTeamTagManager() {
|
||||
return teamTagManager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public UnlimitedTagManager getUnlimitedTagManager() {
|
||||
return unlimitedTagManager;
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ public class EntityDestroyListener extends PacketAdapter {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
manager.onEntityDestroy(event.getPlayer(), packet.getIntLists().read(0));
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ public class EntityLookListener extends PacketAdapter {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
manager.onEntityMove(event.getPlayer(),
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ public class EntityMoveListener extends PacketAdapter {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
manager.onEntityMove(event.getPlayer(),
|
||||
|
||||
+2
-1
@@ -33,7 +33,8 @@ public class EntitySpawnListener extends PacketAdapter {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
public synchronized void onPacketSending(PacketEvent event) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
manager.onEntitySpawn(event.getPlayer(), event.getPacket().getIntegers().read(0));
|
||||
}
|
||||
}
|
||||
+1
@@ -34,6 +34,7 @@ public class EntityTeleportListener extends PacketAdapter {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
manager.onEntityTeleport(
|
||||
|
||||
+1
-2
@@ -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;
|
||||
@@ -44,6 +42,7 @@ public class PlayerInfoListener extends PacketAdapter {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
Set<EnumWrappers.PlayerInfoAction> actions = packet.getPlayerInfoActions().read(0);
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class TeamTagManagerImpl implements TeamTagManager {
|
||||
private final NameplateManager manager;
|
||||
private final ConcurrentHashMap<UUID, TeamPlayer> teamPlayerMap;
|
||||
private CancellableTask refreshTask;
|
||||
private PlayerInfoListener tabListener;
|
||||
private final PlayerInfoListener tabListener;
|
||||
|
||||
public TeamTagManagerImpl(NameplateManager manager) {
|
||||
this.manager = manager;
|
||||
|
||||
+22
-25
@@ -18,9 +18,11 @@
|
||||
package net.momirealms.customnameplates.paper.mechanic.nameplate.tag.unlimited;
|
||||
|
||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||
import net.momirealms.customnameplates.api.mechanic.nameplate.TagMode;
|
||||
import net.momirealms.customnameplates.api.mechanic.tag.unlimited.*;
|
||||
import net.momirealms.customnameplates.common.team.TeamColor;
|
||||
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
|
||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Pose;
|
||||
|
||||
@@ -32,18 +34,11 @@ public class UnlimitedPlayer extends UnlimitedEntity implements EntityTagPlayer
|
||||
private final Vector<DynamicTextEntity> dynamicTags;
|
||||
private double hatOffset;
|
||||
private boolean isPreviewing;
|
||||
private boolean manageTeams;
|
||||
|
||||
public UnlimitedPlayer(UnlimitedTagManagerImpl manager, Player player) {
|
||||
super(manager, player);
|
||||
this.owner = player;
|
||||
this.dynamicTags = new Vector<>();
|
||||
this.manageTeams = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManageTeams(boolean manageTeams) {
|
||||
this.manageTeams = manageTeams;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -243,27 +238,29 @@ public class UnlimitedPlayer extends UnlimitedEntity implements EntityTagPlayer
|
||||
}
|
||||
|
||||
private void setNameInvisibleFor(Player viewer) {
|
||||
if (!manageTeams) return;
|
||||
CustomNameplatesPlugin.get().getTeamManager().updateTeam(
|
||||
owner,
|
||||
viewer,
|
||||
"",
|
||||
"",
|
||||
TeamColor.WHITE,
|
||||
TeamTagVisibility.NEVER
|
||||
);
|
||||
if (CNConfig.nameplateModule && CustomNameplatesPlugin.get().getNameplateManager().getTagMode() == TagMode.UNLIMITED) {
|
||||
CustomNameplatesPlugin.get().getTeamManager().updateTeam(
|
||||
owner,
|
||||
viewer,
|
||||
"",
|
||||
"",
|
||||
TeamColor.WHITE,
|
||||
TeamTagVisibility.NEVER
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void setNameVisibleFor(Player viewer) {
|
||||
if (!manageTeams) return;
|
||||
CustomNameplatesPlugin.get().getTeamManager().updateTeam(
|
||||
owner,
|
||||
viewer,
|
||||
"",
|
||||
"",
|
||||
TeamColor.WHITE,
|
||||
TeamTagVisibility.ALWAYS
|
||||
);
|
||||
if (CNConfig.nameplateModule && CustomNameplatesPlugin.get().getNameplateManager().getTagMode() == TagMode.UNLIMITED) {
|
||||
CustomNameplatesPlugin.get().getTeamManager().updateTeam(
|
||||
owner,
|
||||
viewer,
|
||||
"",
|
||||
"",
|
||||
TeamColor.WHITE,
|
||||
TeamTagVisibility.ALWAYS
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void timer() {
|
||||
|
||||
-23
@@ -160,29 +160,6 @@ public class UnlimitedTagManagerImpl implements UnlimitedTagManager {
|
||||
return unlimitedPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public UnlimitedPlayer createOrGetTagForPlayer(Player player, boolean manageTeam) {
|
||||
if (!player.isOnline())
|
||||
return null;
|
||||
final UUID uuid = player.getUniqueId();
|
||||
if (this.unlimitedEntityMap.containsKey(uuid)) {
|
||||
UnlimitedPlayer unlimitedPlayer = (UnlimitedPlayer) this.unlimitedEntityMap.get(uuid);
|
||||
unlimitedPlayer.setManageTeams(manageTeam);
|
||||
return unlimitedPlayer;
|
||||
}
|
||||
|
||||
var unlimitedPlayer = new UnlimitedPlayer(this, player);
|
||||
this.unlimitedEntityMap.put(
|
||||
uuid,
|
||||
unlimitedPlayer
|
||||
);
|
||||
unlimitedPlayer.setManageTeams(manageTeam);
|
||||
|
||||
unlimitedPlayer.addNearByPlayerToMap(48);
|
||||
return unlimitedPlayer;
|
||||
}
|
||||
|
||||
public UnlimitedEntity removeUnlimitedEntityFromMap(UUID uuid) {
|
||||
return unlimitedEntityMap.remove(uuid);
|
||||
}
|
||||
|
||||
+34
-24
@@ -111,6 +111,7 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
|
||||
}
|
||||
|
||||
private void generateShaders() {
|
||||
if (!CNConfig.enableShader) return;
|
||||
String path = "ResourcePack" + File.separator + "assets" + File.separator + "minecraft" + File.separator + "shaders" + File.separator + "core" + File.separator;
|
||||
plugin.saveResource(path + "rendertype_text.fsh", true);
|
||||
plugin.saveResource(path + "rendertype_text.json", true);
|
||||
@@ -312,33 +313,42 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
|
||||
}
|
||||
|
||||
private void copyResourcePackToHookedPlugins(File resourcePackFolder) {
|
||||
Plugin ia = Bukkit.getPluginManager().getPlugin("ItemsAdder");
|
||||
if (ia != null) {
|
||||
File file = new File(ia.getDataFolder(), "config.yml");
|
||||
YamlConfiguration iaConfig = YamlConfiguration.loadConfiguration(file);
|
||||
List<String> folders = iaConfig.getStringList("resource-pack.zip.merge_other_plugins_resourcepacks_folders");
|
||||
boolean changed = false;
|
||||
if (CNConfig.copyPackIA) {
|
||||
if (!folders.contains("CustomNameplates/ResourcePack")) {
|
||||
folders.add("CustomNameplates/ResourcePack");
|
||||
iaConfig.set("resource-pack.zip.merge_other_plugins_resourcepacks_folders", folders);
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
if (folders.contains("CustomNameplates/ResourcePack")) {
|
||||
folders.remove("CustomNameplates/ResourcePack");
|
||||
iaConfig.set("resource-pack.zip.merge_other_plugins_resourcepacks_folders", folders);
|
||||
changed = true;
|
||||
}
|
||||
Plugin ia = Bukkit.getPluginManager().getPlugin("ItemsAdder");
|
||||
if (ia != null) {
|
||||
File file = new File(ia.getDataFolder(), "config.yml");
|
||||
YamlConfiguration iaConfig = YamlConfiguration.loadConfiguration(file);
|
||||
List<String> folders = iaConfig.getStringList("resource-pack.zip.merge_other_plugins_resourcepacks_folders");
|
||||
boolean changed = false;
|
||||
if (CNConfig.copyPackIA) {
|
||||
if (!folders.contains("CustomNameplates/ResourcePack")) {
|
||||
folders.add("CustomNameplates/ResourcePack");
|
||||
iaConfig.set("resource-pack.zip.merge_other_plugins_resourcepacks_folders", folders);
|
||||
changed = true;
|
||||
}
|
||||
if (changed) {
|
||||
try {
|
||||
iaConfig.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
if (folders.contains("CustomNameplates/ResourcePack")) {
|
||||
folders.remove("CustomNameplates/ResourcePack");
|
||||
iaConfig.set("resource-pack.zip.merge_other_plugins_resourcepacks_folders", folders);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
try {
|
||||
iaConfig.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CNConfig.copyPackIAOld){
|
||||
try {
|
||||
FileUtils.copyDirectory(new File(resourcePackFolder, "assets"), new File(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("ItemsAdder")).getDataFolder() + File.separator + "contents" + File.separator + "nameplates" + File.separator + "resourcepack" + File.separator + "assets") );
|
||||
}
|
||||
catch (IOException e){
|
||||
e.printStackTrace();
|
||||
LogUtils.warn("Failed to copy files to ItemsAdder...");
|
||||
}
|
||||
}
|
||||
if (CNConfig.copyPackOraxen){
|
||||
try {
|
||||
FileUtils.copyDirectory(new File(resourcePackFolder, "assets"), new File(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("Oraxen")).getDataFolder() + File.separator + "pack" + File.separator + "assets"));
|
||||
|
||||
+19
-7
@@ -24,6 +24,7 @@ import net.momirealms.customnameplates.api.mechanic.placeholder.*;
|
||||
import net.momirealms.customnameplates.api.requirement.Requirement;
|
||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||
import net.momirealms.customnameplates.common.Pair;
|
||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -230,6 +231,7 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
||||
|
||||
vanillaHudMap.put(entry.getKey(),
|
||||
VanillaHud.builder()
|
||||
.reverse(innerSection.getBoolean("reverse", true))
|
||||
.half(halfC.getCharacter())
|
||||
.empty(emptyC.getCharacter())
|
||||
.full(fullC.getCharacter())
|
||||
@@ -241,21 +243,31 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
|
||||
}
|
||||
|
||||
private void loadBackGroundTexts(ConfigurationSection section) {
|
||||
if (!CNConfig.backgroundModule) return;
|
||||
for (Map.Entry<String, Object> entry : section.getValues(false).entrySet()) {
|
||||
if (!(entry.getValue() instanceof ConfigurationSection innerSection))
|
||||
continue;
|
||||
|
||||
backGroundTextMap.put(entry.getKey(),
|
||||
BackGroundText.builder()
|
||||
.background(Objects.requireNonNull(plugin.getBackGroundManager().getBackGround(innerSection.getString("background"))))
|
||||
.text(innerSection.getString("text", ""))
|
||||
.removeShadow(innerSection.getBoolean("remove-shadow"))
|
||||
.build()
|
||||
);
|
||||
if (innerSection.contains("background")) {
|
||||
String bg = innerSection.getString("background");
|
||||
var background = plugin.getBackGroundManager().getBackGround(bg);
|
||||
if (background == null) {
|
||||
LogUtils.warn("Background: " + bg + " doesn't exist");
|
||||
continue;
|
||||
}
|
||||
backGroundTextMap.put(entry.getKey(),
|
||||
BackGroundText.builder()
|
||||
.background(background)
|
||||
.text(innerSection.getString("text", ""))
|
||||
.removeShadow(innerSection.getBoolean("remove-shadow"))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadNameplateTexts(ConfigurationSection section) {
|
||||
if (!CNConfig.nameplateModule) return;
|
||||
for (Map.Entry<String, Object> entry : section.getValues(false).entrySet()) {
|
||||
if (!(entry.getValue() instanceof ConfigurationSection innerSection))
|
||||
continue;
|
||||
|
||||
+5
@@ -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();
|
||||
|
||||
+15
@@ -29,6 +29,7 @@ import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl;
|
||||
import net.momirealms.customnameplates.paper.mechanic.requirement.papi.PapiCondition;
|
||||
import net.momirealms.customnameplates.paper.util.ClassUtils;
|
||||
import net.momirealms.customnameplates.paper.util.ConfigUtils;
|
||||
import net.momirealms.customnameplates.paper.util.GeyserUtils;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@@ -121,6 +122,7 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
this.registerPapiRequirement();
|
||||
this.registerInListRequirement();
|
||||
this.registerGameModeRequirement();
|
||||
this.registerGeyserRequirement();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,6 +291,19 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerGeyserRequirement() {
|
||||
registerRequirement("geyser", (args) -> {
|
||||
boolean arg = (boolean) args;
|
||||
return condition -> {
|
||||
if (arg) {
|
||||
return GeyserUtils.isBedrockPlayer(condition.getOfflinePlayer().getUniqueId());
|
||||
} else {
|
||||
return !GeyserUtils.isBedrockPlayer(condition.getOfflinePlayer().getUniqueId());
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerBiomeRequirement() {
|
||||
registerRequirement("biome", (args) -> {
|
||||
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class PapiCondition implements Requirement {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<PapiRequirement> getRequirements(Map<String, Object> map) {
|
||||
|
||||
+94
-37
@@ -17,6 +17,8 @@
|
||||
|
||||
package net.momirealms.customnameplates.paper.mechanic.team;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
@@ -34,11 +36,16 @@ import net.momirealms.customnameplates.paper.mechanic.team.provider.*;
|
||||
import net.momirealms.customnameplates.paper.setting.CNConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||
|
||||
@@ -52,65 +59,94 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||
this.teamPacketAdaptor = new TeamPacket_1_17();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method would only be called when CustomNameplates manage the team
|
||||
*
|
||||
* @param player player
|
||||
*/
|
||||
@Override
|
||||
public void createTeam(Player player) {
|
||||
if (CNConfig.disableTeamManage) return;
|
||||
String team = teamProvider.getTeam(player);
|
||||
if (team == null) {
|
||||
LogUtils.warn("Failed to get player " + player.getName() + "'s team.");
|
||||
return;
|
||||
}
|
||||
PacketContainer createOwner = teamPacketAdaptor.getTeamCreatePacket(
|
||||
TeamCreate.builder()
|
||||
.teamName(team)
|
||||
.color(TeamColor.WHITE)
|
||||
.display("")
|
||||
.prefix("")
|
||||
.suffix("")
|
||||
.members(Collections.singletonList(player.getName()))
|
||||
.collisionRule(TeamCollisionRule.ALWAYS)
|
||||
.tagVisibility(TeamTagVisibility.ALWAYS)
|
||||
.build()
|
||||
);
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
PacketManager.getInstance().send(online, createOwner);
|
||||
if (online == player) continue;
|
||||
String onlineTeam = teamProvider.getTeam(online);
|
||||
PacketContainer createOther = teamPacketAdaptor.getTeamCreatePacket(
|
||||
if (CNConfig.isOtherTeamPluginHooked()) return;
|
||||
String team = teamProvider.getTeam(player, null);
|
||||
if (!team.equals(player.getName())) return;
|
||||
if (CNConfig.createRealTeam) {
|
||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
Team playerTeam = scoreboard.getTeam(team);
|
||||
if (playerTeam == null) {
|
||||
playerTeam = scoreboard.registerNewTeam(team);
|
||||
}
|
||||
playerTeam.addPlayer(player);
|
||||
} else {
|
||||
PacketContainer createOwner = teamPacketAdaptor.getTeamCreatePacket(
|
||||
TeamCreate.builder()
|
||||
.teamName(onlineTeam)
|
||||
.teamName(team)
|
||||
.color(TeamColor.WHITE)
|
||||
.display("")
|
||||
.prefix("")
|
||||
.suffix("")
|
||||
.members(Collections.singletonList(online.getName()))
|
||||
.members(Collections.singletonList(player.getName()))
|
||||
.collisionRule(TeamCollisionRule.ALWAYS)
|
||||
.tagVisibility(TeamTagVisibility.ALWAYS)
|
||||
.build()
|
||||
);
|
||||
PacketManager.getInstance().send(player, createOther);
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
PacketManager.getInstance().send(online, createOwner);
|
||||
if (online == player) continue;
|
||||
String onlineTeam = teamProvider.getTeam(online, null);
|
||||
PacketContainer createOther = teamPacketAdaptor.getTeamCreatePacket(
|
||||
TeamCreate.builder()
|
||||
.teamName(onlineTeam)
|
||||
.color(TeamColor.WHITE)
|
||||
.display("")
|
||||
.prefix("")
|
||||
.suffix("")
|
||||
.members(Collections.singletonList(online.getName()))
|
||||
.collisionRule(TeamCollisionRule.ALWAYS)
|
||||
.tagVisibility(TeamTagVisibility.ALWAYS)
|
||||
.build()
|
||||
);
|
||||
PacketManager.getInstance().send(player, createOther);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method would only be called when CustomNameplates manage the team
|
||||
*
|
||||
* @param player player
|
||||
*/
|
||||
@Override
|
||||
public void removeTeam(Player player) {
|
||||
if (CNConfig.disableTeamManage) return;
|
||||
String team = teamProvider.getTeam(player);
|
||||
PacketContainer packet = teamPacketAdaptor.getTeamRemovePacket(
|
||||
TeamRemove.builder()
|
||||
.teamName(team)
|
||||
.build()
|
||||
);
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
if (player == online) continue;
|
||||
PacketManager.getInstance().send(online, packet);
|
||||
if (CNConfig.isOtherTeamPluginHooked()) return;
|
||||
String team = teamProvider.getTeam(player, null);
|
||||
// If the team is created by other plugins
|
||||
if (!team.equals(player.getName())) return;
|
||||
if (CNConfig.createRealTeam) {
|
||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
Optional.ofNullable(scoreboard.getTeam(team)).ifPresent(Team::unregister);
|
||||
} else {
|
||||
PacketContainer packet = teamPacketAdaptor.getTeamRemovePacket(
|
||||
TeamRemove.builder()
|
||||
.teamName(team)
|
||||
.build()
|
||||
);
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
if (player == online) continue;
|
||||
PacketManager.getInstance().send(online, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTeam(Player owner, Player viewer, String prefix, String suffix, TeamColor color, TeamTagVisibility visibility) {
|
||||
if (CNConfig.disableTeamManage) return;
|
||||
String team = teamProvider.getTeam(owner);
|
||||
String team = teamProvider.getTeam(owner, viewer);
|
||||
if (team == null) {
|
||||
LogUtils.warn("Failed to get player " + owner.getName() + "'s team for viewer " + viewer.getName());
|
||||
return;
|
||||
}
|
||||
if (color == TeamColor.NONE || color == TeamColor.CUSTOM)
|
||||
color = TeamColor.WHITE;
|
||||
if (plugin.getNameplateManager().isProxyMode()) {
|
||||
@@ -145,6 +181,12 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
if (teamProvider instanceof Listener listener) {
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
if (teamProvider instanceof PacketAdapter adapter) {
|
||||
ProtocolLibrary.getProtocolManager().removePacketListener(adapter);
|
||||
}
|
||||
Bukkit.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL);
|
||||
Bukkit.getServer().getMessenger().unregisterOutgoingPluginChannel(plugin, CHANNEL);
|
||||
}
|
||||
@@ -159,13 +201,19 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||
} else {
|
||||
teamProvider = new DefaultProvider();
|
||||
}
|
||||
if (teamProvider instanceof Listener listener) {
|
||||
Bukkit.getPluginManager().registerEvents(listener, plugin);
|
||||
}
|
||||
if (teamProvider instanceof PacketAdapter adapter) {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(adapter);
|
||||
}
|
||||
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(plugin, CHANNEL);
|
||||
Bukkit.getServer().getMessenger().registerIncomingPluginChannel(plugin, CHANNEL, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeamName(Player player) {
|
||||
return null;
|
||||
public String getTeamName(Player player, Player viewer) {
|
||||
return teamProvider.getTeam(player, viewer);
|
||||
}
|
||||
|
||||
private void handleMessage(String... message) {
|
||||
@@ -198,4 +246,13 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
||||
player.sendPluginMessage(plugin, CHANNEL, dataOutput.toByteArray());
|
||||
});
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
unload();
|
||||
if (CNConfig.disableTeamManage) return;
|
||||
if (CNConfig.isOtherTeamPluginHooked()) return;
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
removeTeam(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.bukkit.scoreboard.Team;
|
||||
public class CMIProvider implements TeamProvider {
|
||||
|
||||
@Override
|
||||
public String getTeam(Player player) {
|
||||
public String getTeam(Player player, Player ignore) {
|
||||
Team team = CMI.getInstance().getSB().getPlayerTeam(player);
|
||||
if (team == null) return null;
|
||||
return team.getName();
|
||||
|
||||
+10
-2
@@ -17,12 +17,20 @@
|
||||
|
||||
package net.momirealms.customnameplates.paper.mechanic.team.provider;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class DefaultProvider implements TeamProvider {
|
||||
|
||||
@Override
|
||||
public String getTeam(Player player) {
|
||||
return player.getName();
|
||||
public String getTeam(Player player, Player ignore) {
|
||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
Team team = scoreboard.getPlayerTeam(player);
|
||||
if (team == null) {
|
||||
return player.getName();
|
||||
}
|
||||
return team.getName();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class TABProvider implements TeamProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeam(Player player) {
|
||||
public String getTeam(Player player, Player ignore) {
|
||||
TabPlayer tabPlayer = api.getPlayer(player.getUniqueId());
|
||||
if (tabPlayer == null) {
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -21,5 +21,5 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public interface TeamProvider {
|
||||
|
||||
String getTeam(Player player);
|
||||
String getTeam(Player player, Player viewer);
|
||||
}
|
||||
+121
-2
@@ -17,15 +17,73 @@
|
||||
|
||||
package net.momirealms.customnameplates.paper.mechanic.team.provider;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class UnknownProvider implements TeamProvider {
|
||||
import java.util.*;
|
||||
|
||||
public class UnknownProvider extends PacketAdapter implements TeamProvider, Listener {
|
||||
|
||||
private final HashMap<UUID, PlayerTeamView> teamViewMap;
|
||||
|
||||
public UnknownProvider() {
|
||||
super(CustomNameplatesPlugin.getInstance(), ListenerPriority.HIGHEST, PacketType.Play.Server.SCOREBOARD_TEAM);
|
||||
this.teamViewMap = new HashMap<>();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
teamViewMap.put(event.getPlayer().getUniqueId(), new PlayerTeamView());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
teamViewMap.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeam(Player player) {
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
Player receiver = event.getPlayer();
|
||||
PlayerTeamView view = teamViewMap.get(receiver.getUniqueId());
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
PacketContainer packet = event.getPacket();
|
||||
String team = (String) packet.getModifier().read(1);
|
||||
switch ((int) packet.getModifier().read(0)) {
|
||||
case 0, 3 -> view.addMembers(team, (Collection<String>) packet.getModifier().read(2));
|
||||
case 1 -> view.removeTeam(team);
|
||||
case 4 -> view.removeMembers(team, (Collection<String>) packet.getModifier().read(2));
|
||||
default -> {
|
||||
// ignore 2 update team info
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeam(Player player, Player viewer) {
|
||||
PlayerTeamView view = teamViewMap.get(viewer.getUniqueId());
|
||||
if (view != null) {
|
||||
String team = view.getTeam(player);
|
||||
if (team != null)
|
||||
return team;
|
||||
}
|
||||
|
||||
// should not reach here
|
||||
CustomNameplatesPlugin.get().debug("Getting real teams for " + player.getName() + " viewer: " + viewer.getName());
|
||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
Team team = scoreboard.getPlayerTeam(player);
|
||||
if (team == null) {
|
||||
@@ -33,4 +91,65 @@ public class UnknownProvider implements TeamProvider {
|
||||
}
|
||||
return team.getName();
|
||||
}
|
||||
|
||||
public static class PlayerTeamView {
|
||||
|
||||
private final HashMap<String, String> playerToTeamMap;
|
||||
private final HashMap<String, String[]> teamToPlayerMap;
|
||||
|
||||
public PlayerTeamView() {
|
||||
this.playerToTeamMap = new HashMap<>();
|
||||
this.teamToPlayerMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public String getTeam(Player player) {
|
||||
return playerToTeamMap.get(player.getName());
|
||||
}
|
||||
|
||||
public void removeTeam(String team) {
|
||||
String[] removedMembers = teamToPlayerMap.remove(team);
|
||||
if (removedMembers != null) {
|
||||
for (String member : removedMembers) {
|
||||
playerToTeamMap.remove(member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addMembers(String team, Collection<String> members) {
|
||||
String[] oldMembers = teamToPlayerMap.remove(team);
|
||||
if (oldMembers != null) {
|
||||
String[] newMembers = new String[members.size() + oldMembers.length];
|
||||
int i = 0;
|
||||
for (String m : oldMembers) {
|
||||
newMembers[i] = m;
|
||||
i++;
|
||||
}
|
||||
for (String m : members) {
|
||||
newMembers[i] = m;
|
||||
i++;
|
||||
}
|
||||
teamToPlayerMap.put(team, newMembers);
|
||||
for (String member : newMembers) {
|
||||
playerToTeamMap.put(member, team);
|
||||
}
|
||||
} else {
|
||||
teamToPlayerMap.put(team, members.toArray(new String[0]));
|
||||
for (String member : members) {
|
||||
playerToTeamMap.put(member, team);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeMembers(String team, Collection<String> members) {
|
||||
String[] oldMembers = teamToPlayerMap.remove(team);
|
||||
if (oldMembers != null) {
|
||||
ArrayList<String> newMembers = new ArrayList<>(Arrays.asList(oldMembers));
|
||||
for (String member : members) {
|
||||
playerToTeamMap.remove(member);
|
||||
newMembers.remove(member);
|
||||
}
|
||||
teamToPlayerMap.put(team, newMembers.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ import java.util.Objects;
|
||||
|
||||
public class CNConfig {
|
||||
|
||||
public static String configVersion = "23";
|
||||
public static String configVersion = "26";
|
||||
public static int cacheSize;
|
||||
public static int corePoolSize;
|
||||
public static long keepAliveTime;
|
||||
@@ -54,6 +54,7 @@ public class CNConfig {
|
||||
public static String font;
|
||||
public static char initChar;
|
||||
public static boolean copyPackIA;
|
||||
public static boolean copyPackIAOld;
|
||||
public static boolean copyPackOraxen;
|
||||
public static boolean trChatChannel;
|
||||
public static boolean ventureChatChannel;
|
||||
@@ -80,6 +81,10 @@ public class CNConfig {
|
||||
public static boolean disableTeamManage;
|
||||
public static boolean velocitab;
|
||||
public static boolean unknownTeam;
|
||||
public static boolean createRealTeam;
|
||||
public static boolean enableShader;
|
||||
public static boolean huskChatChannel;
|
||||
public static boolean carbonChatChannel;
|
||||
|
||||
public static void load() {
|
||||
try {
|
||||
@@ -123,9 +128,12 @@ public class CNConfig {
|
||||
ConfigurationSection integrationSection = config.getConfigurationSection("integrations");
|
||||
if (integrationSection != null) {
|
||||
copyPackIA = integrationSection.getBoolean("resource-pack.ItemsAdder", false);
|
||||
copyPackIAOld = integrationSection.getBoolean("resource-pack.ItemsAdder-old-method", false);
|
||||
copyPackOraxen = integrationSection.getBoolean("resource-pack.Oraxen", false);
|
||||
trChatChannel = integrationSection.getBoolean("chat.TrChat", false);
|
||||
ventureChatChannel = integrationSection.getBoolean("chat.VentureChat", false);
|
||||
huskChatChannel = integrationSection.getBoolean("chat.HuskChat", false);
|
||||
carbonChatChannel = integrationSection.getBoolean("chat.CarbonChat", false);
|
||||
tabTeam = integrationSection.getBoolean("team.TAB", false);
|
||||
cmiTeam = integrationSection.getBoolean("team.CMI", false);
|
||||
velocitab = integrationSection.getBoolean("team.Velocitab", false);
|
||||
@@ -154,6 +162,7 @@ public class CNConfig {
|
||||
|
||||
legacyUnicodes = packSection.getBoolean("legacy-unicodes", true);
|
||||
|
||||
enableShader = packSection.getBoolean("shader.enable", true);
|
||||
hideScoreboardNumber = packSection.getBoolean("shader.hide-scoreboard-number", false);
|
||||
animatedImage = packSection.getBoolean("shader.animated-text", false);
|
||||
textEffects = packSection.getBoolean("shader.ItemsAdder-text-effects", false);
|
||||
@@ -166,9 +175,10 @@ public class CNConfig {
|
||||
cacheSize = config.getInt("other-settings.cache-size", 100);
|
||||
|
||||
legacyColorSupport = config.getBoolean("other-settings.legacy-color-code-support");
|
||||
createRealTeam = config.getBoolean("other-settings.create-real-teams", false);
|
||||
}
|
||||
|
||||
public static boolean isOtherTeamPluginHooked() {
|
||||
return tabTeam || cmiTeam;
|
||||
return tabTeam || cmiTeam || unknownTeam;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) <2022> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.paper.util;
|
||||
|
||||
import org.geysermc.api.Geyser;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class GeyserUtils {
|
||||
|
||||
public static boolean isBedrockPlayer(UUID uuid) {
|
||||
return Geyser.api().isBedrockPlayer(uuid);
|
||||
}
|
||||
}
|
||||
@@ -38,10 +38,37 @@ public class Migration {
|
||||
updateBubble();
|
||||
updateNameplate();
|
||||
updateCustomPlaceholders();
|
||||
updateLanguages();
|
||||
deleteFiles();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void updateLanguages() {
|
||||
File messageFolder = new File(CustomNameplatesPlugin.get().getDataFolder(), "messages");
|
||||
if (messageFolder.exists()) {
|
||||
File[] files = messageFolder.listFiles();
|
||||
if (files == null)
|
||||
return;
|
||||
for (File file : files) {
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
ConfigurationSection messageSection = config.getConfigurationSection("messages");
|
||||
if (messageSection != null) {
|
||||
for (String key : messageSection.getKeys(false)) {
|
||||
String original = messageSection.getString(key);
|
||||
if (original != null && original.contains("{Bubbles}")) {
|
||||
messageSection.set(key, original.replace("{Bubbles}", "{Bubble}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void deleteFiles() {
|
||||
try {
|
||||
FileUtils.delete(new File(CustomNameplatesPlugin.get().getDataFolder(), "database.yml"));
|
||||
|
||||
+32
-4
@@ -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 {
|
||||
|
||||
@@ -38,6 +34,9 @@ public class ReflectionUtils {
|
||||
private static Constructor<?> updateConstructor;
|
||||
private static Method iChatComponentMethod;
|
||||
private static Object emptyComponent;
|
||||
private static Method serializeComponentMethod;
|
||||
private static Method keyAsStringMethod;
|
||||
private static Object miniMessageInstance;
|
||||
|
||||
public static void load() {
|
||||
try {
|
||||
@@ -58,6 +57,17 @@ public class ReflectionUtils {
|
||||
LogUtils.severe("Error occurred when loading reflections", exception);
|
||||
exception.printStackTrace();
|
||||
}
|
||||
try {
|
||||
Class<?> componentClass = Class.forName("net;kyori;adventure;text;Component".replace(";", "."));
|
||||
Class<?> miniMessageClass = Class.forName("net;kyori;adventure;text;minimessage;MiniMessage".replace(";", "."));
|
||||
Method miniMessageInstanceGetMethod = miniMessageClass.getMethod("miniMessage");
|
||||
miniMessageInstance = miniMessageInstanceGetMethod.invoke(null);
|
||||
serializeComponentMethod = miniMessageClass.getMethod("serialize", componentClass);
|
||||
Class<?> keyClass = Class.forName("net;kyori;adventure;key;Key".replace(";", "."));
|
||||
keyAsStringMethod = keyClass.getMethod("asString");
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
|
||||
IllegalAccessException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getRemoveBossBarPacket() {
|
||||
@@ -79,4 +89,22 @@ public class ReflectionUtils {
|
||||
public static Object getEmptyComponent() {
|
||||
return emptyComponent;
|
||||
}
|
||||
|
||||
public static String getKeyAsString(Object key) {
|
||||
try {
|
||||
return (String) keyAsStringMethod.invoke(key);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getMiniMessageTextFromNonShadedComponent(Object component) {
|
||||
try {
|
||||
return (String) serializeComponentMethod.invoke(miniMessageInstance, component);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
# Do not change
|
||||
config-version: '23'
|
||||
config-version: '26'
|
||||
|
||||
# Debug mode
|
||||
debug: false
|
||||
@@ -28,6 +28,7 @@ modules:
|
||||
integrations:
|
||||
resource-pack:
|
||||
ItemsAdder: false
|
||||
ItemsAdder-old-method: false
|
||||
Oraxen: false
|
||||
team:
|
||||
unknown: false
|
||||
@@ -37,6 +38,8 @@ integrations:
|
||||
chat:
|
||||
TrChat: false
|
||||
VentureChat: false
|
||||
HuskChat: false
|
||||
CarbonChat: false
|
||||
|
||||
resource-pack:
|
||||
# disable resource pack generation on server start
|
||||
@@ -58,6 +61,8 @@ resource-pack:
|
||||
space-split: 'font\base\'
|
||||
|
||||
shader:
|
||||
# Enable shaders
|
||||
enable: true
|
||||
# Hide scoreboard numbers
|
||||
hide-scoreboard-number: false
|
||||
# Add Animated text support
|
||||
@@ -79,8 +84,12 @@ resource-pack:
|
||||
|
||||
other-settings:
|
||||
# Disable CustomNameplates' team management
|
||||
# Never enable this if you are using "Team" mode for name tags
|
||||
disable-team-management: false
|
||||
|
||||
# Create real teams on serverside. It's not recommended to enable this unless you meet BungeeCord team bugs.
|
||||
create-real-teams: false
|
||||
|
||||
# It's recommended to use MiniMessage format. If you insist on using legacy color code "&", enable the support below.
|
||||
legacy-color-code-support: false
|
||||
|
||||
@@ -96,7 +105,8 @@ other-settings:
|
||||
|
||||
# delay x ticks before actionbar/bossbar is sent to players
|
||||
send-delay: 0
|
||||
# Set the size for the cache system. This is useful and would bring huge performance if you keep it to a reasonable value
|
||||
|
||||
# Set the size for the cache system. This is useful and would bring huge performance improvement if you keep it to a reasonable value
|
||||
# Many developers don't seem to think that parsing text labels would incur significant performance overhead but actually it does through it's running asynchronously.
|
||||
# With cache system, you can save much CPU resource when the same message is displayed to many players.
|
||||
# The more people on your server, the higher the efficiency of the caching system's operation.
|
||||
|
||||
@@ -7,7 +7,8 @@ actionbar:
|
||||
text-display-order:
|
||||
1:
|
||||
# Measured in ticks
|
||||
duration: 1000
|
||||
# -1 = infinite
|
||||
duration: -1
|
||||
# Text content
|
||||
text: '%nameplates_conditional_actionbar%'
|
||||
# The frequency of refreshing the text, the lower the value is, the faster the placeholders are updated
|
||||
|
||||
@@ -19,7 +19,7 @@ text-suffix: ''
|
||||
line-spacing: 0.4
|
||||
|
||||
# This decides where the bottom line is
|
||||
bottom-line-Y-offset: 0.4
|
||||
bottom-line-Y-offset: 0.8
|
||||
|
||||
# This decides how long will the chat bubble remain (in seconds)
|
||||
stay-time: 8
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates/custom-placeholders/conditional-text
|
||||
conditional-text:
|
||||
actionbar:
|
||||
priority_0:
|
||||
text: '%nameplates_background_other_actionbar%'
|
||||
conditions:
|
||||
'!gamemode': survival
|
||||
priority_1:
|
||||
text: '%nameplates_background_other_actionbar%'
|
||||
conditions:
|
||||
'!=':
|
||||
value1: '%player_remaining_air%'
|
||||
value2: "300"
|
||||
'||':
|
||||
'!=':
|
||||
value1: '%player_remaining_air%'
|
||||
value2: "300"
|
||||
'!gamemode': survival
|
||||
priority_2:
|
||||
text: '%nameplates_static_money_hud%%nameplates_offset_-180%%nameplates_static_other_actionbar%'
|
||||
conditions:
|
||||
@@ -63,7 +61,7 @@ background-text:
|
||||
remove-shadow: true
|
||||
hello:
|
||||
background: bedrock_1
|
||||
text: '%nameplates_image_bubble% %nameplates_unicode_hello%'
|
||||
text: '%nameplates_image_bubble% %nameplates_descent_hello%'
|
||||
remove-shadow: true
|
||||
update:
|
||||
background: bedrock_1
|
||||
@@ -85,7 +83,7 @@ static-text:
|
||||
text: "%nameplates_background_other_actionbar%"
|
||||
value: 180
|
||||
|
||||
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates/custom-placeholders/static-text
|
||||
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates/custom-placeholders/descent-text
|
||||
descent-text:
|
||||
location:
|
||||
text: "Your Location: %player_x%, %player_y%, %player_z%"
|
||||
|
||||
@@ -22,4 +22,14 @@ minecraft:alt:
|
||||
minecraft:asciillager:
|
||||
default: 8
|
||||
template-loading-sequence:
|
||||
- asciillager
|
||||
- asciillager
|
||||
|
||||
customcrops:default:
|
||||
default: 8
|
||||
template-loading-sequence: []
|
||||
values:
|
||||
뀁: -2
|
||||
뀂: 4
|
||||
뀃: 6
|
||||
뀄: 6
|
||||
뀅: 4
|
||||
@@ -15,7 +15,7 @@ messages:
|
||||
force-unequip-nameplates: '<white>你已强制卸下玩家 {Player} 的铭牌!</white>'
|
||||
not-exist-nameplates: '<white>那个铭牌不存在!</white>'
|
||||
not-available-nameplates: '<white>你还未拥有这个铭牌!</white>'
|
||||
available-nameplates: '<white>可用铭牌: {Nameplates}</white>'
|
||||
available-nameplates: '<white>可用铭牌: {Nameplate}</white>'
|
||||
have-no-nameplates: '<white>你还没有拥有任何铭牌.</white>'
|
||||
force-preview: '<white>正在强制玩家 {Player} 预览铭牌</white>'
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ messages:
|
||||
force-unequip-nameplates: '<white>Successfully removed {Player}''s nameplate!</white>'
|
||||
not-exist-nameplates: '<white>This nameplate does not exist!</white>'
|
||||
not-available-nameplates: '<white>This nameplate is currently not available!</white>'
|
||||
available-nameplates: '<white>Available nameplates: {Nameplates}.</white>'
|
||||
available-nameplates: '<white>Available nameplates: {Nameplate}.</white>'
|
||||
have-no-nameplates: '<white>You don''t have any nameplate yet'
|
||||
force-preview: '<white>Forced {Player} to preview the nameplate</white>'
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ messages:
|
||||
force-unequip-nameplates: '<white>La plaque de nom de {Player} a été retirée avec succès !</white>'
|
||||
not-exist-nameplates: '<white>Cette plaque de nom n'existe pas !</white>'
|
||||
not-available-nameplates: '<white>Cette plaque de nom n'est actuellement pas disponible !</white>'
|
||||
available-nameplates: '<white>Plaques de nom disponibles : {Nameplates}.</white>'
|
||||
available-nameplates: '<white>Plaques de nom disponibles : {Nameplate}.</white>'
|
||||
have-no-nameplates: '<white>Vous n'avez pas encore de plaque de nom</white>'
|
||||
force-preview: '<white>Forced {Player} to preview the nameplate</white>'
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ messages:
|
||||
force-unequip-nameplates: '<white>Успешно снят Нэймплейт у {Player}!</white>'
|
||||
not-exist-nameplates: '<white>Такой Нэйплейт не существует!</white>'
|
||||
not-available-nameplates: '<white>Этот Нэймплейт сейчас недоступен!</white>'
|
||||
available-nameplates: '<white>Доступные Нэймплейты: {Nameplates}.</white>'
|
||||
available-nameplates: '<white>Доступные Нэймплейты: {Nameplate}.</white>'
|
||||
have-no-nameplates: '<white>У вас еще нет никаких Нэймплейтов.'
|
||||
force-preview: '<white>Forced {Player} to preview the nameplate</white>'
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ messages:
|
||||
force-unequip-nameplates: '<white>Eliminado con éxito {Player}''s nameplate!</white>'
|
||||
not-exist-nameplates: '<white>Este nameplate no existe!</white>'
|
||||
not-available-nameplates: '<white>Este nameplate no esta actualmente disponible!</white>'
|
||||
available-nameplates: '<white>Nameplates Disponibles: {Nameplates}.</white>'
|
||||
available-nameplates: '<white>Nameplates Disponibles: {Nameplate}.</white>'
|
||||
have-no-nameplates: '<white>No tienes ningun nameplate aun'
|
||||
force-preview: '<white>Forced {Player} to preview the nameplate</white>'
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ messages:
|
||||
force-unequip-nameplates: '<white>{Player} oyuncusunun isim etiketi başarıyla kaldırıldı!</white>'
|
||||
not-exist-nameplates: '<white>Bu isim etiketi mevcut değil!</white>'
|
||||
not-available-nameplates: '<white>Bu isim etiketi şu anda kullanılabilir değil!</white>'
|
||||
available-nameplates: '<white>Mevcut isim etiketleri: {Nameplates}.</white>'
|
||||
available-nameplates: '<white>Mevcut isim etiketleri: {Nameplate}.</white>'
|
||||
have-no-nameplates: '<white>Henüz hiç isim etiketiniz yok</white>'
|
||||
force-preview: '<white>Forced {Player} to preview the nameplate</white>'
|
||||
|
||||
|
||||
@@ -5,35 +5,36 @@ api-version: 1.17
|
||||
authors: [ XiaoMoMi ]
|
||||
folia-supported: true
|
||||
depend: [ ProtocolLib ,PlaceholderAPI ]
|
||||
softdepend: [ MagicCosmetics, TAB, CMI, TrChat, ItemsAdder, Oraxen ]
|
||||
softdepend: [ MagicCosmetics, TAB, CMI, TrChat, ItemsAdder, Oraxen, CarbonChat, HuskChat ]
|
||||
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: true
|
||||
+1
-1
@@ -119,7 +119,7 @@ public class CustomNameplatesVelocity {
|
||||
if (!owner.isActive() || !viewer.isActive()) {
|
||||
return;
|
||||
}
|
||||
String teamNameRetry = teamManager.getTeamName(owner);
|
||||
String teamNameRetry = teamManager.getTeam(owner, null);
|
||||
if (teamNameRetry != null) {
|
||||
teamManager.sendTeamUpdatePacket(viewer, teamNameRetry, teamColor, visibility,
|
||||
MiniMessage.miniMessage().deserialize(prefix),
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public class VelocitabManager implements VelocityTeamManager {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getTeamName(Player player) {
|
||||
public String getTeam(Player player, Player viewer) {
|
||||
Optional<TabPlayer> playerOptional = velocitabAPI.getUser(player);
|
||||
return playerOptional.map(TabPlayer::getTeamName).orElse(null);
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface VelocityTeamManager {
|
||||
|
||||
@Nullable
|
||||
String getTeamName(Player player);
|
||||
String getTeam(Player player, Player viewer);
|
||||
|
||||
void sendTeamUpdatePacket(Player receiver, String team, TeamColor color, TeamTagVisibility visibility, Component prefix, Component suffix);
|
||||
}
|
||||
Reference in new issue
Block a user