fixed the windcharge function, works good now
This commit is contained in:
@@ -74,7 +74,6 @@ public class MaceEventListener implements Listener {
|
|||||||
if (!plugin.isMaceItem(item)) return;
|
if (!plugin.isMaceItem(item)) return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
// remove if does not work
|
|
||||||
attemptWindCharge(player);
|
attemptWindCharge(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +99,7 @@ public class MaceEventListener implements Listener {
|
|||||||
|
|
||||||
// Strict cooldown check
|
// Strict cooldown check
|
||||||
Long lastUse = windChargeCooldowns.get(playerId);
|
Long lastUse = windChargeCooldowns.get(playerId);
|
||||||
|
|
||||||
if (lastUse != null && (now - lastUse) < windCooldown * 1000L) {
|
if (lastUse != null && (now - lastUse) < windCooldown * 1000L) {
|
||||||
int remaining = (int) ((windCooldown * 1000L - (now - lastUse)) / 1000L);
|
int remaining = (int) ((windCooldown * 1000L - (now - lastUse)) / 1000L);
|
||||||
player.sendActionBar(Component.text("§cWind Charge cooldown: " + remaining + "s"));
|
player.sendActionBar(Component.text("§cWind Charge cooldown: " + remaining + "s"));
|
||||||
@@ -107,6 +107,18 @@ public class MaceEventListener implements Listener {
|
|||||||
return; // Block spawn completely
|
return; // Block spawn completely
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// apply a knockback effect to nearby entittys
|
||||||
|
for (Entity entity : player.getNearbyEntities(5, 5, 5)) {
|
||||||
|
if (entity instanceof LivingEntity && !entity.equals(player)) {
|
||||||
|
Vector knockback = entity.getLocation().toVector()
|
||||||
|
.subtract(player.getLocation().toVector())
|
||||||
|
.normalize()
|
||||||
|
.multiply(0.5)
|
||||||
|
.setY(0.3);
|
||||||
|
entity.setVelocity(knockback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Immediately mark the cooldown to prevent spamming
|
// Immediately mark the cooldown to prevent spamming
|
||||||
windChargeCooldowns.put(playerId, now);
|
windChargeCooldowns.put(playerId, now);
|
||||||
|
|
||||||
@@ -129,6 +141,7 @@ public class MaceEventListener implements Listener {
|
|||||||
if (secondsLeft <= 0) {
|
if (secondsLeft <= 0) {
|
||||||
windChargeCooldowns.remove(playerId);
|
windChargeCooldowns.remove(playerId);
|
||||||
cancel();
|
cancel();
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.5f, 0.5f);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.sendActionBar(Component.text("§aWind Charge cooldown: " + secondsLeft + "s"));
|
player.sendActionBar(Component.text("§aWind Charge cooldown: " + secondsLeft + "s"));
|
||||||
|
|||||||
Reference in New Issue
Block a user