diff options
author | bowser0000 <bowser0000@gmail.com> | 2021-06-29 15:22:02 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2021-06-29 15:22:02 -0400 |
commit | 647728fb3945fa4c3ac5e74026343d1a4d5024a7 (patch) | |
tree | 0b4ab2f25756dfb750f2a16c3a30dc5971d942e7 /src/main/java/me/Danker | |
parent | 1b1cb67e9ed9023b62095313297d510e73a44d53 (diff) | |
download | SkyblockMod-647728fb3945fa4c3ac5e74026343d1a4d5024a7.tar.gz SkyblockMod-647728fb3945fa4c3ac5e74026343d1a4d5024a7.tar.bz2 SkyblockMod-647728fb3945fa4c3ac5e74026343d1a4d5024a7.zip |
Add command to reload repo
Diffstat (limited to 'src/main/java/me/Danker')
-rw-r--r-- | src/main/java/me/Danker/DankersSkyblockMod.java | 1 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/DHelpCommand.java | 2 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/ReloadRepoCommand.java | 53 |
3 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 92c30e7..937b411 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -195,6 +195,7 @@ public class DankersSkyblockMod { ClientCommandHandler.instance.registerCommand(new PetsCommand()); ClientCommandHandler.instance.registerCommand(new PlayerCommand()); ClientCommandHandler.instance.registerCommand(new ReloadConfigCommand()); + ClientCommandHandler.instance.registerCommand(new ReloadRepoCommand()); ClientCommandHandler.instance.registerCommand(new ResetLootCommand()); ClientCommandHandler.instance.registerCommand(new ScaleCommand()); ClientCommandHandler.instance.registerCommand(new SetkeyCommand()); diff --git a/src/main/java/me/Danker/commands/DHelpCommand.java b/src/main/java/me/Danker/commands/DHelpCommand.java index 4d595e5..42a82c4 100644 --- a/src/main/java/me/Danker/commands/DHelpCommand.java +++ b/src/main/java/me/Danker/commands/DHelpCommand.java @@ -57,6 +57,8 @@ public class DHelpCommand extends CommandBase { EnumChatFormatting.GOLD + RepartyCommand.usage(arg0) + EnumChatFormatting.AQUA + " - Disbands and reparties all members in the party.\n" + EnumChatFormatting.GOLD + CustomMusicCommand.usage(arg0) + EnumChatFormatting.AQUA + " - Stops or reloads the custom music.\n" + EnumChatFormatting.GOLD + PlayerCommand.usage(arg0) + EnumChatFormatting.AQUA + " - Uses API to find skills, slayers, coins and weight of a player.\n" + + EnumChatFormatting.GOLD + ReloadConfigCommand.usage(arg0) + EnumChatFormatting.AQUA + " - Reloads Danker's Skyblock Mod config.\n" + + EnumChatFormatting.GOLD + ReloadRepoCommand.usage(arg0) + EnumChatFormatting.AQUA + " - Reloads Danker's Skyblock Mod repository.\n" + EnumChatFormatting.GREEN + " Open Maddox Menu" + EnumChatFormatting.AQUA + " - M by default.\n" + EnumChatFormatting.GREEN + " Start/Stop Skill Tracker" + EnumChatFormatting.AQUA + " - Numpad 5 by default.\n")); } diff --git a/src/main/java/me/Danker/commands/ReloadRepoCommand.java b/src/main/java/me/Danker/commands/ReloadRepoCommand.java new file mode 100644 index 0000000..1681971 --- /dev/null +++ b/src/main/java/me/Danker/commands/ReloadRepoCommand.java @@ -0,0 +1,53 @@ +package me.Danker.commands; + +import me.Danker.DankersSkyblockMod; +import me.Danker.features.ColouredNames; +import me.Danker.handlers.APIHandler; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; + +import java.util.ArrayList; +import java.util.Map; +import java.util.stream.Collectors; + +public class ReloadRepoCommand extends CommandBase { + + @Override + public String getCommandName() { + return "reloaddsmrepo"; + } + + @Override + public String getCommandUsage(ICommandSender arg0) { + return "/" + getCommandName(); + } + + public static String usage(ICommandSender arg0) { + return new ReloadRepoCommand().getCommandUsage(arg0); + } + + @Override + public int getRequiredPermissionLevel() { + return 0; + } + + @Override + public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { + // MULTI THREAD DRIFTING + new Thread(() -> { + EntityPlayer player = (EntityPlayer) arg0; + + DankersSkyblockMod.data = APIHandler.getResponse("https://raw.githubusercontent.com/bowser0000/SkyblockMod-REPO/main/data.json"); + System.out.println("Loaded data from GitHub?: " + (DankersSkyblockMod.data != null && DankersSkyblockMod.data.has("trivia"))); + ColouredNames.users = DankersSkyblockMod.data.get("colourednames").getAsJsonObject().entrySet().stream() + .map(Map.Entry::getKey) + .collect(Collectors.toCollection(ArrayList::new)); + + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.MAIN_COLOUR + "Refreshed Danker's Skyblock Mod repo.")); + }).start(); + } + +} |