mirror of
https://github.com/songoda/EpicEnchants.git
synced 2025-01-03 15:08:19 +01:00
FoodSteal
This commit is contained in:
parent
c300c8b8fb
commit
5eb58c74e3
@ -0,0 +1,36 @@
|
|||||||
|
package com.songoda.epicenchants.effect.effects;
|
||||||
|
|
||||||
|
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||||
|
import com.songoda.epicenchants.enums.EventType;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class StealFood extends EffectExecutor {
|
||||||
|
public StealFood(ConfigurationSection section) {
|
||||||
|
super(section);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(@NotNull Player user, LivingEntity opponent, int level, EventType eventType) {
|
||||||
|
int amount = (int)Math.floor(getAmount().get(level, 0, user, opponent));
|
||||||
|
|
||||||
|
if (!(opponent instanceof Player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player opponentPlayer = ((Player) opponent);
|
||||||
|
|
||||||
|
int opponentFood = opponentPlayer.getFoodLevel() - amount;
|
||||||
|
int userFood = user.getFoodLevel() + amount;
|
||||||
|
|
||||||
|
if (opponentFood <= 0) {
|
||||||
|
opponentPlayer.setFoodLevel(0);
|
||||||
|
} else opponentPlayer.setFoodLevel(Math.min(opponentFood, 20));
|
||||||
|
|
||||||
|
if (userFood <= 0) {
|
||||||
|
user.setFoodLevel(0);
|
||||||
|
} else user.setFoodLevel(Math.min(userFood, 20));
|
||||||
|
}
|
||||||
|
}
|
@ -29,7 +29,7 @@ effects:
|
|||||||
# What player should the effect be ran on: WEARER/OPPONENT.
|
# What player should the effect be ran on: WEARER/OPPONENT.
|
||||||
who: USER
|
who: USER
|
||||||
# The potion type.
|
# The potion type.
|
||||||
potion-type: RESISTANCE
|
potion-type: DAMAGE_RESISTANCE
|
||||||
# The amplifier of the potion effect.
|
# The amplifier of the potion effect.
|
||||||
amplifier: "{level}"
|
amplifier: "{level}"
|
||||||
# Duration of the potion effect.
|
# Duration of the potion effect.
|
||||||
|
Loading…
Reference in New Issue
Block a user