I got a code how do I make it work?

Discussion in 'Plugin Development' started by Gonzxor, Jun 22, 2013.

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

    Gonzxor

    Im new at this and I did play another game with scripting and I did get somewhere in it.

    I asked for help and someone gave me this code that they wrote for me! Thanks! I dont know where to put it and stuff. If anyone has or knows a video on how to make a plugin for 1.5.2 and for windows vista can you please post it.




    Also about this code is this all I have to put or is this only part of a plugin. Could this all this code just be one plugin?

    This code should:

    Check for amount of money
    Remove Money
    Send out a command (Such as /warp)

    Thanks

    Code:
     @EventHandler(priority=EventPriority.LOW, ignoreCancelled=true)     //event for bukkit
          public void onPlayerInteract(PlayerInteractEvent event) throws UserDoesNotExistException,  NoLoanPermittedException {     //still event from bukkit
            Player player = event.getPlayer();     //this gets the player from the event of PlayerInteractEvent
            Action action = event.getAction();     //this gets the action that was preformed
         
            if (action == Action.RIGHT_CLICK_BLOCK) {      //check if the action was right clicking
                int clicked = event.getClickedBlock().getTypeId();      //gets the block that was right clicked and gets its id
                if (clicked==63||clicked==68) {      //check if the block id equals 63 or 68 (Sign or sign on wall)
                    Sign theSign = (Sign)event.getClickedBlock().getState();      //cast the block as a sign (so the next line can be done)
                    if (theSign.getLine(0).equals("whateveryouwantthefirstlineofyousignt0be")) {      //checks the sign's (clicked block) first line and if it equals something
                        if (theSign.getLine(1).equals("")) {      //if the first line is equal to what you put, check the second line for a certain string (this would all signs with different functions but all have the same first line (like the first line could be your plugin's name) example: one sign could be potion effects and the other could be items)
                            if (Economy.hasEnough(player.getName(), double(amount of money it cost))) {      //finally if all above is true it gets essentials economy and checks if the player from the event have enough money (accomplished 1)
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  2. Offline

    pkt

    Please surround that in the code brackets
    Code:
     like this 
    please, lol
     
  3. Offline

    Gonzxor

    How ? O nvm

    What are code brackets?

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

    bennie3211

  5. Offline

    pkt

    [ code ] in caps no spaces [/ code]
     
  6. Offline

    Gonzxor

    Got it lol

    [/quote]
    I watched that video before but hes making packages and all that and I dont know what that is and how to do it too mine.

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

    pkt

    now space it out correctly, its still barely readable/sloppy
     
  8. Offline

    Gonzxor

    There
     
  9. Offline

    Ultimate_n00b

    I watched that video before but hes making packages and all that and I dont know what that is and how to do it too mine.[/quote]

    Search TheNewBoston then (you'll need to know java first).
     
  10. Offline

    pkt

    Ok, so all that code means: When a player right clicks a sign, and if that sign says "whateveryouwantthefirstlineofyousignt0be" on the first line (which is not possible, too much text for one line) and there is nothing on the second line, and the player has enough money, do something (the code gets cut off from there)
     
  11. Offline

    Gonzxor

    Also one more thing. Would work if I just put this into eclipse and then turned it into a jar and all that would it work?
     
  12. Offline

    pkt

    uh... no. Do you know any Java?
     
  13. Offline

    Gonzxor

    Not java. I know some Lua
     
  14. Offline

    Ibix13

    If your coding bukkit... Learn. Java. What bennie3211, watch the bcbroz, they do a really good bukkit tutorial
     
  15. Offline

    Gonzxor

    Any tips on how to learn java?
     
  16. Offline

    LordVakar

    Play roblox? LOL
    Also TheNewBoston has java coding tuts.
     
  17. Offline

    Ibix13

    Well.... You could watch thenowboston on youtube and thebcbroz.
     
  18. Offline

    Gonzxor

    No not Roblox but same idea. I downloaded lua
     
  19. Offline

    Ibix13

    Ahhh.... you said before meh...
     
  20. Offline

    Gonzxor

    Ok thanks alot.
     
  21. Offline

    ZeusAllMighty11

    Sadly, lua is nothing like Java.
     
  22. Offline

    pkt

    Lua is a Scripting language, completely diffrent
     
  23. Offline

    Ivan

    JAVA JAVA JAVA
     
  24. Offline

    Gonzxor

    Java isent a scripting language? What is it then? ....?
     
  25. Offline

    pkt

    A programming language
     
  26. Offline

    Gonzxor

    In basic terms what do I have to add to make this a plugin? Is this code a little bit of what I need? Do I need to addd more packages and stuff? Do I need to add more files?
     
  27. Offline

    pkt

    if thats the only code you are going to use, you should only need one class, with more code
     
  28. Offline

    Gonzxor

    What is there too add though? What do you mean by more code?
     
  29. Offline

    pkt

    Learn Java and you would know :p
     
  30. Offline

    Gonzxor

    Ok im going to learn Java. Hopefully I can learn fast and get this plugin done. :).
     
Thread Status:
Not open for further replies.

Share This Page