Fixed guild loading NPE

This commit is contained in:
Jules 2023-04-14 15:45:04 +02:00
parent 99f83a722a
commit 0bcd11cf68
2 changed files with 6 additions and 2 deletions

View File

@ -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<String, Guild> guilds = new HashMap<>();
@ -39,6 +41,7 @@ public abstract class GuildDataManager {
delete(guild);
}
@Nullable
public Guild getGuild(String guild) {
return guilds.get(guild);
}

View File

@ -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"));