mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-03 06:37:47 +01:00
MI player data now uncached on logout
This commit is contained in:
parent
ad5d16b0b0
commit
16a0a1ae14
@ -303,7 +303,7 @@ public class MMOItems extends JavaPlugin {
|
||||
return;
|
||||
|
||||
// Save player data
|
||||
PlayerData.getLoaded().forEach(PlayerData::save);
|
||||
PlayerData.getLoaded().forEach(data -> data.save(false));
|
||||
|
||||
// Drop abandonned soulbound items
|
||||
SoulboundInfo.getAbandonnedInfo().forEach(SoulboundInfo::dropItems);
|
||||
|
@ -82,10 +82,17 @@ public class PlayerData {
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
public void save(boolean clearForMap) {
|
||||
|
||||
// Empty map if required
|
||||
if (clearForMap)
|
||||
data.remove(getUniqueId());
|
||||
|
||||
// Cancel runnables
|
||||
cancelRunnables();
|
||||
|
||||
ConfigFile config = new ConfigFile("/userdata", getUniqueId().toString());
|
||||
// Save data in config
|
||||
final 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"));
|
||||
|
@ -26,22 +26,21 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
private final Map<Player, ArrayList<ItemStack>> deathItems = new HashMap<>();
|
||||
private final Map<Player, List<ItemStack>> deathItems = new HashMap<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void loadPlayerData(PlayerJoinEvent event) {
|
||||
MMOItems.plugin.getRecipes().refreshRecipeBook(event.getPlayer());
|
||||
PlayerData.load(event.getPlayer()); }
|
||||
PlayerData.load(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void savePlayerData(PlayerQuitEvent event) { PlayerData.get(event.getPlayer()).save(); }
|
||||
|
||||
public void savePlayerData(PlayerQuitEvent event) {
|
||||
PlayerData.get(event.getPlayer()).save(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the player dies, its time to roll the death-downgrade stat!
|
||||
|
Loading…
Reference in New Issue
Block a user