Send new players to local planet terrain

This commit is contained in:
unimatrixgit 2026-10-13 02:29:23 +02:00
commit bc6c32e599
3 changed files with 20 additions and 4 deletions

View file

@ -535,8 +535,15 @@ public final class DuneCore extends JavaPlugin implements Listener, CommandExecu
@EventHandler public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
Bukkit.getScheduler().runTask(this, () -> giveMenuItem(p));
if (!selected.containsKey(p.getUniqueId()) || selected.get(p.getUniqueId()).isEmpty()) p.sendMessage(ChatColor.GOLD + "Choose your faction with /dune choose <fremen|harkonnen|corrino|atreides>.");
else Bukkit.getScheduler().runTask(this, () -> {
if (!selected.containsKey(p.getUniqueId()) || selected.get(p.getUniqueId()).isEmpty()) {
p.sendMessage(ChatColor.GOLD + "Choose your faction with /dune choose <fremen|harkonnen|corrino|atreides>.");
if (p.getWorld().getName().equals("world")) Bukkit.getScheduler().runTask(this, () -> {
World localWorld = Bukkit.getWorld(localPlanet());
if (p.isOnline() && localWorld != null && p.getWorld().getName().equals("world")) {
p.teleport(localWorld.getSpawnLocation());
}
});
} else Bukkit.getScheduler().runTask(this, () -> {
if (p.getWorld().getName().equals("world")) teleport(p, planets[Arrays.asList(factions).indexOf(selected.get(p.getUniqueId()))]);
});
}

View file

@ -16,4 +16,6 @@ Valid values are `arrakis`, `giedi_prime`, `kaitain`, `caladan`, and `sigma_drac
Install DuneCore alongside DuneTerrain if you want the Guild navigator to open DuneCore's travel menu. DuneCore reads the loaded planet world to identify its local backend. For proxy travel, set `network.local-planet` and `network.servers` in DuneCore's config to match the DuneTerrain selection and proxy server names.
The generator applies only when a world is first created. Existing worlds and already-generated chunks are not replaced by a config change.
The generator applies when a world is first created and to chunks generated later. Existing chunks are never replaced by a config change. If the selected world already exists with non-Arrakis terrain, stop the server, back up and move that world's folder out of the server directory, then restart to create it with DuneTerrain. DuneTerrain logs a warning when it loads an existing world folder.
DuneCore sends new players who have not chosen a faction from Paper's default `world` to the local planet spawn, so they arrive in the world generated by DuneTerrain.

View file

@ -7,6 +7,7 @@ import org.bukkit.entity.Villager;
import org.bukkit.generator.*;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.*;
public final class DuneTerrain extends JavaPlugin {
@ -27,6 +28,8 @@ public final class DuneTerrain extends JavaPlugin {
getServer().getPluginManager().disablePlugin(this);
return;
}
File worldFolder = new File(getServer().getWorldContainer(), planet);
boolean existingWorld = worldFolder.isDirectory();
World world = Bukkit.createWorld(new WorldCreator(planet)
.environment(World.Environment.NORMAL)
.generator(new PlanetChunkGenerator(this, planet)));
@ -38,7 +41,11 @@ public final class DuneTerrain extends JavaPlugin {
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !planet.equals("arrakis"));
world.setTime(planet.equals("giedi_prime") ? 18000 : 6000);
setupPlanetSpawn(world, planet);
getLogger().info("DuneTerrain is generating " + planet + " on this Paper server.");
if (existingWorld) {
getLogger().warning("Loaded existing world '" + planet + "'. DuneTerrain only generates new chunks; existing terrain will remain unchanged. Back up and move the world folder, then restart, to regenerate it.");
} else {
getLogger().info("Created world '" + planet + "' with DuneTerrain.");
}
}
private void setupPlanetSpawn(World world, String planet) {