Fixed non native RPG plugin compatibility

This commit is contained in:
Indyuce 2020-04-30 16:26:18 +02:00
parent dc404e312d
commit 2e0568c7b7
2 changed files with 4 additions and 4 deletions

View File

@ -236,7 +236,7 @@ public class MMOItems extends JavaPlugin {
findRpgPlugin();
// compatibility with /reload
Bukkit.getOnlinePlayers().forEach(player -> PlayerData.load(player));
Bukkit.getScheduler().runTask(this, () -> Bukkit.getOnlinePlayers().forEach(player -> PlayerData.load(player)));
// advanced recipes
getLogger().log(Level.INFO, "Loading recipes, please wait...");
@ -314,11 +314,11 @@ public class MMOItems extends JavaPlugin {
Validate.notNull(handler, "RPGHandler cannot be null");
// unregister events from current rpgPlugin instance
if (rpgPlugin != null && rpgPlugin instanceof Listener)
if (rpgPlugin != null && rpgPlugin instanceof Listener && isEnabled())
HandlerList.unregisterAll((Listener) rpgPlugin);
rpgPlugin = handler;
if (handler instanceof Listener)
if (handler instanceof Listener && isEnabled())
Bukkit.getPluginManager().registerEvents((Listener) handler, this);
}

View File

@ -26,7 +26,7 @@ import net.mmogroup.mmolib.api.DamageType;
public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOW)
@EventHandler
public void loadPlayerData(PlayerJoinEvent event) {
PlayerData.load(event.getPlayer());
}