Files
src
build.gradle
settings.gradle
Code
4 381
src/main/java/com/kodari/lobby/LobbyHubPlugin.java
package com.kodari.lobby;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.Map;
public final class LobbyHubPlugin extends JavaPlugin implements CommandExecutor {
@Override
public void onEnable() {
getCommand("hubbuild").setExecutor(this);
getCommand("hubclear").setExecutor(this);
getLogger().info("Kodari lobby hub commands enabled.");
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player player)) {
sender.sendMessage(ChatColor.RED + "Only a player can use this command.");
return true;
}
Location origin = player.getLocation().getBlock().getLocation();
HubBuilder builder = new HubBuilder(origin);
if (command.getName().equalsIgnoreCase("hubclear")) {
builder.clear();
player.sendMessage(ChatColor.YELLOW + "The lobby hub volume has been cleared.");
return true;
}
player.sendMessage(ChatColor.AQUA + "Building the grand lobby hub...");
builder.build();
player.sendMessage(ChatColor.GREEN + "Lobby hub complete. Four game-mode gateways and floating islands are ready.");
return true;
}
private static final class HubBuilder {
private static final int HUB_RADIUS = 34;
private final World world;
private final int ox;
private final int oy;
private final int oz;
private final Map<String, Material> palette = new HashMap<>();
private HubBuilder(Location origin) {
this.world = origin.getWorld();
this.ox = origin.getBlockX();
this.oy = origin.getBlockY();
this.oz = origin.getBlockZ();
loadPalette();
}
private void loadPalette() {
String[] names = {
"AIR", "POLISHED_DEEPSLATE", "DEEPSLATE_BRICKS", "DEEPSLATE_TILES", "BLACKSTONE",
"POLISHED_BLACKSTONE", "POLISHED_BLACKSTONE_BRICKS", "QUARTZ_BLOCK", "QUARTZ_PILLAR",
"QUARTZ_SLAB", "QUARTZ_STAIRS", "SMOOTH_QUARTZ", "SEA_LANTERN", "GLOWSTONE",
"LANTERN", "SOUL_LANTERN", "END_ROD", "WATER", "STONE_BRICKS", "MOSS_BLOCK",
"GRASS_BLOCK", "DIRT", "OAK_LOG", "OAK_LEAVES", "AZALEA_LEAVES", "VINE", "CHAIN",
"NETHER_BRICKS", "SHROOMLIGHT", "REDSTONE_LAMP", "TORCH", "CYAN_STAINED_GLASS_PANE",
"PURPLE_STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", "ORANGE_STAINED_GLASS_PANE",
"CYAN_BANNER", "PURPLE_BANNER", "LIME_BANNER", "ORANGE_BANNER", "ALLIUM", "BLUE_ORCHID",
"DANDELION", "POPPY", "FERN", "OAK_SLAB", "COBBLESTONE_WALL", "IRON_BARS"
};
for (String name : names) {
XMaterial.matchXMaterial(name).map(XMaterial::parseMaterial).ifPresent(material -> palette.put(name, material));
}
}
private void build() {
buildFoundation();
buildRadialWalkways();
buildFountain();
buildGateways();
buildFloatingIslands();
buildGardenDetails();
world.setSpawnLocation(ox, oy + 2, oz);
}
private void clear() {
Material air = material("AIR");
for (int x = ox - HUB_RADIUS; x <= ox + HUB_RADIUS; x++) {
for (int y = oy - 4; y <= oy + 25; y++) {
for (int z = oz - HUB_RADIUS; z <= oz + HUB_RADIUS; z++) {
world.getBlockAt(x, y, z).setType(air, false);
}
}
}
}
private void buildFoundation() {
disc(ox, oy, oz, 28, "POLISHED_DEEPSLATE");
disc(ox, oy + 1, oz, 26, "DEEPSLATE_BRICKS");
ring(ox, oy + 2, oz, 26, "POLISHED_BLACKSTONE");
ring(ox, oy + 2, oz, 23, "QUARTZ_BLOCK");
ring(ox, oy + 2, oz, 21, "BLACKSTONE");
for (int i = 0; i < 16; i++) {
double angle = Math.PI * 2 * i / 16;
int x = ox + (int) Math.round(Math.cos(angle) * 24);
int z = oz + (int) Math.round(Math.sin(angle) * 24);
column(x, oy + 2, z, 2, "QUARTZ_PILLAR");
set(x, oy + 5, z, i % 2 == 0 ? "LANTERN" : "SEA_LANTERN");
}
for (int i = 0; i < 8; i++) {
double angle = Math.PI * 2 * i / 8 + Math.PI / 8;
int x = ox + (int) Math.round(Math.cos(angle) * 27);
int z = oz + (int) Math.round(Math.sin(angle) * 27);
set(x, oy + 2, z, "GLOWSTONE");
set(x, oy + 3, z, "IRON_BARS");
}
}
private void buildRadialWalkways() {
walkway(1, 0);
walkway(-1, 0);
walkway(0, 1);
walkway(0, -1);
}
private void walkway(int dx, int dz) {
int px = -dz;
int pz = dx;
for (int distance = 7; distance <= 24; distance++) {
int x = ox + dx * distance;
int z = oz + dz * distance;
for (int width = -3; width <= 3; width++) {
set(x + px * width, oy + 2, z + pz * width, width == -3 || width == 3 ? "QUARTZ_BLOCK" : "SMOOTH_QUARTZ");
}
if (distance % 3 == 0) {
set(x + px * 4, oy + 3, z + pz * 4, "SEA_LANTERN");
set(x - px * 4, oy + 3, z - pz * 4, "SEA_LANTERN");
}
}
}
private void buildFountain() {
disc(ox, oy + 2, oz, 8, "QUARTZ_BLOCK");
ring(ox, oy + 3, oz, 7, "POLISHED_BLACKSTONE");
disc(ox, oy + 3, oz, 5, "WATER");
ring(ox, oy + 4, oz, 4, "SEA_LANTERN");
disc(ox, oy + 4, oz, 3, "QUARTZ_BLOCK");
disc(ox, oy + 5, oz, 2, "WATER");
column(ox, oy + 5, oz, 5, "QUARTZ_PILLAR");
set(ox, oy + 10, oz, "SEA_LANTERN");
for (int i = 0; i < 4; i++) {
int dx = i == 0 ? 1 : i == 1 ? -1 : 0;
int dz = i == 2 ? 1 : i == 3 ? -1 : 0;
set(ox + dx * 6, oy + 4, oz + dz * 6, "SEA_LANTERN");
set(ox + dx * 6, oy + 5, oz + dz * 6, "WATER");
set(ox + dx * 6, oy + 6, oz + dz * 6, "WATER");
}
}
private void buildGateways() {
buildGateway(0, -1, "CYAN_STAINED_GLASS_PANE", "CYAN_BANNER", "NORTH");
buildGateway(1, 0, "PURPLE_STAINED_GLASS_PANE", "PURPLE_BANNER", "EAST");
buildGateway(0, 1, "LIME_STAINED_GLASS_PANE", "LIME_BANNER", "SOUTH");
buildGateway(-1, 0, "ORANGE_STAINED_GLASS_PANE", "ORANGE_BANNER", "WEST");
}
private void buildGateway(int dx, int dz, String glass, String banner, String ignoredName) {
int px = -dz;
int pz = dx;
int cx = ox + dx * 25;
int cz = oz + dz * 25;
for (int side = -6; side <= 6; side++) {
set(cx + px * side, oy + 2, cz + pz * side, "QUARTZ_BLOCK");
if (Math.abs(side) == 6) {
column(cx + px * side, oy + 3, cz + pz * side, 8, "POLISHED_BLACKSTONE_BRICKS");
set(cx + px * side, oy + 5, cz + pz * side, banner);
set(cx + px * side, oy + 10, cz + pz * side, "SEA_LANTERN");
}
}
for (int height = 3; height <= 9; height++) {
set(cx + px * 5, oy + height, cz + pz * 5, "QUARTZ_BLOCK");
set(cx - px * 5, oy + height, cz - pz * 5, "QUARTZ_BLOCK");
if (height >= 5 && height <= 8) {
set(cx + px * 4, oy + height, cz + pz * 4, glass);
set(cx - px * 4, oy + height, cz - pz * 4, glass);
}
}
for (int side = -5; side <= 5; side++) {
set(cx + px * side, oy + 10, cz + pz * side, "QUARTZ_BLOCK");
if (Math.abs(side) < 4) {