From ddd6a994ce0fa2e17e66bd375cb5bc763d1d32bb Mon Sep 17 00:00:00 2001 From: ASangarin Date: Thu, 17 Dec 2020 16:26:41 +0100 Subject: [PATCH] Fixed "Player must be online" error when player logs out --- .../net/Indyuce/mmoitems/api/player/PlayerData.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/Indyuce/mmoitems/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmoitems/api/player/PlayerData.java index eba76df4..8b2c4962 100644 --- a/src/main/java/net/Indyuce/mmoitems/api/player/PlayerData.java +++ b/src/main/java/net/Indyuce/mmoitems/api/player/PlayerData.java @@ -100,19 +100,21 @@ public class PlayerData { private void load(FileConfiguration config) { if (config.contains("crafting-queue")) craftingStatus.load(this, config.getConfigurationSection("crafting-queue")); - } - public void save() { - if (MMOItems.plugin.hasPermissions()) { + if (MMOItems.plugin.hasPermissions() && config.contains("permissions-from-items")) { Permission perms = MMOItems.plugin.getVault().getPermissions(); - permissions.forEach(perm -> { + config.getStringList("permissions-from-items").forEach(perm -> { if (perms.has(getPlayer(), perm)) perms.playerRemove(getPlayer(), perm); }); } + } + + public void save() { cancelRunnables(); ConfigFile config = new ConfigFile("/userdata", getUniqueId().toString()); config.getConfig().createSection("crafting-queue"); + config.getConfig().set("permissions-from-items", new ArrayList<>(permissions)); craftingStatus.save(config.getConfig().getConfigurationSection("crafting-queue")); config.save(); }