223 lines
6.8 KiB
Java
223 lines
6.8 KiB
Java
package me.unurled.raxen.manager.entity;
|
|
|
|
import static me.unurled.raxen.utils.Utils.debug;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
import lombok.Getter;
|
|
import lombok.Setter;
|
|
import me.unurled.raxen.Raxen;
|
|
import me.unurled.raxen.components.entity.Attributes.Defense;
|
|
import me.unurled.raxen.components.entity.Attributes.Health;
|
|
import me.unurled.raxen.components.entity.Attributes.ItemDefense;
|
|
import me.unurled.raxen.components.entity.Attributes.ItemHealth;
|
|
import me.unurled.raxen.components.entity.Attributes.ItemLuck;
|
|
import me.unurled.raxen.components.entity.Attributes.ItemMana;
|
|
import me.unurled.raxen.components.entity.Attributes.ItemSpeed;
|
|
import me.unurled.raxen.components.entity.Attributes.ItemStrength;
|
|
import me.unurled.raxen.components.entity.Attributes.Luck;
|
|
import me.unurled.raxen.components.entity.Attributes.Mana;
|
|
import me.unurled.raxen.components.entity.Attributes.MaxHealth;
|
|
import me.unurled.raxen.components.entity.Attributes.MaxMana;
|
|
import me.unurled.raxen.components.entity.Attributes.MaxManaBuilder;
|
|
import me.unurled.raxen.components.entity.Attributes.Speed;
|
|
import me.unurled.raxen.components.entity.Attributes.Strength;
|
|
import me.unurled.raxen.components.entity.other.EntityNamespacedKey;
|
|
import me.unurled.raxen.components.entity.other.MobData;
|
|
import me.unurled.raxen.components.entity.other.MobType;
|
|
import me.unurled.raxen.components.entity.other.RaxenEntity;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.World;
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
import org.bukkit.entity.Entity;
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
public class EntityManager {
|
|
|
|
private Raxen main;
|
|
|
|
@Getter
|
|
@Setter
|
|
public List<EntityType> list = new ArrayList<>();
|
|
|
|
public HashMap<String, MobType> mobTypes;
|
|
public HashMap<UUID, MobData> spawnedMob;
|
|
public HashMap<UUID, MobData> spawnedMobsOnlyMain;
|
|
|
|
@Getter
|
|
private final HashMap<String, me.unurled.raxen.components.entity.Attributes.Attribute> attribute =
|
|
new HashMap<>();
|
|
|
|
public HashMap<String, me.unurled.raxen.components.entity.other.RaxenEntity> entities =
|
|
new HashMap<>();
|
|
|
|
public HashMap<UUID, Entity> livingEntities = new HashMap<>();
|
|
|
|
// Attributes
|
|
private Defense defense;
|
|
private Health health;
|
|
private ItemDefense itemDefense;
|
|
private ItemHealth itemHealth;
|
|
private ItemLuck itemLuck;
|
|
private ItemMana itemMana;
|
|
private ItemSpeed itemSpeed;
|
|
private ItemStrength itemStrength;
|
|
private Luck luck;
|
|
private Mana mana;
|
|
private MaxHealth maxHealth;
|
|
private MaxMana maxMana;
|
|
private Speed speed;
|
|
private Strength strength;
|
|
|
|
public EntityManager(Raxen main) {
|
|
this.main = main;
|
|
mobTypes = new HashMap<>();
|
|
spawnedMob = new HashMap<>();
|
|
spawnedMobsOnlyMain = new HashMap<>();
|
|
reload();
|
|
registerAttributes();
|
|
}
|
|
|
|
public static void reload() {
|
|
Collection<MobData> collection = new ArrayList<>();
|
|
collection.addAll(spawnedMob.values());
|
|
for (MobData mobData : collection) {
|
|
mobData.entity.die(false);
|
|
}
|
|
}
|
|
|
|
public void registerLivingEntities(World world) {
|
|
}
|
|
|
|
/**
|
|
* used to register entities using fileconfigs but rapidly abandoned
|
|
*
|
|
* @param file
|
|
*/
|
|
@Deprecated
|
|
public void registerEntityFromConfig(FileConfiguration file) {
|
|
debug(file.getString("id"));
|
|
World world = Bukkit.getWorld(file.getString("world"));
|
|
String name = file.getString("name");
|
|
}
|
|
|
|
public RaxenEntity getEntity(UUID uuid) {
|
|
return null;
|
|
}
|
|
|
|
public RaxenEntity getEntity(Entity entity) {
|
|
entities.get(entity.getUniqueId());
|
|
}
|
|
|
|
/**
|
|
* register all Attributes in me.unurled.raxen.components.entity.Attributes;
|
|
*/
|
|
public void registerAttributes() {
|
|
EntityNamespacedKey key = new EntityNamespacedKey(main);
|
|
|
|
this.defense = new Defense(key.defense, "DEFENSE");
|
|
attribute.put("DEFENSE", defense);
|
|
|
|
this.health = new Health(key.health, "HEALTH");
|
|
attribute.put("HEALTH", health);
|
|
|
|
this.itemDefense = new ItemDefense(key.itemDefense, "ITEM_DEFENSE");
|
|
attribute.put("ITEM_DEFENSE", itemDefense);
|
|
|
|
this.itemHealth = new ItemHealth(key.itemHealth, "ITEM_HEALTH");
|
|
attribute.put("ITEM_HEALTH", itemHealth);
|
|
|
|
this.itemLuck = new ItemLuck(key.itemLuck, "ITEM_LUCK");
|
|
attribute.put("ITEM_LUCK", itemLuck);
|
|
|
|
this.itemMana = new ItemMana(key.itemMana, "ITEM_MANA");
|
|
attribute.put("ITEM_MANA", itemMana);
|
|
|
|
this.itemSpeed = new ItemSpeed(key.itemSpeed, "ITEM_SPEED");
|
|
attribute.put("ITEM_SPEED", itemSpeed);
|
|
|
|
this.itemStrength = new ItemStrength(key.itemStrength, "ITEM_STRENGTH");
|
|
attribute.put("ITEM_STRENGTH", itemStrength);
|
|
|
|
this.luck = new Luck(key.luck, "LUCK");
|
|
attribute.put("LUCK", luck);
|
|
|
|
this.mana = new Mana(key.mana, "MANA");
|
|
attribute.put("MANA", mana);
|
|
|
|
this.maxMana =
|
|
new MaxManaBuilder()
|
|
.setNamespacekey(key.maxMana)
|
|
.setName("MAX_MANA")
|
|
.createMaxMana();
|
|
attribute.put("MAX_MANA", maxMana);
|
|
|
|
this.maxHealth = new MaxHealth(key.maxHealth, "MAX_HEALTH");
|
|
attribute.put("MAX_HEALTH", maxHealth);
|
|
|
|
this.speed = new Speed(key.speed, "SPEED");
|
|
attribute.put("SPEED", speed);
|
|
|
|
this.strength = new Strength(key.strength, "STRENGTH");
|
|
attribute.put("STRENGTH", strength);
|
|
}
|
|
|
|
public Defense getDefense() {
|
|
return (Defense) attribute.get("DEFENSE");
|
|
}
|
|
|
|
public Health getHealth() {
|
|
return (Health) attribute.get("HEALTH");
|
|
}
|
|
|
|
public ItemDefense getItemDefense() {
|
|
return (ItemDefense) attribute.get("ITEM_DEFENSE");
|
|
}
|
|
|
|
public ItemHealth getItemHealth() {
|
|
return (ItemHealth) attribute.get("ITEM_HEALTH");
|
|
}
|
|
|
|
public ItemLuck getItemLuck() {
|
|
return (ItemLuck) attribute.get("ITEM_LUCK");
|
|
}
|
|
|
|
public ItemMana getItemMana() {
|
|
return (ItemMana) attribute.get("ITEM_MANA");
|
|
}
|
|
|
|
public ItemSpeed getItemSpeed() {
|
|
return (ItemSpeed) attribute.get("ITEM_SPEED");
|
|
}
|
|
|
|
public ItemStrength getItemStrength() {
|
|
return (ItemStrength) attribute.get("ITEM_STRENGTH");
|
|
}
|
|
|
|
public Luck getLuck() {
|
|
return (Luck) attribute.get("LUCK");
|
|
}
|
|
|
|
public Mana getMana() {
|
|
return (Mana) attribute.get("MANA");
|
|
}
|
|
|
|
public MaxMana getMaxMana() {
|
|
return (MaxMana) attribute.get("MAX_MANA");
|
|
}
|
|
|
|
public MaxHealth getMaxHealth() {
|
|
return (MaxHealth) attribute.get("MAX_HEALTH");
|
|
}
|
|
|
|
public Speed getSpeed() {
|
|
return (Speed) attribute.get("SPEED");
|
|
}
|
|
|
|
public Strength getStrength() {
|
|
return (Strength) attribute.get("STRENGTH");
|
|
}
|
|
}
|