From 0bcd11cf68376d1aed6582bc321124c9ff510a7e Mon Sep 17 00:00:00 2001 From: Jules Date: Fri, 14 Apr 2023 15:45:04 +0200 Subject: [PATCH] Fixed guild loading NPE --- .../net/Indyuce/mmocore/manager/data/GuildDataManager.java | 3 +++ .../mmocore/manager/data/mysql/MMOCoreDataSynchronizer.java | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/GuildDataManager.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/GuildDataManager.java index a8a6bfe6..ef81d0ee 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/GuildDataManager.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/GuildDataManager.java @@ -11,6 +11,8 @@ import org.bukkit.configuration.file.FileConfiguration; import net.Indyuce.mmocore.api.ConfigFile; import net.Indyuce.mmocore.guild.provided.Guild; +import javax.annotation.Nullable; + public abstract class GuildDataManager { protected final Map guilds = new HashMap<>(); @@ -39,6 +41,7 @@ public abstract class GuildDataManager { delete(guild); } + @Nullable public Guild getGuild(String guild) { return guilds.get(guild); } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MMOCoreDataSynchronizer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MMOCoreDataSynchronizer.java index 712f4a18..0aa34d9e 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MMOCoreDataSynchronizer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/mysql/MMOCoreDataSynchronizer.java @@ -78,8 +78,9 @@ public class MMOCoreDataSynchronizer extends DataSynchronizer { } data.setUnlockedItems(unlockedItems); if (!isEmpty(result.getString("guild"))) { - Guild guild = MMOCore.plugin.dataProvider.getGuildManager().getGuild(result.getString("guild")); - data.setGuild(guild.hasMember(data.getUniqueId()) ? guild : null); + final Guild guild = MMOCore.plugin.dataProvider.getGuildManager().getGuild(result.getString("guild")); + if (guild != null) + data.setGuild(guild.hasMember(data.getUniqueId()) ? guild : null); } if (!isEmpty(result.getString("attributes"))) data.getAttributes().load(result.getString("attributes"));