Heavy debugging and refactor for skill trees.

This commit is contained in:
Ka0rX 2023-05-07 19:15:28 +01:00
parent 2bcd505bf8
commit 27d5c93ba7
4 changed files with 69 additions and 4 deletions

View File

@ -893,6 +893,10 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
return profess == null ? MMOCore.plugin.classManager.getDefaultClass() : profess;
}
public boolean isProfessNull() {
return profess == null;
}
/**
* @deprecated Provide reason with {@link #giveMana(double, PlayerResourceUpdateEvent.UpdateReason)}
*/

View File

@ -38,6 +38,10 @@ public class MMOCoreBukkit {
if (plugin.getConfig().getBoolean("vanilla-exp-redirection.enabled"))
Bukkit.getPluginManager().registerEvents(new RedirectVanillaExp(plugin.getConfig().getDouble("vanilla-exp-redirection.ratio")), plugin);
if (plugin.getConfig().getBoolean("force-class-choose-on-first-login"))
Bukkit.getPluginManager().registerEvents(new ForceChooseClassListener(), MMOCore.plugin);
Bukkit.getPluginManager().registerEvents(new WaypointsListener(), plugin);
Bukkit.getPluginManager().registerEvents(new PlayerListener(), plugin);
Bukkit.getPluginManager().registerEvents(new GoldPouchesListener(), plugin);

View File

@ -0,0 +1,54 @@
package net.Indyuce.mmocore.listener;
import io.lumine.mythic.lib.api.event.SynchronizedDataLoadEvent;
import io.lumine.mythic.lib.api.util.TemporaryListener;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.event.PlayerChangeClassEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.InventoryManager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
public class ForceChooseClassListener implements Listener {
@EventHandler
public void onJoin(SynchronizedDataLoadEvent event) {
if (event.getManager().getOwningPlugin().equals(MMOCore.plugin)) {
PlayerData playerData = PlayerData.get(event.getHolder().getProfileId());
if (playerData.isProfessNull()) {
InventoryManager.CLASS_SELECT.newInventory(playerData).open();
//Give 1 class point to make sure the player can choose a class.
playerData.setClassPoints(1);
TemporaryListener closeGUIListener = new TemporaryListener(InventoryCloseEvent.getHandlerList()) {
@EventHandler
public void whenClosed(InventoryCloseEvent e) {
if (e.getPlayer().equals(playerData.getPlayer()))
InventoryManager.CLASS_SELECT.newInventory(playerData).open();
}
@Override
public void whenClosed() {
}
};
new TemporaryListener(PlayerChangeClassEvent.getHandlerList()) {
@EventHandler
public void whenChoose(PlayerChangeClassEvent e) {
if (e.getPlayer().equals(playerData.getPlayer())) {
closeGUIListener.close();
close();
}
}
@Override
public void whenClosed() {
}
};
}
}
}
}

View File

@ -193,6 +193,9 @@ vanilla-exp-redirection:
# Requires a SERVER reload when changed.
override-vanilla-exp: true
#Forces the player to choose a class at first join.
force-class-choose-on-first-login: false
# Check the target player's RPG profile when shift when shift right clicking.
shift-click-player-profile-check: false