Done #12 - Changed color setting
This commit is contained in:
parent
9300e59438
commit
8dc253564c
3 changed files with 59 additions and 71 deletions
|
@ -26,9 +26,10 @@ public class ChatProcessing {
|
||||||
PlayerListener.essentials = (Essentials) (Bukkit.getPluginManager()
|
PlayerListener.essentials = (Essentials) (Bukkit.getPluginManager()
|
||||||
.getPlugin("Essentials"));
|
.getPlugin("Essentials"));
|
||||||
Player player = (sender instanceof Player ? (Player) sender : null);
|
Player player = (sender instanceof Player ? (Player) sender : null);
|
||||||
if (player != null && message.equalsIgnoreCase("F")) {
|
MaybeOfflinePlayer mp = null;
|
||||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AllPlayers.get(player
|
if (player != null) {
|
||||||
.getUniqueId());
|
mp = MaybeOfflinePlayer.AllPlayers.get(player.getUniqueId());
|
||||||
|
if (message.equalsIgnoreCase("F")) {
|
||||||
if (!mp.PressedF && PlayerListener.ActiveF) {
|
if (!mp.PressedF && PlayerListener.ActiveF) {
|
||||||
PlayerListener.FCount++;
|
PlayerListener.FCount++;
|
||||||
mp.PressedF = true;
|
mp.PressedF = true;
|
||||||
|
@ -37,8 +38,8 @@ public class ChatProcessing {
|
||||||
PlayerListener.FPlayer.FCount++;
|
PlayerListener.FPlayer.FCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean greentext = message.startsWith(">");
|
|
||||||
String msg = message.toLowerCase();
|
String msg = message.toLowerCase();
|
||||||
if (player != null && msg.contains("lol")) {
|
if (player != null && msg.contains("lol")) {
|
||||||
Commands.Lastlol = MaybeOfflinePlayer.AllPlayers.get(player
|
Commands.Lastlol = MaybeOfflinePlayer.AllPlayers.get(player
|
||||||
|
@ -54,13 +55,16 @@ public class ChatProcessing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Channel currentchannel = (mp == null ? PlayerListener.ConsoleChannel
|
||||||
|
: mp.CurrentChannel);
|
||||||
|
|
||||||
|
String colormode = currentchannel.Color;
|
||||||
|
if (mp.OtherColorMode.length() > 0)
|
||||||
|
colormode = mp.OtherColorMode;
|
||||||
|
if (message.startsWith(">"))
|
||||||
|
colormode = "green"; // If greentext, ignore channel or player
|
||||||
|
// colors
|
||||||
|
|
||||||
MaybeOfflinePlayer mplayer = null;
|
|
||||||
if (player != null) {
|
|
||||||
mplayer = MaybeOfflinePlayer.AllPlayers.get(player.getUniqueId());
|
|
||||||
}
|
|
||||||
Channel currentchannel = (mplayer == null ? PlayerListener.ConsoleChannel
|
|
||||||
: mplayer.CurrentChannel);
|
|
||||||
String formattedmessage = message;
|
String formattedmessage = message;
|
||||||
formattedmessage = formattedmessage.replace("\\", "\\\\"); // It's
|
formattedmessage = formattedmessage.replace("\\", "\\\\"); // It's
|
||||||
// really
|
// really
|
||||||
|
@ -91,14 +95,11 @@ public class ChatProcessing {
|
||||||
item,
|
item,
|
||||||
String.format(
|
String.format(
|
||||||
"\",\"color\":\"%s\"},{\"text\":\"%s\",\"color\":\"%s\",\"underlined\":\"true\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Open URL\",\"color\":\"blue\"}]}}},{\"text\":\"",
|
"\",\"color\":\"%s\"},{\"text\":\"%s\",\"color\":\"%s\",\"underlined\":\"true\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Open URL\",\"color\":\"blue\"}]}}},{\"text\":\"",
|
||||||
(greentext ? "green"
|
colormode, url, colormode, url));
|
||||||
: currentchannel.Color), url,
|
|
||||||
(greentext ? "green"
|
|
||||||
: currentchannel.Color), url));
|
|
||||||
hadurls = true;
|
hadurls = true;
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
}
|
}
|
||||||
if (mplayer != null && mplayer.RainbowPresserColorMode) { // TODO:
|
if (mp != null && mp.RainbowPresserColorMode) { // TODO:
|
||||||
// Rainbow
|
// Rainbow
|
||||||
// mode
|
// mode
|
||||||
// for
|
// for
|
||||||
|
@ -129,10 +130,6 @@ public class ChatProcessing {
|
||||||
}
|
}
|
||||||
currentindex += item.length() + 3;
|
currentindex += item.length() + 3;
|
||||||
}
|
}
|
||||||
if (mplayer != null && mplayer.OtherColorMode != 0xFF) {
|
|
||||||
formattedmessage = String.format("§%x%s", mplayer.OtherColorMode,
|
|
||||||
formattedmessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hadurls) {
|
if (!hadurls) {
|
||||||
for (Player p : PluginMain.GetPlayers()) {
|
for (Player p : PluginMain.GetPlayers()) {
|
||||||
|
@ -140,27 +137,24 @@ public class ChatProcessing {
|
||||||
if (formattedmessage.matches("(?i).*"
|
if (formattedmessage.matches("(?i).*"
|
||||||
+ Pattern.quote(p.getName()) + ".*")) {
|
+ Pattern.quote(p.getName()) + ".*")) {
|
||||||
if (PlayerListener.NotificationSound == null)
|
if (PlayerListener.NotificationSound == null)
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f,
|
p.playSound(p.getLocation(),
|
||||||
0.5f);
|
Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO:
|
||||||
|
// Airhorn
|
||||||
else
|
else
|
||||||
p.playSound(p.getLocation(),
|
p.playSound(p.getLocation(),
|
||||||
PlayerListener.NotificationSound, 1.0f,
|
PlayerListener.NotificationSound, 1.0f,
|
||||||
(float) PlayerListener.NotificationPitch);
|
(float) PlayerListener.NotificationPitch);
|
||||||
MaybeOfflinePlayer mp = MaybeOfflinePlayer
|
MaybeOfflinePlayer mpp = MaybeOfflinePlayer
|
||||||
.AddPlayerIfNeeded(p.getUniqueId());
|
.AddPlayerIfNeeded(p.getUniqueId());
|
||||||
color = String.format(
|
color = String.format(
|
||||||
"§%x",
|
"§%x",
|
||||||
(mp.GetFlairColor() == 0x00 ? 0xb : mp
|
(mpp.GetFlairColor() == 0x00 ? 0xb : mpp
|
||||||
.GetFlairColor()));
|
.GetFlairColor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
formattedmessage = formattedmessage.replaceAll(
|
formattedmessage = formattedmessage.replaceAll(
|
||||||
"(?i)" + Pattern.quote(p.getName()),
|
"(?i)" + Pattern.quote(p.getName()),
|
||||||
color
|
color + p.getName() + "§r");
|
||||||
+ p.getName()
|
|
||||||
+ (greentext ? "§a"
|
|
||||||
: currentchannel.DisplayName.substring(
|
|
||||||
0, 2)));
|
|
||||||
}
|
}
|
||||||
for (String n : PlayerListener.nicknames.keySet()) {
|
for (String n : PlayerListener.nicknames.keySet()) {
|
||||||
Player p = null;
|
Player p = null;
|
||||||
|
@ -180,8 +174,8 @@ public class ChatProcessing {
|
||||||
+ Pattern.quote(nwithoutformatting) + ".*")) {
|
+ Pattern.quote(nwithoutformatting) + ".*")) {
|
||||||
p = Bukkit.getPlayer(PlayerListener.nicknames.get(n));
|
p = Bukkit.getPlayer(PlayerListener.nicknames.get(n));
|
||||||
if (PlayerListener.NotificationSound == null)
|
if (PlayerListener.NotificationSound == null)
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f,
|
p.playSound(p.getLocation(),
|
||||||
0.5f); // 2015.08.12.
|
Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // 2015.08.12.
|
||||||
else
|
else
|
||||||
p.playSound(p.getLocation(),
|
p.playSound(p.getLocation(),
|
||||||
PlayerListener.NotificationSound, 1.0f,
|
PlayerListener.NotificationSound, 1.0f,
|
||||||
|
@ -189,12 +183,8 @@ public class ChatProcessing {
|
||||||
MaybeOfflinePlayer.AddPlayerIfNeeded(p.getUniqueId());
|
MaybeOfflinePlayer.AddPlayerIfNeeded(p.getUniqueId());
|
||||||
}
|
}
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
formattedmessage = formattedmessage.replaceAll(
|
formattedmessage = formattedmessage.replaceAll("(?i)"
|
||||||
"(?i)" + Pattern.quote(nwithoutformatting),
|
+ Pattern.quote(nwithoutformatting), n + "§r");
|
||||||
n
|
|
||||||
+ (greentext ? "§a"
|
|
||||||
: currentchannel.DisplayName
|
|
||||||
.substring(0, 2)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,27 +204,26 @@ public class ChatProcessing {
|
||||||
json.append("[\"\",");
|
json.append("[\"\",");
|
||||||
json.append(String
|
json.append(String
|
||||||
.format("{\"text\":\"[%s]%s\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Copy message\",\"color\":\"blue\"}},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"%s\"}},",
|
.format("{\"text\":\"[%s]%s\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Copy message\",\"color\":\"blue\"}},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"%s\"}},",
|
||||||
currentchannel.DisplayName, (mplayer != null
|
currentchannel.DisplayName,
|
||||||
&& !mplayer.RPMode ? "[OOC]" : ""), suggestmsg));
|
(mp != null && !mp.RPMode ? "[OOC]" : ""), suggestmsg));
|
||||||
json.append("{\"text\":\" <\"},");
|
json.append("{\"text\":\" <\"},");
|
||||||
json.append(String.format("{\"text\":\"%s%s\",",
|
json.append(String.format("{\"text\":\"%s%s\",",
|
||||||
(player != null ? player.getDisplayName() : sender.getName()),
|
(player != null ? player.getDisplayName() : sender.getName()),
|
||||||
(mplayer != null ? mplayer.GetFormattedFlair() : "")));
|
(mp != null ? mp.GetFormattedFlair() : "")));
|
||||||
json.append("\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[");
|
json.append("\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[");
|
||||||
json.append(String.format("{\"text\":\"%s\n\",",
|
json.append(String.format("{\"text\":\"%s\n\",",
|
||||||
(player != null ? player.getName() : sender.getName())));
|
(player != null ? player.getName() : sender.getName())));
|
||||||
json.append(String
|
json.append(String
|
||||||
.format("\"color\":\"aqua\"},{\"text\":\"World: %s\n\",\"color\":\"white\"},",
|
.format("\"color\":\"aqua\"},{\"text\":\"World: %s\n\",\"color\":\"white\"},",
|
||||||
(player != null ? player.getWorld().getName() : "-")));
|
(player != null ? player.getWorld().getName() : "-")));
|
||||||
json.append(String.format(
|
json.append(String
|
||||||
"{\"text\":\"Respect: %s%s%s\",\"color\":\"white\"}]}}},",
|
.format("{\"text\":\"Respect: %s%s%s\",\"color\":\"white\"}]}}},",
|
||||||
(mplayer != null ? (mplayer.FCount / (double) mplayer.FDeaths)
|
(mp != null ? (mp.FCount / (double) mp.FDeaths)
|
||||||
: "Infinite"),
|
: "Infinite"),
|
||||||
(mplayer != null && mplayer.UserName != null
|
(mp != null && mp.UserName != null
|
||||||
&& !mplayer.UserName.isEmpty() ? "\nUserName: "
|
&& !mp.UserName.isEmpty() ? "\nUserName: "
|
||||||
+ mplayer.UserName : ""),
|
+ mp.UserName : ""),
|
||||||
(mplayer != null
|
(mp != null && mp.PlayerName.equals("\nAlpha_Bacca44") ? "\nDeaths: "
|
||||||
&& mplayer.PlayerName.equals("\nAlpha_Bacca44") ? "\nDeaths: "
|
|
||||||
+ PlayerListener.AlphaDeaths
|
+ PlayerListener.AlphaDeaths
|
||||||
: "")));
|
: "")));
|
||||||
json.append("{\"text\":\"> \",\"color\":\"white\"},");
|
json.append("{\"text\":\"> \",\"color\":\"white\"},");
|
||||||
|
@ -261,13 +250,11 @@ public class ChatProcessing {
|
||||||
"#" + original,
|
"#" + original,
|
||||||
String.format(
|
String.format(
|
||||||
"\",\"color\":\"%s\"},{\"text\":\"#%s\",\"color\":\"blue\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://twitter.com/hashtag/%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Open on Twitter\",\"color\":\"blue\"}]}}},{\"text\":\"",
|
"\",\"color\":\"%s\"},{\"text\":\"#%s\",\"color\":\"blue\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://twitter.com/hashtag/%s\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"Open on Twitter\",\"color\":\"blue\"}]}}},{\"text\":\"",
|
||||||
(greentext ? "green"
|
colormode, original, original));
|
||||||
: currentchannel.Color),
|
|
||||||
original, original));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
json.append(String.format("{\"text\":\"%s\",\"color\":\"%s\"}]",
|
json.append(String.format("{\"text\":\"%s\",\"color\":\"%s\"}]",
|
||||||
formattedmessage, (greentext ? "green" : currentchannel.Color)));
|
formattedmessage, colormode));
|
||||||
String jsonstr = json.toString();
|
String jsonstr = json.toString();
|
||||||
if (jsonstr.length() >= 32767) {
|
if (jsonstr.length() >= 32767) {
|
||||||
sender.sendMessage("§cError: Message too large. Try shortening it, or remove hashtags and other formatting.");
|
sender.sendMessage("§cError: Message too large. Try shortening it, or remove hashtags and other formatting.");
|
||||||
|
@ -460,8 +447,8 @@ public class ChatProcessing {
|
||||||
currentchannel.DisplayName,
|
currentchannel.DisplayName,
|
||||||
(player != null ? player.getDisplayName()
|
(player != null ? player.getDisplayName()
|
||||||
: sender.getName()),
|
: sender.getName()),
|
||||||
(mplayer != null ? mplayer.GetFormattedFlair()
|
(mp != null ? mp.GetFormattedFlair() : ""),
|
||||||
: ""), message));
|
message));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ public class Commands implements CommandExecutor {
|
||||||
Timer timer = new Timer();
|
Timer timer = new Timer();
|
||||||
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
PlayerJoinTimerTask tt = new PlayerJoinTimerTask() {
|
||||||
Player player = Bukkit.getPlayer(mp.UUID);
|
Player player = Bukkit.getPlayer(mp.UUID);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
@ -187,7 +188,7 @@ public class Commands implements CommandExecutor {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
if (PluginMain.permission.has(player, "tbmc.rainbow")) {
|
if (PluginMain.permission.has(player, "tbmc.rainbow")) {
|
||||||
p.RainbowPresserColorMode = !p.RainbowPresserColorMode;
|
p.RainbowPresserColorMode = !p.RainbowPresserColorMode;
|
||||||
p.OtherColorMode = 0xFF;
|
p.OtherColorMode = "";
|
||||||
if (p.RainbowPresserColorMode)
|
if (p.RainbowPresserColorMode)
|
||||||
player.sendMessage("§eRainbow colors §aenabled.");
|
player.sendMessage("§eRainbow colors §aenabled.");
|
||||||
else
|
else
|
||||||
|
@ -199,11 +200,11 @@ public class Commands implements CommandExecutor {
|
||||||
} else {
|
} else {
|
||||||
if (PluginMain.permission.has(player, "tbmc.admin")) {
|
if (PluginMain.permission.has(player, "tbmc.admin")) {
|
||||||
p.RainbowPresserColorMode = false;
|
p.RainbowPresserColorMode = false;
|
||||||
p.OtherColorMode = Short.parseShort(args[1], 16);
|
p.OtherColorMode = args[1];
|
||||||
if (p.OtherColorMode != 0xFF)
|
if (p.OtherColorMode.length() > 0)
|
||||||
player.sendMessage(String.format(
|
player.sendMessage(String.format(
|
||||||
"§eMessage color set to §%x%x",
|
"§eMessage color set to %s",
|
||||||
p.OtherColorMode, p.OtherColorMode));
|
p.OtherColorMode));
|
||||||
else
|
else
|
||||||
player.sendMessage("§eMessage color reset.");
|
player.sendMessage("§eMessage color reset.");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class MaybeOfflinePlayer {
|
||||||
public boolean SendingLink = false;
|
public boolean SendingLink = false;
|
||||||
public int FDeaths;
|
public int FDeaths;
|
||||||
public boolean RainbowPresserColorMode = false;
|
public boolean RainbowPresserColorMode = false;
|
||||||
public short OtherColorMode = 0xFF;
|
public String OtherColorMode = "";
|
||||||
|
|
||||||
public UUID UUID;
|
public UUID UUID;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue