-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* delete island one by one * register before IslandDeletionManager * optimize imports * setting * just some indents * config * run synchronously * a bit reformat before recoding * proper delete chunks * comment * combine the task call * expose the NMS Handler * don't have to try-catch this * we know that this is final * expose copy chunk data so that it can be overridden * Don't have to use Vector * set block from minimum height * remove NMS and use fallback if not set * only get the height once * fix test
- Loading branch information
Showing
13 changed files
with
213 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/world/bentobox/bentobox/managers/IslandChunkDeletionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package world.bentobox.bentobox.managers; | ||
|
||
import world.bentobox.bentobox.BentoBox; | ||
import world.bentobox.bentobox.database.objects.IslandDeletion; | ||
import world.bentobox.bentobox.util.DeleteIslandChunks; | ||
|
||
import java.util.LinkedList; | ||
import java.util.Queue; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
/** | ||
* Manages the queue of island chunks to be deleted. | ||
*/ | ||
public class IslandChunkDeletionManager implements Runnable { | ||
private final boolean slowDeletion; | ||
private final BentoBox plugin; | ||
private final AtomicReference<DeleteIslandChunks> currentTask; | ||
private final Queue<IslandDeletion> queue; | ||
|
||
public IslandChunkDeletionManager(BentoBox plugin) { | ||
this.plugin = plugin; | ||
this.currentTask = new AtomicReference<>(); | ||
this.queue = new LinkedList<>(); | ||
this.slowDeletion = plugin.getSettings().isSlowDeletion(); | ||
|
||
if (slowDeletion) { | ||
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 0L, 20L); | ||
} | ||
} | ||
|
||
@Override | ||
public void run() { | ||
if (queue.isEmpty()) { | ||
return; | ||
} | ||
DeleteIslandChunks task = this.currentTask.get(); | ||
if (task != null && !task.isCompleted()) { | ||
return; | ||
} | ||
IslandDeletion islandDeletion = queue.remove(); | ||
currentTask.set(startDeleteTask(islandDeletion)); | ||
} | ||
|
||
private DeleteIslandChunks startDeleteTask(IslandDeletion islandDeletion) { | ||
return new DeleteIslandChunks(plugin, islandDeletion); | ||
} | ||
|
||
/** | ||
* Adds an island deletion to the queue. | ||
* | ||
* @param islandDeletion island deletion | ||
*/ | ||
public void add(IslandDeletion islandDeletion) { | ||
if (slowDeletion) { | ||
queue.add(islandDeletion); | ||
} else { | ||
startDeleteTask(islandDeletion); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 0 additions & 31 deletions
31
src/main/java/world/bentobox/bentobox/nms/v1_18_R1/NMSHandler.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.