Problem with Spout Developing

Discussion in 'Plugin Development' started by Master24, Aug 6, 2011.

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

    Master24

    Hey.
    I'm currently working on a plugin that makes users able to turn off the clouds with the help of Spout's SkyManager.
    But if I use the command nothing changes.
    It don't get any errors or so.
    Here is my code:
    Code:
    package me.master24.cloudRemove;
    
    import java.util.HashMap;
    import java.util.logging.Logger;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.getspout.spoutapi.SpoutManager;
    import org.getspout.spoutapi.player.SpoutPlayer;
    
    public class CloudRemove extends JavaPlugin {
    
        Logger log = Logger.getLogger("Minecraft");
    
        private HashMap<Player, Boolean> cloudList = new HashMap<Player, Boolean>();
    
        public void onEnable(){
            log.info("CloudRemove by Master24 v0.1 enabled.");
        }
    
        public void onDisable(){
            log.info("CloudRemove by Master24 v0.1 disabled.");
        }
    
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            if(cmd.getName().equalsIgnoreCase("cloudrem") || cmd.getName().equalsIgnoreCase("cr")){
                if(args.length == 1 && args[0].equalsIgnoreCase("on")){
                    if(sender instanceof Player){
                        if(!cloudList.containsKey((Player) sender)){
                            sender.sendMessage("Your clouds are already enabled!");
                        }else{
                        SpoutPlayer sPlayer = (SpoutPlayer) sender;
                        SpoutManager.getSkyManager().setCloudsVisible(sPlayer, true);
                        cloudList.remove((Player)sender);
                        sender.sendMessage("Clouds enabled!");
                        }
                    }
                    return true;
                }else if(args.length == 1 && args[0].equalsIgnoreCase("off")){
                    if(sender instanceof Player){
                        if(cloudList.containsKey((Player)sender)){
                            sender.sendMessage("Your clouds are already disabled!");
                        }else{
                        SpoutPlayer sPlayer = (SpoutPlayer) sender;
                        SpoutManager.getSkyManager().setCloudsVisible(sPlayer, false);
                        cloudList.put((Player) sender, false);
                        sender.sendMessage("Clouds disabled!");
                        }
                    }
                    return true;
                }
            }
            return false;
        }
    }
    
    Would be great if someone could help me.
    Thanks :)
    Master24
     
  2. Offline

    jtripled

    It looks to me like you just need to register the command. Just plop this in the onEnable() block:

    getCommand("cloudrem").setExecutor(this);

    Also, you need to implement a command executor, so your class declaration would be "public class CloudRemove extends JavaPlugin implements CommandExecutor".

    One last thing that may cause a problem is that you need the command "cloudrem" listed in your plugin.yml before it can be registered by the plugin (don't use tabs in the plugin.yml, use four spaces instead):

    commands:
    cloudrem:​
    description: toggles clouds on and off​
    usage: /cloudrem​
     
  3. He wouldn't need to set an executor as the onCommand is in his main class. Also you should check your plugin yml to make sure the commands are registered.
     
  4. Offline

    Master24

    Yes the commands are registered and they work because if I type "/cr off" two times it gives me out the message I coded.
     
  5. Offline

    Shamebot

    You are using the Spout client mod, aren't you?
     
  6. Offline

    jtripled

    He wouldn't? Interesting.
     
  7. Offline

    Shamebot

    JavaPlugin extends CommandExecutor.
     
  8. Offline

    Master24

    sorry that i didn't replied.
    didn't got any alerts ;)
    Yes I use the SpoutcraftLauncher
    still don't working

    EDIT: Ok it works now. SpoutcraftLauncher didn't worked correct on my pc.
    Thanks for all help :)
     
Thread Status:
Not open for further replies.

Share This Page