mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Created ascend enchantment
This commit is contained in:
parent
91c6283ae3
commit
f2dc83508a
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
27
Plugin/src/main/resources/enchants/spell/ascend.yml
Normal file
27
Plugin/src/main/resources/enchants/spell/ascend.yml
Normal 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
|
Loading…
Reference in New Issue
Block a user