diff options
Diffstat (limited to 'src/main/java')
4 files changed, 8 insertions, 520 deletions
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 c5f4317e..e530809a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java @@ -37,7 +37,6 @@ import io.github.moulberry.notenoughupdates.commands.profile.CataCommand; import io.github.moulberry.notenoughupdates.commands.profile.PeekCommand; import io.github.moulberry.notenoughupdates.commands.profile.PvCommand; import io.github.moulberry.notenoughupdates.commands.profile.ViewProfileCommand; -import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor; import io.github.moulberry.notenoughupdates.miscgui.NEUOverlayPlacements; @@ -47,12 +46,6 @@ import net.minecraftforge.fml.common.Loader; public class Commands { public Commands() { - // Help Commands - - // Dev Commands - ClientCommandHandler.instance.registerCommand(new PackDevCommand()); - ClientCommandHandler.instance.registerCommand(new DiagCommand()); - // Profile Commands ClientCommandHandler.instance.registerCommand(new PeekCommand()); ClientCommandHandler.instance.registerCommand(new ViewProfileCommand()); @@ -76,8 +69,5 @@ public class Commands { ClientCommandHandler.instance.registerCommand(new CalendarCommand()); ClientCommandHandler.instance.registerCommand(new UpdateCommand(NotEnoughUpdates.INSTANCE)); ClientCommandHandler.instance.registerCommand(new PronounsCommand()); - - // Fairy Soul Commands - ClientCommandHandler.instance.registerCommand(new FairySouls.FairySoulsCommand()); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java deleted file mode 100644 index fb546efb..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java +++ /dev/null @@ -1,134 +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 io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver; -import io.github.moulberry.notenoughupdates.miscfeatures.CrystalWishingCompassSolver; -import io.github.moulberry.notenoughupdates.options.customtypes.NEUDebugFlag; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; - -public class DiagCommand extends ClientCommandBase { - public DiagCommand() { - super("neudiag"); - } - - private static final String USAGE_TEXT = EnumChatFormatting.WHITE + - "Usage: /neudiag <metal | wishing | debug>\n\n" + - "/neudiag metal Metal Detector Solver diagnostics\n" + - " <no sub-command> Show current solution diags\n" + - " center=<off | on> Disable / enable using center\n" + - "/neudiag wishing Wishing Compass Solver diagnostics\n" + - "/neudiag debug\n" + - " <no sub-command> Show all enabled flags\n" + - " <list> Show all flags\n"+ - " <enable | disable> <flag> Enable/disable flag\n"; - - private void showUsage(ICommandSender sender) { - sender.addChatMessage(new ChatComponentText(USAGE_TEXT)); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length == 0) { - showUsage(sender); - return; - } - - String command = args[0].toLowerCase(); - switch (command) { - case "metal": - if (args.length == 1) { - CrystalMetalDetectorSolver.logDiagnosticData(true); - return; - } - - String subCommand = args[1].toLowerCase(); - if (subCommand.equals("center=off")) { - CrystalMetalDetectorSolver.setDebugDoNotUseCenter(true); - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + - "Center coordinates-based solutions disabled")); - } else if (subCommand.equals("center=on")) { - CrystalMetalDetectorSolver.setDebugDoNotUseCenter(false); - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + - "Center coordinates-based solutions enabled")); - } else { - showUsage(sender); - return; - } - - break; - case "wishing": - CrystalWishingCompassSolver.getInstance().logDiagnosticData(true); - break; - case "debug": - if (args.length > 1) { - boolean enablingFlag = true; - String action = args[1]; - switch (action) { - case "list": - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW + "Here are all flags:\n" + NEUDebugFlag.getFlagList())); - return; - case "disable": - enablingFlag = false; - // falls through - case "enable": - if (args.length != 3) { - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + - "You must specify a flag:\n" + - NEUDebugFlag.getFlagList())); - return; - } - - String flagName = args[2].toUpperCase(); - try { - NEUDebugFlag debugFlag = NEUDebugFlag.valueOf(flagName); - if (enablingFlag) { - NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.add(debugFlag); - } else { - NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.remove(debugFlag); - } - } catch (IllegalArgumentException e) { - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + - flagName + " is invalid. Valid flags are:\n" + - NEUDebugFlag.getFlagList())); - return; - } - break; - default: - showUsage(sender); - return; - } - } - - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Effective debug flags: \n" + - NEUDebugFlag.getEnabledFlags())); - break; - default: - showUsage(sender); - return; - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java deleted file mode 100644 index 1d30a15f..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java +++ /dev/null @@ -1,304 +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 io.github.moulberry.notenoughupdates.core.util.MiscUtils; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; - -import java.util.HashMap; -import java.util.List; -import java.util.function.Supplier; - -public class PackDevCommand extends ClientCommandBase { - static Minecraft mc = Minecraft.getMinecraft(); - - public PackDevCommand() { - super("neupackdev"); - } - - private static final HashMap<String, Command<?, ?>> commands = new HashMap<String, Command<?, ?>>() {{ - put( - "getnpc", - new Command<>( - "NPC", - () -> mc.theWorld.playerEntities, - true, - AbstractClientPlayer.class - ) - ); - put( - "getnpcs", - new Command<>( - "NPC", - () -> mc.theWorld.playerEntities, - false, - AbstractClientPlayer.class - ) - ); - put( - "getmob", - new Command<>( - "mob", - () -> mc.theWorld.loadedEntityList, - true, - EntityLiving.class - ) - ); - put( - "getmobs", - new Command<>( - "mob", - () -> mc.theWorld.loadedEntityList, - false, - EntityLiving.class - ) - ); - put( - "getarmorstand", - new Command<>( - "armor stand", - () -> mc.theWorld.loadedEntityList, - true, - EntityArmorStand.class - ) - ); - put( - "getarmorstands", - new Command<>( - "armor stand", - () -> mc.theWorld.loadedEntityList, - false, - EntityArmorStand.class - ) - ); - }}; - - @Override - public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { - return args.length == 1 ? getListOfStringsMatchingLastWord(args, commands.keySet()) : null; - } - - public static void togglePackDeveloperMode(ICommandSender sender) { - NotEnoughUpdates.INSTANCE.packDevEnabled = !NotEnoughUpdates.INSTANCE.packDevEnabled; - if (NotEnoughUpdates.INSTANCE.packDevEnabled) { - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.GREEN + "Enabled pack developer mode.")); - } else { - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.RED + "Disabled pack developer mode.")); - } - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length == 0) { - togglePackDeveloperMode(sender); - return; - } - - double dist = 5.0; - if (args.length >= 2) { - try { - dist = Double.parseDouble(args[1]); - } catch (NumberFormatException e) { - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.RED + "Invalid distance! Must be a number, defaulting to a radius of 5.")); - } - } - - StringBuilder output; - String subCommand = args[0].toLowerCase(); - if (commands.containsKey(subCommand)) { - Command<?, ?> command = commands.get(subCommand); - output = command.getData(dist); - } else if (subCommand.equals("getall")) { - output = getAll(dist); - } else if (subCommand.equals("getallclose")) { - output = getAllClose(dist); - } else { - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.RED + "Invalid sub-command.")); - return; - } - - if (output.length() != 0) { - MiscUtils.copyToClipboard(output.toString()); - } - } - - private static StringBuilder getAllClose(Double dist) { - StringBuilder sb = new StringBuilder(); - sb.append(commands.get("getmob").getData(dist)); - sb.append(commands.get("getarmorstand").getData(dist)); - sb.append(commands.get("getnpc").getData(dist)); - return sb; - } - - private static StringBuilder getAll(Double dist) { - StringBuilder sb = new StringBuilder(); - sb.append(commands.get("getmobs").getData(dist)); - sb.append(commands.get("getarmorstands").getData(dist)); - sb.append(commands.get("getnpcs").getData(dist)); - return sb; - } - - public static <T extends EntityLivingBase> StringBuilder livingBaseDataBuilder(T entity, Class<T> clazz) { - StringBuilder entityData = new StringBuilder(); - if (EntityPlayer.class.isAssignableFrom(entity.getClass())) { - EntityPlayer entityPlayer = (EntityPlayer) entity; - - // NPC Information - String skinResourcePath = ((AbstractClientPlayer) entityPlayer).getLocationSkin().getResourcePath(); - entityData - .append("Player Id: ") - .append(entityPlayer.getUniqueID() != null ? entityPlayer.getUniqueID().toString() : "null") - .append(entityPlayer.getCustomNameTag() != null ? entityPlayer.getCustomNameTag() : "null") - .append("\nEntity Texture Id: ") - .append(skinResourcePath != null ? skinResourcePath.replace("skins/", "") : "null"); - } - - if (!clazz.isAssignableFrom(entity.getClass())) { - return entityData; - } - - //Entity Information - entityData - .append("Entity Id: ") - .append(entity.getEntityId()) - .append("\nMob: ") - .append(entity.getName() != null ? entity.getName() : "null") - .append("\nCustom Name: ") - .append(entity.getCustomNameTag() != null ? entity.getCustomNameTag() : "null"); - - //Held Item - if (entity.getHeldItem() != null) { - entityData - .append("\nItem: ") - .append(entity.getHeldItem()) - .append("\nItem Display Name: ") - .append(entity.getHeldItem().getDisplayName() != null - ? entity.getHeldItem().getDisplayName() - : "null") - .append("\nItem Tag Compound: "); - NBTTagCompound heldItemTagCompound = entity.getHeldItem().getTagCompound(); - if (heldItemTagCompound != null) { - String heldItemString = heldItemTagCompound.toString(); - NBTBase extraAttrTag = heldItemTagCompound.getTag("ExtraAttributes"); - entityData - .append(heldItemString != null ? heldItemString : "null") - .append("\nItem Tag Compound Extra Attributes: ") - .append(extraAttrTag != null ? extraAttrTag : "null"); - } else { - entityData.append("null"); - } - - } else { - entityData.append("\nItem: null"); - } - - entityData.append(armorDataBuilder(entity)).append("\n\n"); - - return entityData; - } - - private static final String[] armorPieceTypes = {"Boots", "Leggings", "Chestplate", "Helmet"}; - - public static <T extends EntityLivingBase> StringBuilder armorDataBuilder(T entity) { - StringBuilder armorData = new StringBuilder(); - for (int i = 0; i < 4; i++) { - ItemStack currentArmor = entity.getCurrentArmor(0); - armorData.append(String.format("\n%s: ", armorPieceTypes[i])); - if (currentArmor == null) { - armorData.append("null"); - } else { - armorData.append(currentArmor.getTagCompound() != null ? currentArmor.getTagCompound().toString() : "null"); - } - } - return armorData; - } - - static class Command<T extends EntityLivingBase, U extends Entity> { - String typeFriendlyName; - Supplier<List<U>> entitySupplier; - Class<T> clazz; - boolean single; - - Command( - String typeFriendlyName, - Supplier<List<U>> entitySupplier, - boolean single, - Class<T> clazz - ) { - this.typeFriendlyName = typeFriendlyName; - this.entitySupplier = entitySupplier; - this.single = single; - this.clazz = clazz; - } - - @SuppressWarnings("unchecked") - public StringBuilder getData(double dist) { - StringBuilder result = new StringBuilder(); - double distSq = dist * dist; - T closest = null; - for (Entity entity : entitySupplier.get()) { - if (!clazz.isAssignableFrom(entity.getClass()) || entity == mc.thePlayer) { - continue; - } - T entityT = (T) entity; - double entityDistanceSq = entity.getDistanceSq(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ); - if (entityDistanceSq < distSq) { - if (single) { - distSq = entityDistanceSq; - closest = entityT; - } else { - result.append(livingBaseDataBuilder(entityT, clazz)); - } - } - } - - if ((single && closest == null) || (!single && result.length() == 0)) { - Utils.addChatMessage(EnumChatFormatting.RED + "No " + typeFriendlyName + "s found within " + dist + " blocks."); - } else { - Utils.addChatMessage( - EnumChatFormatting.GREEN + "Copied " + typeFriendlyName + " data to clipboard"); - return single ? livingBaseDataBuilder(closest, clazz) : result; - } - - return result; - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java index 5a611178..97aa25d4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java @@ -26,7 +26,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.util.Constants; @@ -34,8 +33,6 @@ import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import lombok.var; import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; @@ -56,7 +53,6 @@ import java.io.OutputStreamWriter; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -87,6 +83,14 @@ public class FairySouls { return instance; } + public boolean isTrackSouls() { + return trackSouls; + } + + public boolean isShowSouls() { + return showSouls; + } + @SubscribeEvent public void onWorldLoad(WorldEvent.Load event) { currentLocation = null; @@ -379,25 +383,6 @@ public class FairySouls { Utils.addChatMessage(s); } - private static void printHelp() { - print(""); - print(EnumChatFormatting.DARK_PURPLE.toString() + EnumChatFormatting.BOLD + " NEU Fairy Soul Waypoint Guide"); - print(EnumChatFormatting.LIGHT_PURPLE + "Shows waypoints for every fairy soul in your world"); - print(EnumChatFormatting.LIGHT_PURPLE + "Clicking a fairy soul automatically removes it from the list"); - if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) { - print(EnumChatFormatting.DARK_RED + "" + EnumChatFormatting.OBFUSCATED + "Ab" + EnumChatFormatting.RESET + - EnumChatFormatting.DARK_RED + "!" + EnumChatFormatting.RESET + EnumChatFormatting.RED + - " This feature cannot and will not work in Dungeons. " + EnumChatFormatting.DARK_RED + "!" + - EnumChatFormatting.OBFUSCATED + "Ab"); - } - print(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + " Commands:"); - print(EnumChatFormatting.YELLOW + "/neusouls help - Display this message"); - print(EnumChatFormatting.YELLOW + "/neusouls on/off - Enable/disable showing waypoint markers"); - print(EnumChatFormatting.YELLOW + - "/neusouls clear/unclear - Marks every waypoint in your current world as completed/uncompleted"); - print(""); - } - @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true) public void onChatReceived(ClientChatReceivedEvent event) { if (!trackSouls || event.type == 2) return; @@ -407,53 +392,4 @@ public class FairySouls { markClosestSoulFound(); } } - - public static class FairySoulsCommand extends ClientCommandBase { - public FairySoulsCommand() { - super("neusouls"); - } - - @Override - public List<String> getCommandAliases() { - return Collections.singletonList("fairysouls"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length != 1) { - printHelp(); - return; - } - - String subcommand = args[0].toLowerCase(); - switch (subcommand) { - case "help": - printHelp(); - break; - case "on": - case "enable": - if (!FairySouls.instance.trackSouls) { - print( - EnumChatFormatting.RED + "Fairy soul tracking is off, enable it using /neu before using this command"); - return; - } - print(EnumChatFormatting.DARK_PURPLE + "Enabled fairy soul waypoints"); - FairySouls.getInstance().setShowFairySouls(true); - break; - case "off": - case "disable": - FairySouls.getInstance().setShowFairySouls(false); - print(EnumChatFormatting.DARK_PURPLE + "Disabled fairy soul waypoints"); - break; - case "clear": - FairySouls.getInstance().markAllAsFound(); - break; - case "unclear": - FairySouls.getInstance().markAllAsMissing(); - break; - default: - print(EnumChatFormatting.RED + "Unknown subcommand: " + subcommand); - } - } - } } |