Added null checks to PartiesListener

This commit is contained in:
AlessioDP 2019-10-09 01:51:22 +02:00
parent 60410f67c6
commit 20f1d2845b
No known key found for this signature in database
GPG Key ID: B92B813840FFCC9F

View File

@ -29,31 +29,49 @@ public class PartiesListener implements Listener {
@EventHandler
public void onPartyCreate(BukkitPartiesPartyPostCreateEvent event) {
Bukkit.getServer().getPlayer(event.getCreator().getPlayerUUID()).sendMessage(ChatColor.YELLOW + Lang.get("questPartiesCreate"));
if (event.getCreator() != null) {
Player p = Bukkit.getServer().getPlayer(event.getCreator().getPlayerUUID());
if (p != null) {
p.sendMessage(ChatColor.YELLOW + Lang.get("questPartiesCreate"));
}
}
}
@EventHandler
public void onPartyDeleteEvent(BukkitPartiesPartyPostDeleteEvent event) {
Bukkit.getServer().getPlayer(event.getCommandSender().getPlayerUUID()).sendMessage(ChatColor.RED + Lang.get("questPartiesDelete"));
if (event.getCommandSender() != null) {
Player p = Bukkit.getServer().getPlayer(event.getCommandSender().getPlayerUUID());
if (p != null) {
p.sendMessage(ChatColor.RED + Lang.get("questPartiesDelete"));
}
}
}
@EventHandler
public void onPlayerJoinEvent(BukkitPartiesPlayerPostJoinEvent event) {
if (event.isInvited()) {
if (event.isInvited() && event.getInviter() != null) {
Player i = Bukkit.getServer().getPlayer(event.getInviter());
i.sendMessage(ChatColor.GREEN + Lang.get(i, "questPartiesInvite").replace("<player>", i.getName()));
if (i != null) {
i.sendMessage(ChatColor.GREEN + Lang.get(i, "questPartiesInvite").replace("<player>", i.getName()));
}
}
Player p = Bukkit.getServer().getPlayer(event.getPartyPlayer().getPlayerUUID());
p.sendMessage(ChatColor.GREEN + Lang.get(p, "questPartiesJoin").replace("<player>", p.getName()));
if (p != null) {
p.sendMessage(ChatColor.GREEN + Lang.get(p, "questPartiesJoin").replace("<player>", p.getName()));
}
}
@EventHandler
public void onPlayerLeaveEvent(BukkitPartiesPlayerPostLeaveEvent event) {
if (event.isKicked()) {
Player k = Bukkit.getServer().getPlayer(event.getKicker().getPlayerUUID());
k.sendMessage(ChatColor.RED + Lang.get(k, "questPartiesKicked").replace("<player>", k.getName()));
if (k != null) {
k.sendMessage(ChatColor.RED + Lang.get(k, "questPartiesKicked").replace("<player>", k.getName()));
}
}
Player p = Bukkit.getServer().getPlayer(event.getPartyPlayer().getPlayerUUID());
p.sendMessage(ChatColor.RED + Lang.get(p, "questPartiesLeave").replace("<player>", p.getName()));
if (p != null) {
p.sendMessage(ChatColor.RED + Lang.get(p, "questPartiesLeave").replace("<player>", p.getName()));
}
}
}