diff --git a/.gitignore b/.gitignore index f68d109..ec376bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,2 @@ -### IntelliJ IDEA ### -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file +.idea +target \ No newline at end of file diff --git a/.idea/artifacts/ResolveRPC_jar.xml b/.idea/artifacts/ResolveRPC_jar.xml deleted file mode 100644 index 539c688..0000000 --- a/.idea/artifacts/ResolveRPC_jar.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - $PROJECT_DIR$/out/artifacts/ResolveRPC_jar - - - - - - \ No newline at end of file diff --git a/.idea/discord.xml b/.idea/discord.xml deleted file mode 100644 index d8e9561..0000000 --- a/.idea/discord.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/libraries/DiscordIPC.xml b/.idea/libraries/DiscordIPC.xml deleted file mode 100644 index 4914dd5..0000000 --- a/.idea/libraries/DiscordIPC.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0d8dd70..3484372 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,13 @@ + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 9fe3fe3..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index 2b63946..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 94a25f7..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/README.md b/README.md index 65d8b7a..c012e47 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # ResolveRPC Very very very simple ~~(and probably not memory efficient)~~ Discord Rich Presence Client for [DaVinci Resolve](https://www.blackmagicdesign.com/products/davinciresolve/). Thanks for little help [nadder](https://github.com/nadderus) :D. +_It works just return to Maven, I guess ~ [BoyBACKS](https://github.com/BoyBACKS)_ + ## Screenshot ![alt text](https://i.imgur.com/KXniQP7.png "Rich Presence in Action") diff --git a/ResolveRPC.iml b/ResolveRPC.iml deleted file mode 100644 index 78013f2..0000000 --- a/ResolveRPC.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml new file mode 100644 index 0000000..1b02751 --- /dev/null +++ b/dependency-reduced-pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + net.jacobb + ResolveRPC + 1.0.3 + + + + maven-compiler-plugin + 3.8.1 + + 16 + 16 + + + + maven-shade-plugin + 2.3 + + + package + + shade + + + + + ${project.artifactId}-${project.version} + + + META-INF/spring.handlers + + + META-INF/spring.schemas + + + net.jacobb.resolverpc.Main + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + jitpack.io + https://jitpack.io + + + + 16 + 16 + UTF-8 + + + diff --git a/lib/discord-rpc-java-1.0.4-javadoc.jar b/lib/discord-rpc-java-1.0.4-javadoc.jar deleted file mode 100644 index c7879c9..0000000 Binary files a/lib/discord-rpc-java-1.0.4-javadoc.jar and /dev/null differ diff --git a/lib/discord-rpc-java-1.0.4-sources.jar b/lib/discord-rpc-java-1.0.4-sources.jar deleted file mode 100644 index 52caef3..0000000 Binary files a/lib/discord-rpc-java-1.0.4-sources.jar and /dev/null differ diff --git a/lib/discord-rpc-java-1.0.4.jar b/lib/discord-rpc-java-1.0.4.jar deleted file mode 100644 index fe5ac0e..0000000 Binary files a/lib/discord-rpc-java-1.0.4.jar and /dev/null differ diff --git a/lib/jna-5.12.1-javadoc.jar b/lib/jna-5.12.1-javadoc.jar deleted file mode 100644 index b1da856..0000000 Binary files a/lib/jna-5.12.1-javadoc.jar and /dev/null differ diff --git a/lib/jna-5.12.1-sources.jar b/lib/jna-5.12.1-sources.jar deleted file mode 100644 index 1ee8eaf..0000000 Binary files a/lib/jna-5.12.1-sources.jar and /dev/null differ diff --git a/lib/jna-5.12.1.jar b/lib/jna-5.12.1.jar deleted file mode 100644 index 77f8c7a..0000000 Binary files a/lib/jna-5.12.1.jar and /dev/null differ diff --git a/lib/jna-platform-5.12.1-javadoc.jar b/lib/jna-platform-5.12.1-javadoc.jar deleted file mode 100644 index 938714b..0000000 Binary files a/lib/jna-platform-5.12.1-javadoc.jar and /dev/null differ diff --git a/lib/jna-platform-5.12.1-sources.jar b/lib/jna-platform-5.12.1-sources.jar deleted file mode 100644 index 49d76fa..0000000 Binary files a/lib/jna-platform-5.12.1-sources.jar and /dev/null differ diff --git a/lib/jna-platform-5.12.1.jar b/lib/jna-platform-5.12.1.jar deleted file mode 100644 index d39193e..0000000 Binary files a/lib/jna-platform-5.12.1.jar and /dev/null differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..25cdd63 --- /dev/null +++ b/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + + net.jacobb + ResolveRPC + 1.0.3 + + + 16 + 16 + UTF-8 + + + + + + maven-compiler-plugin + 3.8.1 + + 16 + 16 + + + + org.apache.maven.plugins + maven-shade-plugin + 2.3 + + + package + + shade + + + + + ${project.artifactId}-${project.version} + + + META-INF/spring.handlers + + + META-INF/spring.schemas + + + net.jacobb.resolverpc.Main + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + jitpack.io + https://jitpack.io + + + + + + com.github.jagrosh + DiscordIPC + 18b6096 + + + \ No newline at end of file diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF deleted file mode 100644 index 44c9e2c..0000000 --- a/src/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: net.jacobb.resolverpc.Main - diff --git a/src/main/java/net/jacobb/resolverpc/DiscordRpc.java b/src/main/java/net/jacobb/resolverpc/DiscordRpc.java new file mode 100644 index 0000000..ba3d24b --- /dev/null +++ b/src/main/java/net/jacobb/resolverpc/DiscordRpc.java @@ -0,0 +1,57 @@ +package net.jacobb.resolverpc; + +import com.jagrosh.discordipc.*; +import com.jagrosh.discordipc.entities.RichPresence; +import com.jagrosh.discordipc.entities.pipe.PipeStatus; +import com.jagrosh.discordipc.entities.pipe.WindowsPipe; +import com.jagrosh.discordipc.exceptions.NoDiscordClientException; + +import java.io.IOException; +import java.time.OffsetDateTime; + +import static net.jacobb.resolverpc.WindowNameFunc.WindowName; + +public class DiscordRpc { + + public static IPCClient client = new IPCClient(1004088618857549844L); + public static RichPresence.Builder builder = new RichPresence.Builder(); + public static void discordIntegration() { + client.setListener(new IPCListener(){ + @Override + public void onReady(IPCClient client) { + try { + builder.setState(WindowName().toString()) + .setStartTimestamp(OffsetDateTime.now()) + .setLargeImage("resolve", "DaVinci Resolve"); + } catch (InterruptedException | IOException e) { + throw new RuntimeException(e); + } + client.sendRichPresence(builder.build()); + } + }); + try { + discordCheck(); + } catch (NoDiscordClientException | IOException | InterruptedException e) { + throw new RuntimeException(e); + } + } + + public static void discordCheck() throws NoDiscordClientException, IOException, InterruptedException { + if (!ProcessListFunc.discordProcessList()) { + System.out.println("[Error] Couldn't find Discord app. Looking for it..."); + return; + } + if (client.getStatus() == PipeStatus.UNINITIALIZED || client.getStatus() == PipeStatus.DISCONNECTED) { + System.out.println("[Log] Found Discord applications."); + System.out.println("[Log] Connecting to Discord servers."); + client.connect(); + System.out.println("[Log] Connection established."); + } else if (client.getStatus() == PipeStatus.CONNECTED) { + System.out.println("[Log] The connection is stable."); + } else { + System.out.println(client.getStatus()); + System.out.println("[Error] All in all I don't know what's going on rally so I close the program and elo, Ride with the ESSA whores"); + System.exit(0); + } + } +} diff --git a/src/main/java/net/jacobb/resolverpc/Main.java b/src/main/java/net/jacobb/resolverpc/Main.java new file mode 100644 index 0000000..1264de2 --- /dev/null +++ b/src/main/java/net/jacobb/resolverpc/Main.java @@ -0,0 +1,41 @@ +package net.jacobb.resolverpc; + +import com.jagrosh.discordipc.IPCClient; +import com.jagrosh.discordipc.entities.RichPresence; +import com.jagrosh.discordipc.entities.pipe.PipeStatus; + +import java.io.IOException; +import java.util.Timer; +import java.util.TimerTask; + +import static net.jacobb.resolverpc.DiscordRpc.*; +import static net.jacobb.resolverpc.WindowNameFunc.WindowName; + +public class Main { + + public static void main(String[] args) { + Timer timer = new Timer(); + TimerTask timerTask = new TimerTask() { + @Override + public void run() { + { + DiscordRpc.discordIntegration(); + } + if (client.getStatus() == PipeStatus.CONNECTED ) { + try { + if (ProcessListFunc.processList()) { + builder.setState(WindowName().toString()); + client.sendRichPresence(builder.build()); + } + else { + System.out.println("[Error] Couldn't find Davinci application. Looking for it..."); + } + } catch (IOException | InterruptedException e) { + throw new RuntimeException(e); + } + } + } + }; + timer.schedule(timerTask, 0, 20*1000); + } +} \ No newline at end of file diff --git a/src/main/java/net/jacobb/resolverpc/ProcessListFunc.java b/src/main/java/net/jacobb/resolverpc/ProcessListFunc.java new file mode 100644 index 0000000..0188e34 --- /dev/null +++ b/src/main/java/net/jacobb/resolverpc/ProcessListFunc.java @@ -0,0 +1,52 @@ +package net.jacobb.resolverpc; + +import java.io.IOException; +import java.util.Scanner; +import java.util.concurrent.atomic.AtomicBoolean; + +public class ProcessListFunc { + + public static boolean processList() throws IOException, InterruptedException { + + AtomicBoolean found = new AtomicBoolean(false); + + Process process = new ProcessBuilder("tasklist.exe", "/fo", "csv", "/nh").start(); + new Thread(() -> { + Scanner sc = new Scanner(process.getInputStream()); + if (sc.hasNextLine()) sc.nextLine(); + while (sc.hasNextLine()) { + String line = sc.nextLine(); + String[] parts = line.split(","); + String unq = parts[0].substring(1).replaceFirst(".$", ""); + if (unq.equals("Resolve.exe")) { + found.set(true); + } + } + }).start(); + process.waitFor(); + if (found.get() == false) {} + return found.get(); + } + + public static boolean discordProcessList() throws IOException, InterruptedException { + + AtomicBoolean found = new AtomicBoolean(false); + + Process process = new ProcessBuilder("tasklist.exe", "/fo", "csv", "/nh").start(); + new Thread(() -> { + Scanner sc = new Scanner(process.getInputStream()); + if (sc.hasNextLine()) sc.nextLine(); + while (sc.hasNextLine()) { + String line = sc.nextLine(); + String[] parts = line.split(","); + String unq = parts[0].substring(1).replaceFirst(".$", ""); + if (unq.equals("Discord.exe")) { + found.set(true); + } + } + }).start(); + process.waitFor(); + if (found.get() == false) {} + return found.get(); + } +} diff --git a/src/main/java/net/jacobb/resolverpc/WindowNameFunc.java b/src/main/java/net/jacobb/resolverpc/WindowNameFunc.java new file mode 100644 index 0000000..efd71d5 --- /dev/null +++ b/src/main/java/net/jacobb/resolverpc/WindowNameFunc.java @@ -0,0 +1,35 @@ +package net.jacobb.resolverpc; + +import java.io.IOException; +import java.util.Scanner; +import java.util.concurrent.atomic.AtomicReference; + +public class WindowNameFunc { + + public static AtomicReference WindowName() throws InterruptedException, IOException { + + AtomicReference current = new AtomicReference<>(""); + + Process process = new ProcessBuilder("tasklist", "/v", "/fo", "csv").start(); + new Thread(() -> { + Scanner sc = new Scanner(process.getInputStream()); + if (sc.hasNextLine()) sc.nextLine(); + while (sc.hasNextLine()) { + String line = sc.nextLine(); + String[] parts = line.split(","); + String unq = parts[8].substring(1).replaceFirst(".$", ""); + unq = unq.replace("N/A", ""); + if (unq.contains("Project Manager")) { + current.set("Inside: Project Manager"); + } + else if (unq.contains("DaVinci Resolve - ") || unq.contains("DaVinci Resolve Studio - ")) { + unq = unq.replace("DaVinci Resolve - ", "") + .replace("DaVinci Resolve Studio - ", ""); + current.set("Editing: " + unq); + } + } + }).start(); + process.waitFor(); + return current; + } +} diff --git a/src/net/jacobb/resolverpc/DiscordRpc.java b/src/net/jacobb/resolverpc/DiscordRpc.java deleted file mode 100644 index af4e690..0000000 --- a/src/net/jacobb/resolverpc/DiscordRpc.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.jacobb.resolverpc; - -import com.jagrosh.discordipc.IPCClient; -import com.jagrosh.discordipc.IPCListener; -import com.jagrosh.discordipc.entities.RichPresence; -import com.jagrosh.discordipc.exceptions.NoDiscordClientException; - -import java.io.IOException; -import java.time.OffsetDateTime; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.TimeUnit; - -import static net.jacobb.resolverpc.WindowNameFunc.WindowName; - -public class DiscordRpc { - public static IPCClient client = new IPCClient(1004088618857549844L); - public static RichPresence.Builder builder = new RichPresence.Builder(); - public static void DiscordIntegration() { - client.setListener(new IPCListener(){ - @Override - public void onReady(IPCClient client) { - try { - builder.setState(WindowName().toString()) - .setStartTimestamp(OffsetDateTime.now()) - .setLargeImage("resolve", "DaVinci Resolve"); - } catch (InterruptedException | IOException e) { - throw new RuntimeException(e); - } - client.sendRichPresence(builder.build()); - } - }); - try { - client.connect(); - } catch (NoDiscordClientException e) { - //Dodać exeption który wraca do początku programu po crashu - throw new RuntimeException(e); - } - - } -} diff --git a/src/net/jacobb/resolverpc/Main.java b/src/net/jacobb/resolverpc/Main.java deleted file mode 100644 index 78e1382..0000000 --- a/src/net/jacobb/resolverpc/Main.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.jacobb.resolverpc; - -import com.jagrosh.discordipc.IPCClient; -import com.jagrosh.discordipc.entities.RichPresence; - -import java.io.IOException; -import java.util.Timer; -import java.util.TimerTask; - -import static net.jacobb.resolverpc.ProcessListFunc.ProcessList; -import static net.jacobb.resolverpc.WindowNameFunc.WindowName; - -public class Main extends DiscordRpc { - - public static void main(String[] args) throws IOException, InterruptedException { - - do { - Thread.sleep(5000); - while(ProcessList()) { - Thread.sleep(5000); - if(!client.getStatus().toString().equals("CONNECTED")) { - DiscordIntegration(); - System.out.println("Discord RPC Started"); - - runTask(client, builder); - - Thread.sleep(5000); - } - - if(!ProcessList()){ - client.close(); - System.out.println("Discord RPC Stopped"); - Thread.sleep(10000); - - } - } - Thread.sleep(5000); - } - while (true); - - } - - private static void runTask(IPCClient ipcClient, RichPresence.Builder builder) { - Timer timer = new Timer(); - TimerTask timerTask = new TimerTask() { - @Override - public void run() { - try { - if (!ProcessList()) { - timer.cancel(); - return; - } - - builder.setState(WindowName().toString()); - - ipcClient.sendRichPresence(builder.build()); - } catch (InterruptedException | IOException e) { - throw new RuntimeException(e); - } - } - }; - timer.schedule(timerTask, 0, 10000); - } - -} \ No newline at end of file diff --git a/src/net/jacobb/resolverpc/ProcessListFunc.java b/src/net/jacobb/resolverpc/ProcessListFunc.java deleted file mode 100644 index 289b8e2..0000000 --- a/src/net/jacobb/resolverpc/ProcessListFunc.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.jacobb.resolverpc; - -import java.io.IOException; -import java.util.Scanner; -import java.util.concurrent.atomic.AtomicBoolean; - -public class ProcessListFunc { - - public static boolean ProcessList() throws IOException, InterruptedException { - - AtomicBoolean found = new AtomicBoolean(false); - - Process process = new ProcessBuilder("tasklist.exe", "/fo", "csv", "/nh").start(); - new Thread(() -> { - Scanner sc = new Scanner(process.getInputStream()); - if (sc.hasNextLine()) sc.nextLine(); - while (sc.hasNextLine()) { - String line = sc.nextLine(); - String[] parts = line.split(","); - String unq = parts[0].substring(1).replaceFirst(".$", ""); -// System.out.println(unq); - - if (unq.equals("Resolve.exe")) { -// System.out.println("Found Resolve.exe"); - found.set(true); - } - } - }).start(); - process.waitFor(); - - if (found.get() == false) { -// System.out.println("Didn't found Resolve.exe"); - } - - return found.get(); - } -} diff --git a/src/net/jacobb/resolverpc/WindowNameFunc.java b/src/net/jacobb/resolverpc/WindowNameFunc.java deleted file mode 100644 index eda9bd2..0000000 --- a/src/net/jacobb/resolverpc/WindowNameFunc.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.jacobb.resolverpc; - -import java.io.IOException; -import java.util.Scanner; -import java.util.concurrent.atomic.AtomicReference; - -public class WindowNameFunc { - - public static AtomicReference WindowName() throws InterruptedException, IOException { - - AtomicReference current = new AtomicReference<>(""); - - Process process = new ProcessBuilder("tasklist", "/v", "/fo", "csv").start(); - new Thread(() -> { - Scanner sc = new Scanner(process.getInputStream()); - if (sc.hasNextLine()) sc.nextLine(); - while (sc.hasNextLine()) { - String line = sc.nextLine(); - String[] parts = line.split(","); - String unq = parts[8].substring(1).replaceFirst(".$", ""); - unq = unq.replace("N/A", ""); -// System.out.println(unq); - - - if (unq.contains("Project Manager")) { - current.set("Inside: Project Manager"); - } - else if (unq.contains("DaVinci Resolve - ") || unq.contains("DaVinci Resolve Studio - ")) { - unq = unq.replace("DaVinci Resolve - ", "") - .replace("DaVinci Resolve Studio - ", ""); - current.set("Editing: " + unq); - } - - } - }).start(); - process.waitFor(); - - return current; - } -}