Fixed flair in onGetInfo, improved channels
This commit is contained in:
parent
e356a401e2
commit
5ec39c3581
2 changed files with 46 additions and 60 deletions
|
@ -81,14 +81,31 @@ public class ChatPlayer extends TBMCPlayer {
|
||||||
public static final short FlairTimeCantPress = -2;
|
public static final short FlairTimeCantPress = -2;
|
||||||
public static final short FlairTimeNone = -3;
|
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)
|
if (getFlairTime() == FlairTimeCantPress)
|
||||||
return String.format("§r(--s)§r");
|
return String.format(noformats ? "(can't press)" : "§r(--s)§r");
|
||||||
if (getFlairTime() == FlairTimeNonPresser)
|
if (getFlairTime() == FlairTimeNonPresser)
|
||||||
return String.format("§7(--s)§r");
|
return String.format(noformats ? "(non-presser)" : "§7(--s)§r");
|
||||||
if (getFlairTime() == FlairTimeNone)
|
if (getFlairTime() == FlairTimeNone)
|
||||||
return "";
|
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) {
|
public void SetFlair(short time) {
|
||||||
|
|
|
@ -321,62 +321,28 @@ public class PlayerListener implements Listener {
|
||||||
String cmd = "";
|
String cmd = "";
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
cmd = event.getCommand();
|
cmd = event.getCommand();
|
||||||
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
|
for (Channel channel : Channel.getChannels()) {
|
||||||
ConsoleChannel = Channel.GlobalChat;
|
if (cmd.equalsIgnoreCase(channel.Command)) {
|
||||||
event.getSender().sendMessage("§6You are now talking in: §b" + ConsoleChannel.DisplayName);
|
if (ConsoleChannel.equals(channel))
|
||||||
event.setCommand("dontrunthiscmd");
|
ConsoleChannel = Channel.GlobalChat;
|
||||||
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
|
else
|
||||||
if (ConsoleChannel.equals(Channel.AdminChat))
|
ConsoleChannel = channel;
|
||||||
ConsoleChannel = Channel.GlobalChat;
|
event.getSender().sendMessage("§6You are now talking in: §b" + ConsoleChannel.DisplayName);
|
||||||
else
|
event.setCommand("dontrunthiscmd");
|
||||||
ConsoleChannel = Channel.AdminChat;
|
break;
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cmd = event.getCommand().substring(0, index);
|
cmd = event.getCommand().substring(0, index);
|
||||||
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
|
for (Channel channel : Channel.getChannels()) {
|
||||||
Channel c = ConsoleChannel;
|
if (cmd.equalsIgnoreCase(channel.Command)) {
|
||||||
ConsoleChannel = Channel.GlobalChat;
|
Channel c = ConsoleChannel;
|
||||||
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
|
ConsoleChannel = channel;
|
||||||
event.getCommand().substring(index + 1));
|
ChatProcessing.ProcessChat(Bukkit.getServer().getConsoleSender(),
|
||||||
ConsoleChannel = c;
|
event.getCommand().substring(index + 1));
|
||||||
event.setCommand("dontrunthiscmd");
|
ConsoleChannel = c;
|
||||||
} else if (cmd.equalsIgnoreCase(Channel.TownChat.Command)) {
|
event.setCommand("dontrunthiscmd");
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cmd.toLowerCase().startsWith("un")) {
|
if (cmd.toLowerCase().startsWith("un")) {
|
||||||
|
@ -409,8 +375,11 @@ public class PlayerListener implements Listener {
|
||||||
e.addInfo("Reddit name: " + cp.getUserName());
|
e.addInfo("Reddit name: " + cp.getUserName());
|
||||||
if (e.getTarget() == InfoTarget.MCCommand)
|
if (e.getTarget() == InfoTarget.MCCommand)
|
||||||
e.addInfo("/r/TheButton flair: " + cp.GetFormattedFlair());
|
e.addInfo("/r/TheButton flair: " + cp.GetFormattedFlair());
|
||||||
else
|
else {
|
||||||
e.addInfo("/r/TheButton flair: (" + cp.getFlairTime() + "s)");
|
final String flair = cp.GetFormattedFlair(true);
|
||||||
e.addInfo("Respect: " + cp.getFCount() / cp.getFDeaths());
|
if (flair.length() > 0)
|
||||||
|
e.addInfo("/r/TheButton flair: " + flair);
|
||||||
|
}
|
||||||
|
e.addInfo("Respect: " + (double) cp.getFCount() / (double) cp.getFDeaths());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue