mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-17 07:35:38 +01:00
Add PlaceholderAPI support.
This commit is contained in:
parent
1bc82b84e1
commit
9543e665ab
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.cnaude.purpleirc.Hooks;
|
||||
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -24,11 +25,24 @@ import org.bukkit.entity.Player;
|
||||
* @author Chris Naude
|
||||
*/
|
||||
public class PlaceholderApiHook {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin the PurpleIRC plugin
|
||||
*/
|
||||
public PlaceholderApiHook(PurpleIRC plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public String setPlaceholders(Player player, String message) {
|
||||
String m = message;
|
||||
plugin.logDebug("[setPlaceholders: before] " + m);
|
||||
if (player != null && message != null) {
|
||||
return PlaceholderAPI.setPlaceholders(player, message);
|
||||
m = PlaceholderAPI.setPlaceholders(player, message);
|
||||
}
|
||||
return "";
|
||||
plugin.logDebug("[setPlaceholders: after] " + m);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
@ -1741,7 +1741,7 @@ public class PurpleIRC extends JavaPlugin {
|
||||
}
|
||||
if (isPluginEnabled(PL_PLACEHOLDERAPI)) {
|
||||
hookList.add(hookFormat(PL_PLACEHOLDERAPI, true));
|
||||
placeholderApiHook = new PlaceholderApiHook();
|
||||
placeholderApiHook = new PlaceholderApiHook(this);
|
||||
} else {
|
||||
hookList.add(hookFormat(PL_PLACEHOLDERAPI, false));
|
||||
}
|
||||
|
@ -199,8 +199,8 @@ public class ChatTokenizer {
|
||||
.replace("%MESSAGE%", message)
|
||||
.replace("%CHANNEL%", channel.getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Normal IRC to game chat tokenizer
|
||||
*
|
||||
* @param ircBot
|
||||
@ -890,6 +890,11 @@ public class ChatTokenizer {
|
||||
}
|
||||
}
|
||||
plugin.logDebug("[P]Raw message: " + message);
|
||||
|
||||
if (plugin.placeholderApiHook != null) {
|
||||
message = plugin.placeholderApiHook.setPlaceholders(player, message);
|
||||
}
|
||||
|
||||
return message.replace("%DISPLAYNAME%", displayName)
|
||||
.replace("%UUID%", uuid.toString())
|
||||
.replace("%JOBS%", job)
|
||||
@ -976,10 +981,10 @@ public class ChatTokenizer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (plugin.placeholderApiHook != null) {
|
||||
message = plugin.placeholderApiHook.setPlaceholders(player, message);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.logDebug("[S]Raw message: " + message);
|
||||
return message.replace("%DISPLAYNAME%", displayName)
|
||||
|
Loading…
Reference in New Issue
Block a user