2 Different Problems

Discussion in 'Plugin Development' started by TheLexoPlexx, Mar 11, 2014.

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

    TheLexoPlexx

    Hey Guys TheLexoPlexx is here :D

    I'm currently trying to make my own API. But I have some Problems...

    ... 1st Problem: I want to execute different commands by once. For example
    Code:
    Player.sendMessage("anybullshittextinhere");
    AND
    Code:
    Player.teleport(AnyBullshitlocationhere);
    shall go together to:
    Code:
    Player.tpmsg("anybullshittexthere", anybullshitlocationhere);
    ... 2nd Problem: I want to make my own Events. For Example

    if any boolean is set to true... and the "PlayerDeathEvent" happens, the same should happen like:
    Code:
    public void onBooleanKill(PlayerDeathBooleanEvent e) 
    (maybe the boolean is no good example
     
  2. Offline

    xTrollxDudex

    TheLexoPlexx
    Stop swearing. This community is literally filled with 8 year olds.

    In this case, you can make your own implementation. The fact is, for number one, you need 2 lines of code, just condense into one method and it will be 1 line of code to execute, teleport and sendMessage.

    Put number two in PlayerDeathEvent and check boolean, the execute ode - seriously, that is even more straightforward than using your own event. In fact, you will still need to use PlayerDeathEvent anyways, so it would be pointless.
     
    97waterpolo and NinjaWAffles like this.
  3. Offline

    Assult

    As you xTrollxDudex said. You would have to make your own method.

    I'm going to show you a detailed method so you might actually learn something.

    Code:java
    1. /*You have to create a method, does not matter in wich class as long as you have access to it.
    2.  
    3. "public" is the visibility modifier, if it was private, you could only access it inside the class.
    4.  
    5. void is a method type that does not have to return anything, unlike Boolean and String.
    6.  
    7. tpmsg is the name of the method, used when you are calling it
    8.  
    9. Inside the parentheses we have 3 arguments, seperated by commas, the first argument, the player, is the player object we are going to teleport and send the message to.
    10.  
    11. The second argument, wich is a String, is the message we are going to send to the player.
    12.  
    13. The third argument is the location we are going to send the player to.
    14.  
    15. The 2 lines within the brackets are methods Provided by the bukkit api, the first line sends the player the message we get from the arguments in the parentheses.
    16. The second line teleport the player to the Location we get from the parentheses.
    17.  
    18. */
    19.  
    20. public void tpmsg (Player p, String message, Location location) {
    21. p.sendMessage(message);
    22. p.teleport(location)
    23. }
    24.  
    25. //you now have to call this methods by doing
    26.  
    27. tpmsg(player, message, location);
     
  4. Offline

    TheLexoPlexx

    xTrollxDudex Assult Oops. It was 7AM and I was really tired and confused. Sorry for taking your time.
     
Thread Status:
Not open for further replies.

Share This Page