Ajout fichier de config
This commit is contained in:
parent
7557a909ea
commit
2f463737d5
205
.gitignore
vendored
205
.gitignore
vendored
@ -1,22 +1,195 @@
|
|||||||
# eclipse
|
|
||||||
bin
|
# Created by https://www.gitignore.io/api/java,eclipse,intellij,forgegradle
|
||||||
*.launch
|
# Edit at https://www.gitignore.io/?templates=java,eclipse,intellij,forgegradle
|
||||||
.settings
|
|
||||||
|
### Eclipse ###
|
||||||
.metadata
|
.metadata
|
||||||
.classpath
|
bin/
|
||||||
|
tmp/
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*~.nib
|
||||||
|
local.properties
|
||||||
|
.settings/
|
||||||
|
.loadpath
|
||||||
|
.recommenders
|
||||||
|
|
||||||
|
# External tool builders
|
||||||
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
# Locally stored "Eclipse launch configurations"
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# PyDev specific (Python IDE for Eclipse)
|
||||||
|
*.pydevproject
|
||||||
|
|
||||||
|
# CDT-specific (C/C++ Development Tooling)
|
||||||
|
.cproject
|
||||||
|
|
||||||
|
# CDT- autotools
|
||||||
|
.autotools
|
||||||
|
|
||||||
|
# Java annotation processor (APT)
|
||||||
|
.factorypath
|
||||||
|
|
||||||
|
# PDT-specific (PHP Development Tools)
|
||||||
|
.buildpath
|
||||||
|
|
||||||
|
# sbteclipse plugin
|
||||||
|
.target
|
||||||
|
|
||||||
|
# Tern plugin
|
||||||
|
.tern-project
|
||||||
|
|
||||||
|
# TeXlipse plugin
|
||||||
|
.texlipse
|
||||||
|
|
||||||
|
# STS (Spring Tool Suite)
|
||||||
|
.springBeans
|
||||||
|
|
||||||
|
# Code Recommenders
|
||||||
|
.recommenders/
|
||||||
|
|
||||||
|
# Annotation Processing
|
||||||
|
.apt_generated/
|
||||||
|
|
||||||
|
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||||
|
.cache-main
|
||||||
|
.scala_dependencies
|
||||||
|
.worksheet
|
||||||
|
|
||||||
|
### Eclipse Patch ###
|
||||||
|
# Eclipse Core
|
||||||
.project
|
.project
|
||||||
|
|
||||||
# idea
|
# JDT-specific (Eclipse Java Development Tools)
|
||||||
out
|
.classpath
|
||||||
*.ipr
|
|
||||||
|
# Annotation Processing
|
||||||
|
.apt_generated
|
||||||
|
|
||||||
|
.sts4-cache/
|
||||||
|
|
||||||
|
### ForgeGradle ###
|
||||||
|
# Minecraft client/server files
|
||||||
|
run/**
|
||||||
|
run/
|
||||||
|
|
||||||
|
|
||||||
|
### Intellij ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**
|
||||||
|
.idea/**/
|
||||||
|
.idea/*
|
||||||
|
.idea/*/
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
*.iws
|
*.iws
|
||||||
*.iml
|
|
||||||
.idea
|
|
||||||
|
|
||||||
# gradle
|
# IntelliJ
|
||||||
build
|
out/
|
||||||
.gradle
|
|
||||||
|
|
||||||
# other
|
# mpeltonen/sbt-idea plugin
|
||||||
eclipse
|
.idea_modules/
|
||||||
run
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
### Intellij Patch ###
|
||||||
|
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||||
|
|
||||||
|
# *.iml
|
||||||
|
# modules.xml
|
||||||
|
# .idea/misc.xml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# Sonarlint plugin
|
||||||
|
.idea/sonarlint
|
||||||
|
|
||||||
|
### Java ###
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
build/**
|
||||||
|
classes/**
|
||||||
|
classes/**/
|
||||||
|
classes/*/
|
||||||
|
classes/*
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Mobile Tools for Java (J2ME)
|
||||||
|
.mtj.tmp/
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
# End of https://www.gitignore.io/api/java,eclipse,intellij,forgegradle
|
||||||
|
@ -11,11 +11,12 @@ 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.
|
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||||
|
|
||||||
|
|
||||||
version = "1.0"
|
version = "1.1"
|
||||||
group = "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
group = "ch.m4th1eu.richpresence" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
archivesBaseName = "modid"
|
archivesBaseName = "richpresence"
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
sourceCompatibility = targetCompatibility = '1.8' // Need
|
||||||
|
// this here so eclipse task generates correctly.
|
||||||
compileJava {
|
compileJava {
|
||||||
sourceCompatibility = targetCompatibility = '1.8'
|
sourceCompatibility = targetCompatibility = '1.8'
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package ch.m4th1eu.richpresence;
|
package ch.m4th1eu.richpresence;
|
||||||
|
|
||||||
|
import ch.m4th1eu.richpresence.events.AdvancedStatusEvent;
|
||||||
import ch.m4th1eu.richpresence.events.EventPresence;
|
import ch.m4th1eu.richpresence.events.EventPresence;
|
||||||
import ch.m4th1eu.richpresence.events.Events;
|
|
||||||
import ch.m4th1eu.richpresence.proxy.CommonProxy;
|
import ch.m4th1eu.richpresence.proxy.CommonProxy;
|
||||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
@ -11,26 +10,35 @@ import net.minecraftforge.fml.common.Mod.EventHandler;
|
|||||||
import net.minecraftforge.fml.common.SidedProxy;
|
import net.minecraftforge.fml.common.SidedProxy;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author M4TH1EU_#0001
|
||||||
|
*/
|
||||||
@Mod(modid = Main.MODID, name = Main.NAME, version = Main.VERSION)
|
@Mod(modid = Main.MODID, name = Main.NAME, version = Main.VERSION)
|
||||||
public class Main {
|
public class Main {
|
||||||
public static final String MODID = "richpresence";
|
public static final String MODID = "richpresence";
|
||||||
public static final String NAME = "Discord Rich Presence";
|
public static final String NAME = "Discord Rich Presence";
|
||||||
public static final String VERSION = "1.0.0";
|
public static final String VERSION = "1.1";
|
||||||
|
|
||||||
public EventPresence rpcClient;
|
|
||||||
|
|
||||||
|
|
||||||
@SidedProxy(clientSide = "ch.m4th1eu.richpresence.proxy.ClientProxy", serverSide = "ch.m4th1eu.richpresence.proxy.CommonProxy")
|
@SidedProxy(clientSide = "ch.m4th1eu.richpresence.proxy.ClientProxy", serverSide = "ch.m4th1eu.richpresence.proxy.CommonProxy")
|
||||||
public static CommonProxy proxy;
|
public static CommonProxy proxy;
|
||||||
|
|
||||||
public static String applicationId;
|
/**
|
||||||
|
* Variables pour la config
|
||||||
|
*/
|
||||||
|
public static String applicationId, largeimage, largeimagetext;
|
||||||
|
public static boolean advancedstatus;
|
||||||
|
|
||||||
|
|
||||||
private static Logger logger;
|
public static Logger logger;
|
||||||
|
public EventPresence rpcClient;
|
||||||
|
|
||||||
|
|
||||||
|
public Main() {
|
||||||
|
MinecraftForge.EVENT_BUS.register(new AdvancedStatusEvent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
logger = event.getModLog();
|
logger = event.getModLog();
|
||||||
proxy.preInit(event.getSuggestedConfigurationFile());
|
proxy.preInit(event.getSuggestedConfigurationFile());
|
||||||
@ -39,7 +47,11 @@ public class Main {
|
|||||||
Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
|
Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
|
||||||
try {
|
try {
|
||||||
cfg.load();
|
cfg.load();
|
||||||
applicationId = cfg.getString("applicationId", "", "applicationId", "this is a comment");
|
applicationId = cfg.getString("applicationID", "DiscordRichPresence", "ex: 491941559181246465", "Ici mettez le client id de votre application (https://bit.ly/2Lu1CC3).");
|
||||||
|
largeimage = cfg.getString("largeimage", "DiscordRichPresence", "logo", "Ici mettez le nom de votre image (celle dans RichPresence -> Art Assets). (sans le .png)");
|
||||||
|
largeimagetext = cfg.getString("largeimagetext", "DiscordRichPresence", "Mon serveur !", "Ici mettez le texte qui s'affichera quand vous passerez la souris sur l'image.");
|
||||||
|
|
||||||
|
advancedstatus = cfg.getBoolean("advancedstatus", "DiscordRichPresence", true, "Ici laissez \"true\" si vous voulez un status avancé sinon mettez \"false\".");
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
event.getModLog().error("Failed to load configuration");
|
event.getModLog().error("Failed to load configuration");
|
||||||
@ -52,10 +64,6 @@ public class Main {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Main() {
|
|
||||||
MinecraftForge.EVENT_BUS.register(new Events());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
|
|
||||||
@ -63,8 +71,12 @@ public class Main {
|
|||||||
rpcClient = new EventPresence();
|
rpcClient = new EventPresence();
|
||||||
|
|
||||||
proxy.rpcinit();
|
proxy.rpcinit();
|
||||||
|
if (Main.advancedstatus) {
|
||||||
proxy.rpcupdate("Dans le menu.", null);
|
proxy.rpcupdate("Dans le menu.", null);
|
||||||
|
} else {
|
||||||
|
proxy.rpcupdate("", null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,27 +7,36 @@ import net.minecraftforge.fml.common.Mod;
|
|||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
|
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author M4TH1EU_#0001
|
||||||
|
*/
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class Events {
|
public class AdvancedStatusEvent {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onServerJoin(FMLNetworkEvent.ClientConnectedToServerEvent event) {
|
public void onServerJoin(FMLNetworkEvent.ClientConnectedToServerEvent event) {
|
||||||
|
if (Main.advancedstatus) {
|
||||||
Main.proxy.rpcupdate("En jeu.", null);
|
Main.proxy.rpcupdate("En jeu.", null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onQuitServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
|
public void onQuitServer(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
|
||||||
Main.proxy.rpcupdate("Dans le menu.", null);
|
if (Main.advancedstatus) {
|
||||||
|
|
||||||
|
Main.proxy.rpcupdate("Dans le menu principal.", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onGuiOpen(GuiOpenEvent event) {
|
public void onGuiOpen(GuiOpenEvent event) {
|
||||||
|
if (Main.advancedstatus) {
|
||||||
if (event.getGui() instanceof GuiIngameMenu) {
|
if (event.getGui() instanceof GuiIngameMenu) {
|
||||||
Main.proxy.rpcupdate("Dans le menu.", null);
|
Main.proxy.rpcupdate("Dans le menu pause.", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(event.getGui());
|
System.out.println(event.getGui());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,16 +1,20 @@
|
|||||||
package ch.m4th1eu.richpresence.events;
|
package ch.m4th1eu.richpresence.events;
|
||||||
|
|
||||||
|
import ch.m4th1eu.richpresence.Main;
|
||||||
import net.arikia.dev.drpc.DiscordEventHandlers;
|
import net.arikia.dev.drpc.DiscordEventHandlers;
|
||||||
import net.arikia.dev.drpc.DiscordRPC;
|
import net.arikia.dev.drpc.DiscordRPC;
|
||||||
import net.arikia.dev.drpc.DiscordRichPresence;
|
import net.arikia.dev.drpc.DiscordRichPresence;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author M4TH1EU_#0001
|
||||||
|
*/
|
||||||
public class EventPresence {
|
public class EventPresence {
|
||||||
|
|
||||||
private static Thread callbackRunner;
|
private static Thread callbackRunner;
|
||||||
|
|
||||||
public synchronized static final void init() {
|
public synchronized static final void init() {
|
||||||
DiscordEventHandlers handlers = new DiscordEventHandlers();
|
DiscordEventHandlers handlers = new DiscordEventHandlers();
|
||||||
DiscordRPC.discordInitialize("BOT CLIENT ID", handlers, true, null);
|
DiscordRPC.discordInitialize(Main.applicationId, handlers, true, null);
|
||||||
if (EventPresence.callbackRunner == null) {
|
if (EventPresence.callbackRunner == null) {
|
||||||
(EventPresence.callbackRunner = new Thread(() -> {
|
(EventPresence.callbackRunner = new Thread(() -> {
|
||||||
while (!Thread.currentThread().isInterrupted()) {
|
while (!Thread.currentThread().isInterrupted()) {
|
||||||
@ -23,13 +27,13 @@ public class EventPresence {
|
|||||||
return;
|
return;
|
||||||
}, "RPC-Callback-Handler")).start();
|
}, "RPC-Callback-Handler")).start();
|
||||||
}
|
}
|
||||||
System.out.println("EventPresence has been started.");
|
Main.logger.info("EventPresence has been started.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void updatePresence(String details, String action) {
|
public static final void updatePresence(String details, String action) {
|
||||||
DiscordRichPresence presence = new DiscordRichPresence();
|
DiscordRichPresence presence = new DiscordRichPresence();
|
||||||
presence.largeImageKey = "image";
|
presence.largeImageKey = Main.largeimage;
|
||||||
presence.largeImageText = "TEXT";
|
presence.largeImageText = Main.largeimagetext;
|
||||||
if (details != null) {
|
if (details != null) {
|
||||||
presence.details = details;
|
presence.details = details;
|
||||||
|
|
||||||
|
@ -5,6 +5,9 @@ import net.minecraftforge.common.MinecraftForge;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author M4TH1EU_#0001
|
||||||
|
*/
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,6 +2,9 @@ package ch.m4th1eu.richpresence.proxy;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author M4TH1EU_#0001
|
||||||
|
*/
|
||||||
public class CommonProxy {
|
public class CommonProxy {
|
||||||
|
|
||||||
public void preInit(File configFile) {
|
public void preInit(File configFile) {
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
{
|
{
|
||||||
"modid": "richpresence",
|
"modid": "richpresence",
|
||||||
"name": "Discord Rich Presence Mod",
|
"name": "Discord Rich Presence Mod",
|
||||||
"description": "Un mod pour ajouter Rich Presence",
|
"description": "Un mod pour ajouter un Rich Presence personnalisé",
|
||||||
"version": "1.0",
|
"version": "${version}",
|
||||||
"mcversion": "1.12.2",
|
"mcversion": "1.12.2",
|
||||||
"url": "https://mathieubroillet.ch/",
|
"url": "https://mathieubroillet.ch/",
|
||||||
"updateUrl": "",
|
"updateUrl": "",
|
||||||
"authorList": ["M4TH1EU_"],
|
"authorList": [
|
||||||
|
"M4TH1EU_"
|
||||||
|
],
|
||||||
"credits": "RPC Lib author(s)",
|
"credits": "RPC Lib author(s)",
|
||||||
"logoFile": "",
|
"logoFile": "",
|
||||||
"screenshots": [],
|
"screenshots": [],
|
||||||
|
Reference in New Issue
Block a user