-
-
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.
* Fix 1.20.4 backwards compatibility * Improve deletion speed and memory usage
- Loading branch information
1 parent
83698c2
commit d288528
Showing
9 changed files
with
92 additions
and
22 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
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
59 changes: 59 additions & 0 deletions
59
src/main/java/world/bentobox/bentobox/listeners/SeedWorldMakerListener.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,59 @@ | ||
package world.bentobox.bentobox.listeners; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.World; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.world.ChunkLoadEvent; | ||
|
||
import world.bentobox.bentobox.BentoBox; | ||
import world.bentobox.bentobox.api.addons.GameModeAddon; | ||
import world.bentobox.bentobox.api.events.BentoBoxReadyEvent; | ||
import world.bentobox.bentobox.util.Util; | ||
|
||
/** | ||
* Updates chunks in seed worlds if they have been generated in the main world | ||
* @author tastybento | ||
*/ | ||
public class SeedWorldMakerListener implements Listener { | ||
|
||
private final BentoBox plugin; | ||
|
||
/** | ||
* Whether BentoBox is ready or not. | ||
* This helps to avoid hanging out the server on startup as a lot of {@link ChunkLoadEvent} are called at this time. | ||
* @since 1.1 | ||
*/ | ||
private boolean ready; | ||
|
||
|
||
public SeedWorldMakerListener(BentoBox bentoBox) { | ||
this.plugin = bentoBox; | ||
} | ||
|
||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) | ||
public void onBentoBoxReady(BentoBoxReadyEvent e) { | ||
ready = true; | ||
} | ||
|
||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) | ||
public void onChunkLoad(ChunkLoadEvent e) { | ||
if (!ready || !e.getChunk().isGenerated()) { | ||
return; | ||
} | ||
World world = e.getWorld(); | ||
plugin.getIWM().getAddon(world).filter(GameModeAddon::isUsesNewChunkGeneration).ifPresent(gma -> { | ||
World seed = Bukkit.getWorld(world.getName() + "/bentobox"); | ||
int x = e.getChunk().getX(); | ||
int z = e.getChunk().getZ(); | ||
if (seed != null && !seed.getChunkAt(x, z, false).isGenerated()) { | ||
Util.getChunkAtAsync(seed, x, z, true); | ||
} | ||
}); | ||
|
||
} | ||
|
||
|
||
|
||
} |
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