Fixed issue with color codes converting regardless of the required

permission.  Removed dead code from older JSON buttons (replaced with
Moderation GUI)
This commit is contained in:
Aust1n46 2019-12-26 16:54:23 -05:00
parent 2d7e1949fc
commit 7b5cdc1399
12 changed files with 48 additions and 302 deletions

View File

@ -1,4 +1,4 @@
name: VentureChat name: VentureChat
main: mineverse.Aust1n46.chat.bungee.MineverseChatBungee main: mineverse.Aust1n46.chat.bungee.MineverseChatBungee
version: 2.17.0 version: 2.17.1
author: Aust1n46 author: Aust1n46

View File

@ -32,7 +32,6 @@ import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import mineverse.Aust1n46.chat.irc.Bot; import mineverse.Aust1n46.chat.irc.Bot;
import mineverse.Aust1n46.chat.irc.command.IRCCommandInfo; import mineverse.Aust1n46.chat.irc.command.IRCCommandInfo;
//import mineverse.Aust1n46.chat.json.JsonButtonInfo;
import mineverse.Aust1n46.chat.json.JsonFormatInfo; import mineverse.Aust1n46.chat.json.JsonFormatInfo;
import mineverse.Aust1n46.chat.listeners.CapeListener; import mineverse.Aust1n46.chat.listeners.CapeListener;
import mineverse.Aust1n46.chat.listeners.CommandListener; import mineverse.Aust1n46.chat.listeners.CommandListener;
@ -40,6 +39,7 @@ import mineverse.Aust1n46.chat.listeners.LoginListener;
import mineverse.Aust1n46.chat.listeners.ChatListener; import mineverse.Aust1n46.chat.listeners.ChatListener;
import mineverse.Aust1n46.chat.listeners.PacketListener; import mineverse.Aust1n46.chat.listeners.PacketListener;
import mineverse.Aust1n46.chat.listeners.SignListener; import mineverse.Aust1n46.chat.listeners.SignListener;
import mineverse.Aust1n46.chat.localization.Localization;
//import mineverse.Aust1n46.chat.alias.Alias; //import mineverse.Aust1n46.chat.alias.Alias;
import mineverse.Aust1n46.chat.alias.AliasInfo; import mineverse.Aust1n46.chat.alias.AliasInfo;
import mineverse.Aust1n46.chat.api.MineverseChatAPI; import mineverse.Aust1n46.chat.api.MineverseChatAPI;
@ -51,7 +51,6 @@ import mineverse.Aust1n46.chat.command.MineverseCommand;
import mineverse.Aust1n46.chat.command.MineverseCommandExecutor; import mineverse.Aust1n46.chat.command.MineverseCommandExecutor;
import mineverse.Aust1n46.chat.command.chat.Broadcast; import mineverse.Aust1n46.chat.command.chat.Broadcast;
import mineverse.Aust1n46.chat.command.chat.BungeeToggle; import mineverse.Aust1n46.chat.command.chat.BungeeToggle;
import mineverse.Aust1n46.chat.command.chat.Buttons;
import mineverse.Aust1n46.chat.command.chat.Channel; import mineverse.Aust1n46.chat.command.chat.Channel;
import mineverse.Aust1n46.chat.command.chat.Channelinfo; import mineverse.Aust1n46.chat.command.chat.Channelinfo;
import mineverse.Aust1n46.chat.command.chat.Chatinfo; import mineverse.Aust1n46.chat.command.chat.Chatinfo;
@ -156,7 +155,6 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
public static ChatChannelInfo ccInfo; public static ChatChannelInfo ccInfo;
public static AliasInfo aaInfo; public static AliasInfo aaInfo;
public static JsonFormatInfo jfInfo; public static JsonFormatInfo jfInfo;
// public static JsonButtonInfo jbInfo;
public static IRCCommandInfo ircInfo; public static IRCCommandInfo ircInfo;
public static GuiSlotInfo gsInfo; public static GuiSlotInfo gsInfo;
public boolean quickchat = true; public boolean quickchat = true;
@ -223,6 +221,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Enabled Successfully")); Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Enabled Successfully"));
// Get config and handle // Get config and handle
// Configuration // Configuration
Localization.initialize();
PlayerData.initialize(); PlayerData.initialize();
if(this.firstRun) { if(this.firstRun) {
for(String uuidString : PlayerData.getPlayerData().getConfigurationSection("players").getKeys(false)) { for(String uuidString : PlayerData.getPlayerData().getConfigurationSection("players").getKeys(false)) {
@ -274,10 +273,9 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
boolean spy = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("spy", false); boolean spy = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("spy", false);
boolean commandSpy = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("commandspy", false); boolean commandSpy = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("commandspy", false);
boolean rangedSpy = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("rangedspy", false); boolean rangedSpy = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("rangedspy", false);
boolean buttons = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("buttons", true);
boolean messageToggle = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("messagetoggle", true); boolean messageToggle = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("messagetoggle", true);
boolean bungeeToggle = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("bungeetoggle", true); boolean bungeeToggle = PlayerData.getPlayerData().getConfigurationSection("players." + uuidString).getBoolean("bungeetoggle", true);
players.add(new MineverseChatPlayer(uuid, name, currentChannel, ignores, listening, mutes, blockedCommands, mail, host, party, filter, notifications, nickname, jsonFormat, spy, commandSpy, rangedSpy, buttons, messageToggle, bungeeToggle)); players.add(new MineverseChatPlayer(uuid, name, currentChannel, ignores, listening, mutes, blockedCommands, mail, host, party, filter, notifications, nickname, jsonFormat, spy, commandSpy, rangedSpy, messageToggle, bungeeToggle));
} }
} }
else { else {
@ -293,7 +291,6 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
ircInfo = new IRCCommandInfo(this); ircInfo = new IRCCommandInfo(this);
aaInfo = new AliasInfo(this); aaInfo = new AliasInfo(this);
jfInfo = new JsonFormatInfo(this); jfInfo = new JsonFormatInfo(this);
// jbInfo = new JsonButtonInfo();
gsInfo = new GuiSlotInfo(); gsInfo = new GuiSlotInfo();
if(ccInfo == null) { if(ccInfo == null) {
@ -341,7 +338,6 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
} }
commands.put("afk", new Afk("afk")); commands.put("afk", new Afk("afk"));
commands.put("buttons", new Buttons("button"));
commands.put("broadcast", new Broadcast("broadcast")); commands.put("broadcast", new Broadcast("broadcast"));
commands.put("channel", new Channel("channel")); commands.put("channel", new Channel("channel"));
commands.put("join", new Channel("join")); commands.put("join", new Channel("join"));
@ -1074,7 +1070,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
Set<String> blockedCommands = new HashSet<String>(); Set<String> blockedCommands = new HashSet<String>();
List<String> mail = new ArrayList<String>(); List<String> mail = new ArrayList<String>();
String jsonFormat = "Default"; String jsonFormat = "Default";
s = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, mail, false, null, true, true, name, jsonFormat, false, false, false, true, true, true); s = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, mail, false, null, true, true, name, jsonFormat, false, false, false, true, true);
MineverseChat.players.add(s); MineverseChat.players.add(s);
} }
p.getPlayer().sendMessage(msg.replace("{playerfrom}", sName).replace("{playerto}", Format.FormatStringAll(p.getNickname()))); p.getPlayer().sendMessage(msg.replace("{playerfrom}", sName).replace("{playerto}", Format.FormatStringAll(p.getNickname())));

