diff --git a/src/main/java/tech/showierdata/pickaxe/Backpack.java b/src/main/java/tech/showierdata/pickaxe/Backpack.java deleted file mode 100644 index 420f0c2..0000000 --- a/src/main/java/tech/showierdata/pickaxe/Backpack.java +++ /dev/null @@ -1,25 +0,0 @@ -package tech.showierdata.pickaxe; - -/*import net.minecraft.inventory.Inventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.SkullItem;*/ - -@SuppressWarnings("unused") -public class Backpack { - /*final int id; - final int i; - - final Inventory inventory; - final ItemStack head; - - public Backpack(int id, int i, Inventory inventory, ItemStack head) { - this.id = id; - this.i = i; - this.inventory = inventory; - this.head = head; - - assert head.getItem() instanceof SkullItem; - - - }*/ -} diff --git a/src/main/java/tech/showierdata/pickaxe/BackupHandler.java b/src/main/java/tech/showierdata/pickaxe/BackupHandler.java deleted file mode 100644 index 30d2d51..0000000 --- a/src/main/java/tech/showierdata/pickaxe/BackupHandler.java +++ /dev/null @@ -1,91 +0,0 @@ -package tech.showierdata.pickaxe; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.ScreenshotRecorder; -import net.minecraft.inventory.Inventory; - -import java.io.File; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Date; - -public class BackupHandler { - final MinecraftClient client; - final ArrayList stack = new ArrayList<>(); - - public BackupHandler(MinecraftClient client) { - this.client = client; - } - - - @SuppressWarnings({"ResultOfMethodCallIgnored", "ReassignedVariable"}) - public void handleInventory(Inventory inventory) { - stack.add(inventory); - if (stack.size() > 10) { - stack.remove(0); - } - - //take a screenshot of the inventory - - Date date = Date.from(Instant.now()); - File directory = new File("./pickaxe/backups/" + date.getTime() + "/"); - - if (!directory.exists()) { - - directory.mkdirs(); - } - - ScreenshotRecorder recorder = null; - - try { - - recorder = new ScreenshotRecorder(directory, client.getWindow().getWidth(), client.getWindow().getHeight(), client.getWindow().getWidth()); - - recorder.finish(); - } catch (Exception e) { - Pickaxe.LOGGER.error("Failed to create backup screenshot", e); - return; - } finally { - //remove the last one - if (!stack.isEmpty()) stack.remove(stack.size() - 1); - - if (recorder != null) { - try { - recorder.finish(); - } catch (Exception e) { - Pickaxe.LOGGER.error("Failed to save backup screenshot (again)", e); - } - } - } - - - //save screenshot to /pickaxe/backups/.png - //get current date and time - // - - - //make sure the directory exists - - /* - try { - if (!file.exists()) { - file.getParentFile().mkdirs(); - file.createNewFile(); - } - } catch (IOException e) { - Pickaxe.LOGGER.error("Failed to create backup screenshot", e); - return; - } - - - - try { - screenshot.writeTo(file); - } catch (IOException e) { - Pickaxe.LOGGER.error("Failed to save backup screenshot", e); - }*/ - - //remove the last one - if (!stack.isEmpty()) stack.remove(stack.size() - 1); - } -} diff --git a/src/main/java/tech/showierdata/pickaxe/Commands/DebugCommand.java b/src/main/java/tech/showierdata/pickaxe/Commands/DebugCommand.java deleted file mode 100644 index a6438a7..0000000 --- a/src/main/java/tech/showierdata/pickaxe/Commands/DebugCommand.java +++ /dev/null @@ -1,51 +0,0 @@ -package tech.showierdata.pickaxe.Commands; - -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.ingame.InventoryScreen; -import tech.showierdata.pickaxe.BackupHandler; - -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; - -public class DebugCommand implements PickaxeCommandManager.CommandBase { - - Boolean commandRunning = false; - - public DebugCommand() { - super(); - - ClientTickEvents.END_CLIENT_TICK.register(this::endTick); - } - - @Override - public LiteralArgumentBuilder commandResponse(LiteralArgumentBuilder builder) { - return builder.then(literal("debug").executes(context -> { - //open users inventory - MinecraftClient client = MinecraftClient.getInstance(); - assert client.player != null; - client.setScreen(new InventoryScreen(client.player)); - - - //wait for next frame - commandRunning = true; - - - return 1; - }).build()); - } - - private void endTick(MinecraftClient client) { - if (!commandRunning) return; - BackupHandler backupHandler = new BackupHandler(client); - - assert client.player != null; - backupHandler.handleInventory(client.player.getInventory()); - - //deregsiter - commandRunning = false; - - - } -} diff --git a/src/main/java/tech/showierdata/pickaxe/Commands/PickaxeCommandManager.java b/src/main/java/tech/showierdata/pickaxe/Commands/PickaxeCommandManager.java deleted file mode 100644 index 27f1d79..0000000 --- a/src/main/java/tech/showierdata/pickaxe/Commands/PickaxeCommandManager.java +++ /dev/null @@ -1,44 +0,0 @@ -package tech.showierdata.pickaxe.Commands; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; - -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; - -public class PickaxeCommandManager { - static PickaxeCommandManager INSTANCE = null; - - PickaxeCommandManager() { - INSTANCE = this; - } - - public static CommandBase[] getCommands() { - return new CommandBase[]{ - new SearchCommand(), - new DebugCommand() - }; - } - - public void register(CommandDispatcher dispatcher) { - LiteralArgumentBuilder literalText = literal("pickaxe"); - - for (CommandBase cmd : getCommands()) { - literalText = cmd.commandResponse(literalText); - } - - dispatcher.register(literalText); - - } - - public static PickaxeCommandManager getInstance() { - if (INSTANCE == null) { - INSTANCE = new PickaxeCommandManager(); - } - return INSTANCE; - } - - public interface CommandBase { - LiteralArgumentBuilder commandResponse(LiteralArgumentBuilder builder); - } -} diff --git a/src/main/java/tech/showierdata/pickaxe/Commands/SearchCommand.java b/src/main/java/tech/showierdata/pickaxe/Commands/SearchCommand.java deleted file mode 100644 index 6fcb821..0000000 --- a/src/main/java/tech/showierdata/pickaxe/Commands/SearchCommand.java +++ /dev/null @@ -1,120 +0,0 @@ -package tech.showierdata.pickaxe.Commands; - - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.mojang.brigadier.Command; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.HttpClientBuilder; -import tech.showierdata.pickaxe.Commands.PickaxeCommandManager.CommandBase; -import tech.showierdata.pickaxe.Pickaxe; - -import static com.mojang.brigadier.arguments.StringArgumentType.string; -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; -import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal; - -public class SearchCommand implements CommandBase { - - - private JsonArray fetchItems() { - //send an http request to the api - //https://pickaxe.monocromeninja.replit.co/json/items - HttpClient client = HttpClientBuilder.create().build(); - try { - String body = client.execute( - new HttpGet("http://pickaxe.monocromeninja.replit.co/json/items") - ).getEntity().toString(); - - Gson gson = new Gson(); - - return gson.fromJson(body, JsonArray.class); - - - - - } catch (Exception e) { - Pickaxe.LOGGER.error("",e); - } - - - return null; - } - - private com.google.gson.JsonObject fetchItem(String item) { - HttpClient client = HttpClientBuilder.create().build(); - try { - String body = client.execute( - new HttpGet("http://pickaxe.monochromeninja.repl.co/json/item/" + item) - ).getEntity().toString(); - - Gson gson = new Gson(); - - return gson.fromJson(body, JsonObject.class); - - - - - } catch (Exception e) { - Pickaxe.LOGGER.error("",e); - } - - - return null; - } - - public LiteralArgumentBuilder commandResponse(LiteralArgumentBuilder literalText) { - literalText.then( - literal("get") - .then(argument("item", string())) - .executes(new Command() { - @Override - public int run(CommandContext context) { - String item = context.getArgument("item", String.class); - JsonObject data = fetchItem(item); - - if (data == null) { - context.getSource().sendFeedback(Text.literal("Data is NULL (Most likely your system did not find the wiki)")); - return 1; - } - JsonArray loreArray = (JsonArray) data.get("lore"); - String[] lore = new String[loreArray.size()]; - - for (int i = 0; i < loreArray.size(); i++) { - lore[i] = loreArray.get(i).getAsString(); - } - - MutableText resp = Text.literal( - "=== " + item + " ===\n" + - String.join("\n", lore) + "\n" + - "Rarity: " + data.get("rarity").getAsString() - ); - - context.getSource().sendFeedback(resp); - - return 1; - } - }).build()); - /*.then(literal("refresh") - .executes(new Command() { - public int run(CommandContext context) throws CommandSyntaxException { - data = fetchItems(); - - if (data == null) { - context.getSource().sendFeedback(Text.literal("Data is NULL (Most likely your system did not find the wiki)")); - return 1; - } - return 1; - } - }).build() - );*/ - - return literalText; - } -} diff --git a/src/main/java/tech/showierdata/pickaxe/Constants.java b/src/main/java/tech/showierdata/pickaxe/Constants.java index face6c3..1caad42 100644 --- a/src/main/java/tech/showierdata/pickaxe/Constants.java +++ b/src/main/java/tech/showierdata/pickaxe/Constants.java @@ -7,32 +7,16 @@ public class Constants { public static final String PICKAXE_STRING = "Pickaxe Mod"; - @SuppressWarnings("unused") - public static final char DIAMOND_CHAR = '◆'; public static final Vec3d Spawn = new Vec3d(7085, 200, 4115); - public static final int PLOT_ID = 50644; - public static final String SERVER_IP = "mcdiamondfire.com"; - - - public static final int nodes = 7; - public static final String NODE_IP = getNode(PLOT_ID); - public static String getNode(int id) throws ArrayIndexOutOfBoundsException { - //get the first number of the id - int first = Integer.parseInt(Integer.toString(id).substring(0, 1)); - - if (first > nodes) { - throw new ArrayIndexOutOfBoundsException("Node " + first + " does not exist"); - } - - String node = "node" + first; - return node + "." + SERVER_IP; - } + public static final int PLOT_ID = 50644; + public static final String SERVER_IP = "mcdiamondfire.com"; + public static final String NODE_IP = "node5." + SERVER_IP; - public static final int NATRAL_OVERCLOCK_VALUE = 3; - public static final int MANUAL_OVERCLOCK_VALUE = 4; - public static final int NATRAL_SAGE_VALUE = 1; - public static final int MANUAL_SAGE_VALUE = 2; + public static final int NATURAL_OVERCLOCK_VALUE = 3; + public static final int MANUAL_OVERCLOCK_VALUE = 4; + public static final int NATURAL_SAGE_VALUE = 1; + public static final int MANUAL_SAGE_VALUE = 2; diff --git a/src/main/java/tech/showierdata/pickaxe/Pickaxe.java b/src/main/java/tech/showierdata/pickaxe/Pickaxe.java index c2a6cf9..f6cf6d8 100644 --- a/src/main/java/tech/showierdata/pickaxe/Pickaxe.java +++ b/src/main/java/tech/showierdata/pickaxe/Pickaxe.java @@ -1,7 +1,6 @@ package tech.showierdata.pickaxe; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; @@ -38,7 +37,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import tech.showierdata.pickaxe.Commands.PickaxeCommandManager; import tech.showierdata.pickaxe.config.TimerLocation; import tech.showierdata.pickaxe.config.MDTConfig; import tech.showierdata.pickaxe.config.Options; @@ -46,7 +44,7 @@ import tech.showierdata.pickaxe.server.Ad; import tech.showierdata.pickaxe.server.CommandHelper; import tech.showierdata.pickaxe.server.Plot; -import tech.showierdata.pickaxe.server.Regexs; +import tech.showierdata.pickaxe.server.Regexps; import java.awt.*; import java.util.ArrayList; @@ -59,9 +57,9 @@ public class Pickaxe implements ModInitializer { public static final char DIAMOND_CHAR = '◆'; public static final Logger LOGGER = LoggerFactory.getLogger(String.format("%s", Constants.PICKAXE_STRING)); - public static Pickaxe instence; + public static Pickaxe instance; - public boolean connectButtenPressed = false; + public boolean connectButtonPressed = false; public double chestTimer = 0; public static final CommandHelper commandHelper = CommandHelper.getInstance(); @@ -73,7 +71,7 @@ public class Pickaxe implements ModInitializer { public static final Identifier COLORS = new Identifier("pickaxe", "textures/gui/colors.png"); public static Pickaxe getInstance() { - return instence; + return instance; } public static PickaxeCommand[] getCommands() { @@ -85,7 +83,7 @@ public static PickaxeCommand[] getCommands() { new PickaxeCommand("itemlock", "Locks your held item", new String[] {}), new PickaxeCommand("pay", "Pay's the specified person the amount specified", new String[] { "[user]", - "[ammount]" + "[amount]" }), new PickaxeCommand("up", "Teleports you to the surface", new String[] {}), new PickaxeCommand("bpname", "Sets the name of the backpack\n (supports colors from /colors)", @@ -125,14 +123,24 @@ public boolean isInPickaxe() { return false; } + + MinecraftClient client = MinecraftClient.getInstance(); if (client.world == null) { return false; + + } if (client.isInSingleplayer()) { return false; } - if (!Objects.requireNonNull(client.getCurrentServerEntry()).address.endsWith(Constants.SERVER_IP)) { + + // replay mod fix + if (Objects.isNull(client.getCurrentServerEntry())) { + return false; + } + + if (!client.getCurrentServerEntry().address.endsWith(Constants.SERVER_IP)) { return false; } @@ -148,7 +156,7 @@ public boolean isInPickaxe() { return status; } - private void drawCoords(DrawContext context, TextRenderer renderer) { + private void drawCords(DrawContext context, TextRenderer renderer) { String[] lines = String.format("X: %d,\nY: %d,\nZ: %d", Math.round(rel_spawn.x), Math.round(rel_spawn.y), Math.round(rel_spawn.z)).split("\n"); @@ -179,12 +187,10 @@ public void onInitialize() { // This code runs as soon as Minecraft is in a mod-load-ready state. // However, some things (like resources) may still be uninitialized. // Proceed with mild caution. - Pickaxe.instence = this; + Pickaxe.instance = this; LOGGER.info(String.format("Starting %s....", Constants.PICKAXE_STRING)); - PickaxeCommandManager commandManager = PickaxeCommandManager.getInstance(); - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> commandManager.register(dispatcher)); register_callbacks(); // send a get request to https://api.modrinth.com/v2/project/{id|slug}/version @@ -224,20 +230,13 @@ private void drawCoinBar(DrawContext context, TextRenderer renderer, MinecraftCl } catch (Exception e) { //Pickaxe.LOGGER.error("Error while drawing custom hunger bar", e); - // Draw a empty hunger bar with 0 coins + // Draw an empty hunger bar with 0 coins // Calculate the hunger bar values int xhp = client.getWindow().getScaledWidth() / 2 - 91; int ybottom = client.getWindow().getScaledHeight() - 39; - - // Define the height of the hunger bar - - // Calculate the health and hunger bar widths int hpWidth = Math.round(20 / 2.0f * 18.0f); - - // Calculate the x-coordinate of the right edge of the health bar int xhpRight = xhp + hpWidth; - // Draw the custom hunger bar String coins = "⛃0 (Error)"; int coinsWidth = renderer.getWidth(coins); context.drawTextWithShadow(renderer, coins, xhpRight - coinsWidth, ybottom, 0xFFFF00); @@ -263,30 +262,15 @@ private void drawForge(DrawContext context, TextRenderer renderer, MinecraftClie // Define the height of the hunger bar - // Calculate the health and hunger bar widths int hpWidth = Math.round(20 / 2.0f * 18.0f); - - // Calculate the x-coordinate of the right edge of the health bar int xhpRight = xhp + hpWidth; - - // Draw the custom hunger bar - - // Draw the forge value int forgeWidth = renderer.getWidth(forge); - int forgeColor = 0x000000; - //noinspection EnhancedSwitchMigration - switch (forge) { - case "Ready": - forgeColor = 0x00FF00; - break; - case "FINISHED": - forgeColor = 0x11DD11; - break; - default: - forgeColor = 0xaaaaaa; - break; - } - context.drawTextWithShadow(renderer, forge, xhpRight - forgeWidth, ybottom - 11, forgeColor); + int forgeColor = switch (forge) { + case "Ready" -> 0x00FF00; + case "FINISHED" -> 0x11DD11; + default -> 0xaaaaaa; + }; + context.drawTextWithShadow(renderer, forge, xhpRight - forgeWidth, ybottom - 11, forgeColor); String tag = "Forge: "; int tagWidth = renderer.getWidth(tag); @@ -294,7 +278,7 @@ private void drawForge(DrawContext context, TextRenderer renderer, MinecraftClie } catch (Exception e) { //Pickaxe.LOGGER.error("Error while drawing custom hunger bar (Forge)", e); - // Draw a empty hunger bar with 0 coins + // Draw an empty hunger bar with 0 coins // Calculate the hunger bar values int xhp = client.getWindow().getScaledWidth() / 2 - 91; int ybottom = client.getWindow().getScaledHeight() - 39; @@ -314,40 +298,7 @@ private void drawForge(DrawContext context, TextRenderer renderer, MinecraftClie } } - private void drawCCT(DrawContext context, TextRenderer renderer) { - List texts = new ArrayList<>(); - texts.add(Text.literal("Pickaxe Chest:").setStyle(Style.EMPTY.withColor(0xD27D2D))); - StringBuilder sb = new StringBuilder(); - MinecraftClient client = MinecraftClient.getInstance(); - if ((int) chestTimer == 0) sb.append("READY"); - else { - if (chestTimer >= 60) { - sb.append((int) (chestTimer / 60)); - sb.append("m "); - } - sb.append((int) (chestTimer % 60)); - sb.append("s"); - } - texts.add(Text.literal(sb.toString()).setStyle(Style.EMPTY.withColor(((int) chestTimer == 0) ? Formatting.GREEN : Formatting.WHITE))); - - TimerLocation cctLoc = Options.getInstance().cctconfig.location; - TimerLocation mdtLoc = Options.getInstance().mdtConfig.location; - boolean rev = Options.getInstance().mdtConfig.reverseCCTOrder; - - int y = 5; - if (mdtLoc == TimerLocation.TOPRIGHT && rev) { - y += 5 + client.textRenderer.fontHeight; - } - - if (cctLoc == TimerLocation.BOTTEMRIGHT) { - y = client.getWindow().getScaledHeight() - client.textRenderer.fontHeight - 5; - if (mdtLoc == TimerLocation.BOTTEMRIGHT && rev) { - y -= 5 + client.textRenderer.fontHeight; - } - } - context.drawTextWithShadow(renderer, Texts.join(texts, Text.literal(" ")), 5, y, Colors.WHITE); - } public boolean readyPlayed = false; public boolean nowPlayed = false; @@ -394,20 +345,12 @@ private void drawMDT(DrawContext context, TextRenderer renderer) { } texts.add(Text.literal(sb.toString()).setStyle(color)); - TimerLocation cctLoc = Options.getInstance().cctconfig.location; TimerLocation mdtLoc = Options.getInstance().mdtConfig.location; - boolean norm = !Options.getInstance().mdtConfig.reverseCCTOrder; int y = 5; - if (cctLoc == TimerLocation.TOPRIGHT && norm) { - y += 5 + client.textRenderer.fontHeight; - } if (mdtLoc == TimerLocation.BOTTEMRIGHT) { y = client.getWindow().getScaledHeight() - client.textRenderer.fontHeight - 5; - if (cctLoc == TimerLocation.BOTTEMRIGHT && norm) { - y -= client.textRenderer.fontHeight + 5; - } } context.drawTextWithShadow(renderer, Texts.join(texts, Text.literal(" ")), 5, y, Colors.WHITE); @@ -460,18 +403,12 @@ private void register_callbacks() { boolean inPickaxe = isInPickaxe(); Options options = Options.getInstance(); - if (options.cctconfig.enabled && (inPickaxe || options.cctconfig.enabledOutsidePickaxe)) try { - drawCCT(context, renderer); - } catch (Exception e) { - Pickaxe.LOGGER.error("Error while drawing CCT", e); - } - if (!inPickaxe) return; try { - drawCoords(context, renderer); + drawCords(context, renderer); } catch (Exception e) { - Pickaxe.LOGGER.error("Error while drawing coords", e); + Pickaxe.LOGGER.error("Error while drawing cords", e); } try { @@ -486,7 +423,7 @@ private void register_callbacks() { Pickaxe.LOGGER.error("Error while drawing forge UI", e); } - if (options.mdtConfig.enabled && inPickaxe) try { + if (options.mdtConfig.enabled) try { drawMDT(context, renderer); } catch (Exception e) { Pickaxe.LOGGER.error("Error while drawing Mood Door UI", e); @@ -519,9 +456,9 @@ private void register_callbacks() { MinecraftClient mc = MinecraftClient.getInstance(); ServerAddress address = ServerAddress.parse(Constants.NODE_IP); - ServerInfo serverInfo = new ServerInfo("Diamondfire", Constants.SERVER_IP, ServerType.OTHER); + ServerInfo serverInfo = new ServerInfo("DiamondFire", Constants.SERVER_IP, ServerType.OTHER); - Pickaxe.getInstance().connectButtenPressed = true; // Just incase java is odd, and connectButtonPressed = true is odd + Pickaxe.getInstance().connectButtonPressed = true; // Just in case java is odd, and connectButtonPressed = true is odd ConnectScreen.connect(screen, mc, address, serverInfo, false); @@ -536,12 +473,12 @@ private void register_callbacks() { }); ClientReceiveMessageEvents.ALLOW_GAME.register((message, overlay) -> { - Plot plot = Regexs.getLocateDetails(message.getString()); + Plot plot = Regexps.getLocateDetails(message.getString()); if (plot != null) { - Pickaxe.LOGGER.info("Located plot: " + plot.name); + Pickaxe.LOGGER.info("Located plot: {}", plot.name); return true; } - Ad ad = Regexs.getAdDetails(message.getString()); + Ad ad = Regexps.getAdDetails(message.getString()); if (ad != null) { if (!Pickaxe.getInstance().isInPickaxe()) return true; Pickaxe.LOGGER.info(String.format("An ad was skipped!: %s by %s", ad.plot.name, ad.plot.owner)); @@ -581,11 +518,11 @@ public void renderHotbarIcons(DrawContext context, int x, int y, ItemStack stack } switch ((int) Objects.requireNonNull(stack.getSubNbt("PublicBukkitValues")).getDouble("hypercube:recomb")) { - case Constants.MANUAL_OVERCLOCK_VALUE, Constants.NATRAL_OVERCLOCK_VALUE -> { + case Constants.MANUAL_OVERCLOCK_VALUE, Constants.NATURAL_OVERCLOCK_VALUE -> { text = "⛨"; color = options.itemconfig.overclocker_color; } - case Constants.MANUAL_SAGE_VALUE, Constants.NATRAL_SAGE_VALUE -> { + case Constants.MANUAL_SAGE_VALUE, Constants.NATURAL_SAGE_VALUE -> { text = "⯫"; // Hermit star color = options.itemconfig.sage_color; } diff --git a/src/main/java/tech/showierdata/pickaxe/config/CCTConfig.java b/src/main/java/tech/showierdata/pickaxe/config/CCTConfig.java deleted file mode 100644 index e1e25d1..0000000 --- a/src/main/java/tech/showierdata/pickaxe/config/CCTConfig.java +++ /dev/null @@ -1,9 +0,0 @@ -package tech.showierdata.pickaxe.config; - -public class CCTConfig { - public boolean enabled = true; - public boolean soundEnabled = false; - public boolean enabledOutsidePickaxe = false; - - public TimerLocation location = TimerLocation.TOPRIGHT; -} \ No newline at end of file diff --git a/src/main/java/tech/showierdata/pickaxe/config/MDTConfig.java b/src/main/java/tech/showierdata/pickaxe/config/MDTConfig.java index 73c35c0..566cc06 100644 --- a/src/main/java/tech/showierdata/pickaxe/config/MDTConfig.java +++ b/src/main/java/tech/showierdata/pickaxe/config/MDTConfig.java @@ -7,7 +7,7 @@ public class MDTConfig { /** The Door opens at 1380 in the daylight cycle */ public static final long MOON_TIME = 13480L; - /** There is a 35 second window for getting to the door */ + /** There is a 35-second window for getting to the door */ public static final int MOON_WINDOW = 35; /** For some reason it ticks by 28 every second */ @@ -22,27 +22,18 @@ public class MDTConfig { * Setting for showierdata9978 *

Allows you to switch which timer is on top */ - public boolean reverseCCTOrder = false; public boolean enabled = true; - /** - * Gets the time of day (in seconds) of the Minecraft world. - * @return (int) Time of day of the Minecraft world - */ - public int getTimeOfDay() { - MinecraftClient client = MinecraftClient.getInstance(); - return (int)(client.world.getTimeOfDay() % 24000L); - } /** * Gets the time until the Mood Door in seconds. - * @return (int) Time (in seconds) until the Moon Door Opens - * @see getTimeOfDay - */ + * @return (int) Time (in seconds) until the Moon Door Open + */ public int getMoonDoorTime() { MinecraftClient client = MinecraftClient.getInstance(); - int ctime = (int)((MOON_TIME - client.world.getTimeOfDay()) % 24000L); + assert client.world != null; + int ctime = (int)((MOON_TIME - client.world.getTimeOfDay()) % 24000L); if (ctime < -MOON_TICK_SPEED) ctime += 24000; // You can get negative numbers, which is not useful >:( return Math.floorDiv(ctime, MOON_TICK_SPEED); } diff --git a/src/main/java/tech/showierdata/pickaxe/config/ModMenuIntergrationImpl.java b/src/main/java/tech/showierdata/pickaxe/config/ModMenuIntegrationImpl.java similarity index 79% rename from src/main/java/tech/showierdata/pickaxe/config/ModMenuIntergrationImpl.java rename to src/main/java/tech/showierdata/pickaxe/config/ModMenuIntegrationImpl.java index 624200d..f6574d7 100644 --- a/src/main/java/tech/showierdata/pickaxe/config/ModMenuIntergrationImpl.java +++ b/src/main/java/tech/showierdata/pickaxe/config/ModMenuIntegrationImpl.java @@ -24,14 +24,14 @@ import java.util.Objects; -public class ModMenuIntergrationImpl implements ModMenuApi { +public class ModMenuIntegrationImpl implements ModMenuApi { public static final String configPath = "config/pickaxe.properties.json"; final ObjectMapper mapper = new ObjectMapper(new GsonBuilder() .registerTypeAdapter(Color.class, new ColorTypeAdapter()) .create() ); - public ModMenuIntergrationImpl() { + public ModMenuIntegrationImpl() { } @SuppressWarnings("ResultOfMethodCallIgnored") @@ -87,7 +87,7 @@ public void createGeneralScreen(YetAnotherConfigLib.@NotNull Builder builder) { .build() ) .option(Option.createBuilder() - .name(Text.literal("Automaticly send /c l")) + .name(Text.literal("Automatically send /c l")) .binding(false, () -> Options.getInstance().AutoCL, e -> Options.getInstance().AutoCL = e) .controller(BooleanControllerBuilder::create) .build() @@ -157,39 +157,6 @@ public void createTimerConfig(YetAnotherConfigLib.@NotNull Builder builder) { builder.category(ConfigCategory.createBuilder() .name(Text.literal("Timers")) - - .group(OptionGroup.createBuilder() - .name(Text.literal("Chest Cooldown Timer")) - .option(Option.createBuilder() - .name(Text.literal("Enabled")) - .binding(true, () -> Options.getInstance().cctconfig.enabled, e -> Options.getInstance().cctconfig.enabled = e) - .controller(BooleanControllerBuilder::create) - .build() - ) - .option(Option.createBuilder() - .name(Text.literal("Play Sound When Chest Ready")) - .binding(false, () -> Options.getInstance().cctconfig.soundEnabled, e -> Options.getInstance().cctconfig.soundEnabled = e) - .controller(BooleanControllerBuilder::create) - .build() - ) - .option(Option.createBuilder() - .name(Text.literal("Function Outside Pickaxe")) - .binding(false, () -> Options.getInstance().cctconfig.enabledOutsidePickaxe, e -> Options.getInstance().cctconfig.enabledOutsidePickaxe = e) - .controller(BooleanControllerBuilder::create) - .build() - ) - .option(Option.createBuilder() - .name(Text.literal("CCT Location")) - .binding(TimerLocation.TOPRIGHT, () -> Options.getInstance().cctconfig.location, e -> Options.getInstance().cctconfig.location = e) - .controller((opt) -> EnumControllerBuilder.create(opt) - .enumClass(TimerLocation.class) - ) - - .build() - ) - .build() - ) - .group(OptionGroup.createBuilder() .name(Text.literal("Moon Door Timer")) .option(Option.createBuilder() @@ -215,20 +182,6 @@ public void createTimerConfig(YetAnotherConfigLib.@NotNull Builder builder) { ) .build() ) - - .option(Option.createBuilder() - .name(Text.literal("Order")) - .binding(false, () -> Options.getInstance().mdtConfig.reverseCCTOrder, e -> Options.getInstance().mdtConfig.reverseCCTOrder = e) - .controller((opt) -> BooleanControllerBuilder.create(opt) - .formatValue((state) -> - state - ? Text.literal("MDT on top") - : Text.literal("CCT on top") - ) - ) - .build() - ) - .build() ); } @@ -246,24 +199,21 @@ private void createPOIConfig(YetAnotherConfigLib.@NotNull Builder builder) { .name(Text.literal("POIS")) .description(OptionDescription.of(Text.literal("POI Config"))) .binding(List.of(POI.values()), () -> List.of(Options.getInstance().pois), e -> Options.getInstance().pois = e.toArray(new POI[0])) - .controller(opt -> { - return EnumControllerBuilder.create(opt) - .enumClass(POI.class); - - }) + .controller(opt -> EnumControllerBuilder.create(opt) + .enumClass(POI.class)) .initial(POI.SPAWN) .build() ) .build()); } - public void createMessageStackingConfig(YetAnotherConfigLib.@NotNull Builder builder, Screen screen) { + public void createMessageStackingConfig(YetAnotherConfigLib.@NotNull Builder builder, Screen ignoredScreen) { Option text = Option.createBuilder() .name(Text.literal("Custom String")) .binding("&8[&bx{num}&8]", () -> Options.getInstance().msgStackConfig.text, e -> Options.getInstance().msgStackConfig.text = e) - .controller(opt -> StringControllerBuilder.create(opt)) - .description(val -> OptionDescription.of(Text.literal("Preview: " + val.replaceAll("&([a-f,j-n,r,x,0-9])", "§$1").replaceAll("\\{num\\}", "2")))) + .controller(StringControllerBuilder::create) + .description(val -> OptionDescription.of(Text.literal("Preview: " + val.replaceAll("&([a-f,j-nrx0-9])", "§$1").replaceAll("\\{num}", "2")))) .build(); builder.category(ConfigCategory.createBuilder() @@ -272,9 +222,7 @@ public void createMessageStackingConfig(YetAnotherConfigLib.@NotNull Builder bui .name(Text.literal("Enable")) .binding(true, () -> Options.getInstance().msgStackConfig.enabled, e -> Options.getInstance().msgStackConfig.enabled = e) .controller(BooleanControllerBuilder::create) - .listener((Option self, Boolean enabled) -> { - text.setAvailable(enabled); - }) + .listener((Option self, Boolean enabled) -> text.setAvailable(enabled)) .build() ) .option(text) diff --git a/src/main/java/tech/showierdata/pickaxe/config/MsgStackConfig.java b/src/main/java/tech/showierdata/pickaxe/config/MsgStackConfig.java index 6458aca..9a0e53c 100644 --- a/src/main/java/tech/showierdata/pickaxe/config/MsgStackConfig.java +++ b/src/main/java/tech/showierdata/pickaxe/config/MsgStackConfig.java @@ -5,7 +5,7 @@ import net.minecraft.text.MutableText; import net.minecraft.text.Text; -import tech.showierdata.pickaxe.server.Regexs; +import tech.showierdata.pickaxe.server.Regexps; public class MsgStackConfig { public boolean enabled = true; @@ -13,21 +13,20 @@ public class MsgStackConfig { public String text = "&8[&bx{num}&8]"; - /** + /* * These cannot be static as settings can change - * Moved from Regexs + * Moved from Regexps */ /** * Returns the current tag for message stacking * @param inside The inner content - * @param regexSafe If you want it to be regex safe * @return The current Border String */ public String getBorderString(Object inside) { String res = this.text - .replaceAll("&([a-f,j-n,r,x,0-9])", "§$1") - .replaceAll("\\{num\\}", "%s"); + .replaceAll("&([a-f,j-nrx0-9])", "§$1") + .replaceAll("\\{num}", "%s"); return String.format(res, inside); } @@ -54,11 +53,11 @@ public boolean hasBeenStacked(String message) { /** * * @param modifiedText {@link Text} - * @return {@link Text} with all {@link MutableText#getSiblings()} matching {@link BracketEnum#hasBeenStacked()} removed + * @return {@link Text} with all {@link MutableText#getSiblings()} matching BracketEnum#hasBeenStacked() removed * @see #hasBeenStacked(String) */ public Text removeStackMods(Text modifiedText) { - MutableText res = Regexs.removeTimestamps(modifiedText).copy(); + MutableText res = Regexps.removeTimestamps(modifiedText).copy(); res.getSiblings().removeIf(text -> hasBeenStacked(text.getString())); return res; } diff --git a/src/main/java/tech/showierdata/pickaxe/config/Options.java b/src/main/java/tech/showierdata/pickaxe/config/Options.java index ac22488..f07e603 100644 --- a/src/main/java/tech/showierdata/pickaxe/config/Options.java +++ b/src/main/java/tech/showierdata/pickaxe/config/Options.java @@ -21,7 +21,6 @@ public class Options { .create() ); public final ItemConfig itemconfig; - public final CCTConfig cctconfig; public boolean hideNonPickaxePlayers = true; public POI[] pois = POI.values(); public boolean enable_poi = true; @@ -36,7 +35,6 @@ public class Options { public Options() { // all default vals this.itemconfig = new ItemConfig(); - this.cctconfig = new CCTConfig(); this.msgStackConfig = new MsgStackConfig(); this.mdtConfig = new MDTConfig(); INSTANCE = this; @@ -50,7 +48,7 @@ public static Options getInstance() { } public static void loadConfig() { - File file = new File(ModMenuIntergrationImpl.configPath); + File file = new File(ModMenuIntegrationImpl.configPath); if (file.exists()) { try { diff --git a/src/main/java/tech/showierdata/pickaxe/config/XPBarEnum.java b/src/main/java/tech/showierdata/pickaxe/config/XPBarEnum.java index 2dcbc23..dd7ed86 100644 --- a/src/main/java/tech/showierdata/pickaxe/config/XPBarEnum.java +++ b/src/main/java/tech/showierdata/pickaxe/config/XPBarEnum.java @@ -1,8 +1,6 @@ package tech.showierdata.pickaxe.config; import net.minecraft.entity.boss.BossBar; -import net.minecraft.network.packet.c2s.play.PickFromInventoryC2SPacket; -import tech.showierdata.pickaxe.Pickaxe; import net.minecraft.client.gui.hud.ClientBossBar; public enum XPBarEnum { @@ -23,9 +21,7 @@ public boolean detect(BossBar bar) { String[] split = bar.getName().getString().split(" "); // Breaks it - //noinspection EnhancedSwitchMigration - assert this != null; - switch (this) { + switch (this) { case Radiation: if (!(split.length > 1)) { break; @@ -67,13 +63,13 @@ public int getBarDetails(BossBar bar) { int index = splits.length - 1; if (this == O2) { index--; - if (splits[index] == "EMPTY") { + if (splits[index].equals("EMPTY")) { return 0; } } - while (last == "" && index >= 0) { + while (last.isEmpty() && index >= 0) { last = splits[index].replaceAll("[^0-9].*$", "") - .replaceAll("[A-Z,a-z,\\:,\\s]", ""); + .replaceAll("[A-Z,a-z:\\s]", ""); index--; } if (index < 0) return 0; diff --git a/src/main/java/tech/showierdata/pickaxe/mixin/BossBarHudMixin.java b/src/main/java/tech/showierdata/pickaxe/mixin/BossBarHudMixin.java index 621af1c..a9387a3 100644 --- a/src/main/java/tech/showierdata/pickaxe/mixin/BossBarHudMixin.java +++ b/src/main/java/tech/showierdata/pickaxe/mixin/BossBarHudMixin.java @@ -12,7 +12,6 @@ import tech.showierdata.pickaxe.IBossBarHudMixin; import tech.showierdata.pickaxe.Pickaxe; import tech.showierdata.pickaxe.config.Options; -import tech.showierdata.pickaxe.config.XPBarEnum; import java.util.Iterator; import java.util.Map; @@ -38,12 +37,14 @@ public Iterator bossBarFix(Iterator var4) { Iterator iter = Iterators.filter(var4, (clientBossBar) -> { boolean val = !(Options.getInstance().XPBarType.detect(clientBossBar)); - if (!val) { + if (!val) //noinspection RedundantSuppression + { MinecraftClient client = MinecraftClient.getInstance(); assert client.player != null; client.player.experienceProgress = clientBossBar.getPercent(); - switch (Options.getInstance().XPBarType) { + //noinspection SwitchStatementWithTooFewBranches (Looks better) + switch (Options.getInstance().XPBarType) { case Depth: int y = -1 * (int)Pickaxe.getInstance().rel_spawn.y; client.player.experienceLevel = Math.max(y, 0); @@ -56,9 +57,11 @@ public Iterator bossBarFix(Iterator var4) { return val; }); - if (!Pickaxe.getInstance().bossbarFound) { + //noinspection ConstantValue + if (!Pickaxe.getInstance().bossbarFound) { MinecraftClient client = MinecraftClient.getInstance(); - client.player.experienceLevel = 0; + assert client.player != null; + client.player.experienceLevel = 0; } return iter; diff --git a/src/main/java/tech/showierdata/pickaxe/mixin/ChatHudMixin.java b/src/main/java/tech/showierdata/pickaxe/mixin/ChatHudMixin.java index a62e651..50e2661 100644 --- a/src/main/java/tech/showierdata/pickaxe/mixin/ChatHudMixin.java +++ b/src/main/java/tech/showierdata/pickaxe/mixin/ChatHudMixin.java @@ -14,10 +14,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import net.minecraft.text.Text; -import tech.showierdata.pickaxe.Pickaxe; import tech.showierdata.pickaxe.config.MsgStackConfig; import tech.showierdata.pickaxe.config.Options; -import tech.showierdata.pickaxe.server.Regexs; +import tech.showierdata.pickaxe.server.Regexps; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.hud.ChatHud; import net.minecraft.client.gui.hud.ChatHudLine; @@ -68,7 +67,7 @@ private Text stackMessages(Text message, Text parameterMessage, MessageSignature if (refreshing) return message; // Timestamps are removed to compare texts (otherwise none would match) - Text withoutTimestamps = Regexs.removeTimestamps(message); + Text withoutTimestamps = Regexps.removeTimestamps(message); Text prevMessage = prevText; prevText = withoutTimestamps; diff --git a/src/main/java/tech/showierdata/pickaxe/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/tech/showierdata/pickaxe/mixin/ClientPlayNetworkHandlerMixin.java index e133152..b46c3e6 100644 --- a/src/main/java/tech/showierdata/pickaxe/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/tech/showierdata/pickaxe/mixin/ClientPlayNetworkHandlerMixin.java @@ -2,13 +2,8 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.sound.PositionedSoundInstance; -import net.minecraft.item.ItemStack; import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; -import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket; -import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; -import net.minecraft.util.collection.DefaultedList; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -18,7 +13,6 @@ import tech.showierdata.pickaxe.Constants; import tech.showierdata.pickaxe.Pickaxe; import tech.showierdata.pickaxe.PickaxeCommand; -import tech.showierdata.pickaxe.config.Options; import java.util.*; @@ -44,9 +38,9 @@ public void onGameJoin(GameJoinS2CPacket packet, CallbackInfo info) { //sleep for 5 seconds - if (pickaxe.connectButtenPressed) { + if (pickaxe.connectButtonPressed) { joinedGame = true; - pickaxe.connectButtenPressed = false; + pickaxe.connectButtonPressed = false; } } @@ -96,39 +90,6 @@ private void sendMessage(String chatText, CallbackInfo info) { - } - } - - @Inject(method = "onGameMessage", at = @At("HEAD")) - private void onGameMessage(GameMessageS2CPacket packet, CallbackInfo ci) { - Pickaxe pickaxe = Pickaxe.getInstance(); - if (pickaxe.chestTimer < 10 && packet.content().getString().matches("^\\[.] You found a chest!") && pickaxe.isInPickaxe()) { - double chestTimer = 1000; - MinecraftClient mc = MinecraftClient.getInstance(); - assert mc.player != null; - DefaultedList armor = mc.player.getInventory().armor; - for (int i = 0; i < 4; i++) { - try { - String id = Objects.requireNonNull(Objects.requireNonNull(armor.get(i).getNbt())).getCompound("PublicBukkitValues").getString("hypercube:id"); - if (id.startsWith("treasure")) { - if (id.contains("_seeker")) chestTimer *= 0.9; - else chestTimer *= 0.8; - } - } catch (NullPointerException ignored) {} - } - pickaxe.chestTimer = chestTimer; - Timer timer = new Timer(); - timer.scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { - if ((int) (--pickaxe.chestTimer) <= 0) { - pickaxe.chestTimer = 0; - if (Options.getInstance().cctconfig.soundEnabled) mc.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.BLOCK_CHEST_LOCKED, 1, 1)); - timer.cancel(); - timer.purge(); - } - } - }, 1000, 1000); } } } diff --git a/src/main/java/tech/showierdata/pickaxe/mixin/InGameHudMixin.java b/src/main/java/tech/showierdata/pickaxe/mixin/InGameHudMixin.java index 4c2e753..2d40e20 100644 --- a/src/main/java/tech/showierdata/pickaxe/mixin/InGameHudMixin.java +++ b/src/main/java/tech/showierdata/pickaxe/mixin/InGameHudMixin.java @@ -25,11 +25,6 @@ @Mixin(InGameHud.class) public abstract class InGameHudMixin { - /*@ModifyVariable(method = "renderStatusBars", at = @At(value = "STORE", ordinal = 0)) - PlayerEntity modifPlayerEntity(PlayerEntity playerEntity) { - if (Pickaxe.getInstance().isInPickaxe()) return null; - return playerEntity; - }*/ @ModifyConstant(method = "renderStatusBars", constant = @Constant(intValue = 0, ordinal = 2)) private int modifyHungerLoop(int zero) { @@ -37,7 +32,6 @@ private int modifyHungerLoop(int zero) { return zero; } - @SuppressWarnings("InvalidInjectorMethodSignature") @ModifyVariable(method = "renderStatusBars", slice = @Slice(from = @At(value = "INVOKE", target = "net/minecraft/entity/player/PlayerEntity.getMaxAir ()I")), at = @At(value = "STORE", ordinal = 0), ordinal = 14) private int modifyAirBar(int y) { if (Pickaxe.getInstance().isInPickaxe()) return 0; @@ -92,6 +86,7 @@ void swapIcons(DrawContext context, Identifier ICONS, int x, int y, int width, i renderNewExperienceBar(context, x, y, width, true); } + @Unique void renderNewExperienceBar(DrawContext context, int x, int y, int width, boolean isBG) { int v = (isBG)? 0 : 5; switch (Options.getInstance().XPBarType) { @@ -112,19 +107,18 @@ void renderNewExperienceBar(DrawContext context, int x, int y, int width, boolea @ModifyConstant(method = "renderExperienceBar", constant = @Constant(intValue = 8453920)) int changeLevelColor(int prev) { if (!Pickaxe.getInstance().isInPickaxe()) return prev; - switch (Options.getInstance().XPBarType) { - case O2: - return 0x33CCFF; - case Depth: - if (Pickaxe.getInstance().rel_spawn.y < -30) return 0xCC33FF; - return 0xFF0000; - case Suit_Charge: - return 0xFFCC00; - default: - return prev; - } + return switch (Options.getInstance().XPBarType) { + case O2 -> 0x33CCFF; + case Depth -> { + if (Pickaxe.getInstance().rel_spawn.y < -30) yield 0xCC33FF; + yield 0xFF0000; + } + case Suit_Charge -> 0xFFCC00; + default -> prev; + }; } + @SuppressWarnings("InvalidInjectorMethodSignature") @ModifyVariable(method = "renderExperienceBar", slice = @Slice( from = @At( @@ -136,16 +130,12 @@ int changeLevelColor(int prev) { String changeLevelString(String prev) { if (!Pickaxe.getInstance().isInPickaxe()) return prev; if (prev.equals("0")) prev = ""; - switch(Options.getInstance().XPBarType) { - case Suit_Charge: - return "⚡" + prev; - case Radiation: - return "☢" + prev; - case O2: - //return "◌" + prev; // I dunno if I want it - default: - return prev; - } + return switch (Options.getInstance().XPBarType) { + case Suit_Charge -> "⚡" + prev; + case Radiation -> "☢" + prev; + //return "◌" + prev; // I dunno if I want it + default -> prev; + }; } @Redirect( diff --git a/src/main/java/tech/showierdata/pickaxe/mixin/MessageHandlerMixin.java b/src/main/java/tech/showierdata/pickaxe/mixin/MessageHandlerMixin.java index 684bf94..864e827 100644 --- a/src/main/java/tech/showierdata/pickaxe/mixin/MessageHandlerMixin.java +++ b/src/main/java/tech/showierdata/pickaxe/mixin/MessageHandlerMixin.java @@ -1,10 +1,8 @@ package tech.showierdata.pickaxe.mixin; -import java.util.List; import com.mojang.authlib.GameProfile; -import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.message.MessageHandler; import net.minecraft.network.message.MessageType; import net.minecraft.network.message.SignedMessage; @@ -15,24 +13,24 @@ import tech.showierdata.pickaxe.Pickaxe; import tech.showierdata.pickaxe.config.Options; import tech.showierdata.pickaxe.server.Plot; -import tech.showierdata.pickaxe.server.Regexs; +import tech.showierdata.pickaxe.server.Regexps; @SuppressWarnings("UnusedMixin") @Mixin(MessageHandler.class) public class MessageHandlerMixin { @Inject(at = @At("HEAD"), method = "onChatMessage", cancellable = true) private void onGameMessage(SignedMessage message, GameProfile sender, MessageType.Parameters params, CallbackInfo info) { - if (Regexs.isLocateCommand(message.getContent().getString())) { + if (Regexps.isLocateCommand(message.getContent().getString())) { //if (Pickaxe.commandHelper.getLastSentCommand().equals("locate")) { Pickaxe.commandHelper.clearLastSentCommand(); - Plot plot = Regexs.getLocateDetails(message.getContent().getString()); + Plot plot = Regexps.getLocateDetails(message.getContent().getString()); //pickaxe.currentPlot = plot; assert plot != null; - Pickaxe.LOGGER.info("Located plot: " + plot.name); + Pickaxe.LOGGER.info("Located plot: {}", plot.name); info.cancel(); // stop the message from being shown to the player. //} } - if (Regexs.isPlotAd(message.getContent().getString())) { + if (Regexps.isPlotAd(message.getContent().getString())) { if (!Options.getInstance().hide_plot_ads) return; if (!Pickaxe.getInstance().isInPickaxe()) return; diff --git a/src/main/java/tech/showierdata/pickaxe/mixin/SoundMixin.java b/src/main/java/tech/showierdata/pickaxe/mixin/SoundMixin.java index 37bddbd..6707ee2 100644 --- a/src/main/java/tech/showierdata/pickaxe/mixin/SoundMixin.java +++ b/src/main/java/tech/showierdata/pickaxe/mixin/SoundMixin.java @@ -8,7 +8,6 @@ import net.minecraft.client.sound.Sound; import net.minecraft.util.math.floatprovider.FloatSupplier; -import net.minecraft.util.math.random.Random; import tech.showierdata.pickaxe.Pickaxe; @Mixin(Sound.class) @@ -16,15 +15,12 @@ public class SoundMixin { @Shadow private @Final FloatSupplier volume; + @SuppressWarnings("MixinAnnotationTarget") @Redirect(method = "getVolume", at = @At("FIELD")) public FloatSupplier muteAds(Sound sound) { if (Pickaxe.getInstance().adFound) { Pickaxe.getInstance().adFound = false; - return new FloatSupplier() { - public float get(Random arg1) { - return 0; - } - }; + return arg1 -> 0; } return volume; } diff --git a/src/main/java/tech/showierdata/pickaxe/server/CommandHelper.java b/src/main/java/tech/showierdata/pickaxe/server/CommandHelper.java index cfed606..97d5266 100644 --- a/src/main/java/tech/showierdata/pickaxe/server/CommandHelper.java +++ b/src/main/java/tech/showierdata/pickaxe/server/CommandHelper.java @@ -1,9 +1,5 @@ package tech.showierdata.pickaxe.server; -import net.minecraft.client.MinecraftClient; - -import java.util.Objects; - public class CommandHelper { String lastSentCommand = ""; private static CommandHelper instance; @@ -11,35 +7,6 @@ public class CommandHelper { private CommandHelper() { //call sendLocate() every 5 seconds - /* - new Thread(() -> { - while (true) { - try { - - Thread.sleep(5000); - if (p[0] == null) { - p[0] = Pickaxe.getInstance(); - } - if (!p[0].enabled) { - continue; - } - if (mc.world == null) { - continue; - } - if (mc.isInSingleplayer()) { - continue; - } - if (!mc.getCurrentServerEntry().address.endsWith("mcdiamondfire.com")) { - continue; - } - - - sendLocate(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }).start();*/ } public static CommandHelper getInstance() { @@ -49,24 +16,10 @@ public static CommandHelper getInstance() { return instance; } - public String getLastSentCommand() { - return lastSentCommand; - } public void clearLastSentCommand() { lastSentCommand = ""; } - public void sendLocate() { - lastSentCommand = "locate"; - - // create a message callback - // this will be called when the server sends a message - - // to the client - - Objects.requireNonNull(MinecraftClient.getInstance().player).networkHandler.sendChatCommand("locate"); - - } } diff --git a/src/main/java/tech/showierdata/pickaxe/server/Plot.java b/src/main/java/tech/showierdata/pickaxe/server/Plot.java index 7808100..d30644a 100644 --- a/src/main/java/tech/showierdata/pickaxe/server/Plot.java +++ b/src/main/java/tech/showierdata/pickaxe/server/Plot.java @@ -1,5 +1,6 @@ package tech.showierdata.pickaxe.server; +@SuppressWarnings("ClassCanBeRecord") public class Plot { public final String server; public final String owner; diff --git a/src/main/java/tech/showierdata/pickaxe/server/Regexs.java b/src/main/java/tech/showierdata/pickaxe/server/Regexps.java similarity index 82% rename from src/main/java/tech/showierdata/pickaxe/server/Regexs.java rename to src/main/java/tech/showierdata/pickaxe/server/Regexps.java index 654e724..de3d867 100644 --- a/src/main/java/tech/showierdata/pickaxe/server/Regexs.java +++ b/src/main/java/tech/showierdata/pickaxe/server/Regexps.java @@ -3,28 +3,20 @@ import net.minecraft.text.MutableText; import net.minecraft.text.Text; -import tech.showierdata.pickaxe.Pickaxe; -import tech.showierdata.pickaxe.config.Options; -import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; -public class Regexs { +public class Regexps { public static Pattern getPlotOwnerPattern() { - /*String donorRanksRegex = String.join("|", Arrays.stream(DonorRank.values()) - .map(DonorRank::toString) - .toArray(String[]::new)); - - return Pattern.compile(String.format("Owner: (?:\\[%s\\])(\\w+)", donorRanksRegex));*/ - return Pattern.compile("Owner: (?:\\[.*\\])?(\\w+)"); + return Pattern.compile("Owner: (?:\\[.*])?(\\w+)"); } public static Pattern getPlotNamePattern() { //return Pattern.compile("You are currently (?:playing on|at): \\n\\n. (.*) (\\[(\\d+)\\])"); - return Pattern.compile(". (.*) (\\[(\\d+)\\])"); + return Pattern.compile(". (.*) (\\[(\\d+)])"); } public static Pattern getServerPattern() { @@ -32,7 +24,7 @@ public static Pattern getServerPattern() { } public static Pattern getPlotAdPattern() { - return Pattern.compile(".*\\n\\s*(.*) by ([\\w\\d]*)"); + return Pattern.compile(".*\\n\\s*(.*) by (\\w*)"); } public static final Pattern PlotOwnerPattern = getPlotOwnerPattern(); @@ -56,7 +48,7 @@ public static boolean isPlotAd(String message) { public static Ad getAdDetails(String message) { /* - * Returns a the plot in the ad. + * Returns the plot in the ad. * server and id are null. */ Matcher plotAdMatcher = PlotAdPattern.matcher(message); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7d391a9..afe97bf 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,8 +19,8 @@ "main": [ "tech.showierdata.pickaxe.Pickaxe" ], - "modmenu": [ - "tech.showierdata.pickaxe.config.ModMenuIntergrationImpl" + "modmenu": [ + "tech.showierdata.pickaxe.config.ModMenuIntegrationImpl" ] },