diff options
author | nea <nea@nea.moe> | 2023-02-01 08:08:20 +0100 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-02-01 08:08:20 +0100 |
commit | 4dd2232839a3f68833e5c7b36c7bd9b07fca1867 (patch) | |
tree | 90d79d6a514c2047026c782c896b394ac9e18452 | |
parent | 8fcdec089563455ae5080d17c66223082124b594 (diff) | |
download | NotEnoughUpdates-4dd2232839a3f68833e5c7b36c7bd9b07fca1867.tar.gz NotEnoughUpdates-4dd2232839a3f68833e5c7b36c7bd9b07fca1867.tar.bz2 NotEnoughUpdates-4dd2232839a3f68833e5c7b36c7bd9b07fca1867.zip |
wikp
19 files changed, 630 insertions, 732 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index a4643eb5..935a4638 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -52,6 +52,7 @@ import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.recipes.RecipeGenerator; import io.github.moulberry.notenoughupdates.util.Utils; +import io.github.moulberry.notenoughupdates.util.brigadier.BrigadierRoot; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; @@ -281,6 +282,7 @@ public class NotEnoughUpdates { manager.registerReloadListener(new CustomBlockSounds.ReloaderListener()); } + BrigadierRoot.INSTANCE.updateHooks(); this.commands = new Commands(); BackgroundBlur.registerListener(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java index 91365cd1..4bf3380c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java @@ -20,13 +20,12 @@ package io.github.moulberry.notenoughupdates.commands; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.dev.DevTestCommand; import io.github.moulberry.notenoughupdates.commands.dev.DiagCommand; import io.github.moulberry.notenoughupdates.commands.dev.DungeonWinTestCommand; import io.github.moulberry.notenoughupdates.commands.dev.EnableStorageCommand; import io.github.moulberry.notenoughupdates.commands.dev.NullzeeSphereCommand; import io.github.moulberry.notenoughupdates.commands.dev.PackDevCommand; -import io.github.moulberry.notenoughupdates.commands.dev.ReloadRepoCommand; +import io.github.moulberry.notenoughupdates.commands.dev.SimpleDevCommands; import io.github.moulberry.notenoughupdates.commands.dev.ResetRepoCommand; import io.github.moulberry.notenoughupdates.commands.dev.StatsCommand; import io.github.moulberry.notenoughupdates.commands.dungeon.DhCommand; @@ -70,10 +69,9 @@ public class Commands { ClientCommandHandler.instance.registerCommand(new PackDevCommand()); ClientCommandHandler.instance.registerCommand(new DungeonWinTestCommand()); ClientCommandHandler.instance.registerCommand(new StatsCommand()); - ClientCommandHandler.instance.registerCommand(new DevTestCommand()); ClientCommandHandler.instance.registerCommand(new NullzeeSphereCommand()); ClientCommandHandler.instance.registerCommand(new DiagCommand()); - ClientCommandHandler.instance.registerCommand(new ReloadRepoCommand()); + ClientCommandHandler.instance.registerCommand(new SimpleDevCommands()); ClientCommandHandler.instance.registerCommand(new ResetRepoCommand()); ClientCommandHandler.instance.registerCommand(new EnableStorageCommand()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java deleted file mode 100644 index 3a2c39ca..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.builder.LiteralArgumentBuilder; -import io.github.moulberry.notenoughupdates.BuildFlags; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor; -import io.github.moulberry.notenoughupdates.core.util.MiscUtils; -import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper; -import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes; -import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent; -import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.SpecialBlockZone; -import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; -import io.github.moulberry.notenoughupdates.util.PronounDB; -import io.github.moulberry.notenoughupdates.util.SBInfo; -import io.github.moulberry.notenoughupdates.util.TabListUtils; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.launchwrapper.Launch; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.EnumParticleTypes; -import net.minecraftforge.common.MinecraftForge; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static com.mojang.brigadier.arguments.IntegerArgumentType.integer; -import static com.mojang.brigadier.builder.RequiredArgumentBuilder.argument; - -public class DevTestCommand extends ClientCommandBase { - - public static final List<String> DEV_TESTERS = - Arrays.asList( - "d0e05de7-6067-454d-beae-c6d19d886191", // moulberry - "66502b40-6ac1-4d33-950d-3df110297aab", // lucycoconut - "a5761ff3-c710-4cab-b4f4-3e7f017a8dbf", // ironm00n - "5d5c548a-790c-4fc8-bd8f-d25b04857f44", // ariyio - "53924f1a-87e6-4709-8e53-f1c7d13dc239", // throwpo - "d3cb85e2-3075-48a1-b213-a9bfb62360c1", // lrg89 - "0b4d470f-f2fb-4874-9334-1eaef8ba4804", // dediamondpro - "ebb28704-ed85-43a6-9e24-2fe9883df9c2", // lulonaut - "698e199d-6bd1-4b10-ab0c-52fedd1460dc", // craftyoldminer - "8a9f1841-48e9-48ed-b14f-76a124e6c9df", // eisengolem - "a7d6b3f1-8425-48e5-8acc-9a38ab9b86f7", // whalker - "0ce87d5a-fa5f-4619-ae78-872d9c5e07fe", // ascynx - "a049a538-4dd8-43f8-87d5-03f09d48b4dc", // egirlefe - "7a9dc802-d401-4d7d-93c0-8dd1bc98c70d", // efefury - "bb855349-dfd8-4125-a750-5fc2cf543ad5" // hannibal2 - ); - - private static final String[] DEV_FAIL_STRINGS = { - "No.", - "I said no.", - "You aren't allowed to use this.", - "Are you sure you want to use this? Type 'Yes' in chat.", - "Are you sure you want to use this? Type 'Yes' in chat.", - "Lmao you thought", - "Ok please stop", - "What do you want from me?", - "This command almost certainly does nothing useful for you", - "Ok, this is the last message, after this it will repeat", - "No.", - "I said no.", - "Dammit. I thought that would work. Uhh...", - "\u00a7dFrom \u00a7c[ADMIN] Minikloon\u00a77: If you use that command again, I'll have to ban you", - "", - "Ok, this is actually the last message, use the command again and you'll crash I promise" - }; - private int devFailIndex = 0; - - public DevTestCommand() { - super("neudevtest"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (!DEV_TESTERS.contains(Minecraft.getMinecraft().thePlayer.getUniqueID().toString()) - && !(boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) { - if (devFailIndex >= DEV_FAIL_STRINGS.length) { - throw new Error("L") { - @Override - public void printStackTrace() { - throw new Error("L"); - } - }; - } - if (devFailIndex == DEV_FAIL_STRINGS.length - 2) { - devFailIndex++; - - ChatComponentText component = new ChatComponentText("\u00a7cYou are permanently banned from this server!"); - component.appendText("\n"); - component.appendText("\n\u00a77Reason: \u00a7rI told you not to run the command - Moulberry"); - component.appendText("\n\u00a77Find out more: \u00a7b\u00a7nhttps://www.hypixel.net/appeal"); - component.appendText("\n"); - component.appendText("\n\u00a77Ban ID: \u00a7r#49871982"); - component.appendText("\n\u00a77Sharing your Ban ID may affect the processing of your appeal!"); - Minecraft.getMinecraft().getNetHandler().getNetworkManager().closeChannel(component); - return; - } - Utils.addChatMessage(EnumChatFormatting.RED + DEV_FAIL_STRINGS[devFailIndex++]); - return; - } - if (args.length >= 1 && args[0].equalsIgnoreCase("profileinfo")) { - String currentProfile = SBInfo.getInstance().currentProfile; - SBInfo.Gamemode gamemode = SBInfo.getInstance().getGamemodeForProfile(currentProfile); - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + - "You are on Profile " + - currentProfile + - " with the mode " + - gamemode)); - } - if (args.length >= 1 && args[0].equalsIgnoreCase("buildflags")) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - "BuildFlags: \n" + - BuildFlags.getAllFlags().entrySet().stream() - .map(it -> " + " + it.getKey() + " - " + it.getValue()) - .collect(Collectors.joining("\n")))); - return; - } - if (args.length >= 1 && args[0].equalsIgnoreCase("exteditor")) { - if (args.length > 1) { - NotEnoughUpdates.INSTANCE.config.hidden.externalEditor = String.join( - " ", - Arrays.copyOfRange(args, 1, args.length) - ); - } - Utils.addChatMessage("§e[NEU] §fYour external editor is: §Z" + NotEnoughUpdates.INSTANCE.config.hidden.externalEditor); - return; - } - if (args.length >= 1 && args[0].equalsIgnoreCase("pricetest")) { - if (args.length == 1) { - NotEnoughUpdates.INSTANCE.manager.auctionManager.updateBazaar(); - } else { - NotEnoughUpdates.INSTANCE.openGui = new GuiPriceGraph(args[1]); - } - } - if (args.length == 1 && args[0].equalsIgnoreCase("zone")) { - BlockPos target = Minecraft.getMinecraft().objectMouseOver.getBlockPos(); - if (target == null) target = Minecraft.getMinecraft().thePlayer.getPosition(); - SpecialBlockZone zone = CustomBiomes.INSTANCE.getSpecialZone(target); - Arrays.asList( - new ChatComponentText("Showing Zone Info for: " + target), - new ChatComponentText("Zone: " + (zone != null ? zone.name() : "null")), - new ChatComponentText("Location: " + SBInfo.getInstance().getLocation()), - new ChatComponentText("Biome: " + CustomBiomes.INSTANCE.getCustomBiome(target)) - ).forEach(Minecraft.getMinecraft().thePlayer::addChatMessage); - MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(SBInfo.getInstance().getLocation(), SBInfo - .getInstance() - .getLocation())); - } - if (args.length == 1 && args[0].equalsIgnoreCase("positiontest")) { - NotEnoughUpdates.INSTANCE.openGui = new GuiPositionEditor(); - return; - } - - if (args.length == 2 && args[0].equalsIgnoreCase("pt")) { - FishingHelper.type = EnumParticleTypes.valueOf(args[1]); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("dev")) { - NotEnoughUpdates.INSTANCE.config.hidden.dev = !NotEnoughUpdates.INSTANCE.config.hidden.dev; - Utils.addChatMessage("§e[NEU] Dev mode " + (NotEnoughUpdates.INSTANCE.config.hidden.dev ? "§aenabled": "§cdisabled")); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("saveconfig")) { - NotEnoughUpdates.INSTANCE.saveConfig(); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("searchmode")) { - NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus = true; - Utils.addChatMessage(EnumChatFormatting.AQUA + "I would never search"); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("bluehair")) { - PronounDB.test(); - return; - } - if (args.length == 2 && args[0].equalsIgnoreCase("openGui")) { - try { - NotEnoughUpdates.INSTANCE.openGui = (GuiScreen) Class.forName(args[1]).newInstance(); - Utils.addChatMessage("Opening gui: " + NotEnoughUpdates.INSTANCE.openGui); - } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | ClassCastException e) { - e.printStackTrace(); - Utils.addChatMessage("Failed to open this GUI."); - } - } - if (args.length == 1 && args[0].equalsIgnoreCase("center")) { - double x = Math.floor(Minecraft.getMinecraft().thePlayer.posX) + 0.5f; - double z = Math.floor(Minecraft.getMinecraft().thePlayer.posZ) + 0.5f; - Minecraft.getMinecraft().thePlayer.setPosition(x, Minecraft.getMinecraft().thePlayer.posY, z); - } - if (args.length >= 1 && args[0].equalsIgnoreCase("minion")) { - MinionHelperManager.getInstance().handleCommand(args); - } - if (args.length == 1 && args[0].equalsIgnoreCase("copytablist")) { - StringBuilder builder = new StringBuilder(); - for (String name : TabListUtils.getTabList()) { - builder.append(name).append("\n"); - } - MiscUtils.copyToClipboard(builder.toString()); - Utils.addChatMessage("§e[NEU] Copied tablist to clipboard!"); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/ReloadRepoCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/ReloadRepoCommand.java deleted file mode 100644 index 0bf57594..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/ReloadRepoCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; - -public class ReloadRepoCommand extends ClientCommandBase { - - public ReloadRepoCommand() { - super("neureloadrepo"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - NotEnoughUpdates.INSTANCE.manager.reloadRepository(); - sender.addChatMessage(new ChatComponentText("§e[NEU] Reloaded repository.")); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java deleted file mode 100644 index bbabc172..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.help; - -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.Constants; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.event.ClickEvent; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; - -public class FeaturesCommand extends ClientCommandBase { - public FeaturesCommand() { - super("neufeatures"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - Utils.addChatMessage(""); - if (Constants.MISC == null || !Constants.MISC.has("featureslist")) { - Utils.showOutdatedRepoNotification(); - return; - } - String url = Constants.MISC.get("featureslist").getAsString(); - - if (Utils.openUrl(url)) { - Utils.addChatMessage( - EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET + - EnumChatFormatting.GOLD + "> Opening Feature List in browser."); - } else { - ChatComponentText clickTextFeatures = new ChatComponentText( - EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET + - EnumChatFormatting.GOLD + "> Click here to open the Feature List in your browser."); - clickTextFeatures.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, url)); - Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextFeatures); - - } - Utils.addChatMessage(""); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.java deleted file mode 100644 index 3a47509d..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.help; - -import com.google.common.collect.Lists; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.command.ICommandSender; - -import java.util.ArrayList; - -public class HelpCommand extends ClientCommandBase { - - public HelpCommand() { - super("neuhelp"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - ArrayList<String> neuHelpMessages = Lists.newArrayList( - "\u00a75\u00a7lNotEnoughUpdates commands", - "\u00a76/neu \u00a77- Opens the main NEU GUI.", - "\u00a76/pv \u00a7b?{name} \u00a72\u2D35 \u00a7r\u00a77- Opens the profile viewer", - "\u00a76/neusouls {on/off/clear/unclear} \u00a7r\u00a77- Shows waypoints to fairy souls.", - "\u00a76/neubuttons \u00a7r\u00a77- Opens a GUI which allows you to customize inventory buttons.", - "\u00a76/neuec \u00a7r\u00a77- Opens the enchant colour GUI.", - "\u00a76/join {floor} \u00a7r\u00a77- Short Command to join a Dungeon. \u00a7lNeed a Party of 5 People\u00a7r\u00a77 {4/f7/m5}.", - "\u00a76/neucosmetics \u00a7r\u00a77- Opens the cosmetic GUI.", - "\u00a76/neurename \u00a7r\u00a77- Opens the NEU Item Customizer.", - "\u00a76/cata \u00a7b?{name} \u00a72\u2D35 \u00a7r\u00a77- Opens the profile viewer's Catacombs page.", - "\u00a76/neulinks \u00a7r\u00a77- Shows links to NEU/Moulberry.", - "\u00a76/neuoverlay \u00a7r\u00a77- Opens GUI Editor for quickcommands and searchbar.", - "\u00a76/neuah \u00a7r\u00a77- Opens NEU's custom auction house GUI.", - "\u00a76/neucalendar \u00a7r\u00a77- Opens NEU's custom calendar GUI.", - "\u00a76/neucalc \u00a7r\u00a77- Run calculations.", - "", - "\u00a76\u00a7lOld commands:", - "\u00a76/peek \u00a7b?{user} \u00a72\u2D35 \u00a7r\u00a77- Shows quick stats for a user.", - "", - "\u00a76\u00a7lDebug commands:", - "\u00a76/neustats \u00a7r\u00a77- Copies helpful info to the clipboard.", - "\u00a76/neustats modlist \u00a7r\u00a77- Copies mod list info to clipboard.", - "\u00a76/neuresetrepo \u00a7r\u00a77- Deletes all repo files.", - "\u00a76/neureloadrepo \u00a7r\u00a77- Debug command with repo.", - "", - "\u00a76\u00a7lDev commands:", - "\u00a76/neupackdev \u00a7r\u00a77- pack creator command - getnpc, getmob(s), getarmorstand(s), getall. Optional radius argument for all." - ); - for (String neuHelpMessage : neuHelpMessages) { - Utils.addChatMessage(neuHelpMessage); - } - if (NotEnoughUpdates.INSTANCE.config.hidden.dev) { - ArrayList<String> neuDevHelpMessages = Lists.newArrayList( - "\u00a76/neudevtest \u00a7r\u00a77- dev test command", - "\u00a76/neuzeephere \u00a7r\u00a77- sphere", - "\u00a76/neudungeonwintest \u00a7r\u00a77- displays the dungeon win screen" - ); - - for (String neuDevHelpMessage : neuDevHelpMessages) { - Utils.addChatMessage(neuDevHelpMessage); - } - } - String[] helpInfo = { - "", - "\u00a77Commands marked with a \u00a72\"\u2D35\"\u00a77 require an api key. You can set your api key via \"/api new\" or by manually putting it in the api field in \"/neu\"", - "", - "\u00a77Arguments marked with a \u00a7b\"?\"\u00a77 are optional.", - "", - "\u00a76\u00a7lScroll up to see everything" - }; - - for (String message : helpInfo) { - Utils.addChatMessage(message); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.java deleted file mode 100644 index 793e652e..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.help; - -import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; - -import java.io.File; - -public class LinksCommand extends ClientCommandBase { - - public LinksCommand() { - super("neulinks"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - File repo = NotEnoughUpdates.INSTANCE.manager.repoLocation; - if (repo.exists()) { - File updateJson = new File(repo, "update.json"); - try { - JsonObject update = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(updateJson); - - Utils.addChatMessage(""); - NotEnoughUpdates.INSTANCE.displayLinks(update,0 ); - Utils.addChatMessage(""); - } catch (Exception ignored) { - } - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.java deleted file mode 100644 index 1855a2b5..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.help; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; -import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import org.apache.commons.lang3.StringUtils; - -import java.util.Arrays; -import java.util.List; - -public class SettingsCommand extends ClientCommandBase { - - public SettingsCommand() { - super("neu"); - } - - @Override - public List<String> getCommandAliases() { - return Arrays.asList("neusettings", "neuconfig"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length > 0) { - NotEnoughUpdates.INSTANCE.openGui = - new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, StringUtils.join(args, " "))); - } else { - NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config)); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java deleted file mode 100644 index 820c6f2a..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.help; - -import com.google.common.collect.Lists; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.NotificationHandler; -import net.minecraft.command.ICommandSender; - -public class StorageViewerWhyCommand extends ClientCommandBase { - - public StorageViewerWhyCommand() { - super("neustwhy"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - NotificationHandler.displayNotification(Lists.newArrayList( - "\u00a7eStorage Viewer", - "\u00a77Currently, the storage viewer requires you to click twice", - "\u00a77in order to switch between pages. This is because Hypixel", - "\u00a77has not yet added a shortcut command to go to any enderchest/", - "\u00a77storage page.", - "\u00a77While it is possible to send the second click", - "\u00a77automatically, doing so violates Hypixel's new mod rules." - ), true); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt b/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt index b8ba7b48..3103d291 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt @@ -34,7 +34,11 @@ import java.util.function.Predicate /** * Hook for converting brigadier commands to normal legacy Minecraft commands (string array style). */ -class NEUBrigadierHook(val brigadierRoot: BrigadierRoot, val commandNode: CommandNode<DefaultSource>) : CommandBase() { +class NEUBrigadierHook( + val brigadierRoot: BrigadierRoot, + val commandNode: CommandNode<DefaultSource>, + val aliases: List<String> +) : CommandBase() { /** * Runs before the command gets executed. Return false to prevent execution. */ @@ -44,6 +48,10 @@ class NEUBrigadierHook(val brigadierRoot: BrigadierRoot, val commandNode: Comman return commandNode.name } + override fun getCommandAliases(): List<String> { + return aliases + } + override fun getCommandUsage(sender: ICommandSender): String { return brigadierRoot.dispatcher.getAllUsage(commandNode, sender, true).joinToString("\n") } diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt new file mode 100644 index 00000000..4b7b42a4 --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt @@ -0,0 +1,247 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.commands.dev + +import com.mojang.brigadier.arguments.StringArgumentType +import io.github.moulberry.notenoughupdates.BuildFlags +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe +import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor +import io.github.moulberry.notenoughupdates.core.util.MiscUtils +import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent +import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper +import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes +import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent +import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager +import io.github.moulberry.notenoughupdates.util.PronounDB +import io.github.moulberry.notenoughupdates.util.SBInfo +import io.github.moulberry.notenoughupdates.util.TabListUtils +import io.github.moulberry.notenoughupdates.util.brigadier.* +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.GuiScreen +import net.minecraft.command.ICommandSender +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.launchwrapper.Launch +import net.minecraft.util.ChatComponentText +import net.minecraft.util.EnumChatFormatting +import net.minecraft.util.EnumChatFormatting.* +import net.minecraft.util.EnumParticleTypes +import net.minecraftforge.common.MinecraftForge +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.function.Predicate +import kotlin.math.floor + +@NEUAutoSubscribe +class DevTestCommand { + companion object { + val DEV_TESTERS: List<String> = mutableListOf( + "d0e05de7-6067-454d-beae-c6d19d886191", // moulberry + "66502b40-6ac1-4d33-950d-3df110297aab", // lucycoconut + "a5761ff3-c710-4cab-b4f4-3e7f017a8dbf", // ironm00n + "5d5c548a-790c-4fc8-bd8f-d25b04857f44", // ariyio + "53924f1a-87e6-4709-8e53-f1c7d13dc239", // throwpo + "d3cb85e2-3075-48a1-b213-a9bfb62360c1", // lrg89 + "0b4d470f-f2fb-4874-9334-1eaef8ba4804", // dediamondpro + "ebb28704-ed85-43a6-9e24-2fe9883df9c2", // lulonaut + "698e199d-6bd1-4b10-ab0c-52fedd1460dc", // craftyoldminer + "8a9f1841-48e9-48ed-b14f-76a124e6c9df", // eisengolem + "a7d6b3f1-8425-48e5-8acc-9a38ab9b86f7", // whalker + "0ce87d5a-fa5f-4619-ae78-872d9c5e07fe", // ascynx + "a049a538-4dd8-43f8-87d5-03f09d48b4dc", // egirlefe + "7a9dc802-d401-4d7d-93c0-8dd1bc98c70d", // efefury + "bb855349-dfd8-4125-a750-5fc2cf543ad5" // hannibal2 + ) + val SPECIAL_KICK = "SPECIAL_KICK" + + val DEV_FAIL_STRINGS = arrayOf( + "No.", + "I said no.", + "You aren't allowed to use this.", + "Are you sure you want to use this? Type 'Yes' in chat.", + "Are you sure you want to use this? Type 'Yes' in chat.", + "Lmao you thought", + "Ok please stop", + "What do you want from me?", + "This command almost certainly does nothing useful for you", + "Ok, this is the last message, after this it will repeat", + "No.", + "I said no.", + "Dammit. I thought that would work. Uhh...", + "\u00a7dFrom \u00a7c[ADMIN] Minikloon\u00a77: If you use that command again, I'll have to ban you", + SPECIAL_KICK, + "Ok, this is actually the last message, use the command again and you'll crash I promise" + ) + } + + var devFailIndex = 0 + + fun canPlayerExecute(commandSender: ICommandSender): Boolean { + return DEV_TESTERS.contains((commandSender as? EntityPlayer)?.uniqueID?.toString()) + || Launch.blackboard.get("fml.deobfuscatedEnvironment") as Boolean + } + + @SubscribeEvent + fun onCommands(event: RegisterBrigadierCommandEvent) { + val hook = event.command("neudevtest") { + requires { + canPlayerExecute(it) + } + thenLiteralExecute("profileinfo") { + val currentProfile = SBInfo.getInstance().currentProfile + val gamemode = SBInfo.getInstance().getGamemodeForProfile(currentProfile) + reply("${GOLD}You are on Profile $currentProfile with the mode $gamemode") + } + thenLiteralExecute("buildflags") { + reply("BuildFlags: \n" + + BuildFlags.getAllFlags().entries + .joinToString(("\n")) { (key, value) -> " + $key - $value" }) + } + thenLiteral("exteditor") { + thenExecute { + reply("Your external editor is: §Z${NotEnoughUpdates.INSTANCE.config.hidden.externalEditor}") + } + thenArgument("editor", StringArgumentType.string()) { newEditor -> + thenExecute { + NotEnoughUpdates.INSTANCE.config.hidden.externalEditor = this[newEditor] + reply("You changed your external editor to: §Z${this[newEditor]}") + } + } + } + thenLiteral("pricetest") { + thenExecute { + NotEnoughUpdates.INSTANCE.manager.auctionManager.updateBazaar() + } + thenArgument("item", StringArgumentType.string()) { item -> + thenExecute { + NotEnoughUpdates.INSTANCE.openGui = GuiPriceGraph(this[item]) + } + } + } + thenLiteralExecute("zone") { + val target = Minecraft.getMinecraft().objectMouseOver.blockPos + ?: Minecraft.getMinecraft().thePlayer.position + val zone = CustomBiomes.INSTANCE.getSpecialZone(target) + listOf( + ChatComponentText("Showing Zone Info for: $target"), + ChatComponentText("Zone: " + (zone?.name ?: "null")), + ChatComponentText("Location: " + SBInfo.getInstance().getLocation()), + ChatComponentText("Biome: " + CustomBiomes.INSTANCE.getCustomBiome(target)) + ).forEach { component -> + reply(component) + } + MinecraftForge.EVENT_BUS.post( + LocationChangeEvent( + SBInfo.getInstance().getLocation(), SBInfo + .getInstance() + .getLocation() + ) + ) + } + thenLiteralExecute("positiontest") { + NotEnoughUpdates.INSTANCE.openGui = GuiPositionEditor() + } + thenLiteral("pt") { + thenArgument("particle", EnumArgumentType.enum<EnumParticleTypes>()) { particle -> + thenExecute { + FishingHelper.type = this[particle] + reply("Fishing particles set to ${FishingHelper.type}") + } + } + } + thenLiteralExecute("dev") { + NotEnoughUpdates.INSTANCE.config.hidden.dev = !NotEnoughUpdates.INSTANCE.config.hidden.dev + reply("§e[NEU] Dev mode " + if (NotEnoughUpdates.INSTANCE.config.hidden.dev) "§aenabled" else "§cdisabled") + } + thenLiteralExecute("saveconfig") { + NotEnoughUpdates.INSTANCE.saveConfig() + reply("Config saved") + } + thenLiteralExecute("searchmode") { + NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus = true + reply(AQUA.toString() + "I would never search") + } + thenLiteralExecute("bluehair") { + PronounDB.test() + } + thenLiteral("opengui") { + thenArgument("class", StringArgumentType.string()) { className -> + thenExecute { + try { + NotEnoughUpdates.INSTANCE.openGui = + Class.forName(this[className]).newInstance() as GuiScreen + reply("Opening gui: " + NotEnoughUpdates.INSTANCE.openGui) + } catch (e: Exception) { + e.printStackTrace() + reply("Failed to open this GUI.") + } + } + } + } + thenLiteralExecute("center") { + val x = floor(Minecraft.getMinecraft().thePlayer.posX) + 0.5f + val z = floor(Minecraft.getMinecraft().thePlayer.posZ) + 0.5f + Minecraft.getMinecraft().thePlayer.setPosition(x, Minecraft.getMinecraft().thePlayer.posY, z) + reply("Literal hacks") + } + thenLiteral("minion") { + thenArgument("args", RestArgumentType) { arg -> + thenExecute { + MinionHelperManager.getInstance().handleCommand(arrayOf("minion") + this[arg].split(" ")) + } + } + } + thenLiteralExecute("copytablist") { + val tabList = TabListUtils.getTabList().joinToString("\n", postfix = "\n") + MiscUtils.copyToClipboard(tabList) + reply("Copied tablist to clipboard!") + } + } + hook.beforeCommand = Predicate { + if (!canPlayerExecute(it.context.source)) { + if (devFailIndex !in DEV_FAIL_STRINGS.indices) { + throw object : Error("L") { + @Override + fun printStackTrace() { + throw Error("L") + } + } + } + val text = DEV_FAIL_STRINGS[devFailIndex++] + if (text == SPECIAL_KICK) { + val component = ChatComponentText("\u00a7cYou are permanently banned from this server!") + component.appendText("\n") + component.appendText("\n\u00a77Reason: \u00a7rI told you not to run the command - Moulberry") + component.appendText("\n\u00a77Find out more: \u00a7b\u00a7nhttps://www.hypixel.net/appeal") + component.appendText("\n") + component.appendText("\n\u00a77Ban ID: \u00a7r#49871982") + component.appendText("\n\u00a77Sharing your Ban ID may affect the processing of your appeal!") + Minecraft.getMinecraft().netHandler.networkManager.closeChannel(component) + } else { + it.context.source.addChatMessage(ChatComponentText("$RED$text")) + } + false + } else { + true + } + } + } + +} diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/SimpleDevCommands.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/SimpleDevCommands.kt new file mode 100644 index 00000000..51e00c02 --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/SimpleDevCommands.kt @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.commands.dev + +import com.mojang.brigadier.arguments.StringArgumentType.string +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe +import io.github.moulberry.notenoughupdates.dungeons.DungeonWin +import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent +import io.github.moulberry.notenoughupdates.util.brigadier.get +import io.github.moulberry.notenoughupdates.util.brigadier.reply +import io.github.moulberry.notenoughupdates.util.brigadier.thenArgumentExecute +import io.github.moulberry.notenoughupdates.util.brigadier.thenExecute +import net.minecraft.util.ResourceLocation +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@NEUAutoSubscribe +class SimpleDevCommands { + @SubscribeEvent + fun onCommands(event: RegisterBrigadierCommandEvent) { + event.command("neureloadrepo") { + thenExecute { + NotEnoughUpdates.INSTANCE.manager.reloadRepository() + reply("§e[NEU] Reloaded repository.") + } + } + event.command("neudungeonwintest") { + thenExecute { + DungeonWin.displayWin() + } + thenArgumentExecute("file", string()) { file -> + DungeonWin.TEAM_SCORE = ResourceLocation("notenoughupdates:dungeon_win/${this[file].lowercase()}.png") + reply("Changed the dungeon win display") + } + } + } +} diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.kt new file mode 100644 index 00000000..49b08d48 --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.kt @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.commands.help + +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe +import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent +import io.github.moulberry.notenoughupdates.util.Constants +import io.github.moulberry.notenoughupdates.util.Utils +import io.github.moulberry.notenoughupdates.util.brigadier.reply +import io.github.moulberry.notenoughupdates.util.brigadier.thenExecute +import net.minecraft.event.ClickEvent +import net.minecraft.util.ChatComponentText +import net.minecraft.util.EnumChatFormatting +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@NEUAutoSubscribe +class FeaturesCommand { + @SubscribeEvent + fun onCommands(event: RegisterBrigadierCommandEvent) { + event.command("neufeatures") { + thenExecute { + reply("") + val url = Constants.MISC?.get("featureslist")?.asString + if (url == null) { + Utils.showOutdatedRepoNotification() + return@thenExecute + } + + if (Utils.openUrl(url)) { + reply( + EnumChatFormatting.DARK_PURPLE.toString() + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET + + EnumChatFormatting.GOLD + "> Opening Feature List in browser." + ) + } else { + val clickTextFeatures = ChatComponentText( + (EnumChatFormatting.DARK_PURPLE.toString() + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET + + EnumChatFormatting.GOLD + "> Click here to open the Feature List in your browser.") + ) + clickTextFeatures.chatStyle = + Utils.createClickStyle(ClickEvent.Action.OPEN_URL, url) + reply(clickTextFeatures) + } + reply("") + + } + } + } +} diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.kt new file mode 100644 index 00000000..a3e730cf --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.kt @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.commands.help + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe +import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent +import io.github.moulberry.notenoughupdates.util.brigadier.reply +import io.github.moulberry.notenoughupdates.util.brigadier.thenExecute +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@NEUAutoSubscribe +class HelpCommand { + val neuHelpMessages = listOf( + "§5§lNotEnoughUpdates commands", + "§6/neu §7- Opens the main NEU GUI.", + "§6/pv §b?{name} §2ⴵ §r§7- Opens the profile viewer", + "§6/neusouls {on/off/clear/unclear} §r§7- Shows waypoints to fairy souls.", + "§6/neubuttons §r§7- Opens a GUI which allows you to customize inventory buttons.", + "§6/neuec §r§7- Opens the enchant colour GUI.", + "§6/join {floor} §r§7- Short Command to join a Dungeon. §lNeed a Party of 5 People§r§7 {4/f7/m5}.", + "§6/neucosmetics §r§7- Opens the cosmetic GUI.", + "§6/neurename §r§7- Opens the NEU Item Customizer.", + "§6/cata §b?{name} §2ⴵ §r§7- Opens the profile viewer's Catacombs page.", + "§6/neulinks §r§7- Shows links to NEU/Moulberry.", + "§6/neuoverlay §r§7- Opens GUI Editor for quickcommands and searchbar.", + "§6/neuah §r§7- Opens NEU's custom auction house GUI.", + "§6/neucalendar §r§7- Opens NEU's custom calendar GUI.", + "§6/neucalc §r§7- Run calculations.", + "", + "§6§lOld commands:", + "§6/peek §b?{user} §2ⴵ §r§7- Shows quick stats for a user.", + "", + "§6§lDebug commands:", + "§6/neustats §r§7- Copies helpful info to the clipboard.", + "§6/neustats modlist §r§7- Copies mod list info to clipboard.", + "§6/neuresetrepo §r§7- Deletes all repo files.", + "§6/neureloadrepo §r§7- Debug command with repo.", + "", + "§6§lDev commands:", + "§6/neupackdev §r§7- pack creator command - getnpc, getmob(s), getarmorstand(s), getall. Optional radius argument for all." + ) + val neuDevHelpMessages = listOf( + "§6/neudevtest §r§7- dev test command", + "§6/neuzeephere §r§7- sphere", + "§6/neudungeonwintest §r§7- displays the dungeon win screen" + ) + val helpInfo = listOf( + "", + "§7Commands marked with a §2\"ⴵ\"§7 require an api key. You can set your api key via \"/api new\" or by manually putting it in the api field in \"/neu\"", + "", + "§7Arguments marked with a §b\"?\"§7 are optional.", + "", + "§6§lScroll up to see everything" + ) + + @SubscribeEvent + fun onCommands(event: RegisterBrigadierCommandEvent) { + event.command("neuhelp") { + thenExecute { + neuHelpMessages.forEach(::reply) + if (NotEnoughUpdates.INSTANCE.config.hidden.dev) + neuDevHelpMessages.forEach(::reply) + helpInfo.forEach(::reply) + } + } + } +} diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.kt new file mode 100644 index 00000000..c6947644 --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.kt @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.commands.help + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe +import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent +import io.github.moulberry.notenoughupdates.util.Utils +import io.github.moulberry.notenoughupdates.util.brigadier.reply +import io.github.moulberry.notenoughupdates.util.brigadier.thenExecute +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@NEUAutoSubscribe +class LinksCommand { + @SubscribeEvent + fun onCommands(event: RegisterBrigadierCommandEvent) { + event.command("neulinks") { + thenExecute { + val manager = NotEnoughUpdates.INSTANCE.manager + val updateJsonFile = manager.repoLocation.resolve("update.json") + if (!updateJsonFile.exists()) { + Utils.showOutdatedRepoNotification() + return@thenExecute + } + try { + val updateJson = manager.getJsonFromFile(updateJsonFile) + reply("") + NotEnoughUpdates.INSTANCE.displayLinks(updateJson, 0) + reply("") + } catch (_: Exception) { + Utils.showOutdatedRepoNotification() + } + } + } + } +} diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt new file mode 100644 index 00000000..719d6957 --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.commands.help + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe +import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper +import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent +import io.github.moulberry.notenoughupdates.options.NEUConfigEditor +import io.github.moulberry.notenoughupdates.util.brigadier.RestArgumentType +import io.github.moulberry.notenoughupdates.util.brigadier.get +import io.github.moulberry.notenoughupdates.util.brigadier.thenArgumentExecute +import io.github.moulberry.notenoughupdates.util.brigadier.thenExecute +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@NEUAutoSubscribe +class SettingsCommand { + @SubscribeEvent + fun onCommands(event: RegisterBrigadierCommandEvent) { + event.command("neu", "neusettings") { + thenExecute { + NotEnoughUpdates.INSTANCE.openGui = + GuiScreenElementWrapper(NEUConfigEditor(NotEnoughUpdates.INSTANCE.config)) + } + thenArgumentExecute("search", RestArgumentType) { search -> + NotEnoughUpdates.INSTANCE.openGui = GuiScreenElementWrapper( + NEUConfigEditor( + NotEnoughUpdates.INSTANCE.config, + this[search] + ) + ) + } + } + } +} diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.kt new file mode 100644 index 00000000..66957e94 --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.kt @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ +package io.github.moulberry.notenoughupdates.commands.help + +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe +import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent +import io.github.moulberry.notenoughupdates.util.NotificationHandler +import io.github.moulberry.notenoughupdates.util.brigadier.thenExecute +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@NEUAutoSubscribe +class StorageViewerWhyCommand { + @SubscribeEvent + fun onCommands(event: RegisterBrigadierCommandEvent) { + event.command("neustwhy") { + thenExecute { + NotificationHandler.displayNotification( + listOf( + "§eStorage Viewer", + "§7Currently, the storage viewer requires you to click twice", + "§7in order to switch between pages. This is because Hypixel", + "§7has not yet added a shortcut command to go to any enderchest/", + "§7storage page.", + "§7While it is possible to send the second click", + "§7automatically, doing so violates Hypixel's new mod rules." + ), true + ) + } + } + } +} diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/events/RegisterBrigadierCommandEvent.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/events/RegisterBrigadierCommandEvent.kt index 1f79d2cd..d3e0b69a 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/events/RegisterBrigadierCommandEvent.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/events/RegisterBrigadierCommandEvent.kt @@ -35,9 +35,16 @@ data class RegisterBrigadierCommandEvent(val brigadierRoot: BrigadierRoot) : NEU } } - fun command(name: String, block: LiteralArgumentBuilder<ICommandSender>.() -> Unit): NEUBrigadierHook { + fun command( + name: String, + vararg aliases: String, + block: LiteralArgumentBuilder<ICommandSender>.() -> Unit + ): NEUBrigadierHook { val node = dispatcher.register(literal(name, block)) - val hook = NEUBrigadierHook(brigadierRoot, node) + for (alias in aliases) { + dispatcher.register(literal(alias) { redirect(node) }) + } + val hook = NEUBrigadierHook(brigadierRoot, node, aliases.toList()) hooks.add(hook) return hook } diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/BrigadierRoot.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/BrigadierRoot.kt index 8af23293..0010f1a6 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/BrigadierRoot.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/util/brigadier/BrigadierRoot.kt @@ -21,42 +21,11 @@ package io.github.moulberry.notenoughupdates.util.brigadier import com.mojang.brigadier.CommandDispatcher import com.mojang.brigadier.ParseResults -import com.mojang.brigadier.arguments.StringArgumentType.string -import com.mojang.brigadier.exceptions.CommandSyntaxException -import com.mojang.brigadier.suggestion.Suggestions -import io.github.moulberry.notenoughupdates.BuildFlags -import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe -import io.github.moulberry.notenoughupdates.commands.dev.DevTestCommand.DEV_TESTERS -import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor -import io.github.moulberry.notenoughupdates.core.util.MiscUtils import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent -import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper -import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes -import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent -import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager import io.github.moulberry.notenoughupdates.util.LRUCache -import io.github.moulberry.notenoughupdates.util.PronounDB -import io.github.moulberry.notenoughupdates.util.SBInfo -import io.github.moulberry.notenoughupdates.util.TabListUtils -import io.github.moulberry.notenoughupdates.util.brigadier.EnumArgumentType.Companion.enum -import net.minecraft.client.Minecraft -import net.minecraft.client.gui.GuiScreen -import net.minecraft.command.CommandBase import net.minecraft.command.ICommandSender -import net.minecraft.entity.player.EntityPlayer -import net.minecraft.launchwrapper.Launch -import net.minecraft.util.BlockPos -import net.minecraft.util.ChatComponentText -import net.minecraft.util.EnumChatFormatting -import net.minecraft.util.EnumChatFormatting.GOLD -import net.minecraft.util.EnumChatFormatting.RED -import net.minecraft.util.EnumParticleTypes import net.minecraftforge.client.ClientCommandHandler -import net.minecraftforge.common.MinecraftForge -import java.util.concurrent.CompletableFuture -import kotlin.math.floor @NEUAutoSubscribe object BrigadierRoot { @@ -67,125 +36,6 @@ object BrigadierRoot { dispatcher.parse(text, sender) }, 1) - init { - dispatcher.register(literal("neudevtest2") { - requires { - DEV_TESTERS.contains((it as? EntityPlayer)?.uniqueID?.toString()) - || Launch.blackboard.get("fml.deobfuscatedEnvironment") as Boolean - } - thenLiteralExecute("profileinfo") { - val currentProfile = SBInfo.getInstance().currentProfile - val gamemode = SBInfo.getInstance().getGamemodeForProfile(currentProfile) - reply("${GOLD}You are on Profile $currentProfile with the mode $gamemode") - } - thenLiteralExecute("buildflags") { - reply("BuildFlags: \n" + - BuildFlags.getAllFlags().entries - .joinToString(("\n")) { (key, value) -> " + $key - $value" }) - } - thenLiteral("exteditor") { - thenExecute { - reply("Your external editor is: §Z${NotEnoughUpdates.INSTANCE.config.hidden.externalEditor}") - } - thenArgument("editor", string()) { newEditor -> - thenExecute { - NotEnoughUpdates.INSTANCE.config.hidden.externalEditor = this[newEditor] - reply("You changed your external editor to: §Z${this[newEditor]}") - } - } - } - thenLiteral("pricetest") { - thenExecute { - NotEnoughUpdates.INSTANCE.manager.auctionManager.updateBazaar() - } - thenArgument("item", string()) { item -> - thenExecute { - NotEnoughUpdates.INSTANCE.openGui = GuiPriceGraph(this[item]) - } - } - } - thenLiteralExecute("zone") { - val target = Minecraft.getMinecraft().objectMouseOver.blockPos - ?: Minecraft.getMinecraft().thePlayer.position - val zone = CustomBiomes.INSTANCE.getSpecialZone(target) - listOf( - ChatComponentText("Showing Zone Info for: $target"), - ChatComponentText("Zone: " + (zone?.name ?: "null")), - ChatComponentText("Location: " + SBInfo.getInstance().getLocation()), - ChatComponentText("Biome: " + CustomBiomes.INSTANCE.getCustomBiome(target)) - ).forEach { component -> - reply(component) - } - MinecraftForge.EVENT_BUS.post( - LocationChangeEvent( - SBInfo.getInstance().getLocation(), SBInfo - .getInstance() - .getLocation() - ) - ) - } - thenLiteralExecute("positiontest") { - NotEnoughUpdates.INSTANCE.openGui = GuiPositionEditor() - } - thenLiteral("pt") { - thenArgument("particle", enum<EnumParticleTypes>()) { particle -> - thenExecute { - FishingHelper.type = this[particle] - reply("Fishing particles set to ${FishingHelper.type}") - } - } - } - thenLiteralExecute("dev") { - NotEnoughUpdates.INSTANCE.config.hidden.dev = !NotEnoughUpdates.INSTANCE.config.hidden.dev - reply("§e[NEU] Dev mode " + if (NotEnoughUpdates.INSTANCE.config.hidden.dev) "§aenabled" else "§cdisabled") - } - thenLiteralExecute("saveconfig") { - NotEnoughUpdates.INSTANCE.saveConfig() - reply("Config saved") - } - thenLiteralExecute("searchmode") { - NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus = true - reply(EnumChatFormatting.AQUA.toString() + "I would never search") - } - thenLiteralExecute("bluehair") { - PronounDB.test() - } - thenLiteral("opengui") { - thenArgument("class", string()) { className -> - thenExecute { - try { - NotEnoughUpdates.INSTANCE.openGui = - Class.forName(this[className]).newInstance() as GuiScreen - reply("Opening gui: " + NotEnoughUpdates.INSTANCE.openGui) - } catch (e: Exception) { - e.printStackTrace() - reply("Failed to open this GUI.") - } - } - } - } - thenLiteralExecute("center") { - val x = floor(Minecraft.getMinecraft().thePlayer.posX) + 0.5f - val z = floor(Minecraft.getMinecraft().thePlayer.posZ) + 0.5f - Minecraft.getMinecraft().thePlayer.setPosition(x, Minecraft.getMinecraft().thePlayer.posY, z) - reply("Literal hacks") - } - thenLiteral("minion") { - thenArgument("args", RestArgumentType) { arg -> - thenExecute { - MinionHelperManager.getInstance().handleCommand(arrayOf("minion") + this[arg].split(" ")) - } - } - } - thenLiteralExecute("copytablist") { - val tabList = TabListUtils.getTabList().joinToString("\n", postfix = "\n") - MiscUtils.copyToClipboard(tabList) - reply("Copied tablist to clipboard!") - } - }) - updateHooks() - } - fun updateHooks() = registerHooks(ClientCommandHandler.instance) fun registerHooks(handler: ClientCommandHandler) { @@ -198,7 +48,11 @@ object BrigadierRoot { val event = RegisterBrigadierCommandEvent(this) event.post() event.hooks.forEach { - handler.registerCommand(it) + if (handler.commands.containsKey(it.commandName)) { + println("Could not register command ${it.commandName}") + } else { + handler.registerCommand(it) + } } } } |