Created ascend enchantment

This commit is contained in:
Auxilor 2020-12-16 12:06:55 +00:00
parent 91c6283ae3
commit f2dc83508a
3 changed files with 66 additions and 0 deletions

View File

@ -246,6 +246,7 @@ public class EcoEnchants {
public static final EcoEnchant VITALIZE = new Vitalize();
public static final EcoEnchant DYNAMITE = new Dynamite();
public static final EcoEnchant CHARGE = new Charge();
public static final EcoEnchant ASCEND = new Ascend();
/**
* Get all registered {@link EcoEnchant}s

View File

@ -0,0 +1,38 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.spell;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Ascend extends Spell {
public Ascend() {
super("ascend");
}
@Override
public void onUse(Player player, int level, PlayerInteractEvent event) {
int ticks = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "ticks-per-level") * level;
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, ticks, this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "power") - 1,false,false));
player.setMetadata("ignore-fall-damage", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), true));
Bukkit.getScheduler().runTaskLater(EcoEnchantsPlugin.getInstance(), () -> player.removeMetadata("ignore-fall-damage", EcoEnchantsPlugin.getInstance()), ticks * 4L);
}
@EventHandler
public void onFallDamage(EntityDamageEvent event) {
if(!event.getCause().equals(EntityDamageEvent.DamageCause.FALL))
return;
if(!event.getEntity().hasMetadata("ignore-fall-damage"))
return;
event.setCancelled(true);
}
}

View File

@ -0,0 +1,27 @@
#
# Ascend EcoEnchant
#
name: "Ascend"
description: Levitates you into the air
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: legendary
general-config:
targets:
- sword
grindstoneable: true
disabled-in-worlds: []
conflicts: []
maximum-level: 3
config:
activation-sound: ENTITY_FIREWORK_ROCKET_LARGE_BLAST
cooldown: 90 # In seconds
power: 15 # Level of levitation to give
ticks-per-level: 5