import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.entity.Player;
import org.bukkit.Location;
import org.bukkit.World;
public class ArenaListener implements Listener {
private final World arenaWorld; // Замените на ваш мир арены
private final int arenaX1, arenaY1, arenaZ1; // Координаты первой точки арены
private final int arenaX2, arenaY2, arenaZ2; // Координаты второй точки арены
public ArenaListener(World world, int x1, int y1, int z1, int x2, int y2, int z2) {
this.arenaWorld = world;
this.arenaX1 = x1;
this.arenaY1 = y1;
this.arenaZ1 = z1;
this.arenaX2 = x2;
this.arenaY2 = y2;
this.arenaZ2 = z2;
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
Location loc = player.getLocation();
if (loc.getWorld().equals(arenaWorld) && isInArena(loc)) {
player.setHealth(player.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue()); // Восстанавливаем здоровье
}
}
private boolean isInArena(Location loc) {
return loc.getBlockX() >= arenaX1 && loc.getBlockX() <= arenaX2 &&
loc.getBlockY() >= arenaY1 && loc.getBlockY() <= arenaY2 &&
loc.getBlockZ() >= arenaZ1 && loc.getBlockZ() <= arenaZ2;
}
}