Posted June 22, 201411 yr I am making a mod that when a player joins the world it detects what their name is and if they have a certain name it gives them an item. How would I go about doing that?
June 22, 201411 yr Author I think the we have both confused each other. Right now I have an event that is triggered when a player logs into the world or server. I want it so that when that player logs in it gets their username. If their username is squirlemaster of Builder_BRP I want it to give them an item. How do I do that?
June 22, 201411 yr Call the getCommandSenderName() method on the player variable of the PlayerLoggedInEvent.
June 22, 201411 yr Author Is what i am suppose to do is type player.getCommandSenderName(); because that is not working?
June 22, 201411 yr Author I know Java, I think I'm just not reading it right. Could you point me to a video tutorial because those are what I learn from the best?
June 22, 201411 yr Author I forgot the event. Didn't know I needed the. I'm new to this. Haven't used events much.
June 22, 201411 yr Author How do I compair the name that was given by the event to squirlemaster or BUilder_BRP because when I try to do it with an if statement it says the it can't convert a boolean to a string but all my variables are strings? I fixed it nevermind.
June 22, 201411 yr Author When I use playername I get an error for inventory. Playername is the variable I set Event.palyer.getCommandSenderName(); to.
June 22, 201411 yr Erm... if you set playername to event.player.getCommandSenderName(), think about what type of variable that is. Now think about what you're trying to do with that variable.
June 22, 201411 yr Author I still don't get it. Can someone please link me to an example or provide one?
June 22, 201411 yr Author I know Java just not that piece. I know how to make GUIs and such but not how to do things with events.
June 22, 201411 yr Author It didn't work. Here is what I have: public class EventHookContainerClass extends ItemRegistry{ @EventHandler public void playerLogginEvent(PlayerLoggedInEvent Event){ String playername = Event.player.getCommandSenderName(); String squirlemaster = "squirlemaster"; String Builder_BRP = "Builder_BRP"; if (playername.equals(squirlemaster)){ Event.player.inventory.addItemStackToInventory(new ItemStack(YAKOB_SWORD, 1)); } } }
June 22, 201411 yr I... what? Why are you extending ItemRegistry? Also, learn which annotations to use.
June 22, 201411 yr So you claim to know Java, yet to access a variable from another class you extend that class? I'm out. Learn Java before you try making a mod.
June 22, 201411 yr You are using the incorrect @Interface. It should be @SubscribeEvent (NOT) @EventHandler.
June 23, 201411 yr I done that but mine is different since i learn java . Heres a tip for you make a string to boolean which detects it into true then u can put an if statement then put your event .
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.