Implement knockback effect for players near captured flag

Added a feature to knock back nearby players when a flag is captured, creating space for the flag bearer.
This commit is contained in:
Teriuihi 2025-03-01 00:25:52 +01:00
parent 436b462ffe
commit b5c59cf173
2 changed files with 11 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.concurrent.CompletableFuture;
@ -80,8 +81,14 @@ public class Flag implements Runnable {
if (flagCarrier != null) {
return;
}
//TODO knockback enemies from flag location to create space for person who captured mayb short speed boost and heal?
//TODO add de-buffs and enable buffs for others?
flagLocation.getNearbyPlayers(5).forEach(nearbyPlayer -> {
if (nearbyPlayer.getUniqueId().equals(player.getUniqueId())) {
return;
}
Vector direction = nearbyPlayer.getLocation().toVector().subtract(flagLocation.toVector()).normalize();
direction.setY(0.2);
nearbyPlayer.setVelocity(direction.multiply(5));
});
player.getInventory().setItem(EquipmentSlot.HEAD, new ItemStack(teamPlayer.getTeam().getFlagMaterial()));
Bukkit.getScheduler().runTask(main, () -> flagLocation.getBlock().setType(Material.AIR));
flagCarrier = player;

View File

@ -1,3 +1,3 @@
#Fri Feb 28 23:59:35 CET 2025
buildNumber=83
#Sat Mar 01 00:23:05 CET 2025
buildNumber=86
version=0.1