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:
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user