Fixed flair in onGetInfo, improved channels

This commit is contained in:
Norbi Peti 2016-11-14 17:58:09 +01:00
parent e356a401e2
commit 5ec39c3581
2 changed files with 46 additions and 60 deletions

View file

@ -81,14 +81,31 @@ public class ChatPlayer extends TBMCPlayer {
public static final short FlairTimeCantPress = -2;
public static final short FlairTimeNone = -3;
public String GetFormattedFlair() {
/**
* Gets the player's flair, optionally formatting for Minecraft.
*
* @param noformats
* The MC formatting codes will be only applied if false
* @return The flair
*/
public String GetFormattedFlair(boolean noformats) {
if (getFlairTime() == FlairTimeCantPress)
return String.format("§r(--s)§r");
return String.format(noformats ? "(can't press)" : "§r(--s)§r");
if (getFlairTime() == FlairTimeNonPresser)
return String.format("§7(--s)§r");
return String.format(noformats ? "(non-presser)" : "§7(--s)§r");
if (getFlairTime() == FlairTimeNone)
return "";
return String.format("§%x(%ss)§r", GetFlairColor(), getFlairTime());
return noformats ? String.format("(%ss)", getFlairTime())
: String.format("§%x(%ss)§r", GetFlairColor(), getFlairTime());
}
/**
* Gets the player's flair, formatted for Minecraft.
*
* @return The flair
*/
public String GetFormattedFlair() {
return GetFormattedFlair(false);
}
public void SetFlair(short time) {

View file

@ -321,62 +321,28 @@ public class PlayerListener implements Listener {
String cmd = "";
if (index == -1) {
cmd = event.getCommand();
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
ConsoleChannel = Channel.GlobalChat;
event.getSender().sendMessage("§6You are now talking in: §b" + ConsoleChannel.DisplayName);
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
if (ConsoleChannel.equals(Channel.AdminChat))
ConsoleChannel = Channel.GlobalChat;
else
ConsoleChannel = Channel.AdminChat;
event.getSender().sendMessage("§6You are now talking in: §b" + ConsoleChannel.DisplayName);
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
if (ConsoleChannel.equals(Channel.ModChat))
ConsoleChannel = Channel.GlobalChat;
else
ConsoleChannel = Channel.ModChat;
event.getSender().sendMessage("§6You are now talking in: §b" + ConsoleChannel.DisplayName);
event.setCommand("dontrunthiscmd");
for (Channel channel : Channel.getChannels()) {
if (cmd.equalsIgnoreCase(channel.Command)) {
if (ConsoleChannel.equals(channel))
ConsoleChannel = Channel.GlobalChat;
else
ConsoleChannel = channel;
event.getSender().sendMessage("§6You are now talking in: §b" + ConsoleChannel.DisplayName);
event.setCommand("dontrunthiscmd");
break;
}
}
} else {
cmd = event.getCommand().substring(0, index);
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
Channel c = ConsoleChannel;
ConsoleChannel = Channel.GlobalChat;
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
event.getCommand().substring(index + 1));
ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.TownChat.Command)) {
Channel c = ConsoleChannel;
ConsoleChannel = Channel.TownChat;
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
event.getCommand().substring(index + 1));
ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.NationChat.Command)) {
Channel c = ConsoleChannel;
ConsoleChannel = Channel.NationChat;
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
event.getCommand().substring(index + 1));
ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
Channel c = ConsoleChannel;
ConsoleChannel = Channel.AdminChat;
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
event.getCommand().substring(index + 1));
ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
Channel c = ConsoleChannel;
ConsoleChannel = Channel.ModChat;
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
event.getCommand().substring(index + 1));
ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
for (Channel channel : Channel.getChannels()) {
if (cmd.equalsIgnoreCase(channel.Command)) {
Channel c = ConsoleChannel;
ConsoleChannel = channel;
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
event.getCommand().substring(index + 1));
ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
}
}
}
if (cmd.toLowerCase().startsWith("un")) {
@ -409,8 +375,11 @@ public class PlayerListener implements Listener {
e.addInfo("Reddit name: " + cp.getUserName());
if (e.getTarget() == InfoTarget.MCCommand)
e.addInfo("/r/TheButton flair: " + cp.GetFormattedFlair());
else
e.addInfo("/r/TheButton flair: (" + cp.getFlairTime() + "s)");
e.addInfo("Respect: " + cp.getFCount() / cp.getFDeaths());
else {
final String flair = cp.GetFormattedFlair(true);
if (flair.length() > 0)
e.addInfo("/r/TheButton flair: " + flair);
}
e.addInfo("Respect: " + (double) cp.getFCount() / (double) cp.getFDeaths());
}
}