Envoyer un message sur Discord quand un serveur Minecraft est ouvert
-
Ce message a été supprimé ! -
Au cas ou, ça ne marche plus, je crois qu’il y a encore quelque chose à changer mais je ne sais pas quoi :anguished_face:
-
ça ne compile pas ou le mod n’a pas l’effet prévu ?
-
@robin4002 Le mod se compile belle et bien, je le met dans le dossier mod du serveur mais quand le serveur est enfin en ligne, rien…
-
Et dans les logs du serveur il y a quoi qui s’affiche ?
-
@robin4002 Tiens les logs, pour moi, je ne vois rien d’anormal :
Starting Magma Checking for new version... No update found, latest version: (bb50f45) current version: (bb50f45) >[20:47:50] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLServerTweaker [20:47:50] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLServerTweaker [20:47:50] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLServerTweaker [20:47:50] [main/INFO] [FML]: Forge Mod Loader version 14.23.5.2855 for Minecraft 1.12.2 loading [20:47:50] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_271, running on Windows 10:amd64:10.0, installed at C:\Program Files\Java\jre1.8.0_271 [20:47:51] [main/WARN] [FML]: The coremod FMLCorePlugin (net.minecraftforge.fml.relauncher.FMLCorePlugin) is not signed! [20:47:51] [main/WARN] [FML]: The coremod FMLForgePlugin (net.minecraftforge.classloading.FMLForgePlugin) is not signed! [20:47:51] [main/WARN] [FML]: The coremod MagmaCorePlugin (org.magmafoundation.magma.MagmaCorePlugin) is not signed! [20:47:51] [main/INFO] [FML]: 2 mod patches loaded! [20:47:51] [main/INFO] [FML]: FirstAid loaded [20:47:51] [main/INFO] [FML]: FTB-Quest loaded [20:47:51] [main/INFO] [FML]: Searching C:\Users\Jovanovic\Desktop\TestMod\.\mods for mods [20:47:51] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [20:47:51] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [20:47:51] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [20:47:51] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [20:47:51] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [20:47:55] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [20:47:55] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [20:47:55] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [20:47:56] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker [20:47:56] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker [20:47:57] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.server.MinecraftServer} [20:48:05] [main/INFO] [FML]: 3 patches loaded! [20:48:05] [main/INFO] [FML]: Essentials [Fixes Commands in Essentials] loaded [20:48:05] [main/INFO] [FML]: CoreProtect [Changes Material to Magma's getBlockMaterial that has modded block materials ] loaded [20:48:05] [main/INFO] [FML]: dynmap [Remaps BukkitVersionHelperCB and BukkitVersionHelperGeneric to support Magma version] loaded [20:48:05] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Starting minecraft server version 1.12.2 [20:48:05] [Server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: To start the server with more ram, launch it as "java -Xmx1024M -Xms1024M -jar minecraft_server.jar" [20:48:05] [Server thread/INFO] [FML]: MinecraftForge v14.23.5.2855 Initialized [20:48:05] [Server thread/INFO] [FML]: Starts to replace vanilla recipe ingredients with ore ingredients. [20:48:05] [Server thread/INFO] [FML]: Invalid recipe found with multiple oredict ingredients in the same ingredient... [20:48:06] [Server thread/INFO] [FML]: Replaced 1227 ore ingredients [20:48:06] [Server thread/INFO] [FML]: Searching C:\Users\Jovanovic\Desktop\TestMod\.\mods for mods [20:48:07] [Server thread/INFO] [FML]: Forge Mod Loader has identified 5 mods to load [20:48:07] [Server thread/WARN] [FML]: Missing English translation for FML: assets/fml/lang/en_us.lang [20:48:07] [Server thread/WARN] [FML]: Missing English translation for discordmessagestatus: assets/discordmessagestatus/lang/en_us.lang [20:48:07] [Server thread/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, discordmessagestatus] at CLIENT [20:48:07] [Server thread/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, discordmessagestatus] at SERVER [20:48:08] [Server thread/INFO] [FML]: Processing ObjectHolder annotations [20:48:08] [Server thread/INFO] [FML]: Found 1168 ObjectHolder annotations [20:48:08] [Server thread/INFO] [FML]: Identifying ItemStackHolder annotations [20:48:08] [Server thread/INFO] [FML]: Found 0 ItemStackHolder annotations [20:48:08] [Server thread/INFO] [FML]: Configured a dormant chunk cache size of 0 [20:48:08] [Server thread/INFO] []: pre init c├┤t├® commun [20:48:08] [Server thread/INFO] []: pre init c├┤t├® serveur [20:48:08] [Server thread/INFO] [FML]: Applying holder lookups [20:48:08] [Server thread/INFO] [FML]: Holder lookups applied [20:48:08] [Server thread/INFO] [FML]: Applying holder lookups [20:48:08] [Server thread/INFO] [FML]: Holder lookups applied [20:48:08] [Server thread/INFO] [FML]: Applying holder lookups [20:48:08] [Server thread/INFO] [FML]: Holder lookups applied [20:48:08] [Server thread/INFO] [FML]: Applying holder lookups [20:48:08] [Server thread/INFO] [FML]: Holder lookups applied [20:48:08] [Server thread/INFO] [FML]: Injecting itemstacks [20:48:08] [Server thread/INFO] [FML]: Itemstack injection complete [20:48:08] [Server thread/WARN] [FML]: Replacing net.minecraftforge.server.permission.DefaultPermissionHandler with org.magmafoundation.magma.commands.permission.BukkitPermissionsHandler [20:48:08] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Loading properties [20:48:08] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Default game type: SURVIVAL [20:48:09] [Server thread/INFO] [Minecraft]: This server is running Magma version bb50f45 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT) [20:48:09] [Server thread/INFO] [Spigot]: Server Ping Player Sample Count: 12 [20:48:09] [Server thread/INFO] [Minecraft]: Using 4 threads for Netty based IO [20:48:10] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Generating keypair [20:48:10] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Starting Minecraft server on 0.0.0.0:25565 [20:48:10] [Server thread/INFO] [net.minecraft.network.NetworkSystem]: Using default channel type [20:48:12] [Server thread/INFO] [FML]: Applying holder lookups [20:48:12] [Server thread/INFO] [FML]: Holder lookups applied [20:48:12] [Server thread/INFO] [FML]: Injecting itemstacks [20:48:12] [Server thread/INFO] [FML]: Itemstack injection complete [20:48:12] [Server thread/INFO] [FML]: Forge Mod Loader has successfully loaded 5 mods [20:48:12] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Preparing level "world" [20:48:13] [Server thread/INFO] [FML]: Injecting existing registry data into this server instance [20:48:13] [Server thread/INFO] [FML]: Applying holder lookups [20:48:13] [Server thread/INFO] [FML]: Holder lookups applied [20:48:14] [Server thread/INFO] [Minecraft]: Server permissions file permissions.yml is empty, ignoring it [20:48:14] [Server thread/INFO] [Minecraft]: -------- World Settings For [world] -------- [20:48:14] [Server thread/INFO] [Minecraft]: Allow Zombie Pigmen to spawn from portal blocks: true [20:48:14] [Server thread/INFO] [Minecraft]: View Distance: 10 [20:48:14] [Server thread/INFO] [Minecraft]: Mob Spawn Range: 4 [20:48:14] [Server thread/INFO] [Minecraft]: Cactus Growth Modifier: 100% [20:48:14] [Server thread/INFO] [Minecraft]: Cane Growth Modifier: 100% [20:48:14] [Server thread/INFO] [Minecraft]: Melon Growth Modifier: 100% [20:48:14] [Server thread/INFO] [Minecraft]: Mushroom Growth Modifier: 100% [20:48:14] [Server thread/INFO] [Minecraft]: Pumpkin Growth Modifier: 100% [20:48:14] [Server thread/INFO] [Minecraft]: Sapling Growth Modifier: 100% [20:48:14] [Server thread/INFO] [Minecraft]: Wheat Growth Modifier: 100% [20:48:14] [Server thread/INFO] [Minecraft]: NetherWart Growth Modifier: 100% [20:48:14] [Server thread/INFO] [Minecraft]: Vine Growth Modifier: 100% [20:48:14] [Server thread/INFO] [Minecraft]: Cocoa Growth Modifier: 100% [20:48:14] [Server thread/INFO] [Minecraft]: Max TNT Explosions: 100 [20:48:14] [Server thread/INFO] [Minecraft]: Entity Activation Range: An 32 / Mo 32 / Mi 16 / Tiv true [20:48:14] [Server thread/INFO] [Minecraft]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1 [20:48:14] [Server thread/INFO] [Minecraft]: Structure Info Saving: true [20:48:14] [Server thread/INFO] [Minecraft]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms [20:48:14] [Server thread/INFO] [Minecraft]: Random Lighting Updates: false [20:48:14] [Server thread/INFO] [Minecraft]: Experience Merge Radius: 3.0 [20:48:14] [Server thread/INFO] [Minecraft]: Nerfing mobs spawned from spawners: false [20:48:14] [Server thread/INFO] [Minecraft]: Zombie Aggressive Towards Villager: true [20:48:14] [Server thread/INFO] [Minecraft]: Item Merge Radius: 2.5 [20:48:14] [Server thread/INFO] [Minecraft]: Arrow Despawn Rate: 1200 [20:48:14] [Server thread/INFO] [Minecraft]: Item Despawn Rate: 6000 [20:48:14] [Server thread/INFO] [Minecraft]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64 [20:48:14] [Server thread/INFO] [Minecraft]: Custom Map Seeds: Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911 [20:48:14] [Server thread/INFO] [FML]: Loading dimension 0 (world) (net.minecraft.server.dedicated.DedicatedServer@6dc594e3) [20:48:16] [Server thread/INFO] [net.minecraft.advancements.AdvancementList]: Loaded 488 advancements [20:48:16] [Server thread/INFO] [Minecraft]: -------- World Settings For [DIM-1] -------- [20:48:16] [Server thread/INFO] [Minecraft]: Allow Zombie Pigmen to spawn from portal blocks: true [20:48:16] [Server thread/INFO] [Minecraft]: View Distance: 10 [20:48:16] [Server thread/INFO] [Minecraft]: Mob Spawn Range: 4 [20:48:16] [Server thread/INFO] [Minecraft]: Cactus Growth Modifier: 100% [20:48:16] [Server thread/INFO] [Minecraft]: Cane Growth Modifier: 100% [20:48:16] [Server thread/INFO] [Minecraft]: Melon Growth Modifier: 100% [20:48:16] [Server thread/INFO] [Minecraft]: Mushroom Growth Modifier: 100% [20:48:16] [Server thread/INFO] [Minecraft]: Pumpkin Growth Modifier: 100% [20:48:16] [Server thread/INFO] [Minecraft]: Sapling Growth Modifier: 100% [20:48:16] [Server thread/INFO] [Minecraft]: Wheat Growth Modifier: 100% [20:48:16] [Server thread/INFO] [Minecraft]: NetherWart Growth Modifier: 100% [20:48:16] [Server thread/INFO] [Minecraft]: Vine Growth Modifier: 100% [20:48:16] [Server thread/INFO] [Minecraft]: Cocoa Growth Modifier: 100% [20:48:16] [Server thread/INFO] [Minecraft]: Max TNT Explosions: 100 [20:48:16] [Server thread/INFO] [Minecraft]: Entity Activation Range: An 32 / Mo 32 / Mi 16 / Tiv true [20:48:16] [Server thread/INFO] [Minecraft]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1 [20:48:16] [Server thread/INFO] [Minecraft]: Structure Info Saving: true [20:48:16] [Server thread/INFO] [Minecraft]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms [20:48:16] [Server thread/INFO] [Minecraft]: Random Lighting Updates: false [20:48:16] [Server thread/INFO] [Minecraft]: Experience Merge Radius: 3.0 [20:48:16] [Server thread/INFO] [Minecraft]: Nerfing mobs spawned from spawners: false [20:48:16] [Server thread/INFO] [Minecraft]: Zombie Aggressive Towards Villager: true [20:48:16] [Server thread/INFO] [Minecraft]: Item Merge Radius: 2.5 [20:48:16] [Server thread/INFO] [Minecraft]: Arrow Despawn Rate: 1200 [20:48:16] [Server thread/INFO] [Minecraft]: Item Despawn Rate: 6000 [20:48:16] [Server thread/INFO] [Minecraft]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64 [20:48:16] [Server thread/INFO] [Minecraft]: Custom Map Seeds: Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911 [20:48:16] [Server thread/INFO] [FML]: Loading dimension -1 (DIM-1) (net.minecraft.server.dedicated.DedicatedServer@6dc594e3) [20:48:17] [Server thread/INFO] [Minecraft]: -------- World Settings For [DIM1] -------- [20:48:17] [Server thread/INFO] [Minecraft]: Allow Zombie Pigmen to spawn from portal blocks: true [20:48:17] [Server thread/INFO] [Minecraft]: View Distance: 10 [20:48:17] [Server thread/INFO] [Minecraft]: Mob Spawn Range: 4 [20:48:17] [Server thread/INFO] [Minecraft]: Cactus Growth Modifier: 100% [20:48:17] [Server thread/INFO] [Minecraft]: Cane Growth Modifier: 100% [20:48:17] [Server thread/INFO] [Minecraft]: Melon Growth Modifier: 100% [20:48:17] [Server thread/INFO] [Minecraft]: Mushroom Growth Modifier: 100% [20:48:17] [Server thread/INFO] [Minecraft]: Pumpkin Growth Modifier: 100% [20:48:17] [Server thread/INFO] [Minecraft]: Sapling Growth Modifier: 100% [20:48:17] [Server thread/INFO] [Minecraft]: Wheat Growth Modifier: 100% [20:48:17] [Server thread/INFO] [Minecraft]: NetherWart Growth Modifier: 100% [20:48:17] [Server thread/INFO] [Minecraft]: Vine Growth Modifier: 100% [20:48:17] [Server thread/INFO] [Minecraft]: Cocoa Growth Modifier: 100% [20:48:17] [Server thread/INFO] [Minecraft]: Max TNT Explosions: 100 [20:48:17] [Server thread/INFO] [Minecraft]: Entity Activation Range: An 32 / Mo 32 / Mi 16 / Tiv true [20:48:17] [Server thread/INFO] [Minecraft]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1 [20:48:17] [Server thread/INFO] [Minecraft]: Structure Info Saving: true [20:48:17] [Server thread/INFO] [Minecraft]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms [20:48:17] [Server thread/INFO] [Minecraft]: Random Lighting Updates: false [20:48:17] [Server thread/INFO] [Minecraft]: Experience Merge Radius: 3.0 [20:48:17] [Server thread/INFO] [Minecraft]: Nerfing mobs spawned from spawners: false [20:48:17] [Server thread/INFO] [Minecraft]: Zombie Aggressive Towards Villager: true [20:48:17] [Server thread/INFO] [Minecraft]: Item Merge Radius: 2.5 [20:48:17] [Server thread/INFO] [Minecraft]: Arrow Despawn Rate: 1200 [20:48:17] [Server thread/INFO] [Minecraft]: Item Despawn Rate: 6000 [20:48:17] [Server thread/INFO] [Minecraft]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64 [20:48:17] [Server thread/INFO] [Minecraft]: Custom Map Seeds: Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911 [20:48:17] [Server thread/INFO] [FML]: Loading dimension 1 (DIM1) (net.minecraft.server.dedicated.DedicatedServer@6dc594e3) [20:48:17] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Preparing start region for level 0 (Seed: -823376857872253602) [20:48:19] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Preparing spawn area: 0% [20:48:20] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Preparing spawn area: 16% [20:48:21] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Preparing spawn area: 47% [20:48:22] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Preparing spawn area: 93% [20:48:22] [Server thread/INFO] [Minecraft]: Server permissions file permissions.yml is empty, ignoring it [20:48:22] [Server thread/INFO] [Minecraft]: Server permissions file permissions.yml is empty, ignoring it [20:48:22] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Done (10,167s)! For help, type "help" or "?" [20:48:22] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Starting Minecraft server on 0.0.0.0:25565 [20:48:22] [Server thread/INFO] [Minecraft]: Timings Reset [20:48:23] [Server thread/INFO] [FML]: Unloading dimension -1
-
Ah mais c’est normal, il manque
@EventHandler
au dessus de la fonctionpublic void onServerStart(FMLServerStartedEvent event)
-
Ce message a été supprimé ! -
Discord a refusé la requête (code 403, forbidden) assures-toi que l’url de web-hook est correcte (d’ailleurs, c’est pas une super idée de la publier sur le forum, des gens pourraient envoyer des messages vers ton discord avec).
-
@robin4002 Ok, j’ai supprimer merci. le lien est le bon pourtant
-
Bizarre. Je vais regarder ça en détails ce soir.
-
@robin4002 Ok, prends ton temps
-
Bon après multiple tentative :
@EventHandler public void onServerStart(FMLServerStartedEvent event) { try { sendDiscordWebhookMessage("Server status notifier", "Le serveur vient de démarrer"); } catch(IOException ex) { System.err.println("Impossible d'envoyer le message de démarrage sur discord"); ex.printStackTrace(); } } public void sendDiscordWebhookMessage(String username, String message) throws IOException { HttpPost post = new HttpPost("lien webhook discord"); post.addHeader("Content-Type", "application/json"); post.addHeader("User-Agent", "Minecraft Server"); JsonObject json = new JsonObject(); json.addProperty("username", username); json.addProperty("content", message); // send a JSON data post.setEntity(new StringEntity(json.toString())); CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpResponse response = httpClient.execute(post); if (response.getEntity() != null) { String result = EntityUtils.toString(response.getEntity()); System.out.println(result); } }
Il faut impérativement avoir un
User-Agent
sinon Discord refuse la requête.
J’ai séparé l’envoie dans une fonction à part, comme ça tu peux également réutiliser la fonctionsendDiscordWebhookMessage
pour l’extinction du serveur -
@robin4002 Ok, je teste ça demain et je te tiens au courant, et déjà d’avance, merci pour toute cette implication
-
@robin4002 Et y-a-t-il des trucs a modifier ? (a part le lien a rajouter) car j’ai encore un crash mais ca na pas l’air d’être le meme
-
Non, il y a que le lien à changer.
Envoies le rapport de crash ?
-
@robin4002 Voici le crash :
---- Minecraft Crash Report ---- // Who set us up the TNT? Time: 16/01/21 14:14 Description: Exception in server tick loop java.lang.NoClassDefFoundError: org/apache/http/HttpEntity at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at net.minecraftforge.fml.common.FMLModContainer.constructMod(FMLModContainer.java:539) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136) at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:566) at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:102) at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:335) at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:169) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:688) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpEntity at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:106) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 34 more
-
hum donc contrairement à ce que je pensais, le client http d’apache est pas dispo, pourtant il était présent sur le classpath de la workspace alors que je n’ai rien ajouté.
Donc il va falloir encore modifier le code, revenir sur le client http de java.
@EventHandler public void onServerStart(FMLServerStartedEvent event) { try { sendDiscordWebhookMessage("Server status notifier", "Le serveur vient de démarrer"); } catch(Exception ex) { System.err.println("Impossible d'envoyer le message de démarrage sur discord"); ex.printStackTrace(); } } public void sendDiscordWebhookMessage(String username, String message) throws Exception { URL url = new URL ("url"); HttpURLConnection con = (HttpURLConnection)url.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type", "application/json; utf-8"); con.setRequestProperty("User-Agent", "Minecraft Server"); con.setRequestProperty("Accpet", "application/json"); con.setDoOutput(true); JsonObject json = new JsonObject(); json.addProperty("username", username); json.addProperty("content", message); try(OutputStream os = con.getOutputStream()) { byte[] input = json.toString().getBytes("utf-8"); os.write(input, 0, input.length); } BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8")); StringBuilder response = new StringBuilder(); String responseLine = null; while ((responseLine = br.readLine()) != null) { response.append(responseLine.trim()); } System.out.println(response.toString()); }
P.S : j’ai reprit le code des précédents message supprimé (les admin voient les messages supprimés) et en testant je crois que j’ai envoyé un message vers ton discord car j’ai oublié de changer l’url par mon webhook de test x).
-
@robin4002 J’ai bien reçu le message ca devrai bien marcher alors. Je vais test
-
@robin4002 Nickel ca marche ! Juste petit problème, le démarrer est bugé sur Discord, il apparait sans le é et il y a @… a la place, possible de modifier ca ? Sinon merci