diff --git a/Plugin/src/main/java/dev/lrxh/neptune/Neptune.java b/Plugin/src/main/java/dev/lrxh/neptune/Neptune.java index ca1f0b15..7d577847 100644 --- a/Plugin/src/main/java/dev/lrxh/neptune/Neptune.java +++ b/Plugin/src/main/java/dev/lrxh/neptune/Neptune.java @@ -130,6 +130,8 @@ private void loadManager() { new PlaceholderImpl(this).register(); } + this.workloadManager = new WorkloadManager(); + this.taskScheduler = new TaskScheduler(this); this.configManager = new ConfigManager(); this.configManager.load(); this.queueManager = new QueueManager(); @@ -149,7 +151,6 @@ private void loadManager() { this.generationManager = new GenerationManager(versionHandler); this.assemble = new Assemble(new ScoreboardAdapter()); this.api = new API(this); - this.workloadManager = new WorkloadManager(); registerListeners(); loadCommandManager(); @@ -202,7 +203,6 @@ private void loadWorlds() { } private void loadTasks() { - taskScheduler = new TaskScheduler(this); new QueueCheckTask(this).start(SettingsLocale.QUEUE_UPDATE_TIME.getInt(), this); new LeaderboardTask(this).start(SettingsLocale.LEADERBOARD_UPDATE_TIME.getInt(), this); new WorkloadTask(workloadManager).start(1,this); diff --git a/Plugin/src/main/java/dev/lrxh/neptune/arena/impl/StandAloneArena.java b/Plugin/src/main/java/dev/lrxh/neptune/arena/impl/StandAloneArena.java index 2e55cd26..577c3869 100644 --- a/Plugin/src/main/java/dev/lrxh/neptune/arena/impl/StandAloneArena.java +++ b/Plugin/src/main/java/dev/lrxh/neptune/arena/impl/StandAloneArena.java @@ -3,6 +3,7 @@ import dev.lrxh.neptune.Neptune; import dev.lrxh.neptune.arena.Arena; import dev.lrxh.neptune.arena.impl.tasks.ArenaCaptureTask; +import dev.lrxh.neptune.arena.impl.tasks.ArenaCopyTask; import dev.lrxh.neptune.arena.impl.tasks.ArenaResetTask; import dev.lrxh.neptune.configs.impl.SettingsLocale; import dev.lrxh.neptune.kit.Kit; @@ -88,9 +89,9 @@ public boolean isSetup() { public void createCopy() { int offset = SettingsLocale.ARENA_COPY_DISTANCE.getInt() * (copies.size() + 1); - plugin.getGenerationManager().pasteRegion(this, min, max, offset); + new ArenaCopyTask(this, offset).start(plugin); - StandAloneArena copy = getArenaCopy(this, LocationUtil.addOffsetToLocation(min, offset), LocationUtil.addOffsetToLocation(max, offset)); + StandAloneArena copy = getArenaCopy(this, offset); copies.add(copy); @@ -112,9 +113,11 @@ public void removeCopy(StandAloneArena copy) { plugin.getKitManager().saveKits(); } - private StandAloneArena getArenaCopy(StandAloneArena arena, Location min, Location max) { - Location redSpawn = new Location(min.getWorld(), arena.getRedSpawn().getX() - arena.getMin().getX() + min.getX(), arena.getRedSpawn().getY(), arena.getRedSpawn().getZ() - arena.getMin().getZ() + min.getZ(), arena.getRedSpawn().getYaw(), arena.getRedSpawn().getPitch()); - Location blueSpawn = new Location(max.getWorld(), arena.getBlueSpawn().getX() - arena.getMin().getX() + min.getX(), arena.getBlueSpawn().getY(), arena.getBlueSpawn().getZ() - arena.getMin().getZ() + min.getZ(), arena.getBlueSpawn().getYaw(), arena.getBlueSpawn().getPitch()); + private StandAloneArena getArenaCopy(StandAloneArena arena, int offset) { + Location redSpawn = getRedSpawn().add(0, 0, offset); + Location blueSpawn = getBlueSpawn().add(0, 0,offset); + Location min = getMin().add(0, 0, offset); + Location max = getMax().add(0, 0,offset); return new StandAloneArena( arena.getName() + "#" + (arena.getCopies().size() + 1), diff --git a/Plugin/src/main/java/dev/lrxh/neptune/arena/impl/tasks/ArenaCopyTask.java b/Plugin/src/main/java/dev/lrxh/neptune/arena/impl/tasks/ArenaCopyTask.java new file mode 100644 index 00000000..6e036fdb --- /dev/null +++ b/Plugin/src/main/java/dev/lrxh/neptune/arena/impl/tasks/ArenaCopyTask.java @@ -0,0 +1,29 @@ +package dev.lrxh.neptune.arena.impl.tasks; + +import dev.lrxh.neptune.Neptune; +import dev.lrxh.neptune.arena.impl.StandAloneArena; +import dev.lrxh.neptune.providers.tasks.Workload; +import org.bukkit.Location; +import org.bukkit.Material; + +import java.util.Map; + +public class ArenaCopyTask implements Workload { + + private final StandAloneArena arena; + private final Neptune plugin; + private final int offset; + + public ArenaCopyTask(StandAloneArena arena, int offset) { + this.arena = arena; + this.plugin = arena.getPlugin(); + this.offset = offset; + } + + @Override + public void compute() { + for (Map.Entry stuff : arena.getBlockMap().entrySet()) { + plugin.getVersionHandler().getReflection().setBlock(plugin.getPlugin(), stuff.getKey().add(0, 0, offset), stuff.getValue(), false); + } + } +} diff --git a/Plugin/src/main/java/dev/lrxh/neptune/utils/LocationUtil.java b/Plugin/src/main/java/dev/lrxh/neptune/utils/LocationUtil.java index d14d216f..8567709f 100644 --- a/Plugin/src/main/java/dev/lrxh/neptune/utils/LocationUtil.java +++ b/Plugin/src/main/java/dev/lrxh/neptune/utils/LocationUtil.java @@ -21,7 +21,7 @@ public String serialize(Location location) { } public Location addOffsetToLocation(Location oldLoc, int offset) { - return new Location(oldLoc.getWorld(), oldLoc.getX() + offset, oldLoc.getY(), oldLoc.getZ() + offset, oldLoc.getYaw(), oldLoc.getPitch()); + return oldLoc.add(0, 0, offset); } public Location deserialize(String source) {