mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 06:28:53 +00:00
Add custom placeholder support
This commit is contained in:
1 parent
cae78d848a
commit
7ef548cbd3
4 files changed
+44
-9
No files matched your search
@@ -141,26 +141,26 @@ public final class CarbonChat extends JavaPlugin {
|
|||||||
private void setupListeners() {
|
private void setupListeners() {
|
||||||
PluginManager pluginManager = getServer().getPluginManager();
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
|
|
||||||
|
filterHandler = new FilterHandler(this);
|
||||||
|
|
||||||
// Register chat listeners
|
// Register chat listeners
|
||||||
pluginManager.registerEvents(new BukkitChatListener(this), this);
|
pluginManager.registerEvents(new BukkitChatListener(this), this);
|
||||||
|
pluginManager.registerEvents(new CapsHandler(this), this);
|
||||||
|
pluginManager.registerEvents(new CustomPlaceholderHandler(this), this);
|
||||||
|
pluginManager.registerEvents(filterHandler, this);
|
||||||
pluginManager.registerEvents(new IgnoredPlayerHandler(), this);
|
pluginManager.registerEvents(new IgnoredPlayerHandler(), this);
|
||||||
pluginManager.registerEvents(new ItemLinkHandler(this), this);
|
pluginManager.registerEvents(new ItemLinkHandler(this), this);
|
||||||
pluginManager.registerEvents(new LegacyFormatHandler(), this);
|
pluginManager.registerEvents(new LegacyFormatHandler(), this);
|
||||||
|
pluginManager.registerEvents(new MuteHandler(), this);
|
||||||
pluginManager.registerEvents(new OfflineNameHandler(), this);
|
pluginManager.registerEvents(new OfflineNameHandler(), this);
|
||||||
pluginManager.registerEvents(new PingHandler(this), this);
|
pluginManager.registerEvents(new PingHandler(this), this);
|
||||||
pluginManager.registerEvents(new PlaceholderHandler(), this);
|
pluginManager.registerEvents(new PlaceholderHandler(), this);
|
||||||
pluginManager.registerEvents(new PlayerJoinListener(this), this);
|
pluginManager.registerEvents(new PlayerJoinListener(this), this);
|
||||||
pluginManager.registerEvents(new RelationalPlaceholderHandler(), this);
|
pluginManager.registerEvents(new RelationalPlaceholderHandler(), this);
|
||||||
pluginManager.registerEvents(new UserFormattingListener(), this);
|
pluginManager.registerEvents(new ShadowMuteHandler(this), this);
|
||||||
|
pluginManager.registerEvents(new UserFormattingHandler(), this);
|
||||||
pluginManager.registerEvents(new WhisperPingHandler(this), this);
|
pluginManager.registerEvents(new WhisperPingHandler(this), this);
|
||||||
|
|
||||||
pluginManager.registerEvents(new CapsHandler(this), this);
|
|
||||||
|
|
||||||
filterHandler = new FilterHandler(this);
|
|
||||||
pluginManager.registerEvents(filterHandler, this);
|
|
||||||
|
|
||||||
pluginManager.registerEvents(new MuteHandler(), this);
|
|
||||||
pluginManager.registerEvents(new ShadowMuteHandler(this), this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package net.draycia.carbon.listeners;
|
||||||
|
|
||||||
|
import net.draycia.carbon.CarbonChat;
|
||||||
|
import net.draycia.carbon.events.PreChatFormatEvent;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public class CustomPlaceholderHandler implements Listener {
|
||||||
|
|
||||||
|
private final CarbonChat carbonChat;
|
||||||
|
|
||||||
|
public CustomPlaceholderHandler(CarbonChat carbonChat) {
|
||||||
|
this.carbonChat = carbonChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
|
public void onPapiPlaceholder(PreChatFormatEvent event) {
|
||||||
|
ConfigurationSection placeholders = carbonChat.getConfig().getConfigurationSection("placeholders");
|
||||||
|
|
||||||
|
for (String key : placeholders.getKeys(false)) {
|
||||||
|
String value = placeholders.getString(key);
|
||||||
|
|
||||||
|
event.setFormat(event.getFormat().replace("<" + key + ">", value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public class UserFormattingListener implements Listener {
|
public class UserFormattingHandler implements Listener {
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onFormat(PreChatFormatEvent event) {
|
public void onFormat(PreChatFormatEvent event) {
|
||||||
@@ -93,6 +93,12 @@ channels:
|
|||||||
is-cross-server: false
|
is-cross-server: false
|
||||||
message-prefix: '!'
|
message-prefix: '!'
|
||||||
|
|
||||||
|
# Used for message formats - custom tags that are replaced in descending order
|
||||||
|
# For example, in the default config, <group> wil be replaced with <green>%vault_group%
|
||||||
|
placeholders:
|
||||||
|
prefix: "<gray>[<group><gray>]"
|
||||||
|
group: "<green>%vault_group%"
|
||||||
|
|
||||||
# Global context options
|
# Global context options
|
||||||
contexts:
|
contexts:
|
||||||
Towny:
|
Towny:
|
||||||
|
|||||||
Reference in new issue
Block a user