Misc cleanup (thanks @Col-E)
Signed-off-by: SticksDev <tanner@teamhydra.dev>
This commit is contained in:
parent
616c6ea517
commit
98290f1c61
4
pom.xml
4
pom.xml
@ -23,8 +23,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -8,6 +8,7 @@ import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import redis.clients.jedis.JedisPooled;
|
||||
@ -159,4 +160,15 @@ public class ManaHandler implements Listener {
|
||||
setEXPBar(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On player death reset the expbar to their current mana
|
||||
*
|
||||
* @param event The PlayerDeathEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
setEXPBar(player);
|
||||
}
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ public class EarthSpell extends ItemBasedSpell {
|
||||
}
|
||||
}
|
||||
|
||||
if (nearestEntity instanceof LivingEntity) {
|
||||
if (nearestEntity instanceof LivingEntity LE) {
|
||||
// Damage the nearest entity
|
||||
((LivingEntity) nearestEntity).damage(earthSpell.getDamage());
|
||||
LE.damage(earthSpell.getDamage());
|
||||
}
|
||||
|
||||
// Cancel the task
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class LightningSpell extends ItemBasedSpell {
|
||||
public LightningSpell() {
|
||||
super("Lightning", "Strikes lightning at the target", 4, 25, "BLAZE_ROD", 3, 10, 0, true, LightningSpell::castLightning);
|
||||
super("Lightning", "Strikes lightning at the target", 4, 25, "BLAZE_ROD", 3, 10, 10, true, LightningSpell::castLightning);
|
||||
}
|
||||
|
||||
private static void castLightning(Player player, Entity nearestEntity) {
|
||||
@ -21,8 +21,8 @@ public class LightningSpell extends ItemBasedSpell {
|
||||
|
||||
world.strikeLightningEffect(location);
|
||||
|
||||
if (nearestEntity instanceof LivingEntity) {
|
||||
((LivingEntity) nearestEntity).damage(lightningSpell.getDamage());
|
||||
if (nearestEntity instanceof LivingEntity LE) {
|
||||
LE.damage(lightningSpell.getDamage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ public class WaterSpell extends ItemBasedSpell {
|
||||
}
|
||||
}
|
||||
|
||||
if (nearestEntity instanceof LivingEntity) {
|
||||
if (nearestEntity instanceof LivingEntity LE) {
|
||||
// Damage the nearest entity
|
||||
((LivingEntity) nearestEntity).damage(waterSpell.getDamage());
|
||||
LE.damage(waterSpell.getDamage());
|
||||
}
|
||||
|
||||
// Cancel the task
|
||||
|
@ -4,9 +4,9 @@ package me.sticksdev.runicspells.structures;
|
||||
* The base class for spells, only contains a name and a description
|
||||
*/
|
||||
public class BaseSpell {
|
||||
public String name;
|
||||
public String description;
|
||||
public int spellID;
|
||||
public final String name;
|
||||
public final String description;
|
||||
public final int spellID;
|
||||
public int range;
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
@ -50,15 +51,12 @@ public class ItemBasedSpell extends BaseSpell implements Listener {
|
||||
*/
|
||||
public ItemBasedSpell(String name, String description, int spellId, int range, String item, int cooldown, int manaCost, int damage, boolean requiresNearbyEntity, BiConsumer<Player, Entity> castHandler) {
|
||||
super(name, description, range, spellId);
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.item = item;
|
||||
this.cooldown = cooldown;
|
||||
this.manaCost = manaCost;
|
||||
this.castHandler = castHandler;
|
||||
this.damage = damage;
|
||||
this.requiresNearbyEntity = requiresNearbyEntity;
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,11 +156,12 @@ public class ItemBasedSpell extends BaseSpell implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
// TODO: Little messy, could clean this up later
|
||||
if (event.getItem() != null && event.getItem().getType() != Material.AIR &&
|
||||
event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK &&
|
||||
(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR)) {
|
||||
if (event.getItem() != null && event.getItem().getType().toString().equals(item)) {
|
||||
final ItemStack eventItem = event.getItem();
|
||||
final Action eventAction = event.getAction();
|
||||
|
||||
if (eventItem != null && eventItem.getType() != Material.AIR &&
|
||||
(eventAction == Action.RIGHT_CLICK_AIR || eventAction == Action.LEFT_CLICK_AIR)) {
|
||||
if (eventItem.getType().toString().equals(item)) {
|
||||
// Check if they have an active cooldown
|
||||
Player player = event.getPlayer();
|
||||
double cooldown = cooldownHandler.getCooldown(player, this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user