View File

@ -48,10 +48,11 @@ public class MineverseChatPlayer {
private boolean editing; private boolean editing;
private int editHash; private int editHash;
private boolean rangedSpy; private boolean rangedSpy;
private boolean buttons;
private boolean messageToggle; private boolean messageToggle;
private boolean bungeeToggle; private boolean bungeeToggle;
//buttons variable no longer used
@Deprecated
public MineverseChatPlayer(UUID uuid, String name, ChatChannel currentChannel, Set<UUID> ignores, Set<String> listening, HashMap<String, Integer> mutes, Set<String> blockedCommands, List<String> mail, boolean host, UUID party, boolean filter, boolean notifications, String nickname, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy, boolean buttons, boolean messageToggle, boolean bungeeToggle) { public MineverseChatPlayer(UUID uuid, String name, ChatChannel currentChannel, Set<UUID> ignores, Set<String> listening, HashMap<String, Integer> mutes, Set<String> blockedCommands, List<String> mail, boolean host, UUID party, boolean filter, boolean notifications, String nickname, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy, boolean buttons, boolean messageToggle, boolean bungeeToggle) {
this.uuid = uuid; this.uuid = uuid;
this.name = name; this.name = name;
@ -73,7 +74,41 @@ public class MineverseChatPlayer {
this.spy = spy; this.spy = spy;
this.rangedSpy = rangedSpy; this.rangedSpy = rangedSpy;
this.commandSpy = commandSpy; this.commandSpy = commandSpy;
this.buttons = buttons; this.afk = false;
this.quickChat = false;
this.quickChannel = null;
this.replyPlayer = null;
this.partyChat = false;
this.modified = false;
this.messages = new ArrayList<ChatMessage>();
this.jsonFormat = jsonFormat;
this.cooldowns = new HashMap<ChatChannel, Integer>();
this.spam = new HashMap<ChatChannel, List<Integer>>();
this.messageToggle = messageToggle;
this.bungeeToggle = bungeeToggle;
}
public MineverseChatPlayer(UUID uuid, String name, ChatChannel currentChannel, Set<UUID> ignores, Set<String> listening, HashMap<String, Integer> mutes, Set<String> blockedCommands, List<String> mail, boolean host, UUID party, boolean filter, boolean notifications, String nickname, String jsonFormat, boolean spy, boolean commandSpy, boolean rangedSpy, boolean messageToggle, boolean bungeeToggle) {
this.uuid = uuid;
this.name = name;
this.currentChannel = currentChannel;
this.ignores = ignores;
this.listening = listening;
this.mutes = mutes;
this.blockedCommands = blockedCommands;
this.mail = mail;
this.host = host;
this.party = party;
this.filter = filter;
this.notifications = notifications;
this.nickname = nickname;
this.online = false;
this.player = null;
this.hasPlayed = false;
this.conversation = null;
this.spy = spy;
this.rangedSpy = rangedSpy;
this.commandSpy = commandSpy;
this.afk = false; this.afk = false;
this.quickChat = false; this.quickChat = false;
this.quickChannel = null; this.quickChannel = null;
@ -104,14 +139,6 @@ public class MineverseChatPlayer {
this.messageToggle = messageToggle; this.messageToggle = messageToggle;
} }
public boolean getButtons() {
return this.buttons;
}
public void setButtons(boolean buttons) {
this.buttons = buttons;
}
public boolean getRangedSpy() { public boolean getRangedSpy() {
return this.rangedSpy; return this.rangedSpy;
} }

View File

@ -1,39 +0,0 @@
package mineverse.Aust1n46.chat.command.chat;
import mineverse.Aust1n46.chat.MineverseChat;
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
import mineverse.Aust1n46.chat.command.MineverseCommand;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Buttons extends MineverseCommand {
private MineverseChat plugin;
public Buttons(String name) {
super(name);
this.plugin = MineverseChat.getInstance();
}
@Override
public void execute(CommandSender sender, String command, String[] args) {
if(!(sender instanceof Player)) {
plugin.getServer().getConsoleSender().sendMessage(ChatColor.RED + "This command must be run by a player.");
return;
}
MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer((Player) sender);
if(mcp.getPlayer().hasPermission("venturechat.ignorebutton") || mcp.getPlayer().hasPermission("venturechat.ignorebutton")) {
if(mcp.getButtons()) {
mcp.setButtons(false);
mcp.getPlayer().sendMessage(ChatColor.GOLD + "You are no longer ignoring json buttons.");
return;
}
mcp.setButtons(true);
mcp.getPlayer().sendMessage(ChatColor.GOLD + "You are now ignoring json buttons.");
return;
}
mcp.getPlayer().sendMessage(ChatColor.RED + "You do not have permission for this command.");
}
}

View File

@ -107,7 +107,6 @@ public class PlayerData {
cs.set("spy", p.isSpy()); cs.set("spy", p.isSpy());
cs.set("commandspy", p.hasCommandSpy()); cs.set("commandspy", p.hasCommandSpy());
cs.set("rangedspy", p.getRangedSpy()); cs.set("rangedspy", p.getRangedSpy());
cs.set("buttons", p.getButtons());
cs.set("messagetoggle", p.getMessageToggle()); cs.set("messagetoggle", p.getMessageToggle());
cs.set("bungeetoggle", p.getBungeeToggle()); cs.set("bungeetoggle", p.getBungeeToggle());
Calendar currentDate = Calendar.getInstance(); Calendar currentDate = Calendar.getInstance();

View File

@ -1,47 +0,0 @@
package mineverse.Aust1n46.chat.json;
public class JsonButton {
private String text;
private String command;
private String permission;
private String icon;
private String name;
private String action;
public JsonButton(String name, String text, String command, String permission, String icon, String action) {
this.name = name;
this.text = text;
this.command = command;
this.permission = "venturechat." + permission;
this.icon = icon;
this.action = action;
}
public String getText() {
return this.text;
}
public String getAction() {
return this.action;
}
public String getCommand() {
return this.command;
}
public String getPermission() {
return this.permission;
}
public String getIcon() {
return this.icon;
}
public String getName() {
return this.name;
}
public boolean hasPermission() {
return !permission.equalsIgnoreCase("venturechat.none");
}
}

View File

@ -1,44 +0,0 @@
package mineverse.Aust1n46.chat.json;
import mineverse.Aust1n46.chat.MineverseChat;
import org.bukkit.configuration.ConfigurationSection;
public class JsonButtonInfo {
private JsonButton[] jb;
private MineverseChat plugin = MineverseChat.getInstance();
public JsonButtonInfo() {
String name;
String text;
String icon;
String command;
String permission;
String action;
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("jsonbuttons");
jb = new JsonButton[cs.getKeys(false).size()];
int x = 0;
for(String key : cs.getKeys(false)) {
name = key;
text = cs.getString(key + ".text");
icon = cs.getString(key + ".icon");
command = cs.getString(key + ".command");
permission = cs.getString(key + ".permission");
action = cs.getString(key + ".click_action");
JsonButton j = new JsonButton(name, text, command, permission, icon, action);
jb[x ++] = j;
}
}
public JsonButton[] getJsonButtons() {
return this.jb;
}
public JsonButton getJsonButton(String name) {
for(JsonButton j : this.jb) {
if(j.getName().equalsIgnoreCase(name))
return j;
}
return null;
}
}

View File

@ -79,7 +79,7 @@ public class LoginListener implements Listener {
Set<String> blockedCommands = new HashSet<String>(); Set<String> blockedCommands = new HashSet<String>();
List<String> mail = new ArrayList<String>(); List<String> mail = new ArrayList<String>();
String jsonFormat = "Default"; String jsonFormat = "Default";
mcp = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, mail, false, null, true, true, name, jsonFormat, false, false, false, true, true, true); mcp = new MineverseChatPlayer(uuid, name, current, ignores, listening, mutes, blockedCommands, mail, false, null, true, true, name, jsonFormat, false, false, false, true, true);
MineverseChat.players.add(mcp); MineverseChat.players.add(mcp);
} }
mcp.setName(event.getPlayer().getName()); mcp.setName(event.getPlayer().getName());

View File

@ -12,18 +12,13 @@ import mineverse.Aust1n46.chat.api.MineverseChatAPI;
import mineverse.Aust1n46.chat.api.MineverseChatPlayer; import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
import mineverse.Aust1n46.chat.utilities.Format; import mineverse.Aust1n46.chat.utilities.Format;
import mineverse.Aust1n46.chat.versions.VersionHandler; import mineverse.Aust1n46.chat.versions.VersionHandler;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.chat.ComponentSerializer;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.WrappedChatComponent;
import me.clip.placeholderapi.PlaceholderAPI;
//This class listens for chat packets and intercepts them before they are sent to the Player. //This class listens for chat packets and intercepts them before they are sent to the Player.
//The packets are modified to include advanced json formating and the message remover button if the //The packets are modified to include advanced json formating and the message remover button if the
//player has permission to remove messages. //player has permission to remove messages.
@ -35,39 +30,10 @@ public class PacketListener extends PacketAdapter {
@Override @Override
public void onPacketSending(PacketEvent event) { public void onPacketSending(PacketEvent event) {
if(event.isCancelled() || event.getPacketType() != PacketType.Play.Server.CHAT) { if(event.isCancelled() || event.getPacketType() != PacketType.Play.Server.CHAT || event.getPacket().getChatComponents().read(0) == null) {
return; return;
} }
StructureModifier<WrappedChatComponent> chatP = event.getPacket().getChatComponents();
WrappedChatComponent c = chatP.read(0);
if (c == null) {
StructureModifier<BaseComponent[]> modifier = event.getPacket().getSpecificModifier(BaseComponent[].class);
BaseComponent[] components = modifier.readSafely(0);
if (components == null) {
return;
}
String msg = ComponentSerializer.toString(components);
if (msg == null) {
return;
}
if (!PlaceholderAPI.getBracketPlaceholderPattern().matcher(msg).find()) {
return;
}
msg = PlaceholderAPI.setBracketPlaceholders(event.getPlayer(), msg);
modifier.write(0, ComponentSerializer.parse(msg));
return;
}
String msg = c.getJson();
if (msg == null) {
return;
}
if (!PlaceholderAPI.getBracketPlaceholderPattern().matcher(msg).find()) {
return;
}
msg = PlaceholderAPI.setBracketPlaceholders(event.getPlayer(), msg);
chatP.write(0, WrappedChatComponent.fromJson(msg));
try { try {
if(VersionHandler.is1_7_10() || VersionHandler.is1_7_9() || VersionHandler.is1_7_2()) { if(VersionHandler.is1_7_10() || VersionHandler.is1_7_9() || VersionHandler.is1_7_2()) {
if((MineverseChat.posField != null) && !(((boolean) MineverseChat.posField.get(event.getPacket().getHandle())))) { if((MineverseChat.posField != null) && !(((boolean) MineverseChat.posField.get(event.getPacket().getHandle())))) {
@ -93,13 +59,12 @@ public class PacketListener extends PacketAdapter {
catch(IllegalArgumentException | IllegalAccessException e) { catch(IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
WrappedChatComponent chat = (WrappedChatComponent) event.getPacket().getChatComponents().read(0);
WrappedChatComponent originalChat = (WrappedChatComponent) event.getPacket().getChatComponents().read(0); WrappedChatComponent chat = event.getPacket().getChatComponents().read(0);
WrappedChatComponent originalChat = event.getPacket().getChatComponents().read(0);
String message = null; String message = null;
int hash = -1; int hash = -1;
//System.out.println(chat.getJson()); //System.out.println(chat.getJson());
//message = TextComponent.toPlainText(new TextComponent(chat.getJson()));
//message = (String) MineverseChat.messageMethod.invoke(chat.getHandle(), new Object[0]);
//System.out.println(MineverseChat.lastChatMessage.getMessage()); //System.out.println(MineverseChat.lastChatMessage.getMessage());
message = MineverseChat.toPlainText(chat.getHandle(), chat.getHandleType()); message = MineverseChat.toPlainText(chat.getHandle(), chat.getHandleType());
//System.out.println(chat.getJson()); //System.out.println(chat.getJson());
@ -110,18 +75,6 @@ public class PacketListener extends PacketAdapter {
MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer(event.getPlayer()); MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer(event.getPlayer());
if(lastChatMessage != null && lastChatMessage.getHash() == hash) { if(lastChatMessage != null && lastChatMessage.getHash() == hash) {
String json = MineverseChat.lastJson; String json = MineverseChat.lastJson;
/*if(mcp.getPlayer().hasPermission("venturechat.message.remove")) {
json = json.substring(0, json.length() - 1);
json += ",{\"text\":\" " + Format.FormatStringAll(plugin.getConfig().getString("messageremovericon")) + "\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/removemessage " + lastChatMessage.getHash() + " true" +"\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"" + Format.FormatStringAll(plugin.getConfig().getString("messageremovertext")) + "\"}}}]";
}
if(!mcp.getButtons()) {
for(JsonButton j : MineverseChat.jbInfo.getJsonButtons()) {
if(j.hasPermission() && mcp.getPlayer().hasPermission(j.getPermission())) {
json = json.substring(0, json.length() - 1);
json += ",{\"text\":\" " + Format.FormatStringAll(j.getIcon()) + "\",\"clickEvent\":{\"action\":\"" + j.getAction() + "\",\"value\":\"/" + j.getCommand().replace("{channel}", lastChatMessage.getChannel()).replace("{player}", lastChatMessage.getSender()) + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"" + Format.FormatStringAll(j.getText()) + "\"}}}]";
}
}
}*/
if(mcp.getPlayer().hasPermission("venturechat.gui")) { if(mcp.getPlayer().hasPermission("venturechat.gui")) {
json = json.substring(0, json.length() - 1); json = json.substring(0, json.length() - 1);
json += "," + Format.convertToJsonColors(Format.FormatStringAll(plugin.getConfig().getString("guiicon")), ",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/vchatgui " + lastChatMessage.getSender() + " " + lastChatMessage.getChannel() + " " + lastChatMessage.getHash() +"\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + Format.convertToJsonColors(Format.FormatStringAll(plugin.getConfig().getString("guitext"))) + "]}}") + "]"; json += "," + Format.convertToJsonColors(Format.FormatStringAll(plugin.getConfig().getString("guiicon")), ",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/vchatgui " + lastChatMessage.getSender() + " " + lastChatMessage.getChannel() + " " + lastChatMessage.getHash() +"\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + Format.convertToJsonColors(Format.FormatStringAll(plugin.getConfig().getString("guitext"))) + "]}}") + "]";

View File

@ -46,67 +46,6 @@ public class Format {
if(icp.getPlayer() != null) { if(icp.getPlayer() != null) {
nickname = FormatStringAll(icp.getPlayer().getDisplayName()); nickname = FormatStringAll(icp.getPlayer().getDisplayName());
} }
/*int prefixIndex = f.indexOf(prefix);
if(prefixIndex == -1) {
prefixIndex = 0;
prefix = "";
}
int nameIndex = f.indexOf(nickname);
if(nameIndex == -1) {
nameIndex = 0;
nickname = "";
}
int suffixIndex = f.indexOf(suffix);
if(suffixIndex == -1) {
suffixIndex = 0;
suffix = "";
}*/
/*int lower = prefixIndex;
int middle = nameIndex;
//int higher = suffixIndex;
String lowerText = prefix;
List<String> lowerList = format.getHoverTextPrefix();
String middleText = nickname;
List<String> middleList = format.getHoverTextName();
String clickLowerAction = format.getClickPrefix();
String clickLowerActionText = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickPrefixText());
String clickMiddleAction = format.getClickName();
String clickMiddleActionText = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickNameText());
if(nameIndex < prefixIndex) {
lower = nameIndex;
middle = prefixIndex;
lowerText = nickname;
lowerList = format.getHoverTextName();
middleText = prefix;
middleList = format.getHoverTextPrefix();
clickLowerAction = format.getClickName();
clickLowerActionText = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickNameText());
clickMiddleAction = format.getClickPrefix();
clickMiddleActionText = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), format.getClickPrefixText());
}
String hoverLower = "";
for(String s : lowerList) {
hoverLower += s + "\n";
}
hoverLower = FormatStringAll(hoverLower.substring(0, hoverLower.length() - 1));
if(pluginManager.isPluginEnabled("PlaceholderAPI")) {
hoverLower = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hoverLower);
}
String hoverMiddle = "";
for(String s : middleList) {
hoverMiddle += s + "\n";
}
hoverMiddle = FormatStringAll(hoverMiddle.substring(0, hoverMiddle.length() - 1));
if(pluginManager.isPluginEnabled("PlaceholderAPI")) {
hoverMiddle = PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hoverMiddle);
}*/
//json += convertToJsonColors(f.substring(0, lower));
//json += "]},{\"text\":\"" + lowerText + "\",\"clickEvent\":{\"action\":\"" + clickLowerAction + "\",\"value\":\"" + clickLowerActionText + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(hoverLower) + "]}}}";
//json += ",{\"text\":\"\",\"extra\":[" + convertToJsonColors(getLastCode(lowerText) + f.substring(lower + lowerText.length(), middle)) + "]}";
//json += ",{\"text\":\"" + getLastCode(lowerText + f.substring(lower + lowerText.length(), middle)) + middleText + "\",\"clickEvent\":{\"action\":\"" + clickMiddleAction + "\",\"value\":\"" + clickMiddleActionText + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(hoverMiddle) + "]}}}";
//json += "," + convertToJsonColors(getLastCode(lowerText + f.substring(lower + lowerText.length(), middle)) + f.substring(middle + middleText.length(), f.length())) + "," + convertLinks(getLastCode(lowerText + f.substring(lower + lowerText.length(), middle) + f.substring(middle + middleText.length(), f.length())) + c);
json += convertPlaceholders(f, format, prefix, nickname, suffix, icp); json += convertPlaceholders(f, format, prefix, nickname, suffix, icp);
json += "]}"; json += "]}";
json += "," + convertLinks(c); json += "," + convertLinks(c);
@ -222,44 +161,6 @@ public class Format {
return ts; return ts;
} }
/*
private static String getLastFormat(String s) {
Stack<Character> temp = new Stack<Character>();
String ts = "";
for(char c : s.toCharArray()) {
temp.push(c);
}
String i = "";
while(!temp.isEmpty()) {
i += temp.pop();
}
char[] ch = i.toCharArray();
for(int a = 0; a < i.length() - 1; a ++) {
if(String.valueOf(ch[a]).matches("[lkonmr]") && ch[a + 1] == '§') {
ts += String.valueOf(ch[a + 1]) + ch[a];
}
}
return ts;
}
private static String getLastColor(String s) {
Stack<Character> temp = new Stack<Character>();
for(char c : s.toCharArray()) {
temp.push(c);
}
String i = "";
while(!temp.isEmpty()) {
i += temp.pop();
}
char[] ch = i.toCharArray();
for(int a = 0; a < i.length() - 1; a ++) {
if(String.valueOf(ch[a]).matches("[0123456789abcdef]") && ch[a + 1] == '§') {
return String.valueOf(ch[a + 1]) + ch[a];
}
}
return "§f";
}*/
public static String convertToJsonColors(String s) { public static String convertToJsonColors(String s) {
return convertToJsonColors(s, ""); return convertToJsonColors(s, "");
} }

View File

@ -1,5 +1,5 @@
name: VentureChat name: VentureChat
version: 2.17.0 version: 2.17.1
api-version: 1.13 api-version: 1.13
main: mineverse.Aust1n46.chat.MineverseChat main: mineverse.Aust1n46.chat.MineverseChat
depend: [Vault, ProtocolLib, PlaceholderAPI] depend: [Vault, ProtocolLib, PlaceholderAPI]