mlgmxyysd Posted December 27, 2018 Posted December 27, 2018 I use Minecraft.getMinecraft().player.sendChatMessage("/login " + password); then game throw a NullPointerException. Context: package org.meowcat.autocommadner; import net.minecraft.client.Minecraft; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.io.*; import java.lang.reflect.Method; import java.util.Properties; public class JoinEvent { private Properties prop = new Properties(); JoinEvent() { MinecraftForge.EVENT_BUS.register(this); FMLCommonHandler.instance().bus().register(this); } @SideOnly(Side.CLIENT) @SubscribeEvent public void PlayerJoinGame(PlayerEvent.PlayerLoggedInEvent event) throws IOException { try{ Class mc = Class.forName(Minecraft.class.getName()); Method[] methods = mc.getMethods(); for (Method method : methods){ Main.logger.info(method.getName()); } } catch (ClassNotFoundException e ) { e.printStackTrace(); } File file = new File("config/user.properties"); if (!file.exists()) { Minecraft.getMinecraft().shutdown(); } InputStream in = new BufferedInputStream(new FileInputStream("config/user.properties")); prop.load(in); String password = prop.getProperty("Password"); String registered = prop.getProperty("IsRegistered"); if (!registered.equals("true")) { Minecraft.getMinecraft().player.sendChatMessage("/register " + password + " " + password); } else { Minecraft.getMinecraft().player.sendChatMessage("/login " + password); } } } Quote
Cadiboo Posted December 27, 2018 Posted December 27, 2018 (edited) What exactly are you trying to do? From an end-user persective Edited December 27, 2018 by Cadiboo Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
mlgmxyysd Posted December 27, 2018 Author Posted December 27, 2018 Auto send a command when player join game (server/single). Quote
mlgmxyysd Posted December 27, 2018 Author Posted December 27, 2018 24 minutes ago, diesieben07 said: Why are you making register / login commands? Mojang already has accounts, there is no need to make a secondary account system. That is not main issue. I can replace by any command,it only is a placeholder. Quote
mlgmxyysd Posted December 28, 2018 Author Posted December 28, 2018 9 hours ago, diesieben07 said: It might not be. Still, why? This usually means you are pirating the game. You need to use ClientTickEvent, PlayedLoggedInEvent is server-side only. And that is not how @SideOnly works. The mod is a client mod,not a server mod. Quote
mlgmxyysd Posted December 28, 2018 Author Posted December 28, 2018 9 hours ago, diesieben07 said: It might not be. Still, why? This usually means you are pirating the game. You need to use ClientTickEvent, PlayedLoggedInEvent is server-side only. And that is not how @SideOnly works. No,I bought Minecraft. Quote
mlgmxyysd Posted December 28, 2018 Author Posted December 28, 2018 3 hours ago, diesieben07 said: Yes, that is why you need ClientTickEvent. It not work. When game inited(not join a game),force close by NullPointer. Quote
Cadiboo Posted December 28, 2018 Posted December 28, 2018 send your code and the error Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
mlgmxyysd Posted December 29, 2018 Author Posted December 29, 2018 19 hours ago, Cadiboo said: send your code and the error All code and error is posted at top. Quote
mlgmxyysd Posted December 30, 2018 Author Posted December 30, 2018 13 hours ago, diesieben07 said: The code above has not changed. No error was posted. It may cause by network problem. package org.meowcat.autocommadner; import net.minecraft.client.Minecraft; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.io.*; import java.lang.reflect.Method; import java.util.Properties; public class JoinEvent { private Properties prop = new Properties(); JoinEvent() { MinecraftForge.EVENT_BUS.register(this); FMLCommonHandler.instance().bus().register(this); } @SideOnly(Side.CLIENT) @SubscribeEvent public void PlayerJoinGame(TickEvent.ClientTickEvent event) throws IOException { try{ Class mc = Class.forName(Minecraft.class.getName()); Method[] methods = mc.getMethods(); for (Method method : methods){ Main.logger.info(method.getName()); } } catch (ClassNotFoundException e ) { e.printStackTrace(); } File file = new File("config/user.properties"); if (!file.exists()) { Minecraft.getMinecraft().shutdown(); } InputStream in = new BufferedInputStream(new FileInputStream("config/user.properties")); prop.load(in); String password = prop.getProperty("Password"); String registered = prop.getProperty("IsRegistered"); if (!registered.equals("true")) { Minecraft.getMinecraft().player.sendChatMessage("/register " + password + " " + password); } else { Minecraft.getMinecraft().player.sendChatMessage("/login " + password); } } } java.lang.NullPointerException: Unexpected error at org.meowcat.autocommadner.JoinEvent.PlayerJoinGame(JoinEvent.java:42) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_18_JoinEvent_PlayerJoinGame_ClientTickEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) at net.minecraftforge.fml.common.FMLCommonHandler.onPreClientTick(FMLCommonHandler.java:344) at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1708) at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1098) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398) at net.minecraft.client.main.Main.main(SourceFile:123) 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) These are codes & errors Quote
Cadiboo Posted December 30, 2018 Posted December 30, 2018 (edited) What are you trying to do with that code? Edited December 30, 2018 by Cadiboo Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
mlgmxyysd Posted December 31, 2018 Author Posted December 31, 2018 5 hours ago, diesieben07 said: Why on earth is this here? And blindly catching ClassNotFoundException and ignoring it is a bad idea. Handle exceptions properly. Why on earth are you doing this every tick?! And registered should not be an option. Do not pirate the game. You can only do this when the game is actually connected to a server. ClientTickEvent fires every client tick (duh), which is also during e.g. the main menu. Please don't get caught up in the secondary problem. I only want to solve NullPointerException. Quote
mlgmxyysd Posted December 31, 2018 Author Posted December 31, 2018 11 hours ago, Cadiboo said: What are you trying to do with that code? When player join a game (server/single), player will send a message(or command) automatically. Quote
mlgmxyysd Posted December 31, 2018 Author Posted December 31, 2018 3 minutes ago, diesieben07 said: Pirating the game is not a secondary problem. Please clearly state why that isRegistered option is present. If not I will assume it is for enabling pirated "accounts", in which case you will receive a ban. A bukkit plugin named Authme. Quote
hiotewdew Posted December 31, 2018 Posted December 31, 2018 On 12/27/2018 at 10:51 AM, diesieben07 said: It might not be. Still, why? This usually means you are pirating the game. You need to use ClientTickEvent, PlayedLoggedInEvent is server-side only. And that is not how @SideOnly works. Not to go too off topic, but /login can be used on servers as a staff security measure as well as for cracked server auth. So, it's not always malicious. I once had to use it on my online mode server because we had this hacker who somehow figured out that commands could be run by staff before they were authenticated (I have no idea how, but I'm not lying, he'd done it) and so I had to add a login command for staff to counteract it. Quote All Projects found here: Website Main Programmer for: Better Animals Plus, Better Animal Models Created independently: QuickHomes, ClaimIt, ClaimIt API, CloneLand, DerpCats, QuickTeleports, QuickSpawns, MCMusicPlayer, MCDevDate, [SBM] Fluid Gun, OpenScreens Work on/Contribute to: Bewitchment Commissioned for: [SBM] Breadstone, [SBM] Infinite Falling, [SBM] Dead Man's Satchel, [SBM] Handheld Piston
mlgmxyysd Posted January 16, 2019 Author Posted January 16, 2019 On 12/31/2018 at 11:20 PM, diesieben07 said: I know, and this is the only reason this thread is not locked yet. This explains nothing. As far as the cause of your exception goes, I have already explained that above. OKAY, I does not use /login command, replace /login to /exp ok? IS THIS OK? package org.meowcat.autocommadner; import net.minecraft.client.Minecraft; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.io.*; import java.lang.reflect.Method; import java.util.Properties; public class JoinEvent { private Properties prop = new Properties(); JoinEvent() { MinecraftForge.EVENT_BUS.register(this); FMLCommonHandler.instance().bus().register(this); } @SideOnly(Side.CLIENT) @SubscribeEvent public void PlayerJoinGame(TickEvent.ClientTickEvent event) throws IOException { try{ Class mc = Class.forName(Minecraft.class.getName()); Method[] methods = mc.getMethods(); for (Method method : methods){ Main.logger.info(method.getName()); } } catch (ClassNotFoundException e ) { e.printStackTrace(); } Minecraft.getMinecraft().player.sendChatMessage("/exp"); } } Quote
mlgmxyysd Posted January 16, 2019 Author Posted January 16, 2019 On 12/31/2018 at 11:20 PM, diesieben07 said: As far as the cause of your exception goes, I have already explained that above. And ClientTickEvent, PlayedLoggedInEvent dont have sendChatMessage() method. Quote
mlgmxyysd Posted January 16, 2019 Author Posted January 16, 2019 On 12/31/2018 at 2:24 PM, hiotewdew said: Not to go too off topic, but /login can be used on servers as a staff security measure as well as for cracked server auth. So, it's not always malicious. I once had to use it on my online mode server because we had this hacker who somehow figured out that commands could be run by staff before they were authenticated (I have no idea how, but I'm not lying, he'd done it) and so I had to add a login command for staff to counteract it. Yes, it is necessary to use unofficial login system in offline-mode server. Quote
mlgmxyysd Posted January 16, 2019 Author Posted January 16, 2019 3 hours ago, diesieben07 said: Don't make an offline-mode server. Why? I WANT to do that. Is that about you? Quote
mlgmxyysd Posted January 16, 2019 Author Posted January 16, 2019 3 hours ago, diesieben07 said: Don't make an offline-mode server. If offline-mode server is not allowed, it is unable to set online-mode=false in server.prop. Quote
coalbricks Posted October 15, 2021 Posted October 15, 2021 On 1/16/2019 at 8:34 AM, diesieben07 said: Why do you want an offline-mode server? There is no reason except: To allow pirating the game, in which case that is not allowed. For a local network, in which case there i no need for whitelisting (you are already in a local network, noone can join from outside). This is an old discussion, but after reading through it seems you've been unfair to @mlgmxyysd and wrong to assume that there are only two reasons why someone might want an offline mode server. I can give you a couple more valid and legitimate reasons: 1. The local network point is valid, and yes nobody can join from outside, but he could be running his server on a university network in which case custom authentication would be useful. It could be that nobody could join from outside, but 30 thousand people could join from inside. 2. He could be running his server on a network where Minecraft's authentication endpoint is blocked. Quote
Luis_ST Posted October 15, 2021 Posted October 15, 2021 (edited) 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support. Edited October 15, 2021 by Luis_ST Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.