From fb914734ce1fc75cd7b0373db15defe38840c4b2 Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 3 Oct 2021 08:26:22 -0600 Subject: [PATCH] Proof of concept implementation Implemented based on what https://forum.totalfreedom.me/d/2882-town-hall-thingy-results says. --- .../command/Command_floatlands.java | 19 +++++++++++ .../world/CleanroomChunkGenerator.java | 25 ++++++++++++-- .../totalfreedommod/world/Floatlands.java | 33 +++++++++++++++++++ .../totalfreedommod/world/WorldManager.java | 3 ++ 4 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_floatlands.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/world/Floatlands.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_floatlands.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_floatlands.java new file mode 100644 index 00000000..b6517948 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_floatlands.java @@ -0,0 +1,19 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Go to the Floatlands (not to be confused with the Flatlands).", usage = "/", aliases = "void") +public class Command_floatlands extends FreedomCommand +{ + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + plugin.wm.floatlands.sendToWorld(playerSender); + + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java b/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java index 8d0b9bd6..a9de9ecf 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java @@ -40,6 +40,11 @@ public class CleanroomChunkGenerator extends ChunkGenerator } public CleanroomChunkGenerator(String id) + { + this(id, true); + } + + public CleanroomChunkGenerator(String id, boolean generateBedrock) { if (id != null) { @@ -48,7 +53,11 @@ public class CleanroomChunkGenerator extends ChunkGenerator int y = 0; materials = new Material[128]; // Default to 128, will be resized later if required - materials[y++] = Material.BEDROCK; + + if (generateBedrock) + { + materials[y++] = Material.BEDROCK; + } if (id.length() > 0) { @@ -115,14 +124,24 @@ public class CleanroomChunkGenerator extends ChunkGenerator e.printStackTrace(); materials = new Material[65]; - materials[0] = Material.BEDROCK; + + if (generateBedrock) + { + materials[0] = Material.BEDROCK; + } + Arrays.fill(materials, 1, 65, Material.STONE); } } else { materials = new Material[65]; - materials[0] = Material.BEDROCK; + + if (generateBedrock) + { + materials[0] = Material.BEDROCK; + } + Arrays.fill(materials, 1, 65, Material.STONE); } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/Floatlands.java b/src/main/java/me/totalfreedom/totalfreedommod/world/Floatlands.java new file mode 100644 index 00000000..5297805f --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/Floatlands.java @@ -0,0 +1,33 @@ +package me.totalfreedom.totalfreedommod.world; + +import org.bukkit.*; + +public class Floatlands extends CustomWorld +{ + + public Floatlands() + { + super("floatlands"); + } + + @Override + protected World generateWorld() + { + final WorldCreator worldCreator = new WorldCreator(getName()); + worldCreator.generateStructures(false); + worldCreator.type(WorldType.NORMAL); + worldCreator.environment(World.Environment.NORMAL); + worldCreator.generator(new CleanroomChunkGenerator("", false)); + + final World world = Bukkit.getServer().createWorld(worldCreator); + + assert world != null; + world.setSpawnFlags(false, false); + world.setSpawnLocation(0, 50, 0); + + plugin.gr.commitGameRules(); + + return world; + } + +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java b/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java index 579da910..ed95df3c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/WorldManager.java @@ -20,12 +20,14 @@ public class WorldManager extends FreedomService public Flatlands flatlands; public AdminWorld adminworld; public MasterBuilderWorld masterBuilderWorld; + public Floatlands floatlands; public WorldManager() { this.flatlands = new Flatlands(); this.adminworld = new AdminWorld(); this.masterBuilderWorld = new MasterBuilderWorld(); + this.floatlands = new Floatlands(); } @Override @@ -34,6 +36,7 @@ public class WorldManager extends FreedomService flatlands.getWorld(); adminworld.getWorld(); masterBuilderWorld.getWorld(); + floatlands.getWorld(); // Disable weather if (ConfigEntry.DISABLE_WEATHER.getBoolean())