Posted February 29, 20169 yr I am trying to detect when the client connects to an SMP Server. But it seems like the onJoin event is not firing. Any help would be greatly appreciated. Here is the code i am trying. I've tried placing it in my EventHandler class, and my Main.class @SubscribeEvent public void onJoin(ClientConnectedToServerEvent event) { if(event.isLocal) { // Local Connection System.out.println("Local Connection"); }else { // Server Connection System.out.println("Server Connection"); //Do stuff to let server know we are here. } }
February 29, 20169 yr Did you register you event? Are you trying to catch connecting on server or client only? 1.7.10 is no longer supported by forge, you are on your own.
February 29, 20169 yr Author In the main class i did not register the event. My EventHandler is registered. I want to catch when the player connects to a multiplayer server, and then send a packet to the server. If the server is running the plugin i am working on, then the server will send a packet back, letting the mod know what permissions it has. Currently i am working on learning spigot plugins. But i am finding that information on packets and communicating between plugins and mods, is limited.
February 29, 20169 yr Author As a small update. I have been able to successfully send a packet to a spigot plugin. Then have the plugin send chat to my client letting me know the packet showed up. However the packet only sends when i force it through a keybind, and not in the onJoin event.
March 7, 20169 yr Author The solution i was able to come up with was to use ClientChatReceivedEvent. Look for the "<player> joined the game" message that the spigot server sends when you connect to the SMP servers. Then it gets the player name, and checks if it is our client's player name. If they match then it sends the packet to the Server. If the companion plugin is enabled on the server, the plugin will respond with permissions set by an OP. @SubscribeEvent public void onChatRecieved(ClientChatReceivedEvent event) { String StandOut = " ***************************************************"; if(event.message.getUnformattedText().contains("joined the game")){ if(event.message.getUnformattedText().contains(mc.thePlayer.getDisplayNameString())){ ForgeMod.network.sendToServer(new MyMessage("12345678901234567890123456789012345678901234567890")); } //System.out.println("Chat contains JSCM" + StandOut); }else{ //System.out.println("" + event.message.getUnformattedText() + StandOut); } } Minecraft mc = Minecraft.getMinecraft(); }
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.