Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ com-googlecode-json-simple = "1.1.1" # https://mvnrepository.com/artifact/com.go
com-palantir-git-version = "4.+" # https://github.com/palantir/gradle-git-version/releases
com-gradleup-shadow = "9.+" # https://github.com/GradleUp/shadow/releases
alpslib-io = "1.2.+" # https://mvn.alps-bte.com/service/rest/repository/browse/alps-bte/com/alpsbte/alpslib/alpslib-io/
alpslib-utils = "1.4.+" # https://mvn.alps-bte.com/service/rest/repository/browse/alps-bte/com/alpsbte/alpslib/alpslib-utils/
alpslib-utils = "1.4.6" # https://mvn.alps-bte.com/service/rest/repository/browse/alps-bte/com/alpsbte/alpslib/alpslib-utils/
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change

fawe-bom = "1.56" # Ref: https://github.com/IntellectualSites/bom
bstats = "3.+" # https://central.sonatype.com/artifact/org.bstats/bstats-bukkit
bluemap-api = "2.+" # Ref: https://github.com/BlueMap-Minecraft/BlueMapAPI
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
//mavenLocal() // NEVER use in Production/Commits!
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't commit that

mavenLocal()
maven {
url = uri("https://repo.papermc.io/repository/maven-public/")
}
Expand Down Expand Up @@ -60,4 +60,4 @@ dependencyResolutionManagement {

maven("https://repo.bluecolored.de/releases")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void registerCommands() {
@Override
public void registerListeners() {
super.registerListeners(
new GeneratorListener()
new GeneratorListener()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
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;
Expand All @@ -16,62 +14,51 @@

public class GeneratorCommand implements CommandExecutor {


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;
}

if(!p.hasPermission(Permissions.GENERATOR_USE)) {
if (!p.hasPermission(Permissions.GENERATOR_USE)) {
p.sendMessage(ChatHelper.getErrorString("You don't have permission to use this command!"));
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 @@ -85,6 +72,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 @@ -93,7 +81,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 @@ -103,7 +90,6 @@ 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");

});
}
}
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
@@ -1,27 +1,51 @@
package net.buildtheearth.buildteamtools.modules.generator.components.rail;

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;

public class Rail extends GeneratorComponent {

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(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().getRail().checkForPlayer(player))
return;

new RailScripts(p, this);
new RailScripts(player, this);
}
}
}
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){
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())
if(railFlag.getFlag().equalsIgnoreCase(flag))
public static @Nullable RailFlag byString(String flag) {
for (RailFlag railFlag : RailFlag.values()) {
if (railFlag.getFlag().equalsIgnoreCase(flag))
return railFlag;
}

return null;
}
Expand Down
Loading
Loading