diff options
Diffstat (limited to 'src')
9 files changed, 176 insertions, 143 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java index a2207c6b..b4a4f161 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java @@ -8,35 +8,27 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiErrorScreen; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.launchwrapper.LaunchClassLoader; import net.minecraft.util.IChatComponent; import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.apache.commons.io.IOUtils; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; -import java.io.*; +import java.io.File; +import java.io.IOException; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; -@Mod(modid = DungeonsGuide.MODID, version = DungeonsGuide.VERSION) -public class DungeonsGuide -{ - public static final String MODID = "skyblock_dungeons_guide"; - public static final String VERSION = "0.1"; +public class DungeonsGuide implements DungeonsGuideInterface { + + private SkyblockStatus skyblockStatus; - private Object skyblockStatus; - private static DungeonsGuide dungeonsGuide; public static boolean DEBUG = false; @@ -46,111 +38,48 @@ public class DungeonsGuide Minecraft.getMinecraft().thePlayer.addChatMessage(iChatComponent); } - @EventHandler public void init(FMLInitializationEvent event) { - Thread.currentThread().setContextClassLoader(classLoader); + dungeonsGuide = this; + skyblockStatus = new SkyblockStatus(); - Class skyblockStatusCls = null; - try { - skyblockStatusCls = classLoader.findClass("kr.syeyoung.dungeonsguide.SkyblockStatus"); - } catch (ClassNotFoundException e) { - e.printStackTrace(); + MinecraftForge.EVENT_BUS.register(new EventListener()); + CommandEditRoom cc = new CommandEditRoom(); + ClientCommandHandler.instance.registerCommand(cc); + MinecraftForge.EVENT_BUS.register(cc); + ClientCommandHandler.instance.registerCommand(new CommandLoadData()); + ClientCommandHandler.instance.registerCommand(new CommandSaveData()); + ClientCommandHandler.instance.registerCommand(new CommandToggleDebug()); + ClientCommandHandler.instance.registerCommand(new CommandWhatYearIsIt()); - error(new String[]{ - "Couldn't load Dungeons Guide", - "Please contact developer if this problem persists after restart" - }); - return; - } - - dungeonsGuide = this; try { - skyblockStatus = skyblockStatusCls.newInstance(); - } catch (InstantiationException e) { + DungeonRoomInfoRegistry.loadAll(); + } catch (BadPaddingException e) { e.printStackTrace(); - - error(new String[]{ - "Couldn't load Dungeons Guide", - "Please contact developer if this problem persists after restart" - }); - } catch (IllegalAccessException e) { + } catch (InvalidAlgorithmParameterException e) { + e.printStackTrace(); + } catch (NoSuchAlgorithmException e) { e.printStackTrace(); - - error(new String[]{ - "Couldn't load Dungeons Guide", - "Please contact developer if this problem persists after restart" - }); - } - } - - @Getter - private File configDir; - - @Getter - private Authenticator authenticator; - private NetworkClassLoader classLoader; - @EventHandler - public void pre(FMLPreInitializationEvent event) { - System.out.println(DungeonsGuide.class.getClassLoader()); - configDir = new File(event.getModConfigurationDirectory(),"dungeonsguide"); - - authenticator = new Authenticator(); - String token = null; - try { - token = authenticator.authenticate(); - System.out.println(token); - if (token != null) { - classLoader = new NetworkClassLoader(authenticator, DungeonsGuide.class.getClassLoader()); - return; - } } catch (IOException e) { e.printStackTrace(); - } catch (AuthenticationException e) { + } catch (IllegalBlockSizeException e) { e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { + } catch (NoSuchPaddingException e) { + e.printStackTrace(); + } catch (InvalidKeyException e) { e.printStackTrace(); } - error(new String[]{ - "Can't validate current installation of Dungeons Guide", - "Please contact mod author if you purchased this mod and getting this error", - "And if you haven't purchased the mod, please consider doing so" - }); + Keybinds.register(); + } + public void pre(FMLPreInitializationEvent event) { + configDir = new File(event.getModConfigurationDirectory(),"dungeonsguide"); } - public void error(final String[] s_msg) { - final GuiScreen errorGui = new GuiErrorScreen(null, null) { - - @Override - public void handleMouseInput() { - } - - @Override - public void handleKeyboardInput() { - } - - @Override - public void drawScreen(int par1, int par2, float par3) { - drawDefaultBackground(); - for (int i = 0; i < s_msg.length; ++i) { - drawCenteredString(fontRendererObj, s_msg[i], width / 2, height / 3 + 12 * i, 0xFFFFFFFF); - } - } - }; - @SuppressWarnings("serial") CustomModLoadingErrorDisplayException e = new CustomModLoadingErrorDisplayException() { + @Getter + private File configDir; - @Override - public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) { - Minecraft.getMinecraft().displayGuiScreen(errorGui); - } - @Override - public void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime) { - } - }; - throw e; - } public Object getSkyblockStatus() { return (SkyblockStatus) skyblockStatus; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuideInterface.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuideInterface.java new file mode 100644 index 00000000..48d58d5b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuideInterface.java @@ -0,0 +1,10 @@ +package kr.syeyoung.dungeonsguide; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public interface DungeonsGuideInterface { + public void init(FMLInitializationEvent event); + + public void pre(FMLPreInitializationEvent event); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuideMain.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuideMain.java new file mode 100644 index 00000000..1c35524d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuideMain.java @@ -0,0 +1,133 @@ +package kr.syeyoung.dungeonsguide; + +import com.mojang.authlib.exceptions.AuthenticationException; +import lombok.Getter; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiErrorScreen; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +import java.io.*; +import java.security.NoSuchAlgorithmException; + +@Mod(modid = DungeonsGuideMain.MODID, version = DungeonsGuideMain.VERSION) +public class DungeonsGuideMain +{ + public static final String MODID = "skyblock_dungeons_guide"; + public static final String VERSION = "0.1"; + + private static DungeonsGuideMain DungeonsGuideMain; + + private DungeonsGuideInterface dungeonsGuideInterface; + + @EventHandler + public void init(FMLInitializationEvent event) + { + + DungeonsGuideMain = this; + + dungeonsGuideInterface.init(event); + } + + @Getter + private Authenticator authenticator; + private NetworkClassLoader classLoader; + @EventHandler + public void pre(FMLPreInitializationEvent event) { + authenticator = new Authenticator(); + String token = null; + try { + token = authenticator.authenticate(); + System.out.println(token); + if (token != null) { + classLoader = new NetworkClassLoader(authenticator, DungeonsGuide.class.getClassLoader()); + + Class skyblockStatusCls = null; + try { + skyblockStatusCls = classLoader.findClass("kr.syeyoung.dungeonsguide.DungeonsGuide"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + + error(new String[]{ + "Couldn't load Dungeons Guide", + "Please contact developer if this problem persists after restart" + }); + return; + } + try { + dungeonsGuideInterface = (DungeonsGuideInterface) skyblockStatusCls.newInstance(); + dungeonsGuideInterface.pre(event); + } catch (InstantiationException e) { + e.printStackTrace(); + + error(new String[]{ + "Couldn't load Dungeons Guide", + "Please contact developer if this problem persists after restart" + }); + } catch (IllegalAccessException e) { + e.printStackTrace(); + + error(new String[]{ + "Couldn't load Dungeons Guide", + "Please contact developer if this problem persists after restart" + }); + } + return; + } + } catch (IOException e) { + e.printStackTrace(); + } catch (AuthenticationException e) { + e.printStackTrace(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + + error(new String[]{ + "Can't validate current installation of Dungeons Guide", + "Please contact mod author if you purchased this mod and getting this error", + "And if you haven't purchased the mod, please consider doing so" + }); + } + + public void error(final String[] s_msg) { + final GuiScreen errorGui = new GuiErrorScreen(null, null) { + + @Override + public void handleMouseInput() { + } + + @Override + public void handleKeyboardInput() { + } + + @Override + public void drawScreen(int par1, int par2, float par3) { + drawDefaultBackground(); + for (int i = 0; i < s_msg.length; ++i) { + drawCenteredString(fontRendererObj, s_msg[i], width / 2, height / 3 + 12 * i, 0xFFFFFFFF); + } + } + }; + @SuppressWarnings("serial") CustomModLoadingErrorDisplayException e = new CustomModLoadingErrorDisplayException() { + + @Override + public void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer) { + Minecraft.getMinecraft().displayGuiScreen(errorGui); + } + + @Override + public void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime) { + } + }; + throw e; + } + public static DungeonsGuideMain getDungeonsGuideMain() { + return DungeonsGuideMain; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java index defe1339..136b3d55 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java @@ -1,7 +1,6 @@ package kr.syeyoung.dungeonsguide; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; -import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; @@ -23,11 +22,9 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; -import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.GL11; import java.awt.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java b/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java index 2710a5b2..c64ecef6 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java @@ -40,37 +40,6 @@ public class SkyblockStatus { private final Pattern SERVER_BRAND_PATTERN = Pattern.compile("(.+) <- (?:.+)"); - public SkyblockStatus() { - MinecraftForge.EVENT_BUS.register(new EventListener()); - CommandEditRoom cc = new CommandEditRoom(); - ClientCommandHandler.instance.registerCommand(cc); - MinecraftForge.EVENT_BUS.register(cc); - ClientCommandHandler.instance.registerCommand(new CommandLoadData()); - ClientCommandHandler.instance.registerCommand(new CommandSaveData()); - ClientCommandHandler.instance.registerCommand(new CommandToggleDebug()); - ClientCommandHandler.instance.registerCommand(new CommandWhatYearIsIt()); - - try { - DungeonRoomInfoRegistry.loadAll(); - } catch (BadPaddingException e) { - e.printStackTrace(); - } catch (InvalidAlgorithmParameterException e) { - e.printStackTrace(); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (IllegalBlockSizeException e) { - e.printStackTrace(); - } catch (NoSuchPaddingException e) { - e.printStackTrace(); - } catch (InvalidKeyException e) { - e.printStackTrace(); - } - - Keybinds.register(); - } - public boolean isOnHypixel() { Minecraft mc = Minecraft.getMinecraft(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandLoadData.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandLoadData.java index 637ec398..4705259f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandLoadData.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandLoadData.java @@ -1,6 +1,5 @@ package kr.syeyoung.dungeonsguide.commands; -import kr.syeyoung.dungeonsguide.DungeonsGuide; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandToggleDebug.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandToggleDebug.java index 6a17fba6..cf1ff459 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandToggleDebug.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandToggleDebug.java @@ -1,7 +1,6 @@ package kr.syeyoung.dungeonsguide.commands; import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.util.ChatComponentText; @@ -20,7 +19,7 @@ public class CommandToggleDebug extends CommandBase { @Override public void processCommand(ICommandSender sender, String[] args) { DungeonsGuide.DEBUG = !DungeonsGuide.DEBUG; - sender.addChatMessage(new ChatComponentText("Toggled Debug mode to "+DungeonsGuide.DEBUG)); + sender.addChatMessage(new ChatComponentText("Toggled Debug mode to "+ DungeonsGuide.DEBUG)); } @Override public int getRequiredPermissionLevel() { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java index 2fc225df..b96e4366 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java @@ -2,6 +2,7 @@ package kr.syeyoung.dungeonsguide.dungeon.roomfinder; import kr.syeyoung.dungeonsguide.Authenticator; import kr.syeyoung.dungeonsguide.DungeonsGuide; +import kr.syeyoung.dungeonsguide.DungeonsGuideMain; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import javax.crypto.BadPaddingException; @@ -66,7 +67,7 @@ public class DungeonRoomInfoRegistry { registered.clear(); shapeMap.clear(); uuidMap.clear(); - Authenticator authenticator = DungeonsGuide.getDungeonsGuide().getAuthenticator(); + Authenticator authenticator = DungeonsGuideMain.getDungeonsGuideMain().getAuthenticator(); InputStream inputStream = authenticator.getInputStream("roomdata/datas.txt"); inputStream.read(new byte[4]); BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/SwitchData.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/SwitchData.java index 79c25f52..0580c226 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/SwitchData.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/waterpuzzle/SwitchData.java @@ -1,13 +1,9 @@ package kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle; -import kr.syeyoung.dungeonsguide.DungeonsGuide; -import kr.syeyoung.dungeonsguide.SkyblockStatus; -import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes.WaterNodeStart; import kr.syeyoung.dungeonsguide.roomprocessor.waterpuzzle.nodes.WaterNodeToggleable; import lombok.AllArgsConstructor; import lombok.Data; -import net.minecraft.block.BlockLever; import net.minecraft.util.BlockPos; import net.minecraft.world.World; |