Changed rainbow mode to tellraw format and fixed /mwiki bugs
This commit is contained in:
parent
7d78246672
commit
18ae134294
2 changed files with 25 additions and 22 deletions
|
@ -64,6 +64,8 @@ public class ChatProcessing {
|
||||||
String colormode = currentchannel.Color;
|
String colormode = currentchannel.Color;
|
||||||
if (mp != null && mp.OtherColorMode.length() > 0)
|
if (mp != null && mp.OtherColorMode.length() > 0)
|
||||||
colormode = mp.OtherColorMode;
|
colormode = mp.OtherColorMode;
|
||||||
|
if (mp != null && mp.RainbowPresserColorMode)
|
||||||
|
colormode = "rpc";
|
||||||
if (message.startsWith(">"))
|
if (message.startsWith(">"))
|
||||||
colormode = "green"; // If greentext, ignore channel or player
|
colormode = "green"; // If greentext, ignore channel or player
|
||||||
// colors
|
// colors
|
||||||
|
@ -115,8 +117,8 @@ public class ChatProcessing {
|
||||||
// URLs + Rainbow text
|
// URLs + Rainbow text
|
||||||
String[] parts = formattedmessage.split("\\s+");
|
String[] parts = formattedmessage.split("\\s+");
|
||||||
boolean hadurls = false;
|
boolean hadurls = false;
|
||||||
final String[] RainbowPresserColors = new String[] { "c", "6", "e",
|
final String[] RainbowPresserColors = new String[] { "red", "gold",
|
||||||
"a", "9", "5" };
|
"yellow", "green", "blue", "dark_purple" };
|
||||||
int rpc = 0;
|
int rpc = 0;
|
||||||
int currentindex = 0;
|
int currentindex = 0;
|
||||||
for (String item : parts) {
|
for (String item : parts) {
|
||||||
|
@ -131,32 +133,33 @@ public class ChatProcessing {
|
||||||
hadurls = true;
|
hadurls = true;
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
}
|
}
|
||||||
if (mp != null && mp.RainbowPresserColorMode) {
|
if (colormode.equals("rpc")) {
|
||||||
if (item.startsWith(RainbowPresserColors[rpc])) { // Prevent
|
|
||||||
// words
|
|
||||||
// being
|
|
||||||
// equal/starting
|
|
||||||
// with a
|
|
||||||
// color
|
|
||||||
// code
|
|
||||||
// letter to
|
|
||||||
// be messed
|
|
||||||
// up
|
|
||||||
if (rpc + 1 < RainbowPresserColors.length)
|
|
||||||
rpc++;
|
|
||||||
else
|
|
||||||
rpc = 0;
|
|
||||||
}
|
|
||||||
StringBuffer buf = new StringBuffer(formattedmessage);
|
StringBuffer buf = new StringBuffer(formattedmessage);
|
||||||
buf.replace(currentindex, currentindex + item.length(),
|
String replacestr;
|
||||||
String.format("§%s%s", RainbowPresserColors[rpc], item));
|
if (currentindex == 0)
|
||||||
|
replacestr = String
|
||||||
|
.format("\",\"color\":\"blue\"},{\"text\":\"%s\",\"color\":\"%s\"}",
|
||||||
|
item, RainbowPresserColors[rpc]);
|
||||||
|
else
|
||||||
|
replacestr = String.format(
|
||||||
|
",{\"text\":\" %s\",\"color\":\"%s\"}", item,
|
||||||
|
RainbowPresserColors[rpc]);
|
||||||
|
buf.replace(currentindex, currentindex + item.length() + 1,
|
||||||
|
replacestr); // +1: spaces
|
||||||
|
currentindex += replacestr.length();
|
||||||
formattedmessage = buf.toString();
|
formattedmessage = buf.toString();
|
||||||
if (rpc + 1 < RainbowPresserColors.length)
|
if (rpc + 1 < RainbowPresserColors.length)
|
||||||
rpc++;
|
rpc++;
|
||||||
else
|
else
|
||||||
rpc = 0;
|
rpc = 0;
|
||||||
}
|
}
|
||||||
currentindex += item.length() + 3;
|
} // TODO: Set properties (color, formatting) per word, so it won't
|
||||||
|
// embed formatting into formatting into formatting...
|
||||||
|
if (colormode.equals("rpc")) { //TODO: Fix URLs in rainbow mode (^)
|
||||||
|
StringBuffer buf = new StringBuffer(formattedmessage);
|
||||||
|
String replacestr = ",{\"text\":\"";
|
||||||
|
buf.append(replacestr);
|
||||||
|
formattedmessage = buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hadurls) {
|
if (!hadurls) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class MWikiCommand extends TBMCCommandBase {
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
String query = "";
|
String query = "";
|
||||||
for (int i = 0; i < args.length; i++)
|
for (int i = 0; i < args.length; i++)
|
||||||
query += args[i];
|
query += args[i] + " ";
|
||||||
query = query.trim();
|
query = query.trim();
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
sender.sendMessage("§bMinecraft Wiki link: http://minecraft.gamepedia.com/");
|
sender.sendMessage("§bMinecraft Wiki link: http://minecraft.gamepedia.com/");
|
||||||
|
|
Loading…
Reference in a new issue