[Solved] Nothing happens during command. No errors either.

Discussion in 'Plugin Development' started by ZeusAllMighty11, May 27, 2012.

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

    ZeusAllMighty11

    Current code as of 5/28/12 @ 5:37pm EST

    main.java

    Code:
    package TransformCreature;
     
    import java.lang.reflect.Constructor;
    import java.util.logging.Logger;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Sheep;
    import org.bukkit.event.Event;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class main extends JavaPlugin implements Listener{
    Logger log = Logger.getLogger("Minecraft"); // define logger as 'log' for console
     
       
        public void onEnable(){       
           
            PluginManager pm = this.getServer().getPluginManager();
            pm.registerEvents(this, this);
       
     
            this.log.info("[TransformCreature] Detected and enabled! <3 "); // Print that the plugin is ENABLED to console
        }
       
        public void onDisable(){
            this.log.info("[TransformCreature] Plugin disabled! D; "); // Print that the plugin has been DISABLED to console
        }
     
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player s = (Player)sender;
     
            if(command.getName().equalsIgnoreCase("transformcreature")){ // If typed command is transformcreature
            s.sendMessage(ChatColor.GOLD + ("[TransformCreature] ") + ChatColor.GREEN + ("Version: v0.1"));
            }
            return true;
        }
    }
    
    colorSheep.java

    Code:
    package TransformCreature;
     
    import java.lang.reflect.Constructor;
    import java.util.logging.Logger;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Sheep;
    import org.bukkit.event.Event;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class main extends JavaPlugin implements Listener{
    Logger log = Logger.getLogger("Minecraft"); // define logger as 'log' for console
     
       
        public void onEnable(){       
           
            PluginManager pm = this.getServer().getPluginManager();
            pm.registerEvents(this, this);
       
     
            this.log.info("[TransformCreature] Detected and enabled! <3 "); // Print that the plugin is ENABLED to console
        }
       
        public void onDisable(){
            this.log.info("[TransformCreature] Plugin disabled! D; "); // Print that the plugin has been DISABLED to console
        }
     
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            Player s = (Player)sender;
     
            if(command.getName().equalsIgnoreCase("transformcreature")){ // If typed command is transformcreature
            s.sendMessage(ChatColor.GOLD + ("[TransformCreature] ") + ChatColor.GREEN + ("Version: v0.1"));
            }
            return true;
        }
    }
    

    plugin.yml

    Code:
    name: TransformCreature
    author: ZeusAllMighty11
    description: A plugin that changes or transforms entities.
    version: 0.1
    main: TransformCreature.main
     
    commands:
      colorsheep:
        description: Gives user stick
        usage: /<command>
        default: Op
      transformcreature:
        description: Checks version
        usage: /<command>
        default: Op
     
  2. First, why do you have a 'default' node for your commands when you don't add the permission to them?
    Second, shouldn't the usage be /<command>?
     
  3. Offline

    ZeusAllMighty11



    I'm going to add permissions after I know the commands work, so I added them. It may be affecting it, I'll test now.

    Nope, it did not change a thing kumpelblase2


    The usage doesn't matter, I think, unless you call upon it later. (which usually you don't)
    And the default node doesn't affect it either, unless you have default: false and you are not op, but even then it shouldn't matter.

    Still not sure what the issue is here.

    The version command executes fine with the message and all.

    But the other command, /colorsheep , does nothing

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  4. Can you provide the registering code as well? Also, why does the command extends javaplugin and implements listener and plugin? These aren't needed at all.
     
  5. Offline

    ZeusAllMighty11


    main.java
    Code:
    package TransformCreature;
     
    import java.lang.reflect.Constructor;
    import java.util.logging.Logger;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class main extends JavaPlugin implements Listener, Plugin{
    Logger log = Logger.getLogger("Minecraft"); // define logger as 'log' for console
     
       
        public void onEnable(){       
           
            getServer().getPluginManager().registerEvents(this, this);
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
           
            this.log.info("[TransformCreature] Detected and enabled! <3 "); // Print that the plugin is ENABLED to console
        }
       
        public void onDisable(){
            this.log.info("[TransformCreature] Plugin disabled! D; "); // Print that the plugin has been DISABLED to console
        }
     
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if(command.getName().equalsIgnoreCase("transformcreature")){ // If typed command is transformcreature
            Player s = (Player)sender;
            s.sendMessage(ChatColor.GOLD + ("[TransformCreature] ") + ChatColor.GREEN + ("Version: v0.1"));
            }
            return true;
           
        }
    }
    
     
  6. I don't see any place where you set the executor of 'colorsheep'. And yet again, you don't need to implement Listener and Plugin nor need to register events since you don't have any in the class (you wouldn't even need to do it twice).
     
  7. Offline

    messageofdeath

    ZeusAllMighty11 You do not need all of that up top change from this to this.

    PHP:
    public class main extends JavaPlugin implements ListenerPlugin{
    to

    PHP:
    public class main extends JavaPlugin {
    Then put your listener in your main class like this.

    PHP:
    getServer().getPluginManager().registerEvents(new Listener() {
        @
    EventHandler
        
    public void someting(Whatever whatever){
     
        }
    }, 
    this;
    For your commands use

    PHP:
    getCommand("command").setExecutor(new CommandExecutor() {
     
        @
    Override
        
    public boolean onCommand(CommandSender senderCommand cmdString commandLabelString[] args) {
        
    Player player = (Playersender;
            if(
    cmd.getName().equalsIgnoreCase("command")) {
                 
            }
        return 
    false;
        }
    });
    Like if it worked!
     
  8. Offline

    ZeusAllMighty11


    I removed the random implements.

    Also, my new colorSheep class:

    Code:
    package TransformCreature;
     
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.DyeColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Sheep;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.event.entity.EntityEvent;
    import org.bukkit.event.entity.SheepDyeWoolEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class colorSheep extends JavaPlugin implements Listener{
       
        public void onEnable(){
           
            colorSheep cs;
            cs = new colorSheep();
            getCommand("colorsheep").setExecutor(cs);
           
            getServer().getPluginManager().registerEvents(this, this);
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
               
        }
       
       
     
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {      // Command time!
     
            Player s = (Player)sender;
     
            if(command.getName().equalsIgnoreCase("colorsheep")){ // user types /colorsheep command
            s.getInventory().addItem(new ItemStack(Material.STICK, 1));
            s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Added wand item 'stick' into your inventory.")); // sends msg
            s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Left click a sheep to change it's colour.")); // sends msg
            }
            return true; // return to next check
        }
       
        // Time to check if a player has a stick in hand
     
        public void checkPlayer(PlayerInteractEntityEvent e) { // player and entity interaction
           
            Player p = (Player) e.getPlayer(); // gets the player variable
            ItemStack inHand = p.getItemInHand(); // gets the iteminhand variable
           
            if (inHand == null || inHand.getType() != Material.STICK) { // checks if item in hand is not a stick
              return;
            }
           
           
            if (!(e.getPlayer() instanceof Player)) { // checks if instance is not player
                return;
            }
           
           
            if (!(e.getRightClicked() instanceof Sheep)){ // checks if entity is not sheep
                return;
            }
           
            getServer().getPluginManager().registerEvents(this, this);
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }
           
        public void woolChange(SheepDyeWoolEvent s){
        s.setColor(DyeColor.RED); // sets sheep to red
        }
       
       
       
    } // finish code before handlers
     
     
     
       
    

    OK, this is what I have now:

    I'm confused btw


    main.java
    Code:
    package TransformCreature;
     
    import java.lang.reflect.Constructor;
    import java.util.logging.Logger;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class main extends JavaPlugin implements Listener, Plugin{
    Logger log = Logger.getLogger("Minecraft"); // define logger as 'log' for console
     
       
        public void onEnable(){       
           
            getServer().getPluginManager().registerEvents(this, this);
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
           
            this.log.info("[TransformCreature] Detected and enabled! <3 "); // Print that the plugin is ENABLED to console
        }
       
        public void onDisable(){
            this.log.info("[TransformCreature] Plugin disabled! D; "); // Print that the plugin has been DISABLED to console
        }
     
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if(command.getName().equalsIgnoreCase("transformcreature")){ // If typed command is transformcreature
            Player s = (Player)sender;
            s.sendMessage(ChatColor.GOLD + ("[TransformCreature] ") + ChatColor.GREEN + ("Version: v0.1"));
            }
            return true;
           
        }
     
            @EventHandler
            public void handler(main ???){
         
            }
               
    }
     
    
    colorSheep.java

    Code:
    package TransformCreature;
     
    import java.lang.reflect.Constructor;
    import java.util.logging.Logger;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class main extends JavaPlugin implements Listener, Plugin{
    Logger log = Logger.getLogger("Minecraft"); // define logger as 'log' for console
     
       
        public void onEnable(){       
           
            getServer().getPluginManager().registerEvents(this, this);
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
           
            this.log.info("[TransformCreature] Detected and enabled! <3 "); // Print that the plugin is ENABLED to console
        }
       
        public void onDisable(){
            this.log.info("[TransformCreature] Plugin disabled! D; "); // Print that the plugin has been DISABLED to console
        }
     
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if(command.getName().equalsIgnoreCase("transformcreature")){ // If typed command is transformcreature
            Player s = (Player)sender;
            s.sendMessage(ChatColor.GOLD + ("[TransformCreature] ") + ChatColor.GREEN + ("Version: v0.1"));
            }
            return true;
           
        }
     
            @EventHandler
            public void handler(main ???){
         
            }
               
    }
     
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  9. You shouldn't implement Plugin at all.
    You don't need to implement Listener for classes that doesn't have events (but you do... you also forgot the @EventHandler).
    You SHOULD NOT extend JavaPlugin for classes other than the main one (which you pasted twice btw).
    You're registering the events twice, why ?
    And you don't need to print enabled/disabled messages because bukkit does that automatically.
     
  10. Offline

    ZeusAllMighty11

    I"ll keep my enabled/disabled messages for now, just for self-comfort? If that makes sense, lol.

    I fixed the implements, and some other things.

    Now my main problem is, where do I put @EventHandler, and what goes inside?


    I figured out the eventhandler ( I think )

    Now I'm having troubles at the @Override.

    sheepColor.java class:
    Code:
    package TransformCreature;
     
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.DyeColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Sheep;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.event.entity.EntityEvent;
    import org.bukkit.event.entity.SheepDyeWoolEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class colorSheep extends JavaPlugin{
       
                 
                getCommand("colorsheep").setExecutor(new CommandExecutor() {
               
                @Override
                public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
                Player s = (Player) sender;
                    if(cmd.getName().equalsIgnoreCase("command")) {
                        s.getInventory().addItem(new ItemStack(Material.STICK, 1));
                        s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Added wand item 'stick' into your inventory.")); // sends msg
                        s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Left click a sheep to change it's colour.")); // sends msg 
                    }
                return false;
                }
            });   
        }
       
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {      // Command time!
           
            Player s = (Player)sender;
     
            if(command.getName().equalsIgnoreCase("colorsheep")){ // user types /colorsheep command
     
            }
            return true; // return to next check
        }
       
        // Time to check if a player has a stick in hand
     
        public void checkPlayer(PlayerInteractEntityEvent e) { // player and entity interaction
           
            Player p = (Player) e.getPlayer(); // gets the player variable
            ItemStack inHand = p.getItemInHand(); // gets the iteminhand variable
           
            if (inHand == null || inHand.getType() != Material.STICK) { // checks if item in hand is not a stick
              return;
            }
           
           
            if (!(e.getPlayer() instanceof Player)) { // checks if instance is not player
                return;
            }
           
           
            if (!(e.getRightClicked() instanceof Sheep)){ // checks if entity is not sheep
                return;
            }
        }
       
        @EventHandler
        public void woolChange(SheepDyeWoolEvent s){
            s.setColor(DyeColor.RED); // sets sheep to red
        }this;)}
        }
       
       
    } // finish code before handlers
     
     
     
       
    
    ok, so I figured out the eventhanlder, I think.

    But now I'm stuck on this class's @override

    Code:
    package TransformCreature;
     
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.DyeColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Sheep;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.event.entity.EntityEvent;
    import org.bukkit.event.entity.SheepDyeWoolEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class colorSheep extends JavaPlugin{
       
                 
                getCommand("colorsheep").setExecutor(new CommandExecutor() {
               
                @Override
                public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
                Player s = (Player) sender;
                    if(cmd.getName().equalsIgnoreCase("command")) {
                        s.getInventory().addItem(new ItemStack(Material.STICK, 1));
                        s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Added wand item 'stick' into your inventory.")); // sends msg
                        s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Left click a sheep to change it's colour.")); // sends msg 
                    }
                return false;
                }
            });   
        }
       
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {      // Command time!
           
            Player s = (Player)sender;
     
            if(command.getName().equalsIgnoreCase("colorsheep")){ // user types /colorsheep command
     
            }
            return true; // return to next check
        }
       
        // Time to check if a player has a stick in hand
     
        public void checkPlayer(PlayerInteractEntityEvent e) { // player and entity interaction
           
            Player p = (Player) e.getPlayer(); // gets the player variable
            ItemStack inHand = p.getItemInHand(); // gets the iteminhand variable
           
            if (inHand == null || inHand.getType() != Material.STICK) { // checks if item in hand is not a stick
              return;
            }
           
           
            if (!(e.getPlayer() instanceof Player)) { // checks if instance is not player
                return;
            }
           
           
            if (!(e.getRightClicked() instanceof Sheep)){ // checks if entity is not sheep
                return;
            }
        }
       
        @EventHandler 
        public void woolChange(SheepDyeWoolEvent s){
            s.setColor(DyeColor.RED); // sets sheep to red
        }this;)}
        }
       
       
    } // finish code before handlers
     
     
     
       
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  11. Offline

    messageofdeath

    change within the command thing from "command" to "colorsheep" within the public boolean onCommand
     
  12. Offline

    ZeusAllMighty11


    Yep, I noticed that before ya posted. I just fixed it.

    Now the code is:
    Code:
    package TransformCreature;
     
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.DyeColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Sheep;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.event.entity.EntityEvent;
    import org.bukkit.event.entity.SheepDyeWoolEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class colorSheep extends JavaPlugin implements Listener{
       
                  public void onEnable(){
                    PluginManager pm = this.getServer().getPluginManager();
                    pm.registerEvents(this, this);
                 
                 
                  }
                 
            public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
                Player s = (Player) sender;
                    if(cmd.getName().equalsIgnoreCase("colorsheep")) {
                        s.getInventory().addItem(new ItemStack(Material.STICK, 1));
                        s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Added wand item 'stick' into your inventory.")); // sends msg
                        s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Left click a sheep to change it's colour.")); // sends msg 
                    }
                return true;
                }
       
        // Time to check on things
     
        public void checkPlayer(PlayerInteractEntityEvent e) { // player and entity interaction
           
            Player p = (Player) e.getPlayer(); // gets the player variable
            ItemStack inHand = p.getItemInHand(); // gets the iteminhand variable
           
            if (inHand == null || inHand.getType() != Material.STICK) { // checks if item in hand is not a stick
              return;
            }
           
           
            if (!(e.getPlayer() instanceof Player)) { // checks if instance is not player
                return;
            }
           
           
            if (!(e.getRightClicked() instanceof Sheep)){ // checks if entity is not sheep
                return;
            }
        }
     
       
        @EventHandler
        public void woolChange(SheepDyeWoolEvent s){
            s.setColor(DyeColor.RED); // sets sheep to red
        }
       
    } // finish code before handlers
     
     
     
       
    
    But sitll nothing

    bumpity bump bump, bumpity bump bump, look at zeusy gooo

    o.o

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  13. Of course it does nothing because PlayerInteractEntityEvent doesn't have an @EventHandler to tell Bukkit to call that event.

    Also, you might want to consider managing your indentation because that code is all over the place and it's not pretty... it also affects how well you can read the code and it most likely confuses you even more, if you want to start with good practices, one is to always indent your code properly.
     
  14. Offline

    ZeusAllMighty11


    Really? Personally, I think that the way I set up my tabs and spaces is what helps me me best at keeping organized. It's just the way I am. Now see, if it affected the actual product itself, I wouldn't do it.

    Just another comfort thing.

    Digi

    But yet, still nothing happens. I've tried benchmarking to see if the code reaches anything in the other class, and it doesn't. :s

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

    Sagacious_Zed Bukkit Docs

    You would be surprised how much bad styling fosters bad code.

    As for nothing happens, Nothing happens after doing what?
     
  16. Offline

    ZeusAllMighty11

    After executing 'colorsheep' command.
     
  17. Offline

    Sagacious_Zed Bukkit Docs

    for testing purposes, replace the conditional with true. like this.
    Code:
                Player s = (Player) sender;
                    if(true) {
                        s.getInventory().addItem(new ItemStack(Material.STICK, 1));
                        s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Added wand item 'stick' into your inventory.")); // sends msg
                        s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Left click a sheep to change it's colour.")); // sends msg 
                    }
                return true;
     
  18. Offline

    ZeusAllMighty11

    Still nothing.
     
  19. Offline

    Sagacious_Zed Bukkit Docs

    Try adding the @override annotation to onCommand, lets make sure that is overriding it, and make it return false. Also it should not have mattered but remove the extra new line in the commands node in the yaml.
     
  20. Offline

    ZeusAllMighty11


    PHP:
            @Override
            
    public boolean onCommand(CommandSender senderCommand cmdString commandLabelString[] args) {
                
    System.out.println("Got this far");
                
    Player s = (Playersender;
                if(
    true) {
                    
    s.getInventory().addItem(new ItemStack(Material.STICK1));
                    
    s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Added wand item 'stick' into your inventory.")); // sends msg
                    
    s.sendMessage(ChatColor.GOLD + ("[TransformCreature]") + ChatColor.GREEN + ("Left click a sheep to change it's colour.")); // sends msg
                
    }
            return 
    true;
            }
    Did I do it right?
     
  21. Offline

    Sagacious_Zed Bukkit Docs

    You did one of three things.
     
  22. Offline

    ZeusAllMighty11


    Sorry for my lack of reading. >_<

    Testing now.


    Edit: Nothing. And I did the other stuff.
     
  23. Offline

    Faelsel

    Personally i didnt understand the code, i tried to correct it ...

     
  24. Offline

    ZeusAllMighty11

    Faelsel

    I corrected some code that I didn't post here. Such as the EventHandler that was missing, and the null check seperation.

    What I'm trying to do, is make it so when a player right clicks a sheep with a stick, it changes the sheep that was right clicked wool into whatever color. In this case, red.

    bump

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

    ZachBora

    Can you update the first post with your current plugin.yml, main.java and colorsheep.java?
     
  26. Offline

    ZeusAllMighty11


    Yep.
     
  27. Offline

    travja

    ZeusAllMighty11 Your colorsheep.java is a Listener and CommandExecutor. In your main class you need to do:
    Code:java
    1. public CommandExecutor colorsheep = new colorsheep(this);
    2. public Listener sheeplistener = new colorsheep(this);
    3. public void onEnable(){
    4. getServer().getPluginManager().registerEvents(colorsheep, this);
    5. getCommand("ColorSheep").setExecutor(colorsheep);
    6. }

    That will set the colorsheep command to the colorsheep.java when you enable the plugin. Before, you had the getcommand thing in the colorsheep.java when it didn't even have a need to go to colorsheep.java

    So just register your events and your command executors in the main class and you should be good.
     
  28. Offline

    ZeusAllMighty11

    travja

    What does 'can not instantiate' mean?
     
  29. Offline

    travja

    Dunno, if you're getting errors, post them
     
  30. Offline

    ZeusAllMighty11

    The method registerEvents(Listener, Plugin) in the type PluginManager is not applicable for the arguments (CommandExecutor, main)main.java/TransformCreature/src/TransformCreatureline 35Java Problem
    colorsheep cannot be resolved to a typemain.java/TransformCreature/src/TransformCreatureline 28Java Problem
    colorsheep cannot be resolved to a typemain.java/TransformCreature/src/TransformCreatureline 29Java Problem
     
Thread Status:
Not open for further replies.

Share This Page