Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

import net.kyori.adventure.text.Component;
import org.battleplugins.arena.ArenaPlayer;
import org.battleplugins.arena.BattleArena;
import org.battleplugins.arena.BattleArenaApi;
import org.battleplugins.arena.BattleArenaConfig;
import org.battleplugins.arena.competition.CompetitionType;
import org.battleplugins.arena.competition.LiveCompetition;
import org.battleplugins.arena.competition.map.MapType;
import org.battleplugins.arena.competition.map.options.Bounds;
import org.battleplugins.arena.ctf.ArenaCtf;
import org.battleplugins.arena.ctf.CtfMessages;
import org.battleplugins.arena.ctf.CtfUtil;
import org.battleplugins.arena.ctf.arena.CtfCompetition.ActiveFlag;
import org.battleplugins.arena.ctf.event.ArenaFlagCaptureEvent;
import org.battleplugins.arena.ctf.event.ArenaFlagReturnEvent;
import org.battleplugins.arena.messages.Message;
Expand All @@ -22,6 +28,7 @@
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.Nullable;
import org.bukkit.util.Vector;

import java.awt.Color;
import java.time.Duration;
Expand Down Expand Up @@ -113,7 +120,23 @@ public void tickFlags() {
continue;
}

if (flag.flag.getCaptureRegion().isInside(player.getLocation().toBlockLocation())) {
Bounds captureRegion = flag.flag.getCaptureRegion();
if (map.getType() == MapType.DYNAMIC && BattleArena.getInstance().getMainConfig().centerDynamicArena()) {
Bounds mapBounds = map.getBounds();
int offsetX = (mapBounds.getMinX() + mapBounds.getMaxX()) / 2;
int offsetZ = (mapBounds.getMinZ() + mapBounds.getMaxZ()) / 2;

captureRegion = new Bounds(
captureRegion.getMinX() - offsetX,
captureRegion.getMinY(),
captureRegion.getMinZ() - offsetZ,
captureRegion.getMaxX() - offsetX,
captureRegion.getMaxY(),
captureRegion.getMaxZ() - offsetZ
);
}

if (captureRegion.isInside(player.getLocation().toBlockLocation())) {
if (flag.team.equals(arenaPlayer.getTeam())) {
// Check to see if a player is holding the opposite team's flag
if (this.capturedFlags.containsKey(arenaPlayer)) {
Expand Down Expand Up @@ -312,6 +335,18 @@ public void placeFlag(float yaw) {
return;
}

if (map.getType() == MapType.DYNAMIC && BattleArena.getInstance().getMainConfig().centerDynamicArena()) {
Bounds bounds = map.getBounds();
Vector center = new Vector(
(bounds.getMinX() + bounds.getMaxX()) / 2.0,
bounds.getMinY(),
(bounds.getMinZ() + bounds.getMaxZ()) / 2.0
);

// Offset the flag location by the dynamic map's center
this.flagLocation = this.flagLocation.clone().subtract(center.getX(), 0, center.getZ());
}

Rotatable rotatable = (Rotatable) bannerMaterial.createBlockData();
rotatable.setRotation(this.flag.getBlockFace(yaw));
this.flagLocation.getBlock().setBlockData(rotatable);
Expand Down