Solved Handing a command to a different plugin

Discussion in 'Plugin Development' started by xYourFreindx, Jun 6, 2014.

Thread Status:
Not open for further replies.
  1. I think you can tell what I'm trying to do...​
    Code:java
    1. public ArrayList<String> stick = new ArrayList<String>();
    2.  
    3.  
    4. public boolean onCommand(final CommandSender sender, Command cmd, String StringLabel, String[] args) {
    5. if (cmd.getName().equalsIgnoreCase("spawn")){
    6. if (!(stick.contains(((Player) sender).getUniqueId().toString()))){
    7. Bukkit.dispatchCommand(sender, "mvspawn");
    8. }else{
    9. Bukkit.dispatchCommand(sender, "spawn");
    10. }
    11. }else if (cmd.getName().equalsIgnoreCase("hub")){
    12. stick.add(((Player) sender).getUniqueId().toString());
    13. ((Player) sender).chat(getConfig().getString("Hub"));
    14. MVSpawn pInst = this;
    15. pInst.getServer().getScheduler().scheduleSyncDelayedTask(pInst, new Runnable(){
    16. public void run() {
    17. stick.remove(((Player) sender).getUniqueId().toString());
    18. }
    19. }, 25L);
    20. }
    21. return true;
    22. }


    I'm trying to make it so that when a player does /spawn, they are sent to multiverse's local spawn.
    That, I've done.
    Now I want for when a player does /hub, they redirect to essentials's set spawn.
    As you can see by the above code, I've made an arraylist to tell who is doing /spawn and who is doing /hub. But I still need a way to say, "ok, essentials... You take it from here".
    Do you know of a way I might be able to do this?
    I know essentials manages to make it so that I handle the command right now, I just want to give it back. ​
     
  2. Offline

    fireblast709

    xYourFreindx in your code, spawn will trigger spawn, which will trigger spawn, etc.
     
  3. fireblast709 -_- No derp.......

    It's not finished yet.
    Still waiting for a HELPFUL reply that can help me figure out what to put in there to allow essentials to have priority over the command.
    fireblast709

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

    fireblast709

    xYourFreindx so you claim that if you react to /spawn, which executes /spawn (which should be intercepted by your plugin again), wouldn't cause an infinite cycle of /spawns? Anyway, to be 'helpful' since I apparently aren't, you should execute espawn or essentials:spawn, both aliases for Essentials's /spawn
     
  5. fireblast709 Thank you so much! :D

    My idea with the plugin was that...
    If the player typed /spawn, they would not be in the array list, and then my if statement would catch that, and redirect the command to /mvtp, BUT if they were to type /hub, then they would be added to the array list, and since /hub acts as /spawn, it would loop back through the /spawn command, only this time, they would be in the array list, and it would... Now that you've helped me out.. Trigger /espawn, which will send them to essentials spawn. And by the time that's happened, they will have been removed from the array list, and will be free to type /spawn by themselves.

    For anyone wanting to know...​
    Code:java
    1. public boolean onCommand(final CommandSender sender, Command cmd, String StringLabel, String[] args) {
    2. if (cmd.getName().equalsIgnoreCase("spawn")){
    3. Bukkit.dispatchCommand(sender, "mvspawn");
    4. }else if (cmd.getName().equalsIgnoreCase("hub")){
    5. Bukkit.dispatchCommand(sender, "espawn");
    6. }
    7. return true;
    8. }

    Here's a scraped down version of what was needed to accomplish this.​

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 30, 2016
Thread Status:
Not open for further replies.

Share This Page