forked from Upstream/mmocore
!removed event triggers
This commit is contained in:
parent
5142437848
commit
63971219a7
@ -13,7 +13,7 @@ import com.google.gson.JsonObject;
|
|||||||
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||||
import net.Indyuce.mmocore.skill.Skill;
|
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||||
import net.Indyuce.mmocore.manager.data.PlayerDataManager.DefaultPlayerData;
|
import net.Indyuce.mmocore.manager.data.PlayerDataManager.DefaultPlayerData;
|
||||||
|
|
||||||
public class SavedClassInformation {
|
public class SavedClassInformation {
|
||||||
@ -102,16 +102,16 @@ public class SavedClassInformation {
|
|||||||
return skills.keySet();
|
return skills.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSkillLevel(Skill skill) {
|
public int getSkillLevel(RegisteredSkill skill) {
|
||||||
return getSkillLevel(skill.getId());
|
return getSkillLevel(skill.getHandler().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSkillLevel(String id) {
|
public int getSkillLevel(String id) {
|
||||||
return skills.get(id);
|
return skills.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerSkillLevel(Skill skill, int level) {
|
public void registerSkillLevel(RegisteredSkill skill, int level) {
|
||||||
registerSkillLevel(skill.getId(), level);
|
registerSkillLevel(skill.getHandler().getId(), level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerSkillLevel(String attribute, int level) {
|
public void registerSkillLevel(String attribute, int level) {
|
||||||
|
@ -1,59 +1,28 @@
|
|||||||
package net.Indyuce.mmocore.manager;
|
package net.Indyuce.mmocore.manager;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.profess.ClassOption;
|
import net.Indyuce.mmocore.api.player.profess.ClassOption;
|
||||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.EventTriggerHandler;
|
import org.apache.commons.lang.Validate;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.AttackEventTrigger;
|
import org.bukkit.Material;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.BlockBrokenTrigger;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.BlockPlacedTrigger;
|
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.ClassChosenEventTrigger;
|
import java.io.File;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.LevelUpEventTrigger;
|
import java.util.Collection;
|
||||||
import net.Indyuce.mmocore.api.player.profess.event.trigger.MultipleLevelUpEventTrigger;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ClassManager implements MMOCoreManager {
|
public class ClassManager implements MMOCoreManager {
|
||||||
private final Map<String, PlayerClass> map = new HashMap<>();
|
private final Map<String, PlayerClass> map = new HashMap<>();
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* cached default class. if there are two default classes, the last one
|
* Cached default class. If there happens to have two default
|
||||||
* overrides the previous.
|
* classes, the last one overrides the previous.
|
||||||
*/
|
*/
|
||||||
private PlayerClass defaultClass;
|
private PlayerClass defaultClass;
|
||||||
|
|
||||||
/*
|
|
||||||
* same different types of trigger events to be able to map them later in
|
|
||||||
* the player class instances.
|
|
||||||
*/
|
|
||||||
private final Set<EventTriggerHandler> triggerHandlers = new HashSet<>();
|
|
||||||
|
|
||||||
public ClassManager() {
|
|
||||||
registerEvent(new LevelUpEventTrigger());
|
|
||||||
registerEvent(new AttackEventTrigger());
|
|
||||||
registerEvent(new ClassChosenEventTrigger());
|
|
||||||
registerEvent(new BlockBrokenTrigger());
|
|
||||||
registerEvent(new BlockPlacedTrigger());
|
|
||||||
registerEvent(new MultipleLevelUpEventTrigger());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerEvent(EventTriggerHandler handler) {
|
|
||||||
triggerHandlers.add(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void register(PlayerClass playerClass) {
|
public void register(PlayerClass playerClass) {
|
||||||
map.put(playerClass.getId(), playerClass);
|
map.put(playerClass.getId(), playerClass);
|
||||||
}
|
}
|
||||||
@ -85,15 +54,8 @@ public class ClassManager implements MMOCoreManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(boolean clearBefore) {
|
public void initialize(boolean clearBefore) {
|
||||||
if (clearBefore) {
|
if (clearBefore)
|
||||||
map.clear();
|
map.clear();
|
||||||
triggerHandlers.forEach(HandlerList::unregisterAll);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Do not clear the list of trigger listeners, since it's only setup
|
|
||||||
* once the server loads and it is never modified.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
for (File file : new File(MMOCore.plugin.getDataFolder() + "/classes").listFiles())
|
for (File file : new File(MMOCore.plugin.getDataFolder() + "/classes").listFiles())
|
||||||
try {
|
try {
|
||||||
@ -112,10 +74,5 @@ public class ClassManager implements MMOCoreManager {
|
|||||||
|
|
||||||
defaultClass = map.values().stream().filter(profess -> profess.hasOption(ClassOption.DEFAULT)).findFirst()
|
defaultClass = map.values().stream().filter(profess -> profess.hasOption(ClassOption.DEFAULT)).findFirst()
|
||||||
.orElse(new PlayerClass("HUMAN", "Human", Material.LEATHER_BOOTS));
|
.orElse(new PlayerClass("HUMAN", "Human", Material.LEATHER_BOOTS));
|
||||||
|
|
||||||
/*
|
|
||||||
* Register event triggers
|
|
||||||
*/
|
|
||||||
triggerHandlers.forEach(handler -> Bukkit.getPluginManager().registerEvents(handler, MMOCore.plugin));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user