Initial commit
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package net.crankedpvp.crankedpets.struct;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTCompound;
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.crankedutils.CrankedUtils;
|
||||
import net.crankedpvp.crankedutils.utils.DamageHandler;
|
||||
import net.crankedpvp.crankedutils.utils.TimeUtils;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.crankedutils.utils.items.SkullUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public abstract class Pet implements Listener {
|
||||
|
||||
@Getter
|
||||
private final DamageHandler damageHandler;
|
||||
|
||||
public Pet() {
|
||||
this.damageHandler = CrankedUtils.instance.getDamageHandler();
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract String getDisplayName();
|
||||
|
||||
public abstract String getTexture();
|
||||
|
||||
public abstract List<String> getPerks();
|
||||
|
||||
public List<String> getLore() {
|
||||
return null;
|
||||
}
|
||||
//make abstract if want to use ^
|
||||
|
||||
public abstract PetType getPetType();
|
||||
|
||||
public abstract int getCooldownInSeconds();
|
||||
|
||||
public abstract void procAbility(Player player);
|
||||
|
||||
public String getID() {
|
||||
return this.getName().toLowerCase(Locale.ROOT).replace(" ", "");
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getItem() {
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(this.getPetType().getName() + " Pet");
|
||||
lore.add("");
|
||||
lore.add(this instanceof PassivePet ? "&e&lPASSIVE" : "&a&lACTIVE");
|
||||
lore.addAll(this.getPerks());
|
||||
if(!(this instanceof PassivePet)) {
|
||||
lore.add("");
|
||||
lore.add("&f&lCooldown:");
|
||||
lore.add("&7" + TimeUtils.formatSeconds(this.getCooldownInSeconds()));
|
||||
}
|
||||
lore.add("");
|
||||
lore.add("&e&lLevel: 100");
|
||||
lore.add("&e&lEXP: 0/10100");
|
||||
lore.add("&c;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;");
|
||||
|
||||
ItemStack skull = SkullUtils.getSkull(this.getTexture());
|
||||
skull = new ItemBuilder(skull).setName(this.getDisplayName() + " &7[Level 100]")
|
||||
.setLore(lore)
|
||||
.colorize()
|
||||
.build();
|
||||
NBTItem wrapper = new NBTItem(skull);
|
||||
wrapper.setString("cosmicType", "pet");
|
||||
NBTCompound cosmicData = wrapper.getOrCreateCompound("cosmicData");
|
||||
cosmicData.setString("petType", this.getID());
|
||||
return wrapper.getItem();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user