Non résolu ModList
-
Bonjour, je voudrait savoir si il était possible de récupérer sous la forme d’une list ou d’un string les mods côté client quand il se connecte grace à mon mod,
j’ai remarqué que lorsque l’on se conecte, celà montre la liste des mods dans la console, mais j’aimerai récupérer cette list pour faire un truc du genre
si listdesmods contient “xray”
shutdownVoici à quoi celà ressemble dans la console, j’aimerai avoir le même type de list
Merci et bonne journée
-
Pas besoin de récupérer la liste complète.
Tu as juste à faire : ```java
if(Loader.isModLoaded(“xray”)) {
System.out.println(“X-Ray a été détecté”);
}Mais cette condition ne sera pas suffisante car le test doit être fait côté client, hors le jar client de ton mod peut être modifié pour supprimer cette condition. Pour limiter ce désagrément, tu vas devoir [signer ton jar](https://mcforge.readthedocs.io/en/latest/concepts/jarsigning/). Mais bon, sache qu'un tricheur motivé et compétent fera tout pour contourner tes mesures de sécurités, la seule "sécurité" qu'il ne pourra pas forcément contourné, c'est celle des modérateurs. Si tes modérateurs sont entraînés à reconnaitre les signes d'un x-ray (sachant qu'un ressource pack peut être un x-ray) alors tu peux pas mal limiter les risques mais tes modérateurs ne seront pas toujours disponibles pour surveiller les faits et gestes de chaque joueur.
-
Merci beaucoup ça marche
-
Bonjour,
J’ajoute que tu peux utiliser l’annotation @NetworkCheckHandler sur une fonction dans ta classe principale qui te donne une map avec tous les mods chargés (modid, version) sur le side donné.
La fonction avec cette annotation sera appelée : pendant le chargement de Mc avec les mods présents, quand tu te connectera sur un serveur avec les mods du serveur, quand un client se connectera au serveur avec les mods du client (ce qui t’intéresse).Il faut que la fonction ait ces paramètres :
@NetworkCheckHandler public boolean nomdelafonction(Map mods, Side side) { return connectionAccepteeOuPas; }
Cette protection, vu que la vérification est sur le serveur, est plus difficilement contournable, même si quelqu’un de décidé peut mettre un faux modid sur un mod de cheat
-
@‘AymericRed’:
Bonjour,
J’ajoute que tu peux utiliser l’annotation @NetworkCheckHandler sur une fonction dans ta classe principale qui te donne une map avec tous les mods chargés (modid, version) sur le side donné.
La fonction avec cette annotation sera appelée : pendant le chargement de Mc avec les mods présents, quand tu te connectera sur un serveur avec les mods du serveur, quand un client se connectera au serveur avec les mods du client (ce qui t’intéresse).Il faut que la fonction ait ces paramètres :
@NetworkCheckHandler public boolean nomdelafonction(Map mods, Side side) { return connectionAccepteeOuPas; }
Cette protection, vu que la vérification est sur le serveur, est plus difficilement contournable, même si quelqu’un de décidé peut mettre un faux modid sur un mod de cheat
Merci bcp je test ça ce weekend !
-
Il y a un souci, le jeu crash lors du démarrage du jeu
:::[21:27:02] [main/INFO] [GradleStart]: Extra: [] [21:27:02] [main/INFO] [GradleStart]: Running with arguments: [–userProperties, {}, --assetsDir, C:/Users/ciol2/.gradle/caches/minecraft/assets, --assetIndex, 1.7.10, --accessToken, {REDACTED}, --version, 1.7.10, --tweakClass, cpw.mods.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker] [21:27:02] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker [21:27:02] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker [21:27:02] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker [21:27:02] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker [21:27:02] [main/INFO] [FML]: Forge Mod Loader version 7.99.40.1614 for Minecraft 1.7.10 loading [21:27:02] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_131, running on Windows 10:amd64:10.0, installed at C:\Program Files\Java\jre1.8.0_131 [21:27:02] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [21:27:02] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker [21:27:02] [main/INFO] [GradleStart]: Injecting location in coremod cpw.mods.fml.relauncher.FMLCorePlugin [21:27:02] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [21:27:02] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [21:27:02] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker [21:27:02] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [21:27:02] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [21:27:02] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [21:27:02] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [21:27:02] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [21:27:03] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [21:27:03] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [21:27:03] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker [21:27:04] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [21:27:04] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.TerminalTweaker [21:27:04] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.TerminalTweaker [21:27:04] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [21:27:05] [main/INFO]: Setting user: Player244 [21:27:06] [Client thread/INFO]: LWJGL Version: 2.9.1 [21:27:07] [Client thread/INFO] [STDOUT]: [cpw.mods.fml.client.SplashProgress:start:188]: –-- Minecraft Crash Report ---- // You should try our sister game, Minceraft! Time: 30/05/18 21:27 Description: Loading screen debug info This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_131, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 797928840 bytes (760 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 375.95' Renderer: 'GeForce GTX 960M/PCIe/SSE2' [21:27:07] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [21:27:07] [Client thread/INFO] [FML]: MinecraftForge v10.13.4.1614 Initialized [21:27:07] [Client thread/INFO] [FML]: Replaced 183 ore recipies [21:27:07] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [21:27:08] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer [21:27:08] [Client thread/INFO] [FML]: Searching D:\Doc\Dev\eclipse\mods for mods [21:27:22] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [21:27:22] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, ciolmod] at CLIENT [21:27:22] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, ciolmod] at SERVER [21:27:23] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from CONSTRUCTING to PREINITIALIZATION. Loading cannot continue [21:27:23] [Client thread/ERROR] [FML]: States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UC mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UC FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UC Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UE ciolmod{1.0.7} [Ciol Mod] (bin) [21:27:23] [Client thread/ERROR] [FML]: The following problems were captured during this phase [21:27:23] [Client thread/ERROR] [FML]: Caught exception from ciolmod java.lang.NoClassDefFoundError: com/sun/javafx/collections/MappingChange$Map at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:1.8.0_131] at java.lang.Class.privateGetDeclaredMethods(Unknown Source) ~[?:1.8.0_131] at java.lang.Class.getDeclaredMethods(Unknown Source) ~[?:1.8.0_131] at cpw.mods.fml.common.FMLModContainer.gatherAnnotations(FMLModContainer.java:317) ~[forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar:?] at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:505) ~[forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar:?] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?] at cpw.mods.fml.common.Loader.loadMods(Loader.java:513) [Loader.class:?] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:942) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] Caused by: java.lang.ClassNotFoundException: com.sun.javafx.collections.MappingChange$Map at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_131] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_131] … 39 more Caused by: java.lang.NullPointerException at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_131] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_131] … 39 more [21:27:23] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ---- // Don't be sad, have a hug! <3 Time: 30/05/18 21:27 Description: There was a severe problem during mod loading that has caused the game to fail cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: com/sun/javafx/collections/MappingChange$Map at cpw.mods.fml.common.LoadController.transition(LoadController.java:163) at cpw.mods.fml.common.Loader.loadMods(Loader.java:544) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:208) at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) at net.minecraft.client.Minecraft.run(Minecraft.java:942) at net.minecraft.client.main.Main.main(Main.java:164) 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 net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) Caused by: java.lang.NoClassDefFoundError: com/sun/javafx/collections/MappingChange$Map at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.getDeclaredMethods(Unknown Source) at cpw.mods.fml.common.FMLModContainer.gatherAnnotations(FMLModContainer.java:317) at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:505) 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.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) 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.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.loadMods(Loader.java:513) ... 12 more Caused by: java.lang.ClassNotFoundException: com.sun.javafx.collections.MappingChange$Map at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 39 more Caused by: java.lang.NullPointerException at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:182) ... 41 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_131, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 628824072 bytes (599 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UC mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UC FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UC Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UE ciolmod{1.0.7} [Ciol Mod] (bin) GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 375.95' Renderer: 'GeForce GTX 960M/PCIe/SSE2' [21:27:23] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:398]: #@!@# Game crashed! Crash report saved to: #@!@# D:\Doc\Dev\eclipse\.\crash-reports\crash-2018-05-30_21.27.23-client.txt Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
:::
-
Mauvaise importation de la classe Map, il faut que tu importes “java.util.Map” et non “com.sun.javafx.collections.MappingChange$Map”
-
@‘Superloup10’:
Mauvaise importation de la classe Map, il faut que tu importes “java.util.Map” et non “com.sun.javafx.collections.MappingChange$Map”
Merci ça fonctionne, mais ça détecte seulement mon modid, si jen choisis un autre, ca ne fonctionne pas :
Mon code :
@NetworkCheckHandler public boolean nomdelafonction(Map mods, Side side) { String uuu = mods.toString(); if(uuu.contains("xray")){ return false; } if(uuu.contains("ciolmod")){ return false; } return true; }
-
Tu as regardé ce que renvoyait mods.toString() ?
-
@‘Superloup10’:
Tu as regardé ce que renvoyait mods.toString() ?
Ah oui ça donne ça :
{FML=7.10.99.99, Forge=10.13.4.1614, mcp=9.05, ciolmod=1.0.7}
il faut que je trouve autre chose alors
-
Déjà, étant donné que tu as une map, tu peux parcourir les clés et les valeurs, à toi maintenant de créer l’algorithme qui te permettra de faire ce que tu veux.
-
Merci beaucoup pour toute votre aide, voici mon code :
@SideOnly(Side.CLIENT) @NetworkCheckHandler public boolean nomdelafonction(Map mods, Side side) { List <modcontainer>uuuh = Loader.instance().getModList(); String fffd = uuuh.toString(); System.out.println("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz " + fffd); if(fffd.contains("xray")) { System.out.println("X-Ray a été détecté"); Minecraft.getMinecraft().displayGuiScreen(new GuiXray()); return false; } if(fffd.contains("Xray")) { System.out.println("X-Ray a été détecté"); Minecraft.getMinecraft().displayGuiScreen(new GuiXray()); return false; } return true; } ```</modcontainer>
-
Si je peux te donner un conseil, tu devrais regarder le fonctionnement des listes, tu verras que tu n’as pas besoin de les transformer en chaînes de caractères pour les utiliser.
Ensuite, comme tu fais 2 fois le même code dans 2 conditions différentes, tu peux regrouper les 2 conditions en mettant des “||”, ça sera plus propre. -
Ok merci