Encoding stuff

This commit is contained in:
Norbi Peti 2016-05-05 21:55:21 +02:00
parent d79b0dd687
commit 14837e1d80
6 changed files with 74 additions and 74 deletions

Binary file not shown.

View file

@ -11,9 +11,9 @@ public class Channel {
Command = command;
}
public static Channel GlobalChat = new Channel("§fg§f", "white", "g");
public static Channel TownChat = new Channel("§3TC§f", "dark_aqua", "tc");
public static Channel NationChat = new Channel("§6NC§f", "gold", "nc");
public static Channel AdminChat = new Channel("§cADMIN§f", "red", "a");
public static Channel ModChat = new Channel("§9MOD§f", "blue", "mod");
public static Channel GlobalChat = new Channel("§fg§f", "white", "g");
public static Channel TownChat = new Channel("§3TC§f", "dark_aqua", "tc");
public static Channel NationChat = new Channel("§6NC§f", "gold", "nc");
public static Channel AdminChat = new Channel("§cADMIN§f", "red", "a");
public static Channel ModChat = new Channel("§9MOD§f", "blue", "mod");
}

View file

@ -92,8 +92,8 @@ public class ChatProcessing {
// first
formattedmessage = formattedmessage.replace("\"", "\\\"");
if (PluginMain.permission.has(sender, "tbmc.admin"))
formattedmessage = formattedmessage.replace("&", "§");
formattedmessage = formattedmessage.replace("§r", "§"
formattedmessage = formattedmessage.replace("&", "§");
formattedmessage = formattedmessage.replace("§r", "§"
+ currentchannel.DisplayName.charAt(1));
String suggestmsg = formattedmessage;
@ -134,7 +134,7 @@ public class ChatProcessing {
}
StringBuffer buf = new StringBuffer(formattedmessage);
buf.replace(currentindex, currentindex + item.length(),
String.format("§%s%s", RainbowPresserColors[rpc], item));
String.format("§%s%s", RainbowPresserColors[rpc], item));
formattedmessage = buf.toString();
if (rpc + 1 < RainbowPresserColors.length)
rpc++;
@ -160,7 +160,7 @@ public class ChatProcessing {
MaybeOfflinePlayer mpp = MaybeOfflinePlayer
.AddPlayerIfNeeded(p.getUniqueId());
color = String.format(
"§%x",
"§%x",
(mpp.GetFlairColor() == 0x00 ? 0xb : mpp
.GetFlairColor()));
}
@ -170,21 +170,21 @@ public class ChatProcessing {
"(?i)" + Pattern.quote(p.getName()),
String.format(
"\",\"color\":\"%s\"},{\"text\":\"%s%s%s\",\"color\":\"blue\"},{\"text\":\"",
colormode, color, p.getName(), "§r"));
colormode, color, p.getName(), "§r"));
}
for (String n : PlayerListener.nicknames.keySet()) {
Player p = null;
String nwithoutformatting = new String(n);
int index;
while ((index = nwithoutformatting.indexOf("§k")) != -1)
nwithoutformatting = nwithoutformatting.replace("§k"
while ((index = nwithoutformatting.indexOf("§k")) != -1)
nwithoutformatting = nwithoutformatting.replace("§k"
+ nwithoutformatting.charAt(index + 2), ""); // Support
// for
// one
// random
// char
while ((index = nwithoutformatting.indexOf('§')) != -1)
nwithoutformatting = nwithoutformatting.replace("§"
while ((index = nwithoutformatting.indexOf('§')) != -1)
nwithoutformatting = nwithoutformatting.replace("§"
+ nwithoutformatting.charAt(index + 1), "");
if (formattedmessage.matches("(?i).*"
+ Pattern.quote(nwithoutformatting) + ".*")) {
@ -205,19 +205,19 @@ public class ChatProcessing {
"(?i)" + Pattern.quote(nwithoutformatting),
String.format(
"\",\"color\":\"%s\"},{\"text\":\"%s%s\",\"color\":\"blue\"},{\"text\":\"",
colormode, n, "§r"));
colormode, n, "§r"));
}
}
if (formattedmessage.matches("(?i).*" + Pattern.quote("@console")
+ ".*")) {
formattedmessage = formattedmessage.replaceAll(
"(?i)" + Pattern.quote("@console"), "§b@console§r");
"(?i)" + Pattern.quote("@console"), "§b@console§r");
formattedmessage = formattedmessage
.replaceAll(
"(?i)" + Pattern.quote("@console"),
String.format(
"\",\"color\":\"%s\"},{\"text\":\"§b@console§r\",\"color\":\"blue\"},{\"text\":\"",
"\",\"color\":\"%s\"},{\"text\":\"§b@console§r\",\"color\":\"blue\"},{\"text\":\"",
colormode));
System.out.println("\007");
}
@ -284,13 +284,13 @@ public class ChatProcessing {
formattedmessage, colormode));
String jsonstr = json.toString();
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.");
return true;
}
if (currentchannel.equals(Channel.TownChat)
|| currentchannel.equals(Channel.NationChat)) {
if (player == null) {
sender.sendMessage("§cYou are not a player!");
sender.sendMessage("§cYou are not a player!");
return true;
}
for (Player p : PluginMain.GetPlayers()) {
@ -316,7 +316,7 @@ public class ChatProcessing {
} catch (NotRegisteredException e) {
}
if (town == null) {
player.sendMessage("§cYou aren't in a town or an error occured.");
player.sendMessage("§cYou aren't in a town or an error occured.");
return true;
}
index = PluginMain.Instance.Towns.indexOf(town);
@ -345,11 +345,11 @@ public class ChatProcessing {
index, index, json.toString()));
} catch (IllegalStateException e) {
e.printStackTrace();
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
return true;
} catch (IllegalArgumentException e) {
e.printStackTrace();
player.sendMessage("§cAn error occured while sending the message. (IllegalArgumentException)");
player.sendMessage("§cAn error occured while sending the message. (IllegalArgumentException)");
return true;
}
} else if (currentchannel.equals(Channel.NationChat)) {
@ -361,7 +361,7 @@ public class ChatProcessing {
} catch (NotRegisteredException e) {
}
if (town == null) {
player.sendMessage("§cYou aren't in a town or an error occured.");
player.sendMessage("§cYou aren't in a town or an error occured.");
return true;
}
Nation nation = null;
@ -370,7 +370,7 @@ public class ChatProcessing {
} catch (NotRegisteredException e) {
}
if (nation == null) {
player.sendMessage("§cYour town isn't in a nation or an error occured.");
player.sendMessage("§cYour town isn't in a nation or an error occured.");
return true;
}
index = PluginMain.Instance.Nations.indexOf(nation);
@ -399,17 +399,17 @@ public class ChatProcessing {
index, index, json.toString()));
} catch (IllegalStateException e) {
e.printStackTrace();
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
return true;
} catch (IllegalArgumentException e) {
e.printStackTrace();
player.sendMessage("§cAn error occured while sending the message. (IllegalArgumentException)");
player.sendMessage("§cAn error occured while sending the message. (IllegalArgumentException)");
return true;
}
} else if (currentchannel.equals(Channel.AdminChat)) {
try { // TODO: Put message JSON into it's structure
if (player != null && !player.isOp()) {
player.sendMessage("§cYou need to be an OP to use this channel.");
player.sendMessage("§cYou need to be an OP to use this channel.");
return true;
}
Objective obj = PluginMain.SB.getObjective("admin");
@ -428,18 +428,18 @@ public class ChatProcessing {
1, 1, json.toString()));
} catch (IllegalStateException e) {
e.printStackTrace();
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
return true;
} catch (IllegalArgumentException e) {
e.printStackTrace();
player.sendMessage("§cAn error occured while sending the message. (IllegalArgumentException)");
player.sendMessage("§cAn error occured while sending the message. (IllegalArgumentException)");
return true;
}
} else if (currentchannel.equals(Channel.ModChat)) {
try {
if (player != null
&& !PermissionsEx.getUser(player).inGroup("mod")) {
player.sendMessage("§cYou need to be a mod to use this channel.");
player.sendMessage("§cYou need to be a mod to use this channel.");
return true;
}
Objective obj = PluginMain.SB.getObjective("mod");
@ -456,11 +456,11 @@ public class ChatProcessing {
1, 1, json.toString()));
} catch (IllegalStateException e) {
e.printStackTrace();
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
player.sendMessage("§cAn error occured while sending the message. (IllegalStateException)");
return true;
} catch (IllegalArgumentException e) {
e.printStackTrace();
player.sendMessage("§cAn error occured while sending the message. (IllegalArgumentException)");
player.sendMessage("§cAn error occured while sending the message. (IllegalArgumentException)");
return true;
}
} else

View file

@ -104,12 +104,12 @@ public class MaybeOfflinePlayer {
public String GetFormattedFlair() {
if (FlairTime == FlairTimeCantPress)
return String.format("§r(--s)§r");
return String.format("§r(--s)§r");
if (FlairTime == FlairTimeNonPresser)
return String.format("§7(--s)§r");
return String.format("§7(--s)§r");
if (FlairTime == FlairTimeNone)
return "";
return String.format("§%x(%ss)§r", GetFlairColor(), FlairTime);
return String.format("§%x(%ss)§r", GetFlairColor(), FlairTime);
}
public void SetFlair(short time) {

View file

@ -227,7 +227,7 @@ public class PlayerListener implements Listener {
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
mp.CurrentChannel = Channel.GlobalChat;
event.getPlayer().sendMessage(
"§6You are now talking in: §b"
"§6You are now talking in: §b"
+ mp.CurrentChannel.DisplayName);
event.setCancelled(true);
} else if (cmd.equalsIgnoreCase(Channel.TownChat.Command)) {
@ -236,7 +236,7 @@ public class PlayerListener implements Listener {
else
mp.CurrentChannel = Channel.TownChat;
event.getPlayer().sendMessage(
"§6You are now talking in: §b"
"§6You are now talking in: §b"
+ mp.CurrentChannel.DisplayName);
event.setCancelled(true);
} else if (cmd.equalsIgnoreCase(Channel.NationChat.Command)) {
@ -245,7 +245,7 @@ public class PlayerListener implements Listener {
else
mp.CurrentChannel = Channel.NationChat;
event.getPlayer().sendMessage(
"§6You are now talking in: §b"
"§6You are now talking in: §b"
+ mp.CurrentChannel.DisplayName);
event.setCancelled(true);
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
@ -254,7 +254,7 @@ public class PlayerListener implements Listener {
else
mp.CurrentChannel = Channel.AdminChat;
event.getPlayer().sendMessage(
"§6You are now talking in: §b"
"§6You are now talking in: §b"
+ mp.CurrentChannel.DisplayName);
event.setCancelled(true);
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
@ -263,7 +263,7 @@ public class PlayerListener implements Listener {
else
mp.CurrentChannel = Channel.ModChat;
event.getPlayer().sendMessage(
"§6You are now talking in: §b"
"§6You are now talking in: §b"
+ mp.CurrentChannel.DisplayName);
event.setCancelled(true);
}
@ -304,9 +304,9 @@ public class PlayerListener implements Listener {
Player player = Bukkit.getPlayer(event.getMessage().substring(
index + 1));
if (player != null)
player.sendMessage("§b"
player.sendMessage("§b"
+ event.getPlayer().getDisplayName()
+ " §bis in this world: "
+ " §bis in this world: "
+ event.getPlayer().getWorld().getName());
} else if (cmd.equalsIgnoreCase("minecraft:me")) {
if (!essentials.getUser(event.getPlayer()).isMuted()) {
@ -352,7 +352,7 @@ public class PlayerListener implements Listener {
.getId().equalsIgnoreCase("tower")) {
event.getPlayer()
.sendMessage(
"§cYou are not allowed to teleport players out from the Tower");
"§cYou are not allowed to teleport players out from the Tower");
event.setCancelled(true);
}
}
@ -370,7 +370,7 @@ public class PlayerListener implements Listener {
PS.valueOf(event.getPlayer().getLocation()))
.getId().equalsIgnoreCase("tower")) {
event.getPlayer().sendMessage(
"§cYou are not allowed to teleport to the Tower");
"§cYou are not allowed to teleport to the Tower");
event.setCancelled(true);
}
}
@ -392,7 +392,7 @@ public class PlayerListener implements Listener {
.contains(town2.getNation())) {
event.getPlayer()
.sendMessage(
"§cYou cannot set homes in enemy territory.");
"§cYou cannot set homes in enemy territory.");
event.setCancelled(true);
return;
}
@ -421,7 +421,7 @@ public class PlayerListener implements Listener {
if (war.isWarZone(new WorldCoord(currentWorld, currentLocation
.getBlockX(), currentLocation.getBlockZ()))) {
event.getPlayer().sendMessage(
"§cError: You can't teleport out of a war zone!");
"§cError: You can't teleport out of a war zone!");
event.setCancelled(true);
}
}
@ -439,7 +439,7 @@ public class PlayerListener implements Listener {
index + 1));
if (target == null) {
event.getPlayer().sendMessage(
"§cError: Player not found. (/un" + s
"§cError: Player not found. (/un" + s
+ " <player>)");
event.setCancelled(true);
}
@ -468,7 +468,7 @@ public class PlayerListener implements Listener {
event.setCancelled(true);
event.getPlayer()
.sendMessage(
"§cYou are not allowed to set New Haven as your enemy faction.");
"§cYou are not allowed to set New Haven as your enemy faction.");
}
}
}
@ -480,15 +480,15 @@ public class PlayerListener implements Listener {
for (String nickname : nicknames.keySet()) {
String nwithoutformatting = nickname;
int index;
while ((index = nwithoutformatting.indexOf("§k")) != -1)
nwithoutformatting = nwithoutformatting.replace("§k"
while ((index = nwithoutformatting.indexOf("§k")) != -1)
nwithoutformatting = nwithoutformatting.replace("§k"
+ nwithoutformatting.charAt(index + 2), ""); // Support
// for
// one
// random
// char
while ((index = nwithoutformatting.indexOf('§')) != -1)
nwithoutformatting = nwithoutformatting.replace("§"
while ((index = nwithoutformatting.indexOf('§')) != -1)
nwithoutformatting = nwithoutformatting.replace("§"
+ nwithoutformatting.charAt(index + 1), "");
if (nwithoutformatting.startsWith(name)
&& !nwithoutformatting.equals(Bukkit.getPlayer(
@ -538,7 +538,7 @@ public class PlayerListener implements Listener {
MaybeOfflinePlayer mp = MaybeOfflinePlayer.AllPlayers.get(p
.getUniqueId());
mp.PressedF = false;
p.sendMessage("§bPress F to pay respects.§r");
p.sendMessage("§bPress F to pay respects.§r");
}
Ftimer = new Timer();
TimerTask tt = new TimerTask() {
@ -547,9 +547,9 @@ public class PlayerListener implements Listener {
if (ActiveF) {
ActiveF = false;
for (Player p : PluginMain.GetPlayers()) {
p.sendMessage("§b" + FCount + " "
p.sendMessage("§b" + FCount + " "
+ (FCount == 1 ? "person" : "people")
+ " paid their respects.§r");
+ " paid their respects.§r");
}
}
}
@ -580,7 +580,7 @@ public class PlayerListener implements Listener {
return;
// System.out.println("D");
SkullMeta meta = (SkullMeta) item.getItemMeta();
if (!meta.getDisplayName().equals("§rOcelot Head")
if (!meta.getDisplayName().equals("§rOcelot Head")
|| !meta.getOwner().equals("MHF_Ocelot"))
return;
// System.out.println("E");
@ -591,7 +591,7 @@ public class PlayerListener implements Listener {
if (!(hat != null
&& (hat.getType().equals(Material.SKULL) || hat.getType()
.equals(Material.SKULL_ITEM)) && ((SkullMeta) hat
.getItemMeta()).getDisplayName().equals("§rWolf Head")))
.getItemMeta()).getDisplayName().equals("§rWolf Head")))
e.getPlayer().damage(1f * item.getAmount(),
Bukkit.getPlayer(meta.getLore().get(0)));
e.getItem().remove();
@ -610,7 +610,7 @@ public class PlayerListener implements Listener {
PluginMain.economy.depositPlayer(op, 50.0);
}
if (p != null) {
p.sendMessage("§bThanks for voting! $50 was added to your account.");
p.sendMessage("§bThanks for voting! $50 was added to your account.");
}
}
@ -658,14 +658,14 @@ public class PlayerListener implements Listener {
* System.out.println("Cause: "+e.getCause());
*/
e.getPlayer().sendMessage(
"§cYou are not allowed to teleport to/from No Mans Land.");
"§cYou are not allowed to teleport to/from No Mans Land.");
}
if (MaybeOfflinePlayer.GetFromPlayer(e.getPlayer()).ChatOnly) {
e.setCancelled(true);
e.getPlayer()
.sendMessage(
"§cYou are not allowed to teleport while in chat-only mode.");
"§cYou are not allowed to teleport while in chat-only mode.");
}
}
@ -684,7 +684,7 @@ public class PlayerListener implements Listener {
if (block.getType() == Material.ENDER_CHEST) {
e.setCancelled(true);
e.getPlayer().sendMessage(
"§You are not allowed to use enderchests here.");
"§You are not allowed to use enderchests here.");
System.out.println(e.getPlayer().getName()
+ " tried to use an enderchest in twohundred.");
}
@ -704,7 +704,7 @@ public class PlayerListener implements Listener {
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
ConsoleChannel = Channel.GlobalChat;
event.getSender().sendMessage(
"§6You are now talking in: §b"
"§6You are now talking in: §b"
+ ConsoleChannel.DisplayName);
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
@ -713,7 +713,7 @@ public class PlayerListener implements Listener {
else
ConsoleChannel = Channel.AdminChat;
event.getSender().sendMessage(
"§6You are now talking in: §b"
"§6You are now talking in: §b"
+ ConsoleChannel.DisplayName);
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
@ -722,7 +722,7 @@ public class PlayerListener implements Listener {
else
ConsoleChannel = Channel.ModChat;
event.getSender().sendMessage(
"§6You are now talking in: §b"
"§6You are now talking in: §b"
+ ConsoleChannel.DisplayName);
event.setCommand("dontrunthiscmd");
}
@ -782,7 +782,7 @@ public class PlayerListener implements Listener {
target = Bukkit.getPlayer(event.getCommand().substring(index + 1));
if (target == null) {
event.getSender().sendMessage(
"§cError: Player not found. (/un" + s + " <player>)");
"§cError: Player not found. (/un" + s + " <player>)");
event.setCommand("dontrunthiscmd");
}
if (target != null) {

View file

@ -82,27 +82,27 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
Commands comm = new Commands();
this.getCommand("u").setExecutor(comm);
this.getCommand("u").setUsage(
this.getCommand("u").getUsage().replace('&', '§'));
this.getCommand("u").getUsage().replace('&', '§'));
this.getCommand("nrp").setExecutor(comm);
this.getCommand("nrp").setUsage(
this.getCommand("nrp").getUsage().replace('&', '§'));
this.getCommand("nrp").getUsage().replace('&', '§'));
this.getCommand("ooc").setExecutor(comm);
this.getCommand("ooc").setUsage(
this.getCommand("ooc").getUsage().replace('&', '§'));
this.getCommand("ooc").getUsage().replace('&', '§'));
this.getCommand("unlol").setExecutor(comm);
this.getCommand("unlaugh").setExecutor(comm);
this.getCommand("mwiki").setExecutor(comm);
this.getCommand("mwiki").setUsage(
this.getCommand("mwiki").getUsage().replace('&', '§'));
this.getCommand("mwiki").getUsage().replace('&', '§'));
this.getCommand("tableflip").setExecutor(comm);
this.getCommand("tableflip").setUsage(
this.getCommand("tableflip").getUsage().replace('&', '§'));
this.getCommand("tableflip").getUsage().replace('&', '§'));
this.getCommand("unflip").setExecutor(comm);
this.getCommand("unflip").setUsage(
this.getCommand("unflip").getUsage().replace('&', '§'));
this.getCommand("unflip").getUsage().replace('&', '§'));
this.getCommand("chatonly").setExecutor(comm);
this.getCommand("chatonly").setUsage(
this.getCommand("chatonly").getUsage().replace('&', '§'));
this.getCommand("chatonly").getUsage().replace('&', '§'));
Instance = this;
Console = this.getServer().getConsoleSender();
LoadFiles(false);
@ -312,9 +312,9 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
Player p = Bukkit.getPlayer(mp.UUID);
if (mp.FlairState.equals(FlairStates.Commented) && p != null)
if (mp.UserNames.size() > 1)
p.sendMessage("§9Multiple Reddit users commented your name. You can select with /u accept.§r §6Type /u accept or /u ignore§r");
p.sendMessage("§9Multiple Reddit users commented your name. You can select with /u accept.§r §6Type /u accept or /u ignore§r");
else
p.sendMessage("§9A Reddit user commented your name. Is that you?§r §6Type /u accept or /u ignore§r");
p.sendMessage("§9A Reddit user commented your name. Is that you?§r §6Type /u accept or /u ignore§r");
}
public static Collection<? extends Player> GetPlayers() {