diff --git a/build.gradle b/build.gradle index a59fcee..afb9b11 100644 --- a/build.gradle +++ b/build.gradle @@ -48,7 +48,7 @@ dependencies { compileOnly("org.spigotmc:spigot-api:1.21.3-R0.1-SNAPSHOT") compileOnly("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT") annotationProcessor("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT") - include(implementation("dev.xdpxi:dependencies:1.1.7")) + include(implementation("dev.xdpxi:dependencies:1.1.8")) modImplementation("net.fabricmc:fabric-loader:0.16.9") modImplementation("net.fabricmc.fabric-api:fabric-api:0.108.1+") diff --git a/gradle/deps/dependencies-1.1.7.jar b/gradle/deps/dependencies-1.1.8.jar similarity index 63% rename from gradle/deps/dependencies-1.1.7.jar rename to gradle/deps/dependencies-1.1.8.jar index af56eba..ae977d6 100644 Binary files a/gradle/deps/dependencies-1.1.7.jar and b/gradle/deps/dependencies-1.1.8.jar differ diff --git a/src/client/java/dev/xdpxi/xdlib/EarlyLoadingBarPreLaunch.java b/src/client/java/dev/xdpxi/xdlib/EarlyLoadingBarPreLaunch.java deleted file mode 100644 index 6846f66..0000000 --- a/src/client/java/dev/xdpxi/xdlib/EarlyLoadingBarPreLaunch.java +++ /dev/null @@ -1,50 +0,0 @@ -package dev.xdpxi.xdlib; - -import dev.xdpxi.xdlib.api.files; -import dev.xdpxi.xdlib.gui.PreLaunchWindow; -import net.fabricmc.api.EnvType; -import net.fabricmc.loader.api.FabricLoader; -import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; - -import java.nio.file.Path; - -public class EarlyLoadingBarPreLaunch implements PreLaunchEntrypoint { - private final Path configDir = FabricLoader.getInstance().getConfigDir().resolve("xdlib"); - private final Path pluginsDir = configDir.resolve("plugins"); - private final Path pluginsTemp = pluginsDir.resolve("plugins.tmp"); - - public static boolean isWindows() { - return System.getProperty("os.name").toLowerCase().contains("windows"); - } - - public boolean isModLoaded(String modID) { - return FabricLoader.getInstance().isModLoaded(modID); - } - - public boolean isNoEarlyLoaders() { - return !(isModLoaded("early-loading-screen") || - isModLoaded("early_loading_bar") || - isModLoaded("earlyloadingscreen") || - isModLoaded("mindful-loading-info") || - isModLoaded("neoforge") || - isModLoaded("connector") || - isModLoaded("mod-loading-screen")); - } - - public boolean isPluginDownload() { - return files.exists(String.valueOf(pluginsTemp)); - } - - @Override - public void onPreLaunch() { - /* - if (isWindows() && FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT && isPluginDownload()) { - PluginDownloader.display(files.readFile(String.valueOf(pluginsTemp))); - } - */ - - if (isWindows() && FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT && isNoEarlyLoaders()) { - PreLaunchWindow.display(); - } - } -} \ No newline at end of file diff --git a/src/client/java/dev/xdpxi/xdlib/XDsLibraryClient.java b/src/client/java/dev/xdpxi/xdlib/XDsLibraryClient.java index 58032e0..ffa685b 100644 --- a/src/client/java/dev/xdpxi/xdlib/XDsLibraryClient.java +++ b/src/client/java/dev/xdpxi/xdlib/XDsLibraryClient.java @@ -2,11 +2,9 @@ import dev.xdpxi.xdlib.config.configManager; import dev.xdpxi.xdlib.config.pluginManager; -import dev.xdpxi.xdlib.gui.PreLaunchWindow; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; @@ -135,10 +133,6 @@ public void onInitializeClient() { } }); - if (isWindows() && FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT && isNoEarlyLoaders()) { - ClientLifecycleEvents.CLIENT_STARTED.register(client -> PreLaunchWindow.remove()); - } - if (WorldCloudHeights.isEmpty()) { WorldCloudHeights.put("minecraft:overworld", 182.0F); } diff --git a/src/client/java/dev/xdpxi/xdlib/gui/PluginDownloader.java b/src/client/java/dev/xdpxi/xdlib/gui/PluginDownloader.java deleted file mode 100644 index 316836c..0000000 --- a/src/client/java/dev/xdpxi/xdlib/gui/PluginDownloader.java +++ /dev/null @@ -1,124 +0,0 @@ -package dev.xdpxi.xdlib.gui; - -import com.formdev.flatlaf.FlatDarkLaf; -import net.fabricmc.loader.api.FabricLoader; - -import javax.swing.*; -import java.awt.*; -import java.awt.geom.RoundRectangle2D; -import java.io.*; -import java.net.URI; -import java.nio.file.Path; - -public class PluginDownloader { - private static final JDialog frame = new JDialog(); - private static final JProgressBar progressBar; - private static final Path configDir = FabricLoader.getInstance().getConfigDir().resolve("xdlib"); - private static final Path pluginsDir = configDir.resolve("plugins"); - private static final Path pluginsTemp = pluginsDir.resolve("plugins.tmp"); - private static boolean disposed = false; - private static String fileContent = ""; - - static { - try { - FlatDarkLaf.setup(); - } catch (Exception ex) { - System.err.println("Failed to initialize FlatLaf."); - } - - frame.setUndecorated(true); - frame.setResizable(false); - frame.setSize(400, 50); - frame.setLocationRelativeTo(null); - frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - frame.setAlwaysOnTop(true); - frame.setShape(new RoundRectangle2D.Double(0, 0, frame.getWidth(), frame.getHeight(), 20, 20)); - frame.setBackground(new Color(0, 0, 0, 0)); - - JPanel mainPanel = new JPanel() { - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - Graphics2D g2 = (Graphics2D) g; - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2.setColor(new Color(60, 63, 65)); - g2.fillRoundRect(0, 0, getWidth(), getHeight(), 40, 40); - } - }; - mainPanel.setLayout(new BorderLayout()); - mainPanel.setOpaque(false); - - progressBar = new JProgressBar(0, 100); - progressBar.setStringPainted(true); - progressBar.setString("Downloading Plugins..."); - progressBar.setBackground(new Color(60, 63, 65)); - progressBar.setForeground(new Color(3, 169, 244)); - mainPanel.add(progressBar, BorderLayout.CENTER); - - frame.add(mainPanel, BorderLayout.CENTER); - } - - public static void display(String url) { - fileContent = url; - if (disposed) throw new IllegalStateException("Pre-launch window has been disposed!"); - frame.setVisible(true); - startDownload(); - } - - private static void startDownload() { - SwingWorker downloader = new SwingWorker<>() { - @Override - protected Void doInBackground() throws Exception { - try (BufferedReader reader = new BufferedReader(new FileReader(String.valueOf(pluginsTemp)))) { - String fileURL; - while ((fileURL = reader.readLine()) != null) { - fileURL = fileContent; - String savePath = "plugin.zip"; - try (BufferedInputStream in = new BufferedInputStream(URI.create(fileURL).toURL().openStream()); - FileOutputStream fileOutputStream = new FileOutputStream(savePath)) { - - byte[] dataBuffer = new byte[1024]; - int bytesRead; - int totalBytesRead = 0; - int fileSize = 1024 * 1024 * 10; - - while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) { - totalBytesRead += bytesRead; - int progress = (int) (((double) totalBytesRead / fileSize) * 100); - publish(progress); - fileOutputStream.write(dataBuffer, 0, bytesRead); - } - } - } - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } - - @Override - protected void process(java.util.List chunks) { - int progress = chunks.get(chunks.size() - 1); - progressBar.setValue(progress); - progressBar.setString("Downloading Plugins... " + progress + "%"); - } - - @Override - protected void done() { - progressBar.setString("Download Complete!"); - } - }; - downloader.execute(); - } - - public static void remove() { - if (disposed) return; - frame.setVisible(false); - frame.dispose(); - disposed = true; - } - - public static void main(String[] args) { - display(""); - } -} \ No newline at end of file diff --git a/src/client/java/dev/xdpxi/xdlib/gui/PreLaunchWindow.java b/src/client/java/dev/xdpxi/xdlib/gui/PreLaunchWindow.java deleted file mode 100644 index 352b299..0000000 --- a/src/client/java/dev/xdpxi/xdlib/gui/PreLaunchWindow.java +++ /dev/null @@ -1,68 +0,0 @@ -package dev.xdpxi.xdlib.gui; - -import com.formdev.flatlaf.FlatDarkLaf; - -import javax.swing.*; -import java.awt.*; -import java.awt.geom.RoundRectangle2D; - -public class PreLaunchWindow { - private static final JDialog frame = new JDialog(); - private static boolean disposed = false; - - static { - try { - FlatDarkLaf.setup(); - } catch (Exception ex) { - System.err.println("Failed to initialize FlatLaf."); - } - - frame.setUndecorated(true); - frame.setResizable(false); - frame.setSize(400, 20); - frame.setLocationRelativeTo(null); - frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - frame.setAlwaysOnTop(true); - frame.setShape(new RoundRectangle2D.Double(0, 0, frame.getWidth(), frame.getHeight(), 20, 20)); - frame.setBackground(new Color(0, 0, 0, 0)); - - JPanel mainPanel = new JPanel() { - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - Graphics2D g2 = (Graphics2D) g; - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2.setColor(new Color(60, 63, 65)); - g2.fillRoundRect(0, 0, getWidth(), getHeight(), 40, 40); - } - }; - mainPanel.setLayout(new BorderLayout()); - mainPanel.setOpaque(false); - - JProgressBar progressBar = new JProgressBar(); - progressBar.setIndeterminate(true); - progressBar.setStringPainted(true); - progressBar.setString("Launching Minecraft..."); - progressBar.setBackground(new Color(60, 63, 65)); - progressBar.setForeground(new Color(3, 169, 244)); - mainPanel.add(progressBar, BorderLayout.CENTER); - - frame.add(mainPanel, BorderLayout.CENTER); - } - - public static void display() { - if (disposed) throw new IllegalStateException("Pre-launch window has been disposed!"); - frame.setVisible(true); - } - - public static void remove() { - if (disposed) return; - frame.setVisible(false); - frame.dispose(); - disposed = true; - } - - public static void main(String[] args) { - display(); - } -} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 44772e0..0d2f870 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -21,9 +21,6 @@ "icon": "assets/xdlib/icon.png", "environment": "*", "entrypoints": { - "preLaunch": [ - "dev.xdpxi.xdlib.EarlyLoadingBarPreLaunch" - ], "main": [ "dev.xdpxi.xdlib.XDsLibrary" ],