forked from Upstream/mmocore
Heavy debugging and refactor for skill trees.
This commit is contained in:
parent
2bcd505bf8
commit
27d5c93ba7
@ -159,8 +159,8 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
||||
MMOCore.log(Level.SEVERE, "[Userdata] Could not find class " + getProfess().getId() + " while refreshing player data.");
|
||||
}
|
||||
//We remove all the stats and buffs associated to triggers.
|
||||
getMMOPlayerData().getStatMap().getInstances().forEach(statInstance -> statInstance.removeIf(key ->key.startsWith(Trigger.TRIGGER_PREFIX)));
|
||||
getMMOPlayerData().getSkillModifierMap().getInstances().forEach(skillModifierInstance -> skillModifierInstance.removeIf(key ->key.startsWith(Trigger.TRIGGER_PREFIX)));
|
||||
getMMOPlayerData().getStatMap().getInstances().forEach(statInstance -> statInstance.removeIf(key -> key.startsWith(Trigger.TRIGGER_PREFIX)));
|
||||
getMMOPlayerData().getSkillModifierMap().getInstances().forEach(skillModifierInstance -> skillModifierInstance.removeIf(key -> key.startsWith(Trigger.TRIGGER_PREFIX)));
|
||||
final Iterator<Map.Entry<Integer, BoundSkillInfo>> ite = boundSkills.entrySet().iterator();
|
||||
while (ite.hasNext())
|
||||
try {
|
||||
@ -376,7 +376,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
||||
|
||||
/**
|
||||
* @return If the item is unlocked by the player
|
||||
* This is used for skills that can be locked & unlocked.
|
||||
* This is used for skills that can be locked & unlocked.
|
||||
*/
|
||||
public boolean hasUnlocked(Unlockable unlockable) {
|
||||
return unlockable.isUnlockedByDefault() || unlockedItems.contains(unlockable.getUnlockNamespacedKey());
|
||||
@ -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)}
|
||||
*/
|
||||
@ -1198,7 +1202,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
||||
* checks if they could potentially upgrade to one of these
|
||||
*
|
||||
* @return If the player can change its current class to
|
||||
* a subclass
|
||||
* a subclass
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean canChooseSubclass() {
|
||||
|
@ -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);
|
||||
|
@ -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() {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user