mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 09:49:05 +00:00
ISSUE #18 Only show hover when it is configured
This commit is contained in:
parent
8527cb5188
commit
0f3b3065bd
@ -1,7 +1,7 @@
|
||||
package mineverse.Aust1n46.chat;
|
||||
|
||||
public enum ClickAction {
|
||||
SUGGEST_COMMAND, RUN_COMMAND, OPEN_URL;
|
||||
SUGGEST_COMMAND, RUN_COMMAND, OPEN_URL, NONE;
|
||||
|
||||
private final String jsonValue;
|
||||
|
||||
|
@ -203,7 +203,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getConfig().getString("loglevel", "info").equals("debug")) {
|
||||
if (getConfig().getString("loglevel", "info").equals("trace")) {
|
||||
Bukkit.getConsoleSender()
|
||||
.sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Updating Player Mutes"));
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class JsonFormat {
|
||||
if (jsonAttributeSection != null) {
|
||||
for (String attribute : jsonAttributeSection.getKeys(false)) {
|
||||
List<String> hoverText = jsonAttributeSection.getStringList(attribute + ".hover_text");
|
||||
String clickActionText = jsonAttributeSection.getString(attribute + ".click_action", "");
|
||||
String clickActionText = jsonAttributeSection.getString(attribute + ".click_action", "none");
|
||||
try {
|
||||
ClickAction clickAction = ClickAction.valueOf(clickActionText.toUpperCase());
|
||||
String clickText = jsonAttributeSection.getString(attribute + ".click_text", "");
|
||||
|
@ -23,6 +23,7 @@ import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import mineverse.Aust1n46.chat.ClickAction;
|
||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
|
||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
||||
import mineverse.Aust1n46.chat.json.JsonAttribute;
|
||||
@ -116,9 +117,6 @@ public class Format {
|
||||
boolean placeholderHasJsonAttribute = false;
|
||||
for (JsonAttribute jsonAttribute : format.getJsonAttributes()) {
|
||||
if (placeholder.contains(jsonAttribute.getName().replace("{", "").replace("}", ""))) {
|
||||
final String action = jsonAttribute.getClickAction().toString();
|
||||
final String text = Format.FormatStringAll(
|
||||
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText()));
|
||||
final StringBuilder hover = new StringBuilder();
|
||||
for (String st : jsonAttribute.getHoverText()) {
|
||||
hover.append(Format.FormatStringAll(st) + "\n");
|
||||
@ -130,11 +128,24 @@ public class Format {
|
||||
} else {
|
||||
hoverText = StringUtils.EMPTY;
|
||||
}
|
||||
temp += convertToJsonColors(lastCode + formattedPlaceholder,
|
||||
",\"clickEvent\":{\"action\":\"" + action + "\",\"value\":\"" + text
|
||||
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
|
||||
+ convertToJsonColors(hoverText) + "]}}")
|
||||
+ ",";
|
||||
final ClickAction clickAction = jsonAttribute.getClickAction();
|
||||
final String actionJson;
|
||||
if (clickAction == ClickAction.NONE) {
|
||||
actionJson = StringUtils.EMPTY;
|
||||
} else {
|
||||
final String clickText = Format.FormatStringAll(
|
||||
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText()));
|
||||
actionJson = ",\"clickEvent\":{\"action\":\"" + jsonAttribute.getClickAction().toString() + "\",\"value\":\"" + clickText
|
||||
+ "\"}";
|
||||
}
|
||||
final String hoverJson;
|
||||
if (hoverText.isEmpty()) {
|
||||
hoverJson = StringUtils.EMPTY;
|
||||
} else {
|
||||
hoverJson = ",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
|
||||
+ convertToJsonColors(hoverText) + "]}}";
|
||||
}
|
||||
temp += convertToJsonColors(lastCode + formattedPlaceholder, actionJson + hoverJson) + ",";
|
||||
placeholderHasJsonAttribute = true;
|
||||
break;
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ messageremovertext: '&c&o<message removed>'
|
||||
# The name of the group is the permissions node for the format
|
||||
# Example: venturechat.json.Owner is the node for the group Owner
|
||||
# A lower priority overrides a higher priority if a player has more than 1 group
|
||||
# Possible options for click_action are suggest_command, run_command, and open_url
|
||||
# Possible options for click_action are suggest_command, run_command, open_url, and none
|
||||
jsonformatting:
|
||||
Default: # This default format is required! Do not delete or rename it!
|
||||
priority: 2147483647 # Integer.MAX_VALUE
|
||||
|
Loading…
x
Reference in New Issue
Block a user