Skip to content

Commit

Permalink
Revert "generic project re-structuration (#106)"
Browse files Browse the repository at this point in the history
This reverts commit 14e02fa.
  • Loading branch information
SrRapero720 authored Nov 23, 2024
1 parent 14e02fa commit e14487c
Show file tree
Hide file tree
Showing 124 changed files with 3,740 additions and 5,364 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ dependencies {

// DEPENDENCIES
shadow "com.github.WaterMediaTeam:videolan-natives:$vlcj_natives_version"
shadow "com.github.WaterMediaTeam:ffmpeg4j:$ffmpeg4j_version"
shadow "com.github.WaterMediaTeam:ytdl-java:$jyd_version"
shadow "net.sf.sevenzipjbinding:sevenzipjbinding:16.02-2.01"
shadow "net.sf.sevenzipjbinding:sevenzipjbinding-all-platforms:16.02-2.01"
shadow project(":lib-vlcj")
Expand Down Expand Up @@ -104,6 +104,10 @@ shadowJar {
// Add relocation rules for each dependency
relocate 'com.github', 'me.lib720'
relocate 'com.alibaba', 'me.lib720.alibaba'
relocate 'com.fasterxml', 'me.lib720'
relocate 'org.apache.commons', 'me.lib720.apache'
relocate 'org.tukaani', 'me.lib720.tukaani'
relocate 'uk.co.caprica', 'me.lib720.caprica'

exclude "META-INF/versions/**"
exclude "META-INF/proguard/**"
Expand Down
19 changes: 7 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ curseforgeid=869524
#########################
#### Version ranges ####
#######################
minecraftrange=[1.18.2,)
forgerange=[40.2.21,)
forgefmlrange=[40,)
minecraftrange=[1.16.5,)
forgerange=[36,)
forgefmlrange=[36,)
neorange=[21,)
neofmlrange=[3,)
fabricrange=>=0.14
javarange=>=17
javarange=>=8

##############################
#### Project information ####
Expand All @@ -40,12 +40,8 @@ authors=SrRapero720, Goedix
authors_list=["SrRapero720", "Goedix"]
contributors=ZenoArrows, zFERDQFREZrzfq, Kekscussino, cyyynthia
contributors_list=["ZenoArrows", "zFERDQFREZrzfq", "Kekscussino", "cyyynthia"]
credits=Powered by FFMPEG and VideoLAN, special thanks to Caprica for vlcj
description=Library and API providing multimedia processing, source patching, rendering, and math tools.

############################
#### Libraries Version ####
##########################
credits=VideoLAN Team for libVLC, Caprica for made VLCJ, Linus torvalds for make us suffer with Linux
description=Library with an API using VLC for multimedia integration with Minecraft. Works also standalone

####################
#### Libraries ####
Expand All @@ -54,8 +50,7 @@ modloaders_version=1.0.1
fabric_version=0.16.0
forge_version=unknown
jyd_version=3.2.3
ffmpeg4j_version=master-SNAPSHOT
vlcj_natives_version=4.11.0
vlcj_natives_version=4.9.0
commoncompress_version=1.26.1
commonslang3_version=3.12.0
commonsio_version=2.7
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public enum State {
ENDED (6),
ERROR (7);

private static final Map<Integer, State> INT_MAP = new HashMap<>();
private static final Map<Integer, State> INT_MAP = new HashMap<Integer, State>();

static {
for (State event : State.values()) {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/me/srrapero720/watermedia/Main.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package me.srrapero720.watermedia;

import org.watermedia.api.MathAPI;
import org.watermedia.tools.IOTool;
import org.watermedia.WaterMedia;
import me.srrapero720.watermedia.api.math.MathAPI;
import me.srrapero720.watermedia.tools.IOTool;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
Expand Down Expand Up @@ -180,7 +179,7 @@ public void run() {
if (crashReportFiles == null || crashReportFiles.length == 0)
throw new NullPointerException("No such directory or is empty");

// Arrays.sort(crashReportFiles, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
Arrays.sort(crashReportFiles, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
File crashReport = crashReportFiles[0];

LOGGER.info("Collected files: " + Arrays.toString(crashReportFiles));
Expand Down
113 changes: 113 additions & 0 deletions src/main/java/me/srrapero720/watermedia/WaterMedia.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package me.srrapero720.watermedia;

import com.sun.jna.Platform;
import me.srrapero720.watermedia.api.WaterMediaAPI;
import me.srrapero720.watermedia.tools.DataTool;
import me.srrapero720.watermedia.tools.JarTool;
import me.srrapero720.watermedia.loader.ILoader;
import me.srrapero720.watermedia.loader.IModule;
import me.srrapero720.watermedia.tools.PairTool;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;

import java.util.*;

public final class WaterMedia {
private static final Marker IT = MarkerManager.getMarker("Bootstrap");

public static final String ID = "watermedia";
public static final String NAME = "WATERMeDIA";
public static final Logger LOGGER = LogManager.getLogger(ID);
private static final Set<IModule> MODULES = new HashSet<>();

private static final PairTool<String, Boolean> NO_BOOT = getArgument("watermedia.disableBoot");
private static final PairTool<String, Boolean> HARDFAIL = getArgument("watermedia.hardFail");
private static ILoader bootstrap;
private static WaterMedia instance;

private WaterMedia() {}

public static WaterMedia prepare(ILoader boot) {
if (boot == null) throw new NullPointerException("Bootstrap is null");
if (instance != null) throw new NullPointerException(NAME + " is already prepared");
LOGGER.info(IT, "Preparing '{}' on '{}'", NAME, boot.name());
LOGGER.info(IT, "WaterMedia version '{}'", JarTool.readString("/watermedia/version.cfg"));
LOGGER.info(IT, "OS Detected: {} ({})", System.getProperty("os.name"), Platform.ARCH);

if (NO_BOOT.getRight())
LOGGER.warn(IT, "No boot was enabled, skipping bootstrap");

if (HARDFAIL.getRight())
LOGGER.warn(IT, "HardFail mode was enable, {} will crash at the minimum exception", NAME);

if (!boot.client() && !boot.name().contains("Fabric"))
throw new UnsupportedSideException();


WaterMedia.bootstrap = boot;
return instance = new WaterMedia();
}

public static void register(IModule module) {
MODULES.add(module);
}

public static Set<IModule> modules() {
return MODULES;
}

public void start() throws Exception {
if (NO_BOOT.getRight()) return;
if (!bootstrap.client()) return;

List<WaterMediaAPI> modules = DataTool.toList(ServiceLoader.load(WaterMediaAPI.class));
modules.sort(Comparator.comparingInt(e -> e.priority().ordinal()));

for (WaterMediaAPI m: modules) {
LOGGER.info(IT, "Starting {}", m.getClass().getSimpleName());
if (!m.prepare(bootstrap)) {
LOGGER.warn(IT, "Module {} refuses to be loaded, skipping", m.getClass().getSimpleName());
continue;
}
m.start(bootstrap);
LOGGER.info(IT, "Module {} loaded successfully", m.getClass().getSimpleName());
}
LOGGER.info(IT, "Startup finished");
}

public static ILoader getLoader() { return bootstrap; }


public static String asResource(String path) {
return WaterMedia.ID + ":" + path;
}

public static PairTool<String, Boolean> getArgument(String argument) {
return new PairTool<>(argument, Boolean.parseBoolean(System.getProperty(argument)));
}

public static class UnsupportedSideException extends RuntimeException {
public UnsupportedSideException() {
super(NAME + " CANNOT be installed on SERVER-SIDE. Please remove " + NAME + " from the server, and keep it on client");
LOGGER.fatal(IT, "############################## ILLEGAL ENVIRONMENT ######################################");
LOGGER.fatal(IT, "{} is not designed to work on server-side, please remove it from server and keep it on client", NAME);
LOGGER.fatal(IT, "Dependent mods can work without {} ON SERVERS, remember keep the mod ONLY ON CLIENT-SIDE", NAME);
LOGGER.fatal(IT, "if dependent mods throws exceptions ON SERVER asking for WATERMeDIA, report it to the creators");
LOGGER.fatal(IT, "############################## ILLEGAL ENVIRONMENT ######################################");
}
}

public static class UnsupportedTLException extends Exception {
public UnsupportedTLException() {
super("TLauncher is NOT supported by " + NAME + ", please stop using it (and consider safe alternatives like SKLauncher or MultiMC)");
LOGGER.fatal(IT, "############################## ILLEGAL LAUNCHER DETECTED ######################################");
LOGGER.fatal(IT, "{} refuses to load sensitive modules in a INFECTED launcher, please stop using TLauncher dammit", NAME);
LOGGER.fatal(IT, "Because TLauncher infects sensitive files (which {} includes) and we prefer avoid any risk", NAME);
LOGGER.fatal(IT, "Consider use safe alternative like SKLauncher or BUY the game and use the CurseForge Launcher");
LOGGER.fatal(IT, "And please avoid Feather Launcher, TLauncher Legacy or any CRACKED LAUNCHER WITH A BAD REPUTATION");
LOGGER.fatal(IT, "############################## ILLEGAL LAUNCHER DETECTED ######################################");
}
}
}
50 changes: 0 additions & 50 deletions src/main/java/me/srrapero720/watermedia/api/MediaContext.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.watermedia.api;
package me.srrapero720.watermedia.api;

import org.watermedia.WaterMedia;

import me.srrapero720.watermedia.api.math.MathAPI;
import me.srrapero720.watermedia.loader.ILoader;

/**
* Boostrap class.
Expand All @@ -20,14 +22,14 @@ public abstract class WaterMediaAPI {
* @return true if can bot, otherwise false
* @throws Exception the module fails to prepare itself, indicating a broken state
*/
public abstract boolean prepare(WaterMedia.ILoader bootCore) throws Exception;
public abstract boolean prepare(ILoader bootCore) throws Exception;

/**
* Starts module
* @throws Exception on some cases a exception breaks WATERMeDIA's intended behavior and making
* dependant mods life harder.
*/
public abstract void start(WaterMedia.ILoader bootCore) throws Exception;
public abstract void start(ILoader bootCore) throws Exception;

/**
* Releases all module resources
Expand All @@ -40,12 +42,26 @@ public abstract class WaterMediaAPI {
* and BENCHMARK what name indicates
*/
public enum Priority {
OVERRIDE,
HIGHEST,
HIGH,
NORMAL,
LOW,
LOWEST,
MONITOR
MONITOR,
BENCHMARK
}

/**
* Returns the color of a specified level in range of 1 ~ 255
* @param a alpha level
* @param r red color
* @param g green color
* @param b blue color
* @deprecated IMPORANT: this method a bouncer of {@link MathAPI#argb(int, int, int, int)}. Please switch as soon as possible
* @return color int
*/
@Deprecated(forRemoval = true)
public static int math_colorARGB(int a, int r, int g, int b) {
return MathAPI.argb(a, r, g, b);
}
}
Loading

0 comments on commit e14487c

Please sign in to comment.