fix: nullpointerexception when player is not online
This commit is contained in:
parent
26971e75bb
commit
4361201b78
2 changed files with 14 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@ test_server/
|
|||
build/
|
||||
server/
|
||||
bin/
|
||||
bin/*
|
||||
|
|
|
@ -47,24 +47,27 @@ public class Core extends JavaPlugin {
|
|||
.color(NamedTextColor.BLUE)
|
||||
.decoration(TextDecoration.BOLD, true)
|
||||
.append(Component.text(" Discord", NamedTextColor.BLUE).decoration(TextDecoration.BOLD, false)
|
||||
.appendSpace()
|
||||
.append(Component.text(author.getName())
|
||||
.append(Component.text(": "))
|
||||
.append(Component.text(message))
|
||||
.color(NamedTextColor.WHITE).decoration(TextDecoration.BOLD, false)));
|
||||
.appendSpace()
|
||||
.append(Component.text(author.getName())
|
||||
.append(Component.text(": "))
|
||||
.append(Component.text(message))
|
||||
.color(NamedTextColor.WHITE).decoration(TextDecoration.BOLD, false)));
|
||||
}
|
||||
|
||||
|
||||
public void sendTeamMessage(CivilPlayer author, Component message) throws SQLException {
|
||||
Component deserializedMessage = renderTeamChat(author, message);
|
||||
discord.sendMessage(author, PlainTextComponentSerializer.plainText().serialize(message));
|
||||
for (CivilPlayer member : database.getAllPlayers(author.getTeam())) {
|
||||
Player player = Bukkit.getPlayer(member.getName());
|
||||
try {
|
||||
Player player = Bukkit.getPlayer(member.getName());
|
||||
|
||||
if (!player.isOnline())
|
||||
if (player == null || !player.isOnline())
|
||||
continue;
|
||||
|
||||
player.sendMessage(deserializedMessage);
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
|
||||
player.sendMessage(deserializedMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue