I need help with something very simple :P

Discussion in 'Plugin Development' started by porrinialex, Nov 3, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    porrinialex

    When i said simple i mean for you not me <: Im pretty new to this, And i know this is probably not even close to right. But what i was trying to make this code do is. When you do the command /clam
    People with the permissions me.gold. Get a messaged "Worked" and the player with the permission
    me.iron gets the message "Also workes"


    Code:java
    1. if (alias.equalsIgnoreCase("claim")) {
    2. if (!sender.hasPermission("me.gold")) {
    3. return true;
    4. }
    5. player.sendMessage("worked!");
    6.  
    7. if (!sender.hasPermission("me.iron")) {
    8. return true;
    9.  
    10. }
    11.  
    12. player.sendMessage("Also worked!");
    13.  
    14. return true;
    15.  
    16. }
     
  2. Offline

    x0pk1n

    Because the player.send.. isn't in the if statements, look the '}' is before each of them. so there is no condition to them being sent. Please learn Java first...
     
    d33k40 and JPG2000 like this.
  3. Offline

    Mathias Eklund

    Code:java
    1. if (alias.equalsIgnoreCase("claim")) {
    2. if (!sender.hasPermission("me.gold")) {
    3. return false;
    4. }else {
    5. player.sendMessage("worked!");
    6. }
    7. else if (!sender.hasPermission("me.iron")) {
    8. return false;
    9.  
    10. } else {
    11.  
    12. player.sendMessage("Also worked!");
    13. }
    14.  
    15. }
     
  4. Offline

    x0pk1n

    Mathias Eklund - How on earth did you come up with that from his? I'm not even sure thats what he wants...
    porrinialex Do it you're way, it's not going to take from the fact you'll needa learn coding. So i suggest you get a book or a youtube series.
     
  5. Offline

    Mathias Eklund

    You should definitely learn java before you mess around with bukkit. By knowing some basic Java before you mess with Bukkit you increase the amount of stuff that get stuck in the brain, so you don't have to look stuff up all the time.

    x0pk1n He asked for instruction to make it like that. When a player has the perm he gets a message. I don't know what his full code looks like. So i just made it all connect.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  6. Offline

    x0pk1n

    Mathias Eklund Does he not want this...

    Code:java
    1. if (alias.equalsIgnoreCase("claim")) {
    2.  
    3. if (!sender.hasPermission("me.gold")) {
    4. player.sendMessage("worked!");
    5. return true;
    6. }
    7.  
    8. if (!sender.hasPermission("me.iron")) {
    9. player.sendMessage("Also worked!");
    10. return true;
    11.  
    12. }
    13.  
    14. return true;
    15.  
    16. }


    So if the person has that permissions they get the messages, not just one message...
     
  7. Offline

    Mathias Eklund

    x0pk1n perhaps, but i don't see why someone would have that.
     
    AndyMcB1 likes this.
  8. Offline

    x0pk1n

    Mathias Eklund - Because they might want a message to be sent to someone if they have that permission.... or something else for each person with that permission, theres a reason.
     
  9. Offline

    AndyMcB1

    x0pk1n Much better to use if/else if/else.
     
  10. Offline

    Mathias Eklund

    x0pk1n I think he only has the messages for tests, cause i don't see why a claim command would send a message, and that the messages would say worked and also worked, with permission gold and iron.
     
  11. Offline

    x0pk1n

    AndyMcB1 We don't even know what he wants and there is no other way to do that without using them! haha...
     
  12. Offline

    Mathias Eklund

    we do know what he wants, player with iron permission get a message and the player with the gold permission get a different message, he said nothing about a player getting both messages.
     
  13. Offline

    x0pk1n

    Mathias Eklund - Well thats obvis they're there for testing... It would send a message to let you know what you've claimed. It could be a kit plugin and the gold gets an extra item compared to iron. So instead of doing an else if and copying and pasting coding from the iron. You could set it out like mine and for the gold only add that one item and if they have the perm iron id adds the others. or you could add that also a gold perm also gets them whats in the iron statement. Also why would it say "also working" if they were both not meant to happen at once?
     
  14. How do you mess around if you don't understand anything?
     
  15. Offline

    porrinialex

    x0pk1n AndyMcB1 I was just testing how i could make a command do diffrent things with for diffrent ranks ahah But also i just started watching the TheNewBoston java videos <:
     
  16. Offline

    Mathias Eklund

    Thats good, watch them first :)
     
  17. Offline

    porrinialex

    SupaHam I know a bit believe it or not im not that advance but i already got some basics with ArrayList, and some other crud <:
     
  18. The only reason you might learn something new is because someone is feeding you code or you pretty much just copy-pasted a plugin's feature, if not the whole plugin.
     
  19. Offline

    porrinialex

    SupaHam um i watch bukkit videos then try and try again to remember it how else am i suppose to learn silly :)

    Also i have multiply classes set up so i dont know how i copied and pasted it all

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  20. Offline

    x0pk1n

    porrinialex Both those comment are our points. Go learning coding and stop trying to skip steps.
     
  21. Offline

    porrinialex

    x0pk1n If you read my comment i said im watching java videos as we speak
     
  22. Offline

    x0pk1n

    porrinialex Good! Then learn first, practice practice practice then come back to bukkit.
     
  23. Offline

    FinalFred

    Not sure why you guys are yelling at him to learn Java before trying to do anything with Bukkit. The best way to learn anything is to have fun while learning. Making Bukkit plugins is pretty fun, so I'd say have at it.

    That said, I still recommend reading through the Java tutorials quickly to get a good general idea of what's going on. Yes, reading. The YouTube videos I've heard of really aren't that great -- sorry. After you got a general idea, do your back and forth thing. If you see something in the Bukkit source code that you don't recognize, research it until you understand what it's doing.
     
  24. Offline

    JPG2000

    porrinialex Agreed. Learn java first.


    That issue, with the message, you could figure it out your self if you learn java. Its really really simple if you start to learn. You will get things 1000x faster. All of your silly post's, are java related. The 'player.hasPermission' returns a boolean, its like normal java.

    Also, heres how I would do it:
    Code:java
    1. if (alias.equalsIgnoreCase("claim") {
    2. if (sender.hasPermission("perm.1") {
    3. sender.sendMessage("perm.1");
    4. return true;
    5. }
    6. if (sender.hasPermission("perm.2") {
    7. sender.sendMessage("perm.2") {
    8. return true;
    9. }
    10. sender.sendMessage("You dont have either permission");
    11. }
    12. }
     
  25. Offline

    porrinialex

    Hehe i just got to this JPG2000
     
  26. Offline

    JPG2000

    porrinialex Thats sad. Don't even attemp bukkit before java.
     
  27. Offline

    porrinialex

    JPG2000 YOU JUST TOLD ME TO LEARN JAVA FIRST! its sad that i just started and was on episode 15 0_0 what i think is sad is you wasting time to write out a insult

    Your comment didnt make sense the video i linked you was for java 0_0

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  28. Offline

    JPG2000

    • This is not appropriate behavior
  29. Offline

    porrinialex

    JPG2000 I SAID OK ALREADY I WILL LEARN JAVA HOW MANY TIME WILL YOU TELL ME THIS
     
  30. Offline

    JPG2000

    porrinialex jeez, calm down. I obviously said I wasn't out there to hurt you, I was there to help. I was responding to your before comment, then by saying 'Learn java BEFORE bukkit' I was confirmign what I previously wrote.
     
Thread Status:
Not open for further replies.

Share This Page