9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-19 15:09:23 +00:00

Added API to take over actionbars

This commit is contained in:
XiaoMoMi
2024-12-26 18:14:06 +08:00
parent 23bde6ab9d
commit 0270830517
13 changed files with 138 additions and 3 deletions

View File

@@ -67,12 +67,28 @@ public abstract class AbstractCNPlayer implements CNPlayer {
private final Map<CNPlayer, Tracker> trackers = new WeakHashMap<>();
private final ReadWriteLock trackerLock = new ReentrantReadWriteLock();
private final List<String> otherActionBarFeatures = new ArrayList<>();
protected AbstractCNPlayer(CustomNameplates plugin, Channel channel) {
this.plugin = plugin;
this.channel = channel;
}
@Override
public void acquireActionBar(String id) {
this.otherActionBarFeatures.add(id);
}
@Override
public void releaseActionBar(String id) {
this.otherActionBarFeatures.remove(id);
}
@Override
public boolean shouldCNTakeOverActionBar() {
return otherActionBarFeatures.isEmpty();
}
@Override
public List<Placeholder> activePlaceholdersToRefresh() {
Placeholder[] activePlaceholders = activePlaceholders();

View File

@@ -181,6 +181,27 @@ public interface CNPlayer {
*/
Placeholder[] activePlaceholders();
/**
* Acquires the actionbar, preventing CustomNameplates from taking control of it.
*
* @param id The feature ID requesting the actionbar.
*/
void acquireActionBar(String id);
/**
* Releases the actionbar, allowing CustomNameplates to take control again if no other features are active.
*
* @param id The feature ID releasing the actionbar.
*/
void releaseActionBar(String id);
/**
* Checks if CustomNameplates should take control of the actionbar.
*
* @return True if CustomNameplates should take over the actionbar, false otherwise.
*/
boolean shouldCNTakeOverActionBar();
/**
* Retrieves the list of placeholders that need to be refreshed based on their refresh intervals.
*

View File

@@ -115,6 +115,9 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
protected boolean chatChatControlRed;
protected boolean chatChatty;
protected boolean twDialogue;
protected boolean twCinematic;
protected String configVersion;
public ConfigManager(CustomNameplates plugin) {
@@ -196,6 +199,9 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
chatChatControlRed = config.getBoolean("integrations.chat.ChatControlRed", false);
chatChatty = config.getBoolean("integrations.chat.Chatty", false);
twDialogue = config.getBoolean("integrations.typewriter.dialogue", true);
twCinematic = config.getBoolean("integrations.typewriter.cinematic", true);
// Packs
generateOnStart = !config.getBoolean("resource-pack.disable-generation-on-start", false);
namespace = config.getString("resource-pack.namespace", "nameplates");
@@ -365,6 +371,14 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
return instance.metrics;
}
public static boolean twDialogue() {
return instance.twDialogue;
}
public static boolean twCinematic() {
return instance.twCinematic;
}
public static int defaultPlaceholderRefreshInterval() {
return instance.defaultPlaceholderRefreshInterval;
}