From f99b10ade201d51ccd7185edf3a526d15731bd34 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 16 Jan 2021 16:41:34 +0100 Subject: [PATCH] Fix NPE --- src/de/steamwar/bungeecore/listeners/BanListener.java | 1 - src/de/steamwar/bungeecore/sql/Punishment.java | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/BanListener.java b/src/de/steamwar/bungeecore/listeners/BanListener.java index a4fbbec..c62a17d 100644 --- a/src/de/steamwar/bungeecore/listeners/BanListener.java +++ b/src/de/steamwar/bungeecore/listeners/BanListener.java @@ -19,7 +19,6 @@ package de.steamwar.bungeecore.listeners; -import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.sql.BannedUserIPs; import de.steamwar.bungeecore.sql.SteamwarUser; diff --git a/src/de/steamwar/bungeecore/sql/Punishment.java b/src/de/steamwar/bungeecore/sql/Punishment.java index 964961d..0e47e05 100644 --- a/src/de/steamwar/bungeecore/sql/Punishment.java +++ b/src/de/steamwar/bungeecore/sql/Punishment.java @@ -43,10 +43,12 @@ public class Punishment { } public static Map getPunishmentsOfPlayer(int user) { - Map punishmentMap = new HashMap<>(); - punishmentMap.put(PunishmentType.Ban, getPunishmentOfPlayer(user, PunishmentType.Ban)); - punishmentMap.put(PunishmentType.Mute, getPunishmentOfPlayer(user, PunishmentType.Mute)); - return punishmentMap; + Map punishments = new HashMap<>(); + Punishment banPunishment = getPunishmentOfPlayer(user, PunishmentType.Ban); + if(banPunishment != null) punishments.put(PunishmentType.Ban, banPunishment); + Punishment mutePunishment = getPunishmentOfPlayer(user, PunishmentType.Mute); + if(mutePunishment != null) punishments.put(PunishmentType.Mute, mutePunishment); + return punishments; } public static List getAllPunishmentsOfPlayer(int user) {