Added /lenny to plugin.yml and fixed an NPE
Fixed NPE for non-players trying to chat
This commit is contained in:
parent
9ab875f73b
commit
2f83a90553
3 changed files with 25 additions and 19 deletions
|
@ -134,8 +134,11 @@ public class ChatProcessing {
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
final int mcScore = VanillaUtils.getMCScoreIfChatOn(p, e);
|
final int mcScore = VanillaUtils.getMCScoreIfChatOn(p, e);
|
||||||
obj.getScore(p.getName())
|
obj.getScore(p.getName())
|
||||||
.setScore(p.getUniqueId().equals(player.getUniqueId()) ? score = mcScore : mcScore);
|
.setScore(p.getUniqueId().equals(player == null ? null : player.getUniqueId()) // p.UniqueID==player?.UniqueID
|
||||||
|
? score = mcScore : mcScore);
|
||||||
}
|
}
|
||||||
|
if (player == null)
|
||||||
|
score = e.getMCScore(sender);
|
||||||
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console, String.format(
|
PluginMain.Instance.getServer().dispatchCommand(PluginMain.Console, String.format(
|
||||||
"tellraw @a[score_%s=%d,score_%s_min=%d] %s", channel.ID, score, channel.ID, score, jsonstr));
|
"tellraw @a[score_%s=%d,score_%s_min=%d] %s", channel.ID, score, channel.ID, score, jsonstr));
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class PlayerListener implements Listener {
|
||||||
int index = event.getMessage().indexOf(" ");
|
int index = event.getMessage().indexOf(" ");
|
||||||
ChatPlayer mp = TBMCPlayer.getPlayer(event.getPlayer().getUniqueId(), ChatPlayer.class);
|
ChatPlayer mp = TBMCPlayer.getPlayer(event.getPlayer().getUniqueId(), ChatPlayer.class);
|
||||||
String cmd = "";
|
String cmd = "";
|
||||||
if (index == -1) {
|
if (index == -1) { // Only the command is run
|
||||||
cmd = event.getMessage().substring(1);
|
cmd = event.getMessage().substring(1);
|
||||||
for (Channel channel : Channel.getChannels()) {
|
for (Channel channel : Channel.getChannels()) {
|
||||||
if (cmd.equalsIgnoreCase(channel.ID)) {
|
if (cmd.equalsIgnoreCase(channel.ID)) {
|
||||||
|
@ -75,16 +75,9 @@ public class PlayerListener implements Listener {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else { // We have arguments
|
||||||
cmd = event.getMessage().substring(1, index);
|
cmd = event.getMessage().substring(1, index);
|
||||||
for (Channel channel : Channel.getChannels()) {
|
if (cmd.equalsIgnoreCase("tpahere")) {
|
||||||
if (cmd.equalsIgnoreCase(channel.ID)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
Channel c = mp.CurrentChannel;
|
|
||||||
mp.CurrentChannel = channel;
|
|
||||||
event.getPlayer().chat(event.getMessage().substring(index + 1));
|
|
||||||
mp.CurrentChannel = c;
|
|
||||||
} else if (cmd.equalsIgnoreCase("tpahere")) {
|
|
||||||
Player player = Bukkit.getPlayer(event.getMessage().substring(index + 1));
|
Player player = Bukkit.getPlayer(event.getMessage().substring(index + 1));
|
||||||
if (player != null)
|
if (player != null)
|
||||||
player.sendMessage("§b" + event.getPlayer().getDisplayName() + " §bis in this world: "
|
player.sendMessage("§b" + event.getPlayer().getDisplayName() + " §bis in this world: "
|
||||||
|
@ -95,9 +88,17 @@ public class PlayerListener implements Listener {
|
||||||
String message = event.getMessage().substring(index + 1);
|
String message = event.getMessage().substring(index + 1);
|
||||||
Bukkit.broadcastMessage(String.format("* %s %s", event.getPlayer().getDisplayName(), message));
|
Bukkit.broadcastMessage(String.format("* %s %s", event.getPlayer().getDisplayName(), message));
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
for (Channel channel : Channel.getChannels()) {
|
||||||
|
if (cmd.equalsIgnoreCase(channel.ID)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
TBMCChatAPI.SendChatMessage(channel, event.getPlayer(),
|
||||||
|
event.getMessage().substring(index + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO: Target selectors
|
||||||
}
|
}
|
||||||
|
// We don't care if we have arguments
|
||||||
if (cmd.toLowerCase().startsWith("un")) {
|
if (cmd.toLowerCase().startsWith("un")) {
|
||||||
for (HelpTopic ht : PluginMain.Instance.getServer().getHelpMap().getHelpTopics()) {
|
for (HelpTopic ht : PluginMain.Instance.getServer().getHelpMap().getHelpTopics()) {
|
||||||
if (ht.getName().equalsIgnoreCase("/" + cmd))
|
if (ht.getName().equalsIgnoreCase("/" + cmd))
|
||||||
|
|
|
@ -26,6 +26,8 @@ commands:
|
||||||
waitwhat:
|
waitwhat:
|
||||||
description: Wait what
|
description: Wait what
|
||||||
aliases: ww
|
aliases: ww
|
||||||
|
lenny:
|
||||||
|
description: Lenny face.
|
||||||
author: NorbiPeti
|
author: NorbiPeti
|
||||||
depend:
|
depend:
|
||||||
- Essentials
|
- Essentials
|
||||||
|
|
Loading…
Reference in a new issue