From fb84910e77e11bb747f7276aeaf3241942b68e22 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Fri, 8 Jul 2022 15:44:27 +0200 Subject: Rename .java to .kt --- src/main/java/at/lorenz/mod/LorenzMod.java | 215 +++++++++++++++++++++ .../com/thatgravyboat/skyblockhud/LorenzMod.java | 215 --------------------- 2 files changed, 215 insertions(+), 215 deletions(-) create mode 100644 src/main/java/at/lorenz/mod/LorenzMod.java delete mode 100644 src/main/java/com/thatgravyboat/skyblockhud/LorenzMod.java diff --git a/src/main/java/at/lorenz/mod/LorenzMod.java b/src/main/java/at/lorenz/mod/LorenzMod.java new file mode 100644 index 000000000..31044a3c7 --- /dev/null +++ b/src/main/java/at/lorenz/mod/LorenzMod.java @@ -0,0 +1,215 @@ +package com.thatgravyboat.skyblockhud; + +import at.lorenz.mod.HideNotClickableItems; +import at.lorenz.mod.ItemDisplayOverlayFeatures; +import at.lorenz.mod.bazaar.BazaarApi; +import at.lorenz.mod.bazaar.BazaarOrderHelper; +import at.lorenz.mod.chat.ChatFilter; +import at.lorenz.mod.chat.ChatManager; +import at.lorenz.mod.chat.PlayerChatFilter; +import at.lorenz.mod.config.Features; +import at.lorenz.mod.dungeon.DungeonChatFilter; +import at.lorenz.mod.dungeon.DungeonHighlightClickedBlocks; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.thatgravyboat.skyblockhud.commands.Commands; +import com.thatgravyboat.skyblockhud.config.SBHConfig; +import com.thatgravyboat.skyblockhud.textures.Textures; +import java.io.*; +import java.nio.charset.StandardCharsets; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.IReloadableResourceManager; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +@Mod(modid = LorenzMod.MODID, version = LorenzMod.VERSION) +public class LorenzMod { + + public static final String MODID = "lorenzmod"; + public static final String VERSION = "0.2.1"; + + @Deprecated + public static SBHConfig config; //TODO delete + + public static Features feature; + private File configFile; + + // private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK", "\u7A7A\u5C9B\u751F\u5B58"); + + private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); + + public static File configDirectory; + + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + new BazaarApi(); + MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.register(new ChatManager()); + + MinecraftForge.EVENT_BUS.register(new BazaarOrderHelper()); + MinecraftForge.EVENT_BUS.register(new ChatFilter()); + MinecraftForge.EVENT_BUS.register(new PlayerChatFilter()); + MinecraftForge.EVENT_BUS.register(new DungeonChatFilter()); + MinecraftForge.EVENT_BUS.register(new HideNotClickableItems()); + MinecraftForge.EVENT_BUS.register(new DungeonHighlightClickedBlocks()); + MinecraftForge.EVENT_BUS.register(new ItemDisplayOverlayFeatures()); + + Commands.init(); + + // MinecraftForge.EVENT_BUS.register(new LeaderboardGetter()); + // MinecraftForge.EVENT_BUS.register(new SeasonDateHandler()); + // MinecraftForge.EVENT_BUS.register(new LocationHandler()); + // MinecraftForge.EVENT_BUS.register(new IslandHandler()); + // MinecraftForge.EVENT_BUS.register(new TimeHandler()); + // MinecraftForge.EVENT_BUS.register(new CurrencyHandler()); + // MinecraftForge.EVENT_BUS.register(new SlayerHandler()); + // MinecraftForge.EVENT_BUS.register(new DungeonHandler()); + // MinecraftForge.EVENT_BUS.register(new MinesHandler()); + // MinecraftForge.EVENT_BUS.register(new FarmingIslandHandler()); + // + // MinecraftForge.EVENT_BUS.register(new TrackerHandler()); + // MinecraftForge.EVENT_BUS.register(new KillTracking()); + // + // MinecraftForge.EVENT_BUS.register(new HeldItemHandler()); + // + // ClientRegistry.registerKeyBinding(KeyBindings.map); + // + // MinecraftForge.EVENT_BUS.register(new ComponentHandler()); + // MinecraftForge.EVENT_BUS.register(new ActionBarParsing()); + // MinecraftForge.EVENT_BUS.register(new CrystalWaypoints()); + // MinecraftForge.EVENT_BUS.register(new FarmHouseHandler()); + // MinecraftForge.EVENT_BUS.register(new WarpHandler()); + // MinecraftForge.EVENT_BUS.register(new CooldownHandler()); + + // + // ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new NpcDialogue()); + ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new Textures()); + // + configDirectory = new File("mods/LorenzMod/config"); + try { + //noinspection ResultOfMethodCallIgnored + configDirectory.mkdir(); + } catch (Exception ignored) {} + + configFile = new File(configDirectory, "config.json"); + + if (configFile.exists()) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { + feature = gson.fromJson(reader, Features.class); + } catch (Exception ignored) {} + } + + if (feature == null) { + feature = new Features(); + saveConfig(); + } + // + // Textures.setTexture(config.misc.style); + // + // if (WarpHandler.load()) { + // WarpHandler.save(); + // } + // + Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig)); + // Runtime.getRuntime().addShutdownHook(new Thread(TrackerFileLoader::saveTrackerStatsFile)); + } + + public void saveConfig() { + try { + //noinspection ResultOfMethodCallIgnored + configFile.createNewFile(); + + try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { + writer.write(gson.toJson(feature)); + } + } catch (IOException ignored) {} + } + + // @EventHandler + // public void postInit(FMLPostInitializationEvent event) { + // MinecraftForge.EVENT_BUS.register(new OverlayHud()); + // MinecraftForge.EVENT_BUS.register(new RPGHud()); + // MinecraftForge.EVENT_BUS.register(new DungeonOverlay()); + // MinecraftForge.EVENT_BUS.register(new BossbarHandler()); + // MinecraftForge.EVENT_BUS.register(new MapHandler()); + // MinecraftForge.EVENT_BUS.register(new MiningHud()); + // MinecraftForge.EVENT_BUS.register(new NpcDialogue()); + // } + + // @EventHandler + // public void loadComplete(FMLLoadCompleteEvent event) { + // TrackerFileLoader.loadTrackersFile(); + // + // if (TrackerFileLoader.loadTrackerStatsFile()) { + // TrackerFileLoader.saveTrackerStatsFile(); + // } + // } + + // @SubscribeEvent + // public void onLeaveServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { + // TrackerFileLoader.saveTrackerStatsFile(); + // } + + public static boolean hasSkyblockScoreboard() { + // Minecraft mc = Minecraft.getMinecraft(); + // + // if (mc != null && mc.theWorld != null) { + // Scoreboard scoreboard = mc.theWorld.getScoreboard(); + // ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); + // if (sidebarObjective != null) { + // String objectiveName = sidebarObjective.getDisplayName().replaceAll("(?i)\\u00A7.", ""); + // for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) { + // if (objectiveName.startsWith(skyblock)) { + // return true; + // } + // } + // } + // } + + return false; + } + + // @SubscribeEvent + // public void onTooltip(ItemTooltipEvent event) { + // if (event.itemStack != null && Keyboard.isKeyDown(Keyboard.KEY_BACKSLASH)) { + // try { + // StringSelection clipboard = new StringSelection(event.itemStack.serializeNBT().toString()); + // Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard); + // } catch (Exception ignored) {} + // } + // } + + // @SubscribeEvent(priority = EventPriority.HIGHEST) + // public void onStatusBar(ClientChatReceivedEvent event) { + // String message = Utils.removeColor(event.message.getUnformattedText()).toLowerCase().trim(); + // + // if (message.startsWith("your profile was changed to:")) { + // String stripped = message.replace("your profile was changed to:", "").replace("(co-op)", "").trim(); + // MinecraftForge.EVENT_BUS.post(new ProfileSwitchedEvent(stripped)); + // } + // if (message.startsWith("you are playing on profile:")) { + // String stripped = message.replace("you are playing on profile:", "").replace("(co-op)", "").trim(); + // MinecraftForge.EVENT_BUS.post(new ProfileJoinedEvent(stripped)); + // } + // } + + public static GuiScreen screenToOpen = null; + private static int screenTicks = 0; + + @SubscribeEvent + public void onClientTick(TickEvent.ClientTickEvent event) { + if (screenToOpen != null) { + screenTicks++; + if (screenTicks == 5) { + Minecraft.getMinecraft().displayGuiScreen(screenToOpen); + screenTicks = 0; + screenToOpen = null; + } + } + } +} diff --git a/src/main/java/com/thatgravyboat/skyblockhud/LorenzMod.java b/src/main/java/com/thatgravyboat/skyblockhud/LorenzMod.java deleted file mode 100644 index 31044a3c7..000000000 --- a/src/main/java/com/thatgravyboat/skyblockhud/LorenzMod.java +++ /dev/null @@ -1,215 +0,0 @@ -package com.thatgravyboat.skyblockhud; - -import at.lorenz.mod.HideNotClickableItems; -import at.lorenz.mod.ItemDisplayOverlayFeatures; -import at.lorenz.mod.bazaar.BazaarApi; -import at.lorenz.mod.bazaar.BazaarOrderHelper; -import at.lorenz.mod.chat.ChatFilter; -import at.lorenz.mod.chat.ChatManager; -import at.lorenz.mod.chat.PlayerChatFilter; -import at.lorenz.mod.config.Features; -import at.lorenz.mod.dungeon.DungeonChatFilter; -import at.lorenz.mod.dungeon.DungeonHighlightClickedBlocks; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.thatgravyboat.skyblockhud.commands.Commands; -import com.thatgravyboat.skyblockhud.config.SBHConfig; -import com.thatgravyboat.skyblockhud.textures.Textures; -import java.io.*; -import java.nio.charset.StandardCharsets; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.resources.IReloadableResourceManager; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -@Mod(modid = LorenzMod.MODID, version = LorenzMod.VERSION) -public class LorenzMod { - - public static final String MODID = "lorenzmod"; - public static final String VERSION = "0.2.1"; - - @Deprecated - public static SBHConfig config; //TODO delete - - public static Features feature; - private File configFile; - - // private static final Set SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK", "\u7A7A\u5C9B\u751F\u5B58"); - - private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); - - public static File configDirectory; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { - new BazaarApi(); - MinecraftForge.EVENT_BUS.register(this); - MinecraftForge.EVENT_BUS.register(new ChatManager()); - - MinecraftForge.EVENT_BUS.register(new BazaarOrderHelper()); - MinecraftForge.EVENT_BUS.register(new ChatFilter()); - MinecraftForge.EVENT_BUS.register(new PlayerChatFilter()); - MinecraftForge.EVENT_BUS.register(new DungeonChatFilter()); - MinecraftForge.EVENT_BUS.register(new HideNotClickableItems()); - MinecraftForge.EVENT_BUS.register(new DungeonHighlightClickedBlocks()); - MinecraftForge.EVENT_BUS.register(new ItemDisplayOverlayFeatures()); - - Commands.init(); - - // MinecraftForge.EVENT_BUS.register(new LeaderboardGetter()); - // MinecraftForge.EVENT_BUS.register(new SeasonDateHandler()); - // MinecraftForge.EVENT_BUS.register(new LocationHandler()); - // MinecraftForge.EVENT_BUS.register(new IslandHandler()); - // MinecraftForge.EVENT_BUS.register(new TimeHandler()); - // MinecraftForge.EVENT_BUS.register(new CurrencyHandler()); - // MinecraftForge.EVENT_BUS.register(new SlayerHandler()); - // MinecraftForge.EVENT_BUS.register(new DungeonHandler()); - // MinecraftForge.EVENT_BUS.register(new MinesHandler()); - // MinecraftForge.EVENT_BUS.register(new FarmingIslandHandler()); - // - // MinecraftForge.EVENT_BUS.register(new TrackerHandler()); - // MinecraftForge.EVENT_BUS.register(new KillTracking()); - // - // MinecraftForge.EVENT_BUS.register(new HeldItemHandler()); - // - // ClientRegistry.registerKeyBinding(KeyBindings.map); - // - // MinecraftForge.EVENT_BUS.register(new ComponentHandler()); - // MinecraftForge.EVENT_BUS.register(new ActionBarParsing()); - // MinecraftForge.EVENT_BUS.register(new CrystalWaypoints()); - // MinecraftForge.EVENT_BUS.register(new FarmHouseHandler()); - // MinecraftForge.EVENT_BUS.register(new WarpHandler()); - // MinecraftForge.EVENT_BUS.register(new CooldownHandler()); - - // - // ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new NpcDialogue()); - ((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new Textures()); - // - configDirectory = new File("mods/LorenzMod/config"); - try { - //noinspection ResultOfMethodCallIgnored - configDirectory.mkdir(); - } catch (Exception ignored) {} - - configFile = new File(configDirectory, "config.json"); - - if (configFile.exists()) { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { - feature = gson.fromJson(reader, Features.class); - } catch (Exception ignored) {} - } - - if (feature == null) { - feature = new Features(); - saveConfig(); - } - // - // Textures.setTexture(config.misc.style); - // - // if (WarpHandler.load()) { - // WarpHandler.save(); - // } - // - Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig)); - // Runtime.getRuntime().addShutdownHook(new Thread(TrackerFileLoader::saveTrackerStatsFile)); - } - - public void saveConfig() { - try { - //noinspection ResultOfMethodCallIgnored - configFile.createNewFile(); - - try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { - writer.write(gson.toJson(feature)); - } - } catch (IOException ignored) {} - } - - // @EventHandler - // public void postInit(FMLPostInitializationEvent event) { - // MinecraftForge.EVENT_BUS.register(new OverlayHud()); - // MinecraftForge.EVENT_BUS.register(new RPGHud()); - // MinecraftForge.EVENT_BUS.register(new DungeonOverlay()); - // MinecraftForge.EVENT_BUS.register(new BossbarHandler()); - // MinecraftForge.EVENT_BUS.register(new MapHandler()); - // MinecraftForge.EVENT_BUS.register(new MiningHud()); - // MinecraftForge.EVENT_BUS.register(new NpcDialogue()); - // } - - // @EventHandler - // public void loadComplete(FMLLoadCompleteEvent event) { - // TrackerFileLoader.loadTrackersFile(); - // - // if (TrackerFileLoader.loadTrackerStatsFile()) { - // TrackerFileLoader.saveTrackerStatsFile(); - // } - // } - - // @SubscribeEvent - // public void onLeaveServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) { - // TrackerFileLoader.saveTrackerStatsFile(); - // } - - public static boolean hasSkyblockScoreboard() { - // Minecraft mc = Minecraft.getMinecraft(); - // - // if (mc != null && mc.theWorld != null) { - // Scoreboard scoreboard = mc.theWorld.getScoreboard(); - // ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); - // if (sidebarObjective != null) { - // String objectiveName = sidebarObjective.getDisplayName().replaceAll("(?i)\\u00A7.", ""); - // for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) { - // if (objectiveName.startsWith(skyblock)) { - // return true; - // } - // } - // } - // } - - return false; - } - - // @SubscribeEvent - // public void onTooltip(ItemTooltipEvent event) { - // if (event.itemStack != null && Keyboard.isKeyDown(Keyboard.KEY_BACKSLASH)) { - // try { - // StringSelection clipboard = new StringSelection(event.itemStack.serializeNBT().toString()); - // Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard); - // } catch (Exception ignored) {} - // } - // } - - // @SubscribeEvent(priority = EventPriority.HIGHEST) - // public void onStatusBar(ClientChatReceivedEvent event) { - // String message = Utils.removeColor(event.message.getUnformattedText()).toLowerCase().trim(); - // - // if (message.startsWith("your profile was changed to:")) { - // String stripped = message.replace("your profile was changed to:", "").replace("(co-op)", "").trim(); - // MinecraftForge.EVENT_BUS.post(new ProfileSwitchedEvent(stripped)); - // } - // if (message.startsWith("you are playing on profile:")) { - // String stripped = message.replace("you are playing on profile:", "").replace("(co-op)", "").trim(); - // MinecraftForge.EVENT_BUS.post(new ProfileJoinedEvent(stripped)); - // } - // } - - public static GuiScreen screenToOpen = null; - private static int screenTicks = 0; - - @SubscribeEvent - public void onClientTick(TickEvent.ClientTickEvent event) { - if (screenToOpen != null) { - screenTicks++; - if (screenTicks == 5) { - Minecraft.getMinecraft().displayGuiScreen(screenToOpen); - screenTicks = 0; - screenToOpen = null; - } - } - } -} -- cgit