mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 10:39:05 +00:00
Add JSON to any PlaceholderAPI placeholder.
This commit is contained in:
parent
dba9ab7d12
commit
47ee2c3ccf
@ -6,6 +6,7 @@ import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
|||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||||
|
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||||
|
|
||||||
public class VentureChatPlaceholders extends PlaceholderExpansion {
|
public class VentureChatPlaceholders extends PlaceholderExpansion {
|
||||||
@Override
|
@Override
|
||||||
@ -24,49 +25,32 @@ public class VentureChatPlaceholders extends PlaceholderExpansion {
|
|||||||
return "value for that identifier *";
|
return "value for that identifier *";
|
||||||
}
|
}
|
||||||
if (identifier.startsWith("channel_")) {
|
if (identifier.startsWith("channel_")) {
|
||||||
if (mcp.getCurrentChannel() == null) {
|
ChatChannel currentChannel = mcp.hasQuickChannel() ? mcp.getQuickChannel() : mcp.getCurrentChannel();
|
||||||
|
if (currentChannel == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
switch (identifier) {
|
switch (identifier) {
|
||||||
case "channel_name":
|
case "channel_name":
|
||||||
return mcp.getCurrentChannel().getName();
|
return currentChannel.getName();
|
||||||
case "channel_alias":
|
case "channel_alias":
|
||||||
return mcp.getCurrentChannel().getAlias();
|
return currentChannel.getAlias();
|
||||||
case "channel_color":
|
case "channel_color":
|
||||||
return this.textToHex(mcp.getCurrentChannel().getColor());
|
return currentChannel.getColor();
|
||||||
case "channel_chatcolor":
|
case "channel_chatcolor":
|
||||||
return this.textToHex(mcp.getCurrentChannel().getChatColor());
|
return currentChannel.getChatColor();
|
||||||
case "channel_is_bungee":
|
case "channel_is_bungee":
|
||||||
return mcp.getCurrentChannel().getBungee() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
return currentChannel.getBungee() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
||||||
case "channel_cooldown":
|
case "channel_cooldown":
|
||||||
return mcp.getCurrentChannel().getCooldown() + "";
|
return currentChannel.getCooldown() + "";
|
||||||
case "channel_distance":
|
case "channel_distance":
|
||||||
return mcp.getCurrentChannel().getDistance() + "";
|
return currentChannel.getDistance() + "";
|
||||||
|
case "channel_prefix":
|
||||||
|
return currentChannel.getPrefix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String textToHex(String color) {
|
|
||||||
if (color.equalsIgnoreCase("black")) return "0";
|
|
||||||
if (color.equalsIgnoreCase("dark_blue")) return "1";
|
|
||||||
if (color.equalsIgnoreCase("dark_green")) return "2";
|
|
||||||
if (color.equalsIgnoreCase("dark_aqua")) return "3";
|
|
||||||
if (color.equalsIgnoreCase("dark_red")) return "4";
|
|
||||||
if (color.equalsIgnoreCase("dark_purple")) return "5";
|
|
||||||
if (color.equalsIgnoreCase("gold")) return "6";
|
|
||||||
if (color.equalsIgnoreCase("gray")) return "7";
|
|
||||||
if (color.equalsIgnoreCase("dark_gray")) return "8";
|
|
||||||
if (color.equalsIgnoreCase("blue")) return "9";
|
|
||||||
if (color.equalsIgnoreCase("green")) return "a";
|
|
||||||
if (color.equalsIgnoreCase("aqua")) return "b";
|
|
||||||
if (color.equalsIgnoreCase("red")) return "c";
|
|
||||||
if (color.equalsIgnoreCase("light_purple")) return "d";
|
|
||||||
if (color.equalsIgnoreCase("yellow")) return "e";
|
|
||||||
if (color.equalsIgnoreCase("white")) return "f";
|
|
||||||
return "f";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean persist() {
|
public boolean persist() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -47,6 +47,7 @@ public class ChatChannel {
|
|||||||
private boolean bungee;
|
private boolean bungee;
|
||||||
private String format;
|
private String format;
|
||||||
private int cooldown;
|
private int cooldown;
|
||||||
|
private String prefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read chat channels from config file and initialize channel array.
|
* Read chat channels from config file and initialize channel array.
|
||||||
@ -73,8 +74,9 @@ public class ChatChannel {
|
|||||||
double distance = cs.getDouble(key + ".distance", (double) 0);
|
double distance = cs.getDouble(key + ".distance", (double) 0);
|
||||||
int cooldown = cs.getInt(key + ".cooldown", 0);
|
int cooldown = cs.getInt(key + ".cooldown", 0);
|
||||||
boolean autojoin = cs.getBoolean(key + ".autojoin", false);
|
boolean autojoin = cs.getBoolean(key + ".autojoin", false);
|
||||||
|
String prefix = cs.getString(key + ".channel_prefix");
|
||||||
ChatChannel chatChannel = new ChatChannel(name, color, chatColor, permission, speakPermission, mutable,
|
ChatChannel chatChannel = new ChatChannel(name, color, chatColor, permission, speakPermission, mutable,
|
||||||
filter, defaultChannel, alias, distance, autojoin, bungee, cooldown, format);
|
filter, defaultChannel, alias, distance, autojoin, bungee, cooldown, prefix, format);
|
||||||
channels[counter++] = chatChannel;
|
channels[counter++] = chatChannel;
|
||||||
chatChannels.put(name.toLowerCase(), chatChannel);
|
chatChannels.put(name.toLowerCase(), chatChannel);
|
||||||
chatChannels.put(alias.toLowerCase(), chatChannel);
|
chatChannels.put(alias.toLowerCase(), chatChannel);
|
||||||
@ -87,7 +89,7 @@ public class ChatChannel {
|
|||||||
if(defaultChatChannel == null) {
|
if(defaultChatChannel == null) {
|
||||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - &cNo default channel found!"));
|
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - &cNo default channel found!"));
|
||||||
defaultChatChannel = new ChatChannel("MissingDefault", "red", "red", "None", "None", false,
|
defaultChatChannel = new ChatChannel("MissingDefault", "red", "red", "None", "None", false,
|
||||||
true, true, "md", 0, true, false, 0, "&f[&cMissingDefault&f] {vault_prefix} {player_displayname}&c:");
|
true, true, "md", 0, true, false, 0, "&f[&cMissingDefault&f]", "{venturechat_channel_prefix} {vault_prefix}{player_displayname}&c:");
|
||||||
defaultColor = defaultChatChannel.getColor();
|
defaultColor = defaultChatChannel.getColor();
|
||||||
chatChannels.put("missingdefault", defaultChatChannel);
|
chatChannels.put("missingdefault", defaultChatChannel);
|
||||||
chatChannels.put("md", defaultChatChannel);
|
chatChannels.put("md", defaultChatChannel);
|
||||||
@ -192,7 +194,7 @@ public class ChatChannel {
|
|||||||
*/
|
*/
|
||||||
public ChatChannel(String name, String color, String chatColor, String permission, String speakPermission,
|
public ChatChannel(String name, String color, String chatColor, String permission, String speakPermission,
|
||||||
boolean mutable, boolean filter, boolean defaultChannel, String alias, double distance, boolean autojoin,
|
boolean mutable, boolean filter, boolean defaultChannel, String alias, double distance, boolean autojoin,
|
||||||
boolean bungee, int cooldown, String format) {
|
boolean bungee, int cooldown, String prefix, String format) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.chatColor = chatColor;
|
this.chatColor = chatColor;
|
||||||
@ -207,6 +209,7 @@ public class ChatChannel {
|
|||||||
this.bungee = bungee;
|
this.bungee = bungee;
|
||||||
this.cooldown = cooldown;
|
this.cooldown = cooldown;
|
||||||
this.format = format;
|
this.format = format;
|
||||||
|
this.prefix = prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -274,6 +277,14 @@ public class ChatChannel {
|
|||||||
return cooldown;
|
return cooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the prefix of the chat channel.
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public String getPrefix() {
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the chat channel is BungeeCord enabled.
|
* Check if the chat channel is BungeeCord enabled.
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package mineverse.Aust1n46.chat.json;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class JsonAttribute {
|
||||||
|
private String name;
|
||||||
|
private List<String> hoverText;
|
||||||
|
private String clickAction;
|
||||||
|
private String clickText;
|
||||||
|
|
||||||
|
public JsonAttribute(String name, List<String> hoverText, String clickAction, String clickText) {
|
||||||
|
this.name = name;
|
||||||
|
this.hoverText = hoverText;
|
||||||
|
this.clickAction = clickAction;
|
||||||
|
this.clickText = clickText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getHoverText() {
|
||||||
|
return hoverText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClickAction() {
|
||||||
|
return clickAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClickText() {
|
||||||
|
return clickText;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package mineverse.Aust1n46.chat.json;
|
package mineverse.Aust1n46.chat.json;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -12,48 +13,30 @@ public class JsonFormat {
|
|||||||
private static MineverseChat plugin = MineverseChat.getInstance();
|
private static MineverseChat plugin = MineverseChat.getInstance();
|
||||||
private static HashMap<String, JsonFormat> jsonFormats;
|
private static HashMap<String, JsonFormat> jsonFormats;
|
||||||
|
|
||||||
private List<String> hoverTextName;
|
private List<JsonAttribute> jsonAttributes;
|
||||||
private List<String> hoverTextPrefix;
|
|
||||||
private List<String> hoverTextSuffix;
|
|
||||||
private String clickName;
|
|
||||||
private String clickNameText;
|
|
||||||
private String clickPrefix;
|
|
||||||
private String clickPrefixText;
|
|
||||||
private String clickSuffix;
|
|
||||||
private String clickSuffixText;
|
|
||||||
private int priority;
|
private int priority;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public JsonFormat(String name, int priority, List<String> hoverTextName, String clickName, String clickNameText, List<String> hoverTextPrefix, String clickPrefix, String clickPrefixText, String clickSuffix, String clickSuffixText, List<String> hoverTextSuffix) {
|
public JsonFormat(String name, int priority, List<JsonAttribute> jsonAttributes) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
this.hoverTextName = hoverTextName;
|
this.jsonAttributes = jsonAttributes;
|
||||||
this.clickNameText = clickNameText;
|
|
||||||
this.hoverTextPrefix = hoverTextPrefix;
|
|
||||||
this.clickPrefix = clickPrefix;
|
|
||||||
this.clickPrefixText = clickPrefixText;
|
|
||||||
this.clickName = clickName;
|
|
||||||
this.clickSuffix = clickSuffix;
|
|
||||||
this.clickSuffixText = clickSuffixText;
|
|
||||||
this.hoverTextSuffix = hoverTextSuffix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
jsonFormats = new HashMap<String, JsonFormat>();
|
jsonFormats = new HashMap<String, JsonFormat>();
|
||||||
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("jsonformatting");
|
ConfigurationSection jsonFormatSection = plugin.getConfig().getConfigurationSection("jsonformatting");
|
||||||
for (String key : cs.getKeys(false)) {
|
for (String jsonFormat : jsonFormatSection.getKeys(false)) {
|
||||||
String name = key;
|
int priority = jsonFormatSection.getInt(jsonFormat + ".priority", 0);
|
||||||
int priority = cs.getInt(key + ".priority", 0);
|
List<JsonAttribute> jsonAttributes = new ArrayList<>();
|
||||||
List<String> hoverTextName = cs.getStringList(key + ".hover_name");
|
ConfigurationSection jsonAttributeSection = jsonFormatSection.getConfigurationSection(jsonFormat + ".json_attributes");
|
||||||
List<String> hoverTextPrefix = cs.getStringList(key + ".hover_prefix");
|
for (String attribute : jsonAttributeSection.getKeys(false)) {
|
||||||
List<String> hoverTextSuffix = cs.getStringList(key + ".hover_suffix");
|
List<String> hoverText = jsonAttributeSection.getStringList(attribute + ".hover_text");
|
||||||
String clickPrefix = cs.getString(key + ".click_prefix");
|
String clickAction = jsonAttributeSection.getString(attribute + ".click_action");
|
||||||
String clickName = cs.getString(key + ".click_name");
|
String clickText = jsonAttributeSection.getString(attribute + ".click_text");
|
||||||
String clickNameText = cs.getString(key + ".click_name_text");
|
jsonAttributes.add(new JsonAttribute(attribute, hoverText, clickAction, clickText));
|
||||||
String clickPrefixText = cs.getString(key + ".click_prefix_text");
|
}
|
||||||
String clickSuffixText = cs.getString(key + ".click_suffix_text");
|
jsonFormats.put(jsonFormat.toLowerCase(), new JsonFormat(jsonFormat, priority, jsonAttributes));
|
||||||
String clickSuffix = cs.getString(key + ".click_suffix");
|
|
||||||
jsonFormats.put(name.toLowerCase(), new JsonFormat(name, priority, hoverTextName, clickName, clickNameText, hoverTextPrefix, clickPrefix, clickPrefixText, clickSuffix, clickSuffixText, hoverTextSuffix));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,43 +52,11 @@ public class JsonFormat {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClickName() {
|
|
||||||
return clickName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClickNameText() {
|
|
||||||
return clickNameText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClickSuffix() {
|
|
||||||
return clickSuffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClickSuffixText() {
|
|
||||||
return clickSuffixText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPriority() {
|
public int getPriority() {
|
||||||
return priority;
|
return priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getHoverTextName() {
|
public List<JsonAttribute> getJsonAttributes() {
|
||||||
return hoverTextName;
|
return jsonAttributes;
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getHoverTextPrefix() {
|
|
||||||
return hoverTextPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getHoverTextSuffix() {
|
|
||||||
return hoverTextSuffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClickPrefix() {
|
|
||||||
return clickPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClickPrefixText() {
|
|
||||||
return clickPrefixText;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,11 +343,12 @@ public class ChatListener implements Listener {
|
|||||||
chDistance = eventChannel.getDistance();
|
chDistance = eventChannel.getDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
format = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), Format.FormatStringAll(eventChannel.getFormat())));
|
// format = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), Format.FormatStringAll(eventChannel.getFormat())));
|
||||||
if(plugin.getConfig().getBoolean("formatcleaner", false)) {
|
// if(plugin.getConfig().getBoolean("formatcleaner", false)) {
|
||||||
format = format.replace("[]", " ");
|
// format = format.replace("[]", " ");
|
||||||
format = format.replace(" ", " ").replace(" ", " ").replace(" ", " ");
|
// format = format.replace(" ", " ").replace(" ", " ").replace(" ", " ");
|
||||||
}
|
// }
|
||||||
|
format = Format.FormatStringAll(eventChannel.getFormat());
|
||||||
|
|
||||||
filterthis = eventChannel.isFiltered();
|
filterthis = eventChannel.isFiltered();
|
||||||
if(filterthis) {
|
if(filterthis) {
|
||||||
@ -478,7 +479,6 @@ public class ChatListener implements Listener {
|
|||||||
if(!mcp.isQuickChat()) {
|
if(!mcp.isQuickChat()) {
|
||||||
chat = " " + chat;
|
chat = " " + chat;
|
||||||
}
|
}
|
||||||
mcp.setQuickChat(false);
|
|
||||||
if(curColor.equalsIgnoreCase("None")) {
|
if(curColor.equalsIgnoreCase("None")) {
|
||||||
chat = Format.getLastCode(format) + chat;
|
chat = Format.getLastCode(format) + chat;
|
||||||
}
|
}
|
||||||
@ -497,6 +497,8 @@ public class ChatListener implements Listener {
|
|||||||
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
||||||
//Call method to send the processed chat
|
//Call method to send the processed chat
|
||||||
handleVentureChatEvent(ventureChatEvent);
|
handleVentureChatEvent(ventureChatEvent);
|
||||||
|
// Reset quick chat flag
|
||||||
|
mcp.setQuickChat(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleVentureChatEvent(VentureChatEvent event) {
|
public void handleVentureChatEvent(VentureChatEvent event) {
|
||||||
|
@ -22,9 +22,9 @@ import com.comphenix.protocol.events.PacketContainer;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import mineverse.Aust1n46.chat.MineverseChat;
|
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||||
|
import mineverse.Aust1n46.chat.json.JsonAttribute;
|
||||||
import mineverse.Aust1n46.chat.json.JsonFormat;
|
import mineverse.Aust1n46.chat.json.JsonFormat;
|
||||||
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
import mineverse.Aust1n46.chat.localization.LocalizedMessage;
|
||||||
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
import mineverse.Aust1n46.chat.versions.VersionHandler;
|
||||||
@ -67,32 +67,7 @@ public class Format {
|
|||||||
String f = escapeJsonChars(format);
|
String f = escapeJsonChars(format);
|
||||||
String c = escapeJsonChars(chat);
|
String c = escapeJsonChars(chat);
|
||||||
String json = "[\"\",{\"text\":\"\",\"extra\":[";
|
String json = "[\"\",{\"text\":\"\",\"extra\":[";
|
||||||
String prefix = "";
|
json += convertPlaceholders(f, JSONformat, sender);
|
||||||
String suffix = "";
|
|
||||||
try {
|
|
||||||
prefix = FormatStringAll(MineverseChat.getVaultChat().getPlayerPrefix(sender.getPlayer()));
|
|
||||||
suffix = FormatStringAll(MineverseChat.getVaultChat().getPlayerSuffix(sender.getPlayer()));
|
|
||||||
// Don't apply JSON if the prefix or suffix is just a color code
|
|
||||||
if (suffix.isEmpty() || (suffix.length() == 2 && suffix.substring(1).matches("[0-9a-fA-F]"))) {
|
|
||||||
suffix = "venturechat_no_suffix_code";
|
|
||||||
}
|
|
||||||
if (prefix.isEmpty() || (prefix.length() == 2 && prefix.substring(1).matches("[0-9a-fA-F]"))) {
|
|
||||||
prefix = "venturechat_no_prefix_code";
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("Exception?" + e.getLocalizedMessage());
|
|
||||||
if (getInstance().getConfig().getString("loglevel", "info").equals("debug")) {
|
|
||||||
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll(
|
|
||||||
"&8[&eVentureChat&8]&e - Prefix and / or suffix don't exist, setting to nothing."));
|
|
||||||
}
|
|
||||||
suffix = "venturechat_no_suffix_code";
|
|
||||||
prefix = "venturechat_no_prefix_code";
|
|
||||||
}
|
|
||||||
String nickname = "";
|
|
||||||
if (sender.getPlayer() != null) {
|
|
||||||
nickname = FormatStringAll(sender.getPlayer().getDisplayName());
|
|
||||||
}
|
|
||||||
json += convertPlaceholders(f, JSONformat, prefix, nickname, suffix, sender);
|
|
||||||
json += "]}";
|
json += "]}";
|
||||||
json += "," + convertLinks(c);
|
json += "," + convertLinks(c);
|
||||||
json += "]";
|
json += "]";
|
||||||
@ -118,61 +93,47 @@ public class Format {
|
|||||||
* @param icp
|
* @param icp
|
||||||
* @return {@link String}
|
* @return {@link String}
|
||||||
*/
|
*/
|
||||||
private static String convertPlaceholders(String s, JsonFormat format, String prefix, String nickname,
|
private static String convertPlaceholders(String s, JsonFormat format, MineverseChatPlayer icp) {
|
||||||
String suffix, MineverseChatPlayer icp) {
|
|
||||||
String remaining = s;
|
String remaining = s;
|
||||||
String temp = "";
|
String temp = "";
|
||||||
int indexStart = -1;
|
int indexStart = -1;
|
||||||
int indexEnd = -1;
|
int indexEnd = -1;
|
||||||
String placeholder = "";
|
String placeholder = "";
|
||||||
|
String formattedPlaceholder = "";
|
||||||
String lastCode = DEFAULT_COLOR_CODE;
|
String lastCode = DEFAULT_COLOR_CODE;
|
||||||
do {
|
do {
|
||||||
Pattern pattern = Pattern.compile(
|
Pattern pattern = Pattern.compile("(\\{[A-Za-z0-9-_]+\\})");
|
||||||
"(" + escapeAllRegex(prefix) + "|" + escapeAllRegex(nickname) + "|" + escapeAllRegex(suffix) + ")");
|
|
||||||
Matcher matcher = pattern.matcher(remaining);
|
Matcher matcher = pattern.matcher(remaining);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
indexStart = matcher.start();
|
indexStart = matcher.start();
|
||||||
indexEnd = matcher.end();
|
indexEnd = matcher.end();
|
||||||
placeholder = remaining.substring(indexStart, indexEnd);
|
placeholder = remaining.substring(indexStart, indexEnd);
|
||||||
|
formattedPlaceholder = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), placeholder);
|
||||||
temp += convertToJsonColors(lastCode + remaining.substring(0, indexStart)) + ",";
|
temp += convertToJsonColors(lastCode + remaining.substring(0, indexStart)) + ",";
|
||||||
lastCode = getLastCode(lastCode + remaining.substring(0, indexStart));
|
lastCode = getLastCode(lastCode + remaining.substring(0, indexStart));
|
||||||
String action = "";
|
String action = "";
|
||||||
String text = "";
|
String text = "";
|
||||||
String hover = "";
|
String hover = "";
|
||||||
if (placeholder.contains(prefix)) {
|
for (JsonAttribute jsonAttribute : format.getJsonAttributes()) {
|
||||||
action = format.getClickPrefix();
|
if (placeholder.contains(jsonAttribute.getName().replace("{", "").replace("}", ""))) {
|
||||||
text = Format.FormatStringAll(
|
action = jsonAttribute.getClickAction();
|
||||||
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickPrefixText()));
|
text = Format.FormatStringAll(
|
||||||
for (String st : format.getHoverTextPrefix()) {
|
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText()));
|
||||||
hover += Format.FormatStringAll(st) + "\n";
|
for (String st : jsonAttribute.getHoverText()) {
|
||||||
}
|
hover += Format.FormatStringAll(st) + "\n";
|
||||||
}
|
}
|
||||||
if (placeholder.contains(nickname)) {
|
|
||||||
action = format.getClickName();
|
|
||||||
text = Format.FormatStringAll(
|
|
||||||
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickNameText()));
|
|
||||||
for (String st : format.getHoverTextName()) {
|
|
||||||
hover += Format.FormatStringAll(st) + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (placeholder.contains(suffix)) {
|
|
||||||
action = format.getClickSuffix();
|
|
||||||
text = Format.FormatStringAll(
|
|
||||||
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickSuffixText()));
|
|
||||||
for (String st : format.getHoverTextSuffix()) {
|
|
||||||
hover += Format.FormatStringAll(st) + "\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!hover.isEmpty()) {
|
if(!hover.isEmpty()) {
|
||||||
hover = Format.FormatStringAll(
|
hover = Format.FormatStringAll(
|
||||||
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hover.substring(0, hover.length() - 1)));
|
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hover.substring(0, hover.length() - 1)));
|
||||||
}
|
}
|
||||||
temp += convertToJsonColors(lastCode + placeholder,
|
temp += convertToJsonColors(lastCode + formattedPlaceholder,
|
||||||
",\"clickEvent\":{\"action\":\"" + action + "\",\"value\":\"" + text
|
",\"clickEvent\":{\"action\":\"" + action + "\",\"value\":\"" + text
|
||||||
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
|
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
|
||||||
+ convertToJsonColors(hover) + "]}}")
|
+ convertToJsonColors(hover) + "]}}")
|
||||||
+ ",";
|
+ ",";
|
||||||
lastCode = getLastCode(lastCode + placeholder);
|
lastCode = getLastCode(lastCode + formattedPlaceholder);
|
||||||
remaining = remaining.substring(indexEnd);
|
remaining = remaining.substring(indexEnd);
|
||||||
} else {
|
} else {
|
||||||
temp += convertToJsonColors(lastCode + remaining);
|
temp += convertToJsonColors(lastCode + remaining);
|
||||||
|
@ -140,33 +140,41 @@ messageremovertext: '&c&o<message removed>'
|
|||||||
jsonformatting:
|
jsonformatting:
|
||||||
Default: # This default format is required! Do not delete or rename it!
|
Default: # This default format is required! Do not delete or rename it!
|
||||||
priority: 2147483647 # Integer.MAX_VALUE
|
priority: 2147483647 # Integer.MAX_VALUE
|
||||||
hover_name:
|
json_attributes:
|
||||||
- '&6I have no rank!'
|
player_displayname:
|
||||||
click_name: 'suggest_command'
|
hover_text:
|
||||||
click_name_text: '/msg {player_name}'
|
- '&6I have no rank!'
|
||||||
hover_prefix:
|
click_action: 'suggest_command'
|
||||||
- '&dI am default!'
|
click_text: '/msg {player_name}'
|
||||||
click_prefix: 'run_command'
|
vault_prefix:
|
||||||
click_prefix_text: '/help'
|
hover_text:
|
||||||
hover_suffix:
|
- '&cI am default!'
|
||||||
- '&dI am default suffix!'
|
click_action: 'run_command'
|
||||||
click_suffix: 'suggest_command'
|
click_text: '/help'
|
||||||
click_suffix_text: '/msg {player_name}'
|
venturechat_channel_prefix:
|
||||||
|
hover_text:
|
||||||
|
- '&fChannel: {venturechat_channel_color}{venturechat_channel_name}'
|
||||||
|
click_action: 'run_command'
|
||||||
|
click_text: '/chlist'
|
||||||
Owner:
|
Owner:
|
||||||
priority: 1 # Lowest Priority
|
priority: 1
|
||||||
hover_name:
|
json_attributes:
|
||||||
- '&cOwner of the server!'
|
player_displayname:
|
||||||
- '&bMessage me for help!'
|
hover_text:
|
||||||
click_name: 'suggest_command'
|
- '&cOwner of the server!'
|
||||||
click_name_text: '/msg {player_name}'
|
- '&bMessage me for help!'
|
||||||
hover_prefix:
|
click_action: 'suggest_command'
|
||||||
- '&dServer Owner'
|
click_text: '/msg {player_name}'
|
||||||
click_prefix: 'run_command'
|
vault_prefix:
|
||||||
click_prefix_text: '/help'
|
hover_text:
|
||||||
hover_suffix:
|
- '&dServer Owner'
|
||||||
- '&dI am Owner suffix!'
|
click_action: 'run_command'
|
||||||
click_suffix: 'suggest_command'
|
click_text: '/help'
|
||||||
click_suffix_text: '/msg {player_name}'
|
venturechat_channel_prefix:
|
||||||
|
hover_text:
|
||||||
|
- '&fChannel: {venturechat_channel_color}{venturechat_channel_name}'
|
||||||
|
click_action: 'run_command'
|
||||||
|
click_text: '/chlist'
|
||||||
|
|
||||||
# The icon is the block shown in the GUI
|
# The icon is the block shown in the GUI
|
||||||
# The text is the display name of the block icon
|
# The text is the display name of the block icon
|
||||||
@ -282,62 +290,6 @@ enable_factions_channel: false
|
|||||||
# Important!!!
|
# Important!!!
|
||||||
# If you delete a channel, restart the server! Do not use /chatreload!!!
|
# If you delete a channel, restart the server! Do not use /chatreload!!!
|
||||||
channels:
|
channels:
|
||||||
GroupChatColorExample:
|
|
||||||
color: '#706C1E'
|
|
||||||
chatcolor: 'None'
|
|
||||||
mutable: true
|
|
||||||
filter: true
|
|
||||||
autojoin: true
|
|
||||||
default: false
|
|
||||||
distance: 0
|
|
||||||
cooldown: 0
|
|
||||||
bungeecord: false
|
|
||||||
alias: ge
|
|
||||||
permissions: None
|
|
||||||
speak_permissions: None
|
|
||||||
format: '&f[#706C1EGroupColorChat&f] {vault_prefix} {player_displayname}#706C1E:{vault_suffix}'
|
|
||||||
HexExample:
|
|
||||||
color: '#ff0000'
|
|
||||||
chatcolor: '#ff0000'
|
|
||||||
mutable: true
|
|
||||||
filter: true
|
|
||||||
autojoin: true
|
|
||||||
default: false
|
|
||||||
distance: 0
|
|
||||||
cooldown: 0
|
|
||||||
bungeecord: false
|
|
||||||
alias: he
|
|
||||||
permissions: None
|
|
||||||
speak_permissions: None
|
|
||||||
format: '&f[#ff0000Hex&f] {vault_prefix} {player_displayname}#ff0000:'
|
|
||||||
BungeeExample:
|
|
||||||
color: gold
|
|
||||||
chatcolor: gold
|
|
||||||
mutable: true
|
|
||||||
filter: true
|
|
||||||
autojoin: true
|
|
||||||
default: false
|
|
||||||
distance: 0
|
|
||||||
cooldown: 3
|
|
||||||
bungeecord: true
|
|
||||||
alias: be
|
|
||||||
permissions: None
|
|
||||||
speak_permissions: None
|
|
||||||
format: '&f[&6Network&f] {vault_prefix} {player_displayname}&6:'
|
|
||||||
AnnouncementExample:
|
|
||||||
color: red
|
|
||||||
chatcolor: red
|
|
||||||
mutable: false
|
|
||||||
filter: false
|
|
||||||
autojoin: true
|
|
||||||
default: false
|
|
||||||
distance: 0
|
|
||||||
cooldown: 0
|
|
||||||
bungeecord: true
|
|
||||||
alias: announce
|
|
||||||
permissions: None
|
|
||||||
speak_permissions: announcement
|
|
||||||
format: '&f[&aServer Announcement&f] {vault_prefix} {player_displayname}&c:'
|
|
||||||
Global:
|
Global:
|
||||||
color: dark_green
|
color: dark_green
|
||||||
chatcolor: dark_green
|
chatcolor: dark_green
|
||||||
@ -351,7 +303,38 @@ channels:
|
|||||||
alias: g
|
alias: g
|
||||||
permissions: None
|
permissions: None
|
||||||
speak_permissions: None
|
speak_permissions: None
|
||||||
format: '&f[&2Global&f] {vault_prefix} {player_displayname}&2:'
|
channel_prefix: '&f[&2Global&f]'
|
||||||
|
format: '{venturechat_channel_prefix} {vault_prefix}{player_displayname}&2:'
|
||||||
|
Network:
|
||||||
|
color: gold
|
||||||
|
chatcolor: gold
|
||||||
|
mutable: true
|
||||||
|
filter: true
|
||||||
|
autojoin: true
|
||||||
|
default: false
|
||||||
|
distance: 0
|
||||||
|
cooldown: 3
|
||||||
|
bungeecord: true
|
||||||
|
alias: be
|
||||||
|
permissions: None
|
||||||
|
speak_permissions: None
|
||||||
|
channel_prefix: '&f[&6Network&f]'
|
||||||
|
format: '{venturechat_channel_prefix} {vault_prefix}{player_displayname}&6:'
|
||||||
|
Announcement:
|
||||||
|
color: red
|
||||||
|
chatcolor: red
|
||||||
|
mutable: false
|
||||||
|
filter: false
|
||||||
|
autojoin: true
|
||||||
|
default: false
|
||||||
|
distance: 0
|
||||||
|
cooldown: 0
|
||||||
|
bungeecord: true
|
||||||
|
alias: announce
|
||||||
|
permissions: None
|
||||||
|
speak_permissions: announcement
|
||||||
|
channel_prefix: '&f[&aServer Announcement&f]'
|
||||||
|
format: '{venturechat_channel_prefix} {vault_prefix}{player_displayname}&c:'
|
||||||
Staff:
|
Staff:
|
||||||
color: green
|
color: green
|
||||||
chatcolor: green
|
chatcolor: green
|
||||||
@ -365,7 +348,8 @@ channels:
|
|||||||
alias: st
|
alias: st
|
||||||
permissions: staffchannel
|
permissions: staffchannel
|
||||||
speak_permissions: None
|
speak_permissions: None
|
||||||
format: '&f[&aStaff&f] {vault_prefix} {player_displayname}&a:'
|
channel_prefix: '&f[&aStaff&f]'
|
||||||
|
format: '{venturechat_channel_prefix} {vault_prefix}{player_displayname}&a:'
|
||||||
Donator:
|
Donator:
|
||||||
color: light_purple
|
color: light_purple
|
||||||
chatcolor: light_purple
|
chatcolor: light_purple
|
||||||
@ -379,7 +363,8 @@ channels:
|
|||||||
alias: d
|
alias: d
|
||||||
permissions: donatorchannel
|
permissions: donatorchannel
|
||||||
speak_permissions: None
|
speak_permissions: None
|
||||||
format: '&f[&dDonator&f] {vault_prefix} {player_displayname}&d:'
|
channel_prefix: '&f[&dDonator&f]'
|
||||||
|
format: '{venturechat_channel_prefix} {vault_prefix}{player_displayname}&d:'
|
||||||
Help:
|
Help:
|
||||||
color: aqua
|
color: aqua
|
||||||
chatcolor: aqua
|
chatcolor: aqua
|
||||||
@ -393,7 +378,8 @@ channels:
|
|||||||
alias: h
|
alias: h
|
||||||
permissions: None
|
permissions: None
|
||||||
speak_permissions: None
|
speak_permissions: None
|
||||||
format: '&f[&bHelp&f] {vault_prefix} {player_displayname}&b:'
|
channel_prefix: '&f[&bHelp&f]'
|
||||||
|
format: '{venturechat_channel_prefix} {vault_prefix}{player_displayname}&b:'
|
||||||
Trade:
|
Trade:
|
||||||
color: dark_aqua
|
color: dark_aqua
|
||||||
chatcolor: dark_aqua
|
chatcolor: dark_aqua
|
||||||
@ -407,7 +393,8 @@ channels:
|
|||||||
alias: t
|
alias: t
|
||||||
permissions: None
|
permissions: None
|
||||||
speak_permissions: None
|
speak_permissions: None
|
||||||
format: '&f[&3Trade&f] {vault_prefix} {player_displayname}&3:'
|
channel_prefix: '&f[&3Trade&f]'
|
||||||
|
format: '{venturechat_channel_prefix} {vault_prefix}{player_displayname}&3:'
|
||||||
Local:
|
Local:
|
||||||
color: yellow
|
color: yellow
|
||||||
chatcolor: yellow
|
chatcolor: yellow
|
||||||
@ -421,4 +408,5 @@ channels:
|
|||||||
alias: l
|
alias: l
|
||||||
permissions: None
|
permissions: None
|
||||||
speak_permissions: None
|
speak_permissions: None
|
||||||
format: '&f[&eLocal&f] {vault_prefix} {player_displayname}&e:'
|
channel_prefix: '&f[&eLocal&f]'
|
||||||
|
format: '{venturechat_channel_prefix} {vault_prefix}{player_displayname}&e:'
|
Loading…
x
Reference in New Issue
Block a user