Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c80e7b5
feature: added a rail generator command including a custom undo and redo
Jasupa Apr 26, 2026
a9766e3
feature: added a first version for the cuboid and poly rail generator
Jasupa Apr 27, 2026
9ca55bf
feature:
Jasupa Apr 29, 2026
7e340ef
feature:
Jasupa Apr 30, 2026
f014b16
refactor:
Jasupa May 1, 2026
385f8ee
refactor:
Jasupa May 5, 2026
2bac069
fix:
Jasupa May 7, 2026
693f3fd
fix:
Jasupa May 17, 2026
47704c9
refractor:
Jasupa May 19, 2026
873526b
refractor:
Jasupa May 24, 2026
9a9380a
refractor:
Jasupa May 25, 2026
6a6a97e
style(generator): restore single-line guard statements for railscripts
Jasupa May 26, 2026
e6894d5
refactor(rail): remove custom rail point commands
Jasupa May 26, 2026
7e3cbb1
fix(generator): address review feedback
Jasupa May 27, 2026
a032d46
fix(generator): address rail review feedback
Jasupa May 27, 2026
d41eb32
fix(generator): address command execution review feedback
Jasupa May 28, 2026
5bc7da4
fix(rail): address rail review feedback
Jasupa May 28, 2026
7ea760f
fix(generator): improve rail placement and shared block updates
Jasupa May 28, 2026
92bd78c
fix(generator): resolve qodana warnings
Jasupa Jun 6, 2026
dfc5118
fix(generator): resolve merge issues
Jasupa Jun 6, 2026
1ac7434
fix(generator): avoid deprecated rail type icon parsing
Jasupa Jun 6, 2026
f131c80
fix(generator): add rail generation safeguards
Jasupa Jun 8, 2026
a067abb
fix(generator): resolve remaining qodana warnings
Jasupa Jun 8, 2026
4c52322
fix(rail): make generation limits configurable
Jasupa Jun 14, 2026
918d88e
fix(generator): resolve main rebase conflicts
Jasupa Jun 14, 2026
48c48c2
fix(generator): resolve qodana warnings
Jasupa Jun 14, 2026
8c6a1b4
fix(generator): added future support logic for multiple lanes using G…
Jasupa Jun 14, 2026
0bca3bb
fix(generator): smooth weighted progress updates
Jasupa Jun 16, 2026
a0640e0
fix(generator): keep rail progress continuous until completion
Jasupa Jun 16, 2026
6fad864
Merge branch 'main' into rail-generator
Jasupa Jun 19, 2026
203c744
fix(generator): address config and menu review feedback
Jasupa Jun 19, 2026
4f5d45f
Merge remote-tracking branch 'origin/rail-generator' into rail-generator
Jasupa Jun 19, 2026
d6b7362
fix(rail): address generation feedback handling
Jasupa Jun 19, 2026
6124667
fix(rail): resolve underground placement issues
Jasupa Jun 19, 2026
c2b5e10
fix(rail): improve height resolution stability
Jasupa Jun 19, 2026
4ddee65
fix(generator): address component and rail menu feedback
Jasupa Jun 19, 2026
1c13c78
fix(generator): align component messaging style
Jasupa Jun 19, 2026
0f24037
fix(generator): address history and utility cleanup
Jasupa Jun 19, 2026
4c3e283
fix(generator): make help wiki links clickable
Jasupa Jun 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Comment thread
Jasupa marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,35 @@
import com.alpsbte.alpslib.utils.ChatHelper;
import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
import net.buildtheearth.buildteamtools.modules.generator.menu.GeneratorMenu;
import net.buildtheearth.buildteamtools.modules.generator.model.History;
import net.buildtheearth.buildteamtools.modules.generator.model.HistoryEntry;
import net.buildtheearth.buildteamtools.modules.network.model.Permissions;
import net.buildtheearth.buildteamtools.utils.Utils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class GeneratorCommand implements CommandExecutor {
import java.util.ArrayList;
import java.util.List;

public class GeneratorCommand implements CommandExecutor, TabCompleter {

public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String cmdLabel,
String @NotNull [] args) {
private static final List<String> SUB_COMMANDS = List.of(
"house",
"road",
"rail",
"tree",
"field",
"history",
"undo",
"redo"
);

private static final List<String> HELP_ARGUMENTS = List.of("help", "info", "?");

public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String cmdLabel, String @NotNull [] args) {
if (!(sender instanceof Player p)) {
sender.sendMessage("§cOnly players can execute this command.");
return true;
Expand All @@ -29,52 +42,40 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
return true;
}

// Command Usage: /gen
if (args.length == 0) {
new GeneratorMenu(p, true);
return true;
}


// Command Usage: /gen house ...
switch (args[0]) {
switch (args[0].toLowerCase()) {
case "house":
GeneratorModule.getInstance().getHouse().analyzeCommand(p, args);
return true;

// Command Usage: /gen road ...
case "road":
GeneratorModule.getInstance().getRoad().analyzeCommand(p, args);
return true;

// Command Usage: /gen rail ...
case "rail":
p.sendMessage(Component.text("This generator have some serious issues and is currently disabled.",
NamedTextColor.DARK_RED));
//GeneratorModule.getInstance().getRail().analyzeCommand(p, args);
GeneratorModule.getInstance().getRail().analyzeCommand(p, args);
return true;

// Command Usage: /gen tree ...
case "tree":
GeneratorModule.getInstance().getTree().analyzeCommand(p, args);
return true;

// Command Usage: /gen field ...
case "field":
p.sendMessage(Component.text("This generator have some serious issues and is currently disabled.",
NamedTextColor.DARK_RED));
//GeneratorModule.getInstance().getField().analyzeCommand(p, args);
p.sendMessage("§cThis generator has serious issues and is currently disabled.");
return true;

// Command Usage: /gen history
case "history":
if (GeneratorModule.getInstance().getPlayerHistory(p).getHistoryEntries().isEmpty()) {
p.sendMessage("§cYou didn't generate any structures yet. Use /gen to create one.");
return true;
}

ChatHelper.sendMessageBox(sender, "Generator History for " + p.getName(), () -> {
for (History.HistoryEntry history : GeneratorModule.getInstance().getPlayerHistory(p).getHistoryEntries()) {
for (HistoryEntry history : GeneratorModule.getInstance().getPlayerHistory(p).getHistoryEntries()) {
long timeDifference = System.currentTimeMillis() - history.getTimeCreated();
p.sendMessage("§e- " + history.getGeneratorType().name() + " §7-§e " + Utils.toDate(timeDifference) +
" ago §7-§e " + history.getWorldEditCommandCount() + " Commands executed");
Expand All @@ -89,6 +90,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
case "redo":
GeneratorModule.getInstance().getPlayerHistory(p).redoCommand(p);
return true;

default:
sendHelp(p);
return true;
Expand All @@ -97,7 +99,6 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N

public static void sendHelp(CommandSender sender) {
ChatHelper.sendMessageBox(sender, "Generator Command", () -> {

sender.sendMessage("§eHouse Generator:§7 /gen house help");
sender.sendMessage("§eRoad Generator:§7 /gen road help");
sender.sendMessage("§eRail Generator:§7 /gen rail help");
Expand All @@ -107,7 +108,44 @@ public static void sendHelp(CommandSender sender) {
sender.sendMessage("§eGenerator History:§7 /gen history");
sender.sendMessage("§eUndo last command:§7 /gen undo");
sender.sendMessage("§eRedo last command:§7 /gen redo");

});
}

@Override
public List<String> onTabComplete(
@NotNull CommandSender sender,
@NotNull Command command,
@NotNull String label,
String @NotNull [] args
) {
if (!sender.hasPermission(Permissions.GENERATOR_USE))
return List.of();

if (args.length == 1)
return getMatchingCompletions(SUB_COMMANDS, args[0]);

if (args.length == 2 && isGeneratorSubCommand(args[0]))
return getMatchingCompletions(HELP_ARGUMENTS, args[1]);

return List.of();
}

private boolean isGeneratorSubCommand(String value) {
return value.equalsIgnoreCase("house")
|| value.equalsIgnoreCase("road")
|| value.equalsIgnoreCase("rail")
|| value.equalsIgnoreCase("tree")
|| value.equalsIgnoreCase("field");
}

private List<String> getMatchingCompletions(List<String> options, String input) {
String normalizedInput = input.toLowerCase();
List<String> completions = new ArrayList<>();

for (String option : options)
if (option.startsWith(normalizedInput))
completions.add(option);

return completions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public boolean checkForPlayer(Player p) {
if (GeneratorUtils.checkForNoWorldEditSelection(p))
return false;

if (getPlayerSettings().get(p.getUniqueId()).getBlocks() == null) // Needed because block checks are made afterwards
if (getPlayerSettings().get(p.getUniqueId()).getBlocks() == null)
getPlayerSettings().get(p.getUniqueId()).setBlocks(GeneratorUtils.analyzeRegion(p, p.getWorld()));

Block[][][] blocks = getPlayerSettings().get(p.getUniqueId()).getBlocks();
Expand All @@ -35,4 +35,4 @@ public void generate(Player p) {

new HouseScripts(p, this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.buildtheearth.buildteamtools.modules.generator.components.rail;

import org.bukkit.util.Vector;

record PositionKey(int x, int y, int z) {

static PositionKey from(Vector vector) {
return new PositionKey(
vector.getBlockX(),
vector.getBlockY(),
vector.getBlockZ()
);
}

static PositionKey of(int x, int y, int z) {
return new PositionKey(x, y, z);
}

Vector toVector() {
return new Vector(x, y, z);
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,76 @@
package net.buildtheearth.buildteamtools.modules.generator.components.rail;

import com.alpsbte.alpslib.utils.ChatHelper;
import com.alpsbte.alpslib.utils.GeneratorUtils;
import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region;
import net.buildtheearth.buildteamtools.modules.generator.GeneratorModule;
import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorComponent;
import net.buildtheearth.buildteamtools.modules.generator.model.GeneratorType;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;

import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public class Rail extends GeneratorComponent {

private final Set<UUID> preparingPlayers = ConcurrentHashMap.newKeySet();

public Rail() {
super(GeneratorType.RAILWAY);
super(GeneratorType.RAIL);
}

@Override
public boolean checkForPlayer(Player p) {
return !GeneratorUtils.checkForNoWorldEditSelection(p);
public boolean checkForPlayer(Player player) {
if (GeneratorUtils.checkForNoWorldEditSelection(player))
return false;

Region region = GeneratorUtils.getWorldEditSelection(player);

if (isSupportedRailSelection(region))
return true;

player.sendMessage(ChatHelper.PREFIX_COMPONENT.append(Component.text(
"Rail Generator supports cuboid, polygonal and convex WorldEdit selections.",
NamedTextColor.RED
)));
player.closeInventory();
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
return false;
}

private boolean isSupportedRailSelection(Region region) {
return region instanceof CuboidRegion
|| region instanceof Polygonal2DRegion
|| region instanceof ConvexPolyhedralRegion;
}

@Override
public void generate(Player p) {
if (!GeneratorModule.getInstance().getRail().checkForPlayer(p))
public void generate(Player player) {
if (GeneratorModule.getInstance().isGenerating(player) || !preparingPlayers.add(player.getUniqueId())) {
sendAlreadyGeneratingMessage(player);
return;
}

if (!GeneratorModule.getInstance().getRail().checkForPlayer(player)) {
preparingPlayers.remove(player.getUniqueId());
return;
}

new RailScripts(player, this, () -> preparingPlayers.remove(player.getUniqueId()));
}

new RailScripts(p, this);
private void sendAlreadyGeneratingMessage(Player player) {
player.sendMessage(ChatHelper.PREFIX_COMPONENT.append(Component.text(
"Rail Generator is already running. Please wait until the current generation is finished.",
NamedTextColor.RED
)));
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
package net.buildtheearth.buildteamtools.modules.generator.components.rail;

import lombok.Getter;
import net.buildtheearth.buildteamtools.modules.generator.model.Flag;
import net.buildtheearth.buildteamtools.modules.generator.model.FlagType;
import org.jspecify.annotations.Nullable;

public enum RailFlag implements Flag {
LANE_COUNT("c", FlagType.INTEGER);

RAIL_TYPE("t", FlagType.RAIL_TYPE);

@Getter
private final String flag;

@Getter
private final FlagType flagType;

RailFlag(String flag, FlagType flagType) {
this.flag = flag;
this.flagType = flagType;
}

@Override
public String getFlag() {
return flag;
}

@Override
public FlagType getFlagType() {
return flagType;
}

public static RailFlag byString(String flag) {
for (RailFlag railFlag : RailFlag.values())
public static @Nullable RailFlag byString(String flag) {
for (RailFlag railFlag : RailFlag.values()) {
if (railFlag.getFlag().equalsIgnoreCase(flag))
return railFlag;
}

return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package net.buildtheearth.buildteamtools.modules.generator.components.rail;

import net.buildtheearth.buildteamtools.BuildTeamTools;
import net.buildtheearth.buildteamtools.utils.io.ConfigPaths;
import net.buildtheearth.buildteamtools.utils.io.ConfigUtil;
import org.bukkit.configuration.file.FileConfiguration;

record RailLimits(
int maxControlPoints,
int maxPathPoints,
int maxBlockPlacements,
long maxPreparedRegionVolume,
int maxPreparedRegionAxisLength,
int blockPlacementBatchSize
) {

private static final int DEFAULT_MAX_CONTROL_POINTS = 500;
private static final int DEFAULT_MAX_PATH_POINTS = 12_000;
private static final int DEFAULT_MAX_BLOCK_PLACEMENTS = 75_000;
private static final long DEFAULT_MAX_PREPARED_REGION_VOLUME = 750_000L;
private static final int DEFAULT_MAX_PREPARED_REGION_AXIS_LENGTH = 768;
private static final int DEFAULT_BLOCK_PLACEMENT_BATCH_SIZE = 500;
private static final int MAX_CONTROL_POINTS = 500;
private static final int MAX_PATH_POINTS = 25_000;
private static final int MAX_BLOCK_PLACEMENTS = 100_000;
private static final long MAX_PREPARED_REGION_VOLUME = 2_000_000L;
private static final int MAX_PREPARED_REGION_AXIS_LENGTH = 1_024;
private static final int MAX_BLOCK_PLACEMENT_BATCH_SIZE = 1_000;

static RailLimits fromConfig() {
FileConfiguration config = BuildTeamTools.getInstance().getConfig(ConfigUtil.GENERATOR);

return new RailLimits(
getBoundedInt(config, ConfigPaths.Generator.Rail.MAX_CONTROL_POINTS, DEFAULT_MAX_CONTROL_POINTS, 2, MAX_CONTROL_POINTS),
getBoundedInt(config, ConfigPaths.Generator.Rail.MAX_PATH_POINTS, DEFAULT_MAX_PATH_POINTS, 2, MAX_PATH_POINTS),
getBoundedInt(config, ConfigPaths.Generator.Rail.MAX_BLOCK_PLACEMENTS, DEFAULT_MAX_BLOCK_PLACEMENTS, 1, MAX_BLOCK_PLACEMENTS),
getBoundedLong(config, ConfigPaths.Generator.Rail.MAX_PREPARED_REGION_VOLUME, DEFAULT_MAX_PREPARED_REGION_VOLUME, 1L, MAX_PREPARED_REGION_VOLUME),
getBoundedInt(config, ConfigPaths.Generator.Rail.MAX_PREPARED_REGION_AXIS_LENGTH, DEFAULT_MAX_PREPARED_REGION_AXIS_LENGTH, 1, MAX_PREPARED_REGION_AXIS_LENGTH),
getBoundedInt(config, ConfigPaths.Generator.Rail.BLOCK_PLACEMENT_BATCH_SIZE, DEFAULT_BLOCK_PLACEMENT_BATCH_SIZE, 1, MAX_BLOCK_PLACEMENT_BATCH_SIZE)
);
}

private static int getBoundedInt(FileConfiguration config, String path, int fallback, int minimum, int maximum) {
return Math.max(minimum, Math.min(maximum, config.getInt(path, fallback)));
}

private static long getBoundedLong(FileConfiguration config, String path, long fallback, long minimum, long maximum) {
return Math.max(minimum, Math.min(maximum, config.getLong(path, fallback)));
}
}
Loading
Loading