diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java index 492ec3e4..1bb9970c 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Bot.java @@ -64,7 +64,6 @@ public class Bot { public TrustedPlugin trusted; public BruhifyPlugin bruhify; public CloopPlugin cloop; - public MazePlugin maze; public ExploitsPlugin exploits; public FilterPlugin filter; public CommandSuggestionPlugin commandSuggestion; @@ -110,7 +109,6 @@ public class Bot { this.trusted = new TrustedPlugin(this); this.bruhify = new BruhifyPlugin(this); this.cloop = new CloopPlugin(this); - this.maze = new MazePlugin(this); this.exploits = new ExploitsPlugin(this); this.filter = new FilterPlugin(this); this.commandSuggestion = new CommandSuggestionPlugin(this); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GenerateMazeCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GenerateMazeCommand.java deleted file mode 100644 index 5a01a971..00000000 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/GenerateMazeCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package land.chipmunk.chayapak.chomens_bot.commands; - -import land.chipmunk.chayapak.chomens_bot.Bot; -import land.chipmunk.chayapak.chomens_bot.command.Command; -import land.chipmunk.chayapak.chomens_bot.command.CommandContext; -import land.chipmunk.chayapak.chomens_bot.command.TrustLevel; -import land.chipmunk.chayapak.chomens_bot.util.MazeGenerator; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.NamedTextColor; - -public class GenerateMazeCommand extends Command { - public GenerateMazeCommand () { - super( - "generatemaze", - "Generates a maze", - new String[] { " " }, - new String[] { "genmaze", "mazegen" }, - TrustLevel.PUBLIC - ); - } - - @Override - public Component execute(CommandContext context, String[] args, String[] fullArgs) { - final Bot bot = context.bot; - - try { - final int x = Integer.parseInt(args[0]); - final int y = Integer.parseInt(args[1]); - final int z = Integer.parseInt(args[2]); - - final int width = Integer.parseInt(args[3]); - final int height = Integer.parseInt(args[4]); - - if (width > 100 || height > 100) return Component.text("Size is too big").color(NamedTextColor.RED); - - final MazeGenerator generator = new MazeGenerator(width, height); - - generator.generateMaze(); - - bot.maze.generate(generator, x, y, z); - } catch (NumberFormatException e) { - return Component.text("Invalid position/size").color(NamedTextColor.RED); - } - - return null; - } -} diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java index 901e53e4..35414d4e 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CommandHandlerPlugin.java @@ -51,7 +51,6 @@ public class CommandHandlerPlugin { registerCommand(new EndCommand()); registerCommand(new CloopCommand()); registerCommand(new WeatherCommand()); - registerCommand(new GenerateMazeCommand()); registerCommand(new TranslateCommand()); registerCommand(new KickCommand()); registerCommand(new ClearChatQueueCommand()); diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MazePlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MazePlugin.java deleted file mode 100644 index 57b8cacf..00000000 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MazePlugin.java +++ /dev/null @@ -1,175 +0,0 @@ -package land.chipmunk.chayapak.chomens_bot.plugins; - -import land.chipmunk.chayapak.chomens_bot.Bot; -import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; -import land.chipmunk.chayapak.chomens_bot.util.MazeGenerator; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.event.ClickEvent; -import net.kyori.adventure.text.format.NamedTextColor; - -public class MazePlugin { - private final Bot bot; - - public MazePlugin (Bot bot) { - this.bot = bot; - } - - // also totally didn't ask chatgpt for this too (but modified a bit) - public void generate (MazeGenerator generator, int startX, int startY, int startZ) { - bot.chat.tellraw( - Component.translatable( - "Generating maze at %s %s %s...", - Component.text(startX).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), - Component.text(startY).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)), - Component.text(startZ).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)) - ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) - ); - - final int[][] maze = generator.maze; - - int x = startX; - int z = startZ; - - // Find the starting and ending positions of the maze - int startRow = 0; - int startCol = 0; - int endRow = maze.length - 1; - int endCol = maze[0].length - 1; - while (maze[startRow][startCol] != 0) { - startCol++; - if (startCol == maze[0].length) { - startCol = 0; - startRow++; - } - } - while (maze[endRow][endCol] != 0) { - endCol--; - if (endCol < 0) { - endCol = maze[0].length - 1; - endRow--; - } - } - - final String command = "minecraft:fill %s %s %s %s %s %s %s"; - - // fill the floor - bot.core.run( - String.format( - command, - x, - startY - 1, - z, - x + generator.width, - startY - 1, - z + generator.height, - "minecraft:stone_bricks replace minecraft:air" - ) - ); - - // actually build the maze - for (int row = 0; row < generator.height; row++) { - for (int col = 0; col < generator.width; col++) { - if (maze[row][col] == 1) { - // makes the wall - bot.core.run( - String.format( - command, - x, - startY, - z, - x, - startY + 3, - z, - "minecraft:stone" - ) - ); - } else if ((row == startRow && col == startCol)) { - // Set a marker block for the start position - bot.core.run( - String.format( - command, - x, - startY - 1, - z, - x, - startY - 1, - z, - "minecraft:glowstone" - ) - ); - } else if ((row == endRow && col == endCol)) { - // Set a marker block for the end position - bot.core.run( - String.format( - command, - x, - startY - 1, - z, - x, - startY - 1, - z, - "minecraft:lime_concrete" - ) - ); - } - - // Increment the x-coordinate - x++; - - // If we've reached the end of the x-axis, reset x and increment z - if (x == startX + maze[0].length) { - x = startX; - z++; - } - } - } - - // lazy fix for the sus border issue - bot.core.run( - String.format( - command, - x + generator.width, - startY, - z, - x + generator.width, - startY + 3, - z + generator.height, - "minecraft:stone" - ) - ); - - bot.core.run( - String.format( - command, - x, - startY, - z + generator.height, - x + generator.width, - startY + 3, - z + generator.height, - "minecraft:stone" - ) - ); - - bot.chat.tellraw( - Component.empty() - .append(Component.text("Done generating maze. ")) - .append( - Component - .text("Click here to teleport") - .color(NamedTextColor.GREEN) - .clickEvent( - ClickEvent.runCommand( - String.format( - "/tp %s %s %s", - startX, - startY + 4, - startZ - ) - ) - ) - ) - .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)) - ); - } -} diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/MazeGenerator.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/MazeGenerator.java deleted file mode 100644 index 99c1bcc9..00000000 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/MazeGenerator.java +++ /dev/null @@ -1,76 +0,0 @@ -package land.chipmunk.chayapak.chomens_bot.util; - -import java.util.*; - -// totally didn't ask chatgpt for this lmao -public class MazeGenerator { - public final int width; - public final int height; - public final int[][] maze; - private final Random rand; - - public MazeGenerator(int width, int height) { - this.width = width; - this.height = height; - this.maze = new int[height][width]; - this.rand = new Random(); - } - - public void generateMaze() { - // Set all cells to walls - for (int row = 0; row < height; row++) { - Arrays.fill(maze[row], 1); - } - - // Create a starting point - int startX = rand.nextInt(width); - int startY = rand.nextInt(height); - maze[startY][startX] = 0; - - // Recursive backtracking algorithm - backtrack(startX, startY); - } - - private void backtrack(int x, int y) { - // Get a list of neighboring cells - List neighbors = getNeighbors(x, y); - - // Shuffle the list of neighbors - Collections.shuffle(neighbors, rand); - - for (int[] neighbor : neighbors) { - int nx = neighbor[0]; - int ny = neighbor[1]; - - // Check if the neighboring cell is a wall - if (maze[ny][nx] == 1) { - // Remove the wall between the current cell and the neighboring cell - maze[(y + ny) / 2][(x + nx) / 2] = 0; - maze[ny][nx] = 0; - - // Recursively backtrack from the neighboring cell - backtrack(nx, ny); - } - } - } - - private List getNeighbors(int x, int y) { - List neighbors = new ArrayList<>(); - - if (x > 1) { - neighbors.add(new int[]{x - 2, y}); - } - if (y > 1) { - neighbors.add(new int[]{x, y - 2}); - } - if (x < width - 2) { - neighbors.add(new int[]{x + 2, y}); - } - if (y < height - 2) { - neighbors.add(new int[]{x, y + 2}); - } - - return neighbors; - } -} -