Merge remote-tracking branch 'origin/1018-playerjoinevent'

# Conflicts:
#	MMOItems-Dist/src/main/java/net/Indyuce/mmoitems/listener/ItemListener.java
This commit is contained in:
Indyuce 2022-12-15 12:24:23 +01:00
commit 59f1b4261b
2 changed files with 6 additions and 7 deletions

View File

@ -132,7 +132,7 @@ public class PlayerData {
/** /**
* @return If the player hands are full i.e if the player is holding * @return If the player hands are full i.e if the player is holding
* two items in their hands, one being two handed * two items in their hands, one being two handed
*/ */
public boolean isEncumbered() { public boolean isEncumbered() {
@ -443,8 +443,7 @@ public class PlayerData {
/** /**
* Called when the corresponding MMOPlayerData has already been initialized. * Called when the corresponding MMOPlayerData has already been initialized.
*/ */
public static void load(@NotNull UUID player) { public static PlayerData load(@NotNull UUID player) {
/* /*
* Double check they are online, for some reason even if this is fired * Double check they are online, for some reason even if this is fired
* from the join event the player can be offline if they left in the * from the join event the player can be offline if they left in the
@ -454,7 +453,7 @@ public class PlayerData {
PlayerData playerData = new PlayerData(MMOPlayerData.get(player)); PlayerData playerData = new PlayerData(MMOPlayerData.get(player));
data.put(player, playerData); data.put(player, playerData);
playerData.updateInventory(); playerData.updateInventory();
return; return playerData;
} }
/* /*
@ -463,6 +462,7 @@ public class PlayerData {
*/ */
PlayerData playerData = data.get(player); PlayerData playerData = data.get(player);
playerData.rpgPlayer = MMOItems.plugin.getRPG().getInfo(playerData); playerData.rpgPlayer = MMOItems.plugin.getRPG().getInfo(playerData);
return playerData;
} }
public static Collection<PlayerData> getLoaded() { public static Collection<PlayerData> getLoaded() {

View File

@ -31,13 +31,13 @@ import java.util.*;
public class PlayerListener implements Listener { public class PlayerListener implements Listener {
private final Map<Player, List<ItemStack>> deathItems = new HashMap<>(); private final Map<Player, List<ItemStack>> deathItems = new HashMap<>();
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.LOWEST)
public void loadPlayerData(PlayerJoinEvent event) { public void loadPlayerData(PlayerJoinEvent event) {
MMOItems.plugin.getRecipes().refreshRecipeBook(event.getPlayer()); MMOItems.plugin.getRecipes().refreshRecipeBook(event.getPlayer());
PlayerData.load(event.getPlayer()); PlayerData.load(event.getPlayer());
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGHEST)
public void savePlayerData(PlayerQuitEvent event) { public void savePlayerData(PlayerQuitEvent event) {
PlayerData.get(event.getPlayer()).save(true); PlayerData.get(event.getPlayer()).save(true);
} }
@ -48,7 +48,6 @@ public class PlayerListener implements Listener {
@SuppressWarnings("InstanceofIncompatibleInterface") @SuppressWarnings("InstanceofIncompatibleInterface")
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onDeathForUpgradeLoss(@NotNull PlayerDeathEvent event) { public void onDeathForUpgradeLoss(@NotNull PlayerDeathEvent event) {
// No // No
if (event instanceof Cancellable) { if (((Cancellable) event).isCancelled()) { return; } } if (event instanceof Cancellable) { if (((Cancellable) event).isCancelled()) { return; } }