diff options
| author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-27 11:53:57 -0500 |
|---|---|---|
| committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-02-27 11:53:57 -0500 |
| commit | b09f774d422263ce15b97d6d0804beddf856176d (patch) | |
| tree | e542258481d7496b15679f3c329ef9e087c7d8fc /src/main/java/io/github/moulberry/notenoughupdates/commands/dev | |
| parent | 22cb02adbeb24b7ec98f843bcaba99cebe3e4f03 (diff) | |
| download | notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.tar.gz notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.tar.bz2 notenoughupdates-b09f774d422263ce15b97d6d0804beddf856176d.zip | |
feat: improve formating :)
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/commands/dev')
5 files changed, 380 insertions, 319 deletions
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 index 7d31d2d9..66da4f9f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java @@ -27,158 +27,181 @@ import java.util.concurrent.atomic.AtomicInteger; public class DevTestCommand extends ClientCommandBase { - private static final List<String> DEV_TESTERS = Arrays.asList("moulberry", "lucycoconut", "ironm00n", "ariyio", "throwpo", "lrg89", "dediamondpro"); + private static final List<String> DEV_TESTERS = + Arrays.asList("moulberry", "lucycoconut", "ironm00n", "ariyio", "throwpo", "lrg89", "dediamondpro"); - 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 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; - private final ScheduledExecutorService devES = Executors.newSingleThreadScheduledExecutor(); + private int devFailIndex = 0; + private final ScheduledExecutorService devES = Executors.newSingleThreadScheduledExecutor(); - public DevTestCommand() { - super("neudevtest"); - } + public DevTestCommand() { + super("neudevtest"); + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (!DEV_TESTERS.contains(Minecraft.getMinecraft().thePlayer.getName().toLowerCase())) { - 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++; + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (!DEV_TESTERS.contains(Minecraft.getMinecraft().thePlayer.getName().toLowerCase())) { + 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; - } - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + DEV_FAIL_STRINGS[devFailIndex++])); - return; - } + 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; + } + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + + DEV_FAIL_STRINGS[devFailIndex++])); + return; + } /*if(args.length == 1) { DupePOC.doDupe(args[0]); 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("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 >= 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("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")) { - EnumParticleTypes t = EnumParticleTypes.valueOf(args[1]); - FishingHelper.type = t; - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("dev")) { - NotEnoughUpdates.INSTANCE.config.hidden.dev = true; - 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; - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "I would never search")); - return; - } - 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); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("pansc")) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Taking panorama screenshot")); + if (args.length == 2 && args[0].equalsIgnoreCase("pt")) { + EnumParticleTypes t = EnumParticleTypes.valueOf(args[1]); + FishingHelper.type = t; + return; + } + if (args.length == 1 && args[0].equalsIgnoreCase("dev")) { + NotEnoughUpdates.INSTANCE.config.hidden.dev = true; + 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; + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + + "I would never search")); + return; + } + 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); + return; + } + if (args.length == 1 && args[0].equalsIgnoreCase("pansc")) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + + "Taking panorama screenshot")); - AtomicInteger perspective = new AtomicInteger(0); - FancyPortals.perspectiveId = 0; + AtomicInteger perspective = new AtomicInteger(0); + FancyPortals.perspectiveId = 0; - EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; - p.prevRotationYaw = p.rotationYaw = 0; - p.prevRotationPitch = p.rotationPitch = 90; - devES.schedule(new Runnable() { - @Override - public void run() { - Minecraft.getMinecraft().addScheduledTask(() -> { - ScreenShotHelper.saveScreenshot(new File("C:/Users/James/Desktop/"), "pansc-" + perspective.get() + ".png", - Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight, - Minecraft.getMinecraft().getFramebuffer()); - }); - if (perspective.incrementAndGet() >= 6) { - FancyPortals.perspectiveId = -1; - return; - } - devES.schedule(() -> { - FancyPortals.perspectiveId = perspective.get(); - if (FancyPortals.perspectiveId == 5) { - p.prevRotationYaw = p.rotationYaw = 0; - p.prevRotationPitch = p.rotationPitch = -90; - } else if (FancyPortals.perspectiveId >= 1 && FancyPortals.perspectiveId <= 4) { - float yaw = 90 * FancyPortals.perspectiveId - 180; - if (yaw > 180) yaw -= 360; - p.prevRotationYaw = p.rotationYaw = yaw; - p.prevRotationPitch = p.rotationPitch = 0; - } - devES.schedule(this, 3000L, TimeUnit.MILLISECONDS); - }, 100L, TimeUnit.MILLISECONDS); - } - }, 3000L, TimeUnit.MILLISECONDS); + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + p.prevRotationYaw = p.rotationYaw = 0; + p.prevRotationPitch = p.rotationPitch = 90; + devES.schedule(new Runnable() { + @Override + public void run() { + Minecraft.getMinecraft().addScheduledTask(() -> { + ScreenShotHelper.saveScreenshot(new File("C:/Users/James/Desktop/"), "pansc-" + perspective.get() + ".png", + Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight, + Minecraft.getMinecraft().getFramebuffer() + ); + }); + if (perspective.incrementAndGet() >= 6) { + FancyPortals.perspectiveId = -1; + return; + } + devES.schedule(() -> { + FancyPortals.perspectiveId = perspective.get(); + if (FancyPortals.perspectiveId == 5) { + p.prevRotationYaw = p.rotationYaw = 0; + p.prevRotationPitch = p.rotationPitch = -90; + } else if (FancyPortals.perspectiveId >= 1 && FancyPortals.perspectiveId <= 4) { + float yaw = 90 * FancyPortals.perspectiveId - 180; + if (yaw > 180) yaw -= 360; + p.prevRotationYaw = p.rotationYaw = yaw; + p.prevRotationPitch = p.rotationPitch = 0; + } + devES.schedule(this, 3000L, TimeUnit.MILLISECONDS); + }, 100L, TimeUnit.MILLISECONDS); + } + }, 3000L, TimeUnit.MILLISECONDS); - return; - } + return; + } /* if(args.length == 1 && args[0].equalsIgnoreCase("update")) { NEUEventListener.displayUpdateMessageIfOutOfDate(); } */ - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Executing dubious code")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + + "Executing dubious code")); /*Minecraft.getMinecraft().thePlayer.rotationYaw = 0; Minecraft.getMinecraft().thePlayer.rotationPitch = 0; Minecraft.getMinecraft().thePlayer.setPosition( Math.floor(Minecraft.getMinecraft().thePlayer.posX) + Float.parseFloat(args[0]), Minecraft.getMinecraft().thePlayer.posY, Minecraft.getMinecraft().thePlayer.posZ);*/ - //Hot reload me yay! - } + //Hot reload me yay! + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java index 35a57b2b..223e154a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java @@ -8,16 +8,16 @@ import net.minecraft.util.ResourceLocation; public class DungeonWinTestCommand extends ClientCommandBase { - public DungeonWinTestCommand() { - super("neudungeonwintest"); - } + public DungeonWinTestCommand() { + super("neudungeonwintest"); + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length > 0) { - DungeonWin.TEAM_SCORE = new ResourceLocation("notenoughupdates:dungeon_win/" + args[0].toLowerCase() + ".png"); - } + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (args.length > 0) { + DungeonWin.TEAM_SCORE = new ResourceLocation("notenoughupdates:dungeon_win/" + args[0].toLowerCase() + ".png"); + } - DungeonWin.displayWin(); - } + DungeonWin.displayWin(); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java index 9d957f88..64d64545 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java @@ -11,31 +11,32 @@ import net.minecraft.util.EnumChatFormatting; public class NullzeeSphereCommand extends ClientCommandBase { - public NullzeeSphereCommand() { - super("neuzeesphere"); - } + public NullzeeSphereCommand() { + super("neuzeesphere"); + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length != 1) { - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: /neuzeesphere [on/off] or /neuzeesphere (radius) or /neuzeesphere setCenter")); - return; - } - if (args[0].equalsIgnoreCase("on")) { - NullzeeSphere.enabled = true; - } else if (args[0].equalsIgnoreCase("off")) { - NullzeeSphere.enabled = false; - } else if (args[0].equalsIgnoreCase("setCenter")) { - EntityPlayerSP p = ((EntityPlayerSP) sender); - NullzeeSphere.centerPos = new BlockPos(p.posX, p.posY, p.posZ); - NullzeeSphere.overlayVBO = null; - } else { - try { - NullzeeSphere.size = Float.parseFloat(args[0]); - NullzeeSphere.overlayVBO = null; - } catch (Exception e) { - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Can't parse radius: " + args[0])); - } - } - } + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (args.length != 1) { + sender.addChatMessage(new ChatComponentText( + EnumChatFormatting.RED + "Usage: /neuzeesphere [on/off] or /neuzeesphere (radius) or /neuzeesphere setCenter")); + return; + } + if (args[0].equalsIgnoreCase("on")) { + NullzeeSphere.enabled = true; + } else if (args[0].equalsIgnoreCase("off")) { + NullzeeSphere.enabled = false; + } else if (args[0].equalsIgnoreCase("setCenter")) { + EntityPlayerSP p = ((EntityPlayerSP) sender); + NullzeeSphere.centerPos = new BlockPos(p.posX, p.posY, p.posZ); + NullzeeSphere.overlayVBO = null; + } else { + try { + NullzeeSphere.size = Float.parseFloat(args[0]); + NullzeeSphere.overlayVBO = null; + } catch (Exception e) { + sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Can't parse radius: " + args[0])); + } + } + } } 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 index e73fc6b1..e809ed72 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java @@ -14,39 +14,46 @@ import net.minecraft.util.EnumChatFormatting; public class PackDevCommand extends ClientCommandBase { - public PackDevCommand() { - super("neupackdev"); - } + public PackDevCommand() { + super("neupackdev"); + } - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length == 1 && args[0].equalsIgnoreCase("getnpc")) { - double distSq = 25; - EntityPlayer closestNPC = null; - EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; - for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { - if (player instanceof AbstractClientPlayer && p != player && player.getUniqueID().version() != 4) { - double dSq = player.getDistanceSq(p.posX, p.posY, p.posZ); - if (dSq < distSq) { - distSq = dSq; - closestNPC = player; - } - } - } + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + if (args.length == 1 && args[0].equalsIgnoreCase("getnpc")) { + double distSq = 25; + EntityPlayer closestNPC = null; + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { + if (player instanceof AbstractClientPlayer && p != player && player.getUniqueID().version() != 4) { + double dSq = player.getDistanceSq(p.posX, p.posY, p.posZ); + if (dSq < distSq) { + distSq = dSq; + closestNPC = player; + } + } + } - if (closestNPC == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "No NPCs found within 5 blocks :(")); - } else { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Copied entity texture id to clipboard")); - MiscUtils.copyToClipboard(((AbstractClientPlayer) closestNPC).getLocationSkin().getResourcePath().replace("skins/", "")); - } - return; - } - NotEnoughUpdates.INSTANCE.packDevEnabled = !NotEnoughUpdates.INSTANCE.packDevEnabled; - if (NotEnoughUpdates.INSTANCE.packDevEnabled) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Enabled pack developer mode.")); - } else { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Disabled pack developer mode.")); - } - } + if (closestNPC == null) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.RED + "No NPCs found within 5 blocks :(")); + } else { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.GREEN + "Copied entity texture id to clipboard")); + MiscUtils.copyToClipboard(((AbstractClientPlayer) closestNPC) + .getLocationSkin() + .getResourcePath() + .replace("skins/", "")); + } + return; + } + NotEnoughUpdates.INSTANCE.packDevEnabled = !NotEnoughUpdates.INSTANCE.packDevEnabled; + if (NotEnoughUpdates.INSTANCE.packDevEnabled) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.GREEN + "Enabled pack developer mode.")); + } else { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.RED + "Disabled pack developer mode.")); + } + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java index 98eed1be..38eafe39 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java @@ -28,124 +28,154 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class StatsCommand extends ClientCommandBase { - private final ExecutorService threadPool = Executors.newFixedThreadPool(1); - - public StatsCommand() { - super("neustats"); - } - - private static final int activeModCount = Loader.instance().getActiveModList().size(); - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (args.length > 0) { - switch (args[0].toLowerCase(Locale.ROOT)) { - case "modlist": - if (activeModCount > 15) { - clipboardAndSendMessage(createModList(new DiscordMarkdownBuilder()).toString()); - } else { - clipboardAndSendMessage(createStats()); - } - break; - case "dump": - modPrefixedMessage(EnumChatFormatting.GREEN + "This will upload a dump of the java classes your game has loaded how big they are and how many there are. This can take a few seconds as it is uploading to HasteBin."); - threadPool.submit(() -> { - try { - final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); - final ObjectName objectName = ObjectName.getInstance("com.sun.management:type=DiagnosticCommand"); - final DiagnosticCommandMXBean proxy = JMX.newMXBeanProxy(server, objectName, DiagnosticCommandMXBean.class); - clipboardAndSendMessage(HastebinUploader.upload(proxy.gcClassHistogram(new String[0]).replace("[", "[]"), HastebinUploader.Mode.NORMAL)); - } catch (Exception e) { - clipboardAndSendMessage(null); - } - }); - break; - } - } else { - clipboardAndSendMessage(createStats()); - } - - } - - @Override - public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { - return args.length == 1 ? getListOfStringsMatchingLastWord(args, "modlist", "dump") : null; - } - - public interface DiagnosticCommandMXBean { - String gcClassHistogram(String[] array); - } - - private static void clipboardAndSendMessage(String data) { - if (data == null) { - modPrefixedMessage(EnumChatFormatting.DARK_RED + "Error occurred trying to perform command."); - return; - } - try { - StringSelection clipboard = new StringSelection(data); - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard); - modPrefixedMessage(EnumChatFormatting.GREEN + "Dev info copied to clipboard."); - } catch (Exception ignored) { - modPrefixedMessage(EnumChatFormatting.DARK_RED + "Could not copy to clipboard."); - } - } - - private static void modPrefixedMessage(String message) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "[" + EnumChatFormatting.RED + "NotEnoughUpdates" + EnumChatFormatting.GOLD + "]: " + message)); - - } - - private static String createStats() { - DiscordMarkdownBuilder builder = new DiscordMarkdownBuilder(); - long maxMemory = Runtime.getRuntime().maxMemory(); - long totalMemory = Runtime.getRuntime().totalMemory(); - long freeMemory = Runtime.getRuntime().freeMemory(); - long currentMemory = totalMemory - freeMemory; - - builder.category("System Stats"); - builder.append("OS", System.getProperty("os.name")); - builder.append("CPU", OpenGlHelper.getCpu()); - builder.append("Display", String.format("%dx%d (%s)", Display.getWidth(), Display.getHeight(), GL11.glGetString(GL11.GL_VENDOR))); - builder.append("GPU", GL11.glGetString(GL11.GL_RENDERER)); - builder.append("GPU Driver", GL11.glGetString(GL11.GL_VERSION)); - if (getMemorySize() > 0) builder.append("Maximum Memory", (getMemorySize() / 1024L / 1024L) + "MB"); - builder.append("Shaders", ("" + OpenGlHelper.isFramebufferEnabled()).toUpperCase()); - builder.category("Java Stats"); - builder.append("Java", String.format("%s %dbit", System.getProperty("java.version"), Minecraft.getMinecraft().isJava64bit() ? 64 : 32)); - builder.append("Memory", String.format("% 2d%% %03d/%03dMB", currentMemory * 100L / maxMemory, currentMemory / 1024L / 1024L, maxMemory / 1024L / 1024L)); - builder.append("Memory Allocated", String.format("% 2d%% %03dMB", totalMemory * 100L / maxMemory, totalMemory / 1024L / 1024L)); - builder.category("Game Stats"); - builder.append("FPS", String.valueOf(Minecraft.getDebugFPS())); - builder.append("Loaded Mods", String.valueOf(activeModCount)); - builder.append("Forge", ForgeVersion.getVersion()); - builder.category("Neu Settings"); - builder.append("API Key", NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.isEmpty() ? "FALSE" : "TRUE"); - builder.append("On Skyblock", NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ? "TRUE" : "FALSE"); - builder.append("Mod Version", Loader.instance().getIndexedModList().get(NotEnoughUpdates.MODID).getDisplayVersion()); - builder.append("SB Profile", SBInfo.getInstance().currentProfile); - builder.append("Has Advanced Tab", SBInfo.getInstance().hasNewTab ? "TRUE" : "FALSE"); - builder.category("Repo Stats"); - builder.append("Last Commit", NotEnoughUpdates.INSTANCE.manager.latestRepoCommit); - builder.append("Loaded Items", String.valueOf(NotEnoughUpdates.INSTANCE.manager.getItemInformation().size())); - if (activeModCount <= 15) createModList(builder); - - return builder.toString(); - } - - private static DiscordMarkdownBuilder createModList(DiscordMarkdownBuilder builder) { - builder.category("Mods Loaded"); - Loader.instance().getActiveModList().forEach(mod -> builder.append(mod.getName(), mod.getSource().getName())); - return builder; - } - - private static long getMemorySize() { - try { - return ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize(); - } catch (Exception e) { - try { - return ((com.sun.management.UnixOperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize(); - } catch (Exception ignored) {/*IGNORE*/} - } - return -1; - } + private final ExecutorService threadPool = Executors.newFixedThreadPool(1); + + public StatsCommand() { + super("neustats"); + } + + private static final int activeModCount = Loader.instance().getActiveModList().size(); + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (args.length > 0) { + switch (args[0].toLowerCase(Locale.ROOT)) { + case "modlist": + if (activeModCount > 15) { + clipboardAndSendMessage(createModList(new DiscordMarkdownBuilder()).toString()); + } else { + clipboardAndSendMessage(createStats()); + } + break; + case "dump": + modPrefixedMessage(EnumChatFormatting.GREEN + + "This will upload a dump of the java classes your game has loaded how big they are and how many there are. This can take a few seconds as it is uploading to HasteBin."); + threadPool.submit(() -> { + try { + final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + final ObjectName objectName = ObjectName.getInstance("com.sun.management:type=DiagnosticCommand"); + final DiagnosticCommandMXBean proxy = JMX.newMXBeanProxy( + server, + objectName, + DiagnosticCommandMXBean.class + ); + clipboardAndSendMessage(HastebinUploader.upload( + proxy.gcClassHistogram(new String[0]).replace("[", "[]"), + HastebinUploader.Mode.NORMAL + )); + } catch (Exception e) { + clipboardAndSendMessage(null); + } + }); + break; + } + } else { + clipboardAndSendMessage(createStats()); + } + + } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + return args.length == 1 ? getListOfStringsMatchingLastWord(args, "modlist", "dump") : null; + } + + public interface DiagnosticCommandMXBean { + String gcClassHistogram(String[] array); + } + + private static void clipboardAndSendMessage(String data) { + if (data == null) { + modPrefixedMessage(EnumChatFormatting.DARK_RED + "Error occurred trying to perform command."); + return; + } + try { + StringSelection clipboard = new StringSelection(data); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard); + modPrefixedMessage(EnumChatFormatting.GREEN + "Dev info copied to clipboard."); + } catch (Exception ignored) { + modPrefixedMessage(EnumChatFormatting.DARK_RED + "Could not copy to clipboard."); + } + } + + private static void modPrefixedMessage(String message) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.GOLD + "[" + EnumChatFormatting.RED + "NotEnoughUpdates" + EnumChatFormatting.GOLD + "]: " + + message)); + + } + + private static String createStats() { + DiscordMarkdownBuilder builder = new DiscordMarkdownBuilder(); + long maxMemory = Runtime.getRuntime().maxMemory(); + long totalMemory = Runtime.getRuntime().totalMemory(); + long freeMemory = Runtime.getRuntime().freeMemory(); + long currentMemory = totalMemory - freeMemory; + + builder.category("System Stats"); + builder.append("OS", System.getProperty("os.name")); + builder.append("CPU", OpenGlHelper.getCpu()); + builder.append( + "Display", + String.format("%dx%d (%s)", Display.getWidth(), Display.getHeight(), GL11.glGetString(GL11.GL_VENDOR)) + ); + builder.append("GPU", GL11.glGetString(GL11.GL_RENDERER)); + builder.append("GPU Driver", GL11.glGetString(GL11.GL_VERSION)); + if (getMemorySize() > 0) builder.append("Maximum Memory", (getMemorySize() / 1024L / 1024L) + "MB"); + builder.append("Shaders", ("" + OpenGlHelper.isFramebufferEnabled()).toUpperCase()); + builder.category("Java Stats"); + builder.append( + "Java", + String.format("%s %dbit", System.getProperty("java.version"), Minecraft.getMinecraft().isJava64bit() ? 64 : 32) + ); + builder.append( + "Memory", + String.format( + "% 2d%% %03d/%03dMB", + currentMemory * 100L / maxMemory, + currentMemory / 1024L / 1024L, + maxMemory / 1024L / 1024L + ) + ); + builder.append( + "Memory Allocated", + String.format("% 2d%% %03dMB", totalMemory * 100L / maxMemory, totalMemory / 1024L / 1024L) + ); + builder.category("Game Stats"); + builder.append("FPS", String.valueOf(Minecraft.getDebugFPS())); + builder.append("Loaded Mods", String.valueOf(activeModCount)); + builder.append("Forge", ForgeVersion.getVersion()); + builder.category("Neu Settings"); + builder.append("API Key", NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.isEmpty() ? "FALSE" : "TRUE"); + builder.append("On Skyblock", NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ? "TRUE" : "FALSE"); + builder.append( + "Mod Version", + Loader.instance().getIndexedModList().get(NotEnoughUpdates.MODID).getDisplayVersion() + ); + builder.append("SB Pro |
