|
| 1 | +package parallelmc.ctf.classes; |
| 2 | + |
| 3 | +import net.kyori.adventure.text.Component; |
| 4 | +import org.bukkit.Material; |
| 5 | +import org.bukkit.enchantments.Enchantment; |
| 6 | +import org.bukkit.entity.Player; |
| 7 | +import org.bukkit.inventory.ItemStack; |
| 8 | +import org.bukkit.inventory.meta.ItemMeta; |
| 9 | +import org.bukkit.inventory.meta.PotionMeta; |
| 10 | +import org.bukkit.potion.PotionEffect; |
| 11 | +import org.bukkit.potion.PotionEffectType; |
| 12 | +import org.bukkit.scheduler.BukkitRunnable; |
| 13 | + |
| 14 | +public class ChemistClass extends CTFClass { |
| 15 | + |
| 16 | + private int energy = 0; |
| 17 | + |
| 18 | + public ChemistClass(Player player) { |
| 19 | + super(player); |
| 20 | + this.name = "Chemist"; |
| 21 | + ItemStack chestplate = new ItemStack(Material.GOLDEN_CHESTPLATE); |
| 22 | + chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2); |
| 23 | + ItemStack leggings = new ItemStack(Material.GOLDEN_LEGGINGS); |
| 24 | + leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2); |
| 25 | + this.armor = new ItemStack[] { |
| 26 | + new ItemStack(Material.LEATHER_BOOTS), |
| 27 | + leggings, |
| 28 | + chestplate, |
| 29 | + new ItemStack(Material.LEATHER_HELMET) |
| 30 | + }; |
| 31 | + for (ItemStack i : armor) { |
| 32 | + ItemMeta ameta = i.getItemMeta(); |
| 33 | + ameta.setUnbreakable(true); |
| 34 | + i.setItemMeta(ameta); |
| 35 | + } |
| 36 | + ItemStack sword = new ItemStack(Material.IRON_SWORD); |
| 37 | + ItemMeta meta = sword.getItemMeta(); |
| 38 | + meta.setUnbreakable(true); |
| 39 | + meta.displayName(Component.text("§fChemist Sword")); |
| 40 | + sword.setItemMeta(meta); |
| 41 | + |
| 42 | + ItemStack damage = new ItemStack(Material.SPLASH_POTION, 12); |
| 43 | + PotionMeta pmeta = (PotionMeta)damage.getItemMeta(); |
| 44 | + pmeta.setColor(PotionEffectType.HARM.getColor()); |
| 45 | + pmeta.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 1, 1), true); |
| 46 | + pmeta.displayName(Component.text("§fInstant Damage II")); |
| 47 | + damage.setItemMeta(pmeta); |
| 48 | + |
| 49 | + ItemStack poison = new ItemStack(Material.SPLASH_POTION, 8); |
| 50 | + pmeta = (PotionMeta)poison.getItemMeta(); |
| 51 | + pmeta.setColor(PotionEffectType.POISON.getColor()); |
| 52 | + pmeta.addCustomEffect(new PotionEffect(PotionEffectType.POISON, 100, 1), true); |
| 53 | + pmeta.displayName(Component.text("§fPoison II")); |
| 54 | + poison.setItemMeta(pmeta); |
| 55 | + |
| 56 | + ItemStack health = new ItemStack(Material.SPLASH_POTION, 5); |
| 57 | + pmeta = (PotionMeta)health.getItemMeta(); |
| 58 | + pmeta.setColor(PotionEffectType.HEAL.getColor()); |
| 59 | + pmeta.addCustomEffect(new PotionEffect(PotionEffectType.HEAL, 1, 2), true); |
| 60 | + pmeta.displayName(Component.text("§fInstant Health III")); |
| 61 | + health.setItemMeta(pmeta); |
| 62 | + |
| 63 | + ItemStack regen = new ItemStack(Material.SPLASH_POTION, 5); |
| 64 | + pmeta = (PotionMeta)regen.getItemMeta(); |
| 65 | + pmeta.setColor(PotionEffectType.REGENERATION.getColor()); |
| 66 | + pmeta.addCustomEffect(new PotionEffect(PotionEffectType.REGENERATION, 320, 2), true); |
| 67 | + pmeta.displayName(Component.text("§fRegeneration III")); |
| 68 | + regen.setItemMeta(pmeta); |
| 69 | + |
| 70 | + ItemStack str = new ItemStack(Material.SPLASH_POTION, 3); |
| 71 | + pmeta = (PotionMeta)str.getItemMeta(); |
| 72 | + pmeta.setColor(PotionEffectType.INCREASE_DAMAGE.getColor()); |
| 73 | + pmeta.addCustomEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 3600, 0), true); |
| 74 | + pmeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 3600, 0), true); |
| 75 | + pmeta.displayName(Component.text("§fStrength + Speed")); |
| 76 | + str.setItemMeta(pmeta); |
| 77 | + |
| 78 | + ItemStack fire = new ItemStack(Material.SPLASH_POTION, 5); |
| 79 | + pmeta = (PotionMeta)fire.getItemMeta(); |
| 80 | + pmeta.setColor(PotionEffectType.FIRE_RESISTANCE.getColor()); |
| 81 | + pmeta.addCustomEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 600, 0), true); |
| 82 | + pmeta.displayName(Component.text("§fFire Resistance")); |
| 83 | + fire.setItemMeta(pmeta); |
| 84 | + |
| 85 | + ItemStack jump = new ItemStack(Material.SPLASH_POTION, 3); |
| 86 | + pmeta = (PotionMeta)jump.getItemMeta(); |
| 87 | + pmeta.setColor(PotionEffectType.JUMP.getColor()); |
| 88 | + pmeta.addCustomEffect(new PotionEffect(PotionEffectType.JUMP, 80, 1), true); |
| 89 | + pmeta.displayName(Component.text("§fJump Boost II")); |
| 90 | + jump.setItemMeta(pmeta); |
| 91 | + |
| 92 | + this.hotbar = new ItemStack[] { |
| 93 | + sword, |
| 94 | + damage, |
| 95 | + poison, |
| 96 | + health, |
| 97 | + regen, |
| 98 | + str, |
| 99 | + fire, |
| 100 | + jump |
| 101 | + }; |
| 102 | + initRunnable(); |
| 103 | + this.runnableTicks = 20L; |
| 104 | + } |
| 105 | + |
| 106 | + public int getEnergy() { |
| 107 | + return energy; |
| 108 | + } |
| 109 | + |
| 110 | + public void addCooldown(int amount) { |
| 111 | + if (energy <= 0) return; |
| 112 | + energy -= amount; |
| 113 | + player.setExp(energy / 7f); |
| 114 | + } |
| 115 | + |
| 116 | + public int getThrowCost(PotionEffectType p) { |
| 117 | + switch (p.getName()) { |
| 118 | + case "HARM", "HEAL" -> { return 3; } |
| 119 | + case "REGENERATION", "POISON" -> { return 2; } |
| 120 | + default -> { return 1; } |
| 121 | + } |
| 122 | + } |
| 123 | + |
| 124 | + public void initRunnable() { |
| 125 | + this.runnable = new BukkitRunnable() { |
| 126 | + @Override |
| 127 | + public void run() { |
| 128 | + if (energy < 7) { |
| 129 | + energy++; |
| 130 | + player.setExp(energy / 7f); |
| 131 | + } |
| 132 | + } |
| 133 | + }; |
| 134 | + } |
| 135 | +} |
0 commit comments