Source Code For Balance And Kill For Reward

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

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

    Gonzxor

    Im just wondering if anyone knows the source code for bal (Essentials) and Kill for reward (Essentials).

    I want to make a cool plugin for pvp.

    --------------------------------------------------------------------

    Also if anyone knows how to make plugin so that when you click a sign it checks if you have the certain amount of money and then if you do it sends out a command.

    Example.

    Sign
    Permission For Warp
    $200

    So if you bought this it would give you permission for warp.


    Thanks

    The sign is almost as a command block that tests for money and then if its true it goes to another command block.

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

    Rocoty

    <Edit by Moderator: Redacted bit url>
     
    Last edited by a moderator: Feb 16, 2017
  3. Offline

    Windy Day

    Better yet!
    Just import essentials as a external jar then just use Economy.whatever!
    Example for buying:
    if (Economy.hasEnough(player.getName(), double amount)) {
    //stuff here for whatever they just bought!
    }
     
  4. Offline

    Gonzxor

    I dont understand.
     
  5. Offline

    Windy Day

    What don't you understand? This is telling you how you could implement Essentials economy into the plugin, so you can buy things.
     
  6. Offline

    Gonzxor

    Im sorry im new at this stuff. So I believe you are answering my second question about the signs. Well its not that I want people to buy stuff with signs Im wondering if you can make a sign that when it.

    1. Checks that the player has the amount of money.
    2. Removes money
    3. Sends out command (Like /warp test)

    Sorry also, I am not trying to sound like "I want" or "I need". I dont want you too wright it all I just dont how to do this.
     
  7. Offline

    Windy Day

    It's all good here is a bit of code that you could use and I'll tell you what it accomplishes in the code:
    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)
                                Economy.subtract(player.getName(), 10.0);     //then if they do subtract the amount from their balance (accomplished 2)
                                player.sendMessage("it worked!");      //this is where you put what you want the sign to do this will just send them a message saying it worked! However, you can put whatever you want here. (accomplished 3)
    Hope this helps you and clears somethings up!
    This accomplishes :
    1. Checks that the player has the amount of money.
    2. Removes money
    3. Sends out command (Like /warp test)
    I put in the notes where it is accompished
     
Thread Status:
Not open for further replies.

Share This Page