Enable own world generator and handling
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Bea 2022-11-12 04:59:45 +01:00
parent 73bb8e4de2
commit cadc5854ef
5 changed files with 33 additions and 4 deletions

View File

@ -1,5 +1,6 @@
package wtf.beatrice.limbomanager;
import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import wtf.beatrice.limbomanager.objects.Coordinates;
import wtf.beatrice.limbomanager.objects.LocationCheckRunnable;
@ -9,6 +10,8 @@ import java.util.HashMap;
public class Cache
{
public static final String worldName = "limbo";
public static World limboWorld;
public static final Coordinates baseCoords = new Coordinates(1000, 1000);
public static int islandsDistance = 500;

View File

@ -8,6 +8,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import wtf.beatrice.limbomanager.commands.Spawn;
import wtf.beatrice.limbomanager.listeners.*;
import wtf.beatrice.limbomanager.objects.LocationCheckRunnable;
import wtf.beatrice.limbomanager.objects.WorldGenerator;
import wtf.beatrice.limbomanager.utils.FileUtils;
import java.io.File;
@ -58,6 +59,9 @@ public class LimboManager extends JavaPlugin {
Cache.locationCheckRunnable = new LocationCheckRunnable();
Cache.locationCheckRunnable.task = Bukkit.getScheduler().runTaskTimerAsynchronously(this, Cache.locationCheckRunnable, 10L, 5L);
// create limbo world
WorldGenerator worldGenerator = new WorldGenerator();
worldGenerator.generateWorld();
}

View File

@ -47,7 +47,7 @@ public class PlayerTeleporter implements Listener
Coordinates islandCoords = calcNewCoordinates();
Cache.playerIslands.put(playerName, islandCoords);
Location islandLocation = new Location(player.getWorld(), islandCoords.getX(), 64, islandCoords.getZ());
Location islandLocation = new Location(Cache.limboWorld, islandCoords.getX(), 64, islandCoords.getZ());
// load chunk otherwise it will be buggy (no schem load, no tp)
islandLocation.getWorld().loadChunk(islandLocation.getChunk().getX(), islandLocation.getChunk().getZ(), true);
@ -64,7 +64,7 @@ public class PlayerTeleporter implements Listener
// todo: improve and make as async as possible
World islandWEWorld = BukkitAdapter.adapt(islandLocation.getWorld());
World islandWEWorld = BukkitAdapter.adapt(Cache.limboWorld);
Clipboard shematicClipboard;
ClipboardFormat clipboardFormat = ClipboardFormats.findByFile(schematicFile);
@ -107,7 +107,7 @@ public class PlayerTeleporter implements Listener
int maxRange = Cache.islandWalkingRange + 20;
Location islandSpawnLocation = LocationUtils.getPlayerSpawnLocation(player);
Location startFrom = new Location(islandSpawnLocation.getWorld(),
Location startFrom = new Location(Cache.limboWorld,
islandSpawnLocation.getX() - maxRange,
islandSpawnLocation.getWorld().getMinHeight(),
islandSpawnLocation.getZ() - maxRange);

View File

@ -0,0 +1,21 @@
package wtf.beatrice.limbomanager.objects;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import wtf.beatrice.limbomanager.Cache;
public class WorldGenerator
{
public void generateWorld()
{
// create world
WorldCreator worldCreator = new WorldCreator(Cache.worldName);
worldCreator.environment(World.Environment.THE_END);
worldCreator.generateStructures(false);
worldCreator.type(WorldType.FLAT);
worldCreator.generator("VoidGen");
Cache.limboWorld = worldCreator.createWorld();
}
}

View File

@ -1,12 +1,13 @@
name: LimboManager
main: wtf.beatrice.limbomanager.LimboManager
version: 0.0.3
load: STARTUP
# load: STARTUP
description: Mix of tools to run a Limbo server
api-version: 1.19
author: astro_bea
depend:
- WorldEdit
- VoidGen
commands:
spawn: