Implement the Naga class and update some behaviors and effects of other classes
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package net.rawmod.mineclass.utils;
|
||||
|
||||
import net.rawmod.mineclass.classes.MineClass;
|
||||
import net.rawmod.mineclass.classes.MineClassFactory;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class PlayerTimerEffects extends BukkitRunnable {
|
||||
|
||||
private final Player player;
|
||||
private boolean inWater;
|
||||
|
||||
public PlayerTimerEffects(Player player) {
|
||||
this.player = player;
|
||||
this.inWater = player.isInWater();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Optional<MineClass> mineClass = MineClassFactory.getInstance().getRightClass(player);
|
||||
if (mineClass.isPresent() && mineClass.get().getCode().equals("naga")) {
|
||||
if (!player.isInWater()) {
|
||||
player.damage(1);
|
||||
|
||||
}
|
||||
if (player.isInWater() != inWater) {
|
||||
inWater = player.isInWater();
|
||||
mineClass.get().reapplyEffects(player);
|
||||
}
|
||||
}
|
||||
if (mineClass.isPresent() && mineClass.get().getCode().equals("fire_dwarf")) {
|
||||
if (player.getFireTicks() > 0) {
|
||||
PlayerUtils.heal(player, 2);
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 40, 3));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 40, 1));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 40, 1));
|
||||
}
|
||||
if (player.isInWater()) {
|
||||
player.damage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
src/main/java/net/rawmod/mineclass/utils/PlayerUtils.java
Normal file
14
src/main/java/net/rawmod/mineclass/utils/PlayerUtils.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package net.rawmod.mineclass.utils;
|
||||
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerUtils {
|
||||
public static void heal(Player player, double amount) {
|
||||
AttributeInstance maxHealh = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
||||
if (maxHealh != null) {
|
||||
player.setHealth(Math.min(player.getHealth() + amount, maxHealh.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user