getting a sender from a command to a other class

Discussion in 'Plugin Development' started by plarsootje, Feb 8, 2013.

Thread Status:
Not open for further replies.
  1. hello,
    So i have some problems

    I'm trying to make a plugin request but i'm stuck
    I gonna try to explain
    I have a command /join
    When a player does that command the player is getting teleported to a location sort of a lobby
    i'm making the teleportation in a method
    But how can i get the sender that has sended the /join command in my method class?
    Also i need to do that when players leave the game they get back teleported to the lobby also with the method but with a different command
    Is there an way that i get the sender from multiple commands in 1 sender in the method?

    If you don't understand something just ask :)

    thanks by advance
     
  2. plarsootje
    Code:java
    1.  
    2. boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    3. if(sender instanceof Player){
    4. Player p = (Player) sender;
    5. }
    6. }
     
  3. i know how to make a command
    But how can i get the sender from a command to a other class
     
  4. plarsootje
    If you don't know how to pass method arguments then you need to learn more Java before attempting to create a plugin. I suggest you click on the Plugin Tutorial link in my signature.
     
  5. Okay and if you can show me where i can find the thing about getting the sender in a other class then you can show my because you can't find that thing on your wiki!
    And the best way to learn java is making mistakes! not reading a whole site to find 1 thing while the rest on the site you already know !
    if you know how to make the sender in a other class? then make it on the wiki because i'm not the only one that needs that !
     
  6. plarsootje
    That is true in some cases but not in terms of programming. To start programming you actually need to have a least a basic understanding of the fundamentals of the language you are working in.

    Believe me it will do you more harm than good if you try to learn java as you start developing plugins. It's what I tried to do initially and after a week or so I still didn't understand much. Then after spending a few weeks learning basic Java I came back and was able to get into plugin development much more easily.

    I suggest you check out thenewboston's Java tutorials on youtube, links to his videos are on the wiki I referred you to.
     
  7. I know the basics of java i can make my own java games, but bukkit is new to me and i'm trying to do my best to learn bukkit while i'm scripting and it works so my only questions was how i get the sender to a other class
     
  8. Offline

    Tog

    Read up on constructors and public variables.
     
  9. Offline

    SuperOmegaCow

    I assume you know how to use arrays:
    Code:java
    1. public static ArrayList<String> halo = new ArrayList<String>();

    create that then:
    if(commandLabel//blablabla){
    Code:java
    1. if(!halo.contains(sender.getName()){
    2. halo.add(sender.getName())
    3.  
    4. // ALL YOUR CODE
    5. this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    6.  
    7.  
    8. public void run() {
    9.  
    10. halo.remove(player.getName());
    11.  
    12.  
    13. }
    14.  
    15. }, <put ticks they are not allowed to type command>);
    16. }
    17. }

    Basically the concept is if the player is in the array it means they cant use the command so what we do is if they are not in the array run the command if they are in the array do nothing. If they are not in the array it will add them to the array execute your code then remove them from the array 1 tick later.
     
Thread Status:
Not open for further replies.

Share This Page