From 21a77c799a43b5f7e27210086e500bacb1c3824f Mon Sep 17 00:00:00 2001 From: M4TH1EU <41210834+M4TH1EU@users.noreply.github.com> Date: Sun, 21 Jul 2019 20:09:39 +0200 Subject: [PATCH] =?UTF-8?q?Fichier=20de=20config=20d=C3=A9plac=C3=A9=20dan?= =?UTF-8?q?s=20le=20mod=20et=20fixage=20de=20bugs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 12 ++--- .../ch/m4th1eu/richpresence/Main.class | Bin 3201 -> 0 bytes .../richpresence/events/EventPresence.class | Bin 2608 -> 0 bytes .../m4th1eu/richpresence/events/Events.class | Bin 2310 -> 0 bytes .../richpresence/proxy/ClientProxy.class | Bin 1313 -> 0 bytes .../richpresence/proxy/CommonProxy.class | Bin 916 -> 0 bytes .../discord-presence_main/mcmod.info | 16 ------- .../discord-presence_main/pack.mcmeta | 7 --- .../java/ch/m4th1eu/richpresence/Main.java | 22 ++++++--- .../java/ch/m4th1eu/richpresence/Utils.java | 45 ++++++++++++------ .../events/AdvancedStatusEvent.java | 27 +++++++---- .../richpresence/events/EventPresence.java | 4 +- src/main/resources/config/richpresence.json | 2 + 13 files changed, 73 insertions(+), 62 deletions(-) delete mode 100644 classes/production/discord-presence_main/ch/m4th1eu/richpresence/Main.class delete mode 100644 classes/production/discord-presence_main/ch/m4th1eu/richpresence/events/EventPresence.class delete mode 100644 classes/production/discord-presence_main/ch/m4th1eu/richpresence/events/Events.class delete mode 100644 classes/production/discord-presence_main/ch/m4th1eu/richpresence/proxy/ClientProxy.class delete mode 100644 classes/production/discord-presence_main/ch/m4th1eu/richpresence/proxy/CommonProxy.class delete mode 100644 classes/production/discord-presence_main/mcmod.info delete mode 100644 classes/production/discord-presence_main/pack.mcmeta create mode 100644 src/main/resources/config/richpresence.json diff --git a/build.gradle b/build.gradle index 201bb30..60d0a49 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge' //Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -version = "1.2" +version = "1.3" group = "ch.m4th1eu.richpresence" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "richpresence" @@ -24,7 +24,7 @@ compileJava { minecraft { version = "1.12.2-14.23.5.2768" runDir = "run" - + // the mappings can be changed at any time, and must be in the following format. // snapshot_YYYYMMDD snapshot are built nightly. // stable_# stables are built at the discretion of the MCP team. @@ -39,7 +39,7 @@ dependencies { // or you may define them like so.. //compile "some.group:artifact:version:classifier" //compile "some.group:artifact:version" - + // real examples //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env @@ -66,11 +66,11 @@ processResources { // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' - + // replace version and mcversion - expand 'version':project.version, 'mcversion':project.minecraft.version + expand 'version': project.version, 'mcversion': project.minecraft.version } - + // copy everything else except the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' diff --git a/classes/production/discord-presence_main/ch/m4th1eu/richpresence/Main.class b/classes/production/discord-presence_main/ch/m4th1eu/richpresence/Main.class deleted file mode 100644 index 59091b6c466f291130257b97030286e054174f95..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3201 zcmbtWX;%|h7=DIrLL6MMXt7d*xBy}X759a*gbGbS2~x4Pc9;ywU^0`=Ob~7DUc2wB z{R921p5kder~Tf4)DK;rdlMkqAe>W{d*{CMzVChBDL1)WH-(DuhEJSRu@aRa$6f#FH(CSru19$gV>UP8bom^~mED6b3H-k zfK|{v+sx!W%eNfU(yciv_ z8A}&J)rFm9FU9CmCby1#vuFlD~=p+ua?7ACflwQtB>WeHAph=LBdBJK@w zCTp~io3^|OgXt6<;hIKv((r7tE(xowc?C^ny%L)@t-Q!Ok<|nlo5_EA#WE%gTjEp3d@j44~ z%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kPm8F~zpD?8|9Q_{&7_L2yWh4TAEJ8v3dnl!f z+(;-%q{^>IX)0^Gvgvc})Z<3zY0=<@SK88VViBcXvv8l`MoM;DgkIWJO0%m~(AU@> zUaym*z)e5De+8-08#NN1A*@7UPIBZlR^L2T={dvN(8JL}FlQ?7H>T4S5pw3sEV6`=pe&@GT@;GJ+qgz(@6fj-+q<-q1o8eL?1@3xR|$JzD0cA@ z_9AX{v0L4`3v1_?`~%j{uoDI*%L_~;)^lVNE*aB}JT(neX^yI#Ljl)O?8#fW;8Y+^ sH!1IuiDYwqjl02?V01A_>S>vuvmBkbN}MEs>ukAAtD5 zAK;HN-kEJnMU2M%FgtVh-ZST(d-wZ~uipTy;B^`%rqyykg$H<;#G^DGV@4tQ6lPIK zqlmdQ=8;#+f&t6G6Nbc^@I|=J(3hV*V2E!970xhN7Czr;d52u?+lMY8*>d36?tv|Z zI=8`iSQkx(V%e!%-bz?s4P;D=B4=RH#1fVnMt3Ej zSJI{&UG#iYRJef^6RUV?VhkAr&rCeW3j;4rl(1&tm5FssFwFk5i+_&|JTLII;|xRE zYK|)$%oYRnP6@@?)Bwy6sn7F0Czf*l0CL=JJ1} zF(f6g335SRspG@p5qCm8gL8jsgjUjwG*F}UjMJ1x1K0sDjRE@W)YA{9W`x#3I$88) z3N4(2eW6VZL$oF|n8Yyc%_sm_jL?b32{~F-@;i!-(K}Npo+EaOzHIyq{g*5m^y&P5 zx=>xI*ltD{Z8pj!it|j78 zT=5H}E;-U##Te-u@5zsM^KWCKt>q0xswxu2xeKJPGE9=4cQwOQ6xFROfjgMgHzz1! MQde}3cw(6P2_6_FbN~PV diff --git a/classes/production/discord-presence_main/ch/m4th1eu/richpresence/proxy/CommonProxy.class b/classes/production/discord-presence_main/ch/m4th1eu/richpresence/proxy/CommonProxy.class deleted file mode 100644 index e42e00535a71a09eea33c419e055fdbeeb332c50..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 916 zcma)4TW=CU7(KI4mPKj-q24W3+k#EqnDh;!F-=TNh>~DV5{PrEdDY_MuaM!^-+%Mxn1$$`Q*thXep!8ftDtRGL z=yXQ{#j|)K1$O!>l5dycSnBuQIAEmFk9{u~d0H7i4;GV|S_mBX{h1q{CbMU9>1yTA z=2|Xf{ zCp|-!5PI%smP2bfpLhwYk8-%ci>B@{(JGquGJy4n8DdXl;;Det8&?aciRULOj!0%0 zFSRc-GPSieo*Ld&*eKh0RK;T)2s8&;o)}i`h13^PpDffw+BmG@2pxg$e`_RAOJzw} zzZ;)RpDVA0hL?*(hJ3Mj$wX_V(SRE#+*^7fWxnxS+O=>hK8phG*4m&}cZ7Xx@n13D z7FdolPluk%TbSsRuMnSTSg7zUWkFn{UCr$(w(0Tpu*1_dzhbq;+xZNuQTT%5AAm}l zD07aJg6w961T!FPK@D}n@Tpc@ju|&xuJG7i;~{bgD)H~e`o_j4TKNJmIjyj1Vl!=Q XXUP?5fnD6pDB>0^i}r1{Te$NJo8hsl diff --git a/classes/production/discord-presence_main/mcmod.info b/classes/production/discord-presence_main/mcmod.info deleted file mode 100644 index 186498a..0000000 --- a/classes/production/discord-presence_main/mcmod.info +++ /dev/null @@ -1,16 +0,0 @@ -[ -{ - "modid": "richpresence", - "name": "Discord Rich Presence Mod", - "description": "Un mod pour ajouter Rich Presence", - "version": "1.0", - "mcversion": "1.12.2", - "url": "https://mathieubroillet.ch/", - "updateUrl": "", - "authorList": ["M4TH1EU_"], - "credits": "RPC Lib author(s)", - "logoFile": "", - "screenshots": [], - "dependencies": [] -} -] diff --git a/classes/production/discord-presence_main/pack.mcmeta b/classes/production/discord-presence_main/pack.mcmeta deleted file mode 100644 index 4018267..0000000 --- a/classes/production/discord-presence_main/pack.mcmeta +++ /dev/null @@ -1,7 +0,0 @@ -{ - "pack": { - "description": "examplemod resources", - "pack_format": 3, - "_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)." - } -} diff --git a/src/main/java/ch/m4th1eu/richpresence/Main.java b/src/main/java/ch/m4th1eu/richpresence/Main.java index 426f863..5a831ff 100644 --- a/src/main/java/ch/m4th1eu/richpresence/Main.java +++ b/src/main/java/ch/m4th1eu/richpresence/Main.java @@ -4,7 +4,6 @@ import ch.m4th1eu.json.JSONObject; import ch.m4th1eu.richpresence.events.AdvancedStatusEvent; import ch.m4th1eu.richpresence.events.EventPresence; import ch.m4th1eu.richpresence.proxy.CommonProxy; -import net.minecraft.client.Minecraft; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; @@ -17,6 +16,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; /** * @author M4TH1EU_#0001 @@ -25,7 +25,7 @@ import java.io.UnsupportedEncodingException; public class Main { public static final String MODID = "richpresence"; public static final String NAME = "Discord Rich Presence"; - public static final String VERSION = "1.2"; + public static final String VERSION = "1.3"; @Mod.Instance(Main.MODID) public static Main instance; @@ -49,7 +49,13 @@ public class Main { //Configuration event.getModConfigurationDirectory().mkdir(); - File config_file = new File(event.getModConfigurationDirectory(), "\\" + Main.MODID + ".json"); + + File config_file = null; + try { + config_file = new File(getClass().getResource("/config/richpresence.json").toURI()); + } catch (URISyntaxException e) { + e.printStackTrace(); + } if (!config_file.exists() || config_file.length() < 10) { try { @@ -106,16 +112,20 @@ public class Main { MinecraftForge.EVENT_BUS.register(instance); MinecraftForge.EVENT_BUS.register(new AdvancedStatusEvent()); - JSONObject config = new JSONObject(Utils.readFileToString(new File(Minecraft.getMinecraft().mcDataDir, "\\config\\" + Main.MODID + ".json"))); + JSONObject config = null; + try { + config = new JSONObject(Utils.readFileToString(new File(getClass().getResource("/config/richpresence.json").toURI()))); + } catch (URISyntaxException e) { + e.printStackTrace(); + } applicationId = config.getJSONObject("application-settings").getString("applicationID"); largeimage = config.getJSONObject("application-settings").getString("large-image-name"); - largeimagetext = Utils.replaceArgsString(config.getJSONObject("application-settings").getString("large-image-text")); + largeimagetext = Utils.instance.replaceArgsString(config.getJSONObject("application-settings").getString("large-image-text")); proxy.init(); rpcClient = new EventPresence(); - proxy.rpcinit(); if (config.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu").getBoolean("enable")) { diff --git a/src/main/java/ch/m4th1eu/richpresence/Utils.java b/src/main/java/ch/m4th1eu/richpresence/Utils.java index 1057748..fb51ade 100644 --- a/src/main/java/ch/m4th1eu/richpresence/Utils.java +++ b/src/main/java/ch/m4th1eu/richpresence/Utils.java @@ -4,12 +4,26 @@ import ch.m4th1eu.json.JSONObject; import net.minecraft.client.Minecraft; import java.io.*; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; import java.nio.charset.Charset; public class Utils { + public static final Utils instance = new Utils(); + + private JSONObject config; + + { + try { + config = new JSONObject(Utils.readFileToString(new File(getClass().getResource("/config/richpresence.json").toURI()))); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + } + + /** * @author Nathanaƫl#4314 */ @@ -33,10 +47,6 @@ public class Utils { } } - - /** - * @author Nathanael - */ public static String readTextFromURL(String url) throws IOException { URL urlObject; URLConnection uc; @@ -61,8 +71,13 @@ public class Utils { /** * @author M4TH1EU_ */ - public static String replaceArgsString(String variable) { - File config_file = new File(Minecraft.getMinecraft().mcDataDir, "\\config\\" + Main.MODID + ".json"); + public String replaceArgsString(String variable) { + File config_file = null; + try { + config_file = new File(getClass().getResource("/config/richpresence.json").toURI()); + } catch (URISyntaxException e) { + e.printStackTrace(); + } JSONObject config = new JSONObject(Utils.readFileToString(config_file)); String serverip = config.getString("server-ip"); @@ -78,9 +93,9 @@ public class Utils { return variable; } - public static void updateStatus(int id) { + public void updateStatus(int id) { Thread t = new Thread(() -> { - JSONObject config = new JSONObject(Utils.readFileToString(new File(Minecraft.getMinecraft().mcDataDir, "\\config\\" + Main.MODID + ".json"))); + JSONObject onQuitServer = config.getJSONObject("advanced-status-custom").getJSONObject("onQuitServer"); JSONObject onJoinServer = config.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer"); JSONObject inPauseMenu = config.getJSONObject("advanced-status-custom").getJSONObject("inPauseMenu"); @@ -89,25 +104,25 @@ public class Utils { switch (id) { case 0: - Main.proxy.rpcupdate(Utils.replaceArgsString(config.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu").getString("message")), null, false); + Main.proxy.rpcupdate(replaceArgsString(config.getJSONObject("advanced-status-custom").getJSONObject("inMainMenu").getString("message")), null, false); break; case 1: - Main.proxy.rpcupdate(Utils.replaceArgsString(onJoinServer.getString("message")), null, false); + Main.proxy.rpcupdate(replaceArgsString(onJoinServer.getString("message")), null, false); break; case 2: - Main.proxy.rpcupdate(Utils.replaceArgsString(onQuitServer.getString("message")), null, false); + Main.proxy.rpcupdate(replaceArgsString(onQuitServer.getString("message")), null, false); break; case 3: - Main.proxy.rpcupdate(Utils.replaceArgsString(inPauseMenu.getString("message")), null, false); + Main.proxy.rpcupdate(replaceArgsString(inPauseMenu.getString("message")), null, false); break; case 4: - Main.proxy.rpcupdate(Utils.replaceArgsString(inMainMenu.getString("message")), null, false); + Main.proxy.rpcupdate(replaceArgsString(inMainMenu.getString("message")), null, false); break; case 5: - Main.proxy.rpcupdate(Utils.replaceArgsString(inInventory.getString("message")), null, false); + Main.proxy.rpcupdate(replaceArgsString(inInventory.getString("message")), null, false); break; case 6: - Main.proxy.rpcupdate(Utils.replaceArgsString(config.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer").getString("message")), null, false); + Main.proxy.rpcupdate(replaceArgsString(config.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer").getString("message")), null, false); break; default: break; diff --git a/src/main/java/ch/m4th1eu/richpresence/events/AdvancedStatusEvent.java b/src/main/java/ch/m4th1eu/richpresence/events/AdvancedStatusEvent.java index 1f0c114..04ffb74 100644 --- a/src/main/java/ch/m4th1eu/richpresence/events/AdvancedStatusEvent.java +++ b/src/main/java/ch/m4th1eu/richpresence/events/AdvancedStatusEvent.java @@ -1,9 +1,7 @@ package ch.m4th1eu.richpresence.events; import ch.m4th1eu.json.JSONObject; -import ch.m4th1eu.richpresence.Main; import ch.m4th1eu.richpresence.Utils; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiIngameMenu; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.inventory.GuiInventory; @@ -13,6 +11,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent; import java.io.File; +import java.net.URISyntaxException; /** * @author M4TH1EU_#0001 @@ -20,15 +19,23 @@ import java.io.File; @Mod.EventBusSubscriber public class AdvancedStatusEvent { - File config_file = new File(Minecraft.getMinecraft().mcDataDir, "\\config\\" + Main.MODID + ".json"); - JSONObject config = new JSONObject(Utils.readFileToString(config_file)); + JSONObject config = null; + + { + try { + config = new JSONObject(Utils.readFileToString(new File(getClass().getResource("/config/richpresence.json").toURI()))); + } catch ( + URISyntaxException e) { + e.printStackTrace(); + } + } @SubscribeEvent public void onJoinServer(FMLNetworkEvent.ClientConnectedToServerEvent event) { JSONObject onJoinServer = config.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer"); if (onJoinServer.getBoolean("enable")) { - Utils.updateStatus(1); + Utils.instance.updateStatus(1); } } @@ -37,7 +44,7 @@ public class AdvancedStatusEvent { JSONObject onQuitServer = config.getJSONObject("advanced-status-custom").getJSONObject("onQuitServer"); if (onQuitServer.getBoolean("enable")) { - Utils.updateStatus(1); + Utils.instance.updateStatus(1); } } @@ -50,25 +57,25 @@ public class AdvancedStatusEvent { if (inPauseMenu.getBoolean("enable")) { if (event.getGui() instanceof GuiIngameMenu) { - Utils.updateStatus(3); + Utils.instance.updateStatus(3); } } if (inMainMenu.getBoolean("enable")) { if (event.getGui() instanceof GuiMainMenu) { - Utils.updateStatus(4); + Utils.instance.updateStatus(4); } } if (inInventory.getBoolean("enable")) { if (event.getGui() instanceof GuiInventory) { - Utils.updateStatus(5); + Utils.instance.updateStatus(5); } } if (event.getGui() == null) { if (config.getJSONObject("advanced-status-custom").getJSONObject("onJoinServer").getBoolean("enable")) { - Utils.updateStatus(6); + Utils.instance.updateStatus(6); } } } diff --git a/src/main/java/ch/m4th1eu/richpresence/events/EventPresence.java b/src/main/java/ch/m4th1eu/richpresence/events/EventPresence.java index 3dc37fe..00b058c 100644 --- a/src/main/java/ch/m4th1eu/richpresence/events/EventPresence.java +++ b/src/main/java/ch/m4th1eu/richpresence/events/EventPresence.java @@ -15,7 +15,7 @@ public class EventPresence { public synchronized static void init() { DiscordEventHandlers handlers = new DiscordEventHandlers(); - DiscordRPC.discordInitialize(Main.applicationId, handlers, true, null); + DiscordRPC.discordInitialize(Main.applicationId, handlers, true); if (EventPresence.callbackRunner == null) { (EventPresence.callbackRunner = new Thread(() -> { while (!Thread.currentThread().isInterrupted()) { @@ -27,7 +27,7 @@ public class EventPresence { Main.logger.info("EventPresence has been started."); } - public synchronized static void updatePresence(String details, String action, Boolean changeTime) { + public static void updatePresence(String details, String action, Boolean changeTime) { DiscordRichPresence presence = new DiscordRichPresence(); presence.largeImageKey = Main.largeimage; presence.largeImageText = Main.largeimagetext; diff --git a/src/main/resources/config/richpresence.json b/src/main/resources/config/richpresence.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/src/main/resources/config/richpresence.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file