[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

    travja

  2. Offline

    ZeusAllMighty11

    PHP:
    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 CommandExecutor colorsheep = new colorsheep(this);
    public 
    Listener sheeplistener = new colorsheep(this);
     
     
     
    public 
    void onEnable(){
     
       
    getServer().getPluginManager().registerEvents(colorsheepthis);
       
    getCommand("ColorSheep").setExecutor(colorsheep);
     
    PluginManager pm this.getServer().getPluginManager();
    pm.registerEvents(thisthis);
     
     
       
    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 senderCommand commandString labelString[] 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;
    }
    }
     
  3. Offline

    Faelsel

    So no uses of all these events all can be done under playertentityinteract event....

    try this, maybe is wrong because i repeat i never used hthese codes ;)
     
    ZeusAllMighty11 likes this.
  4. Offline

    ZeusAllMighty11

    Faelsel


    I've got some things in that working, while the last part of it just dies.

    Code:
            [I][SIZE=12px]if (!(Sheep1 = (Sheep)e.getRightClicked() instanceof Sheep))[/SIZE][/I]
    
    For some reason, it dies for me there.

    Code:
    DescriptionResourcePathLocationType
    Type mismatch: cannot convert from boolean to SheepcolorSheep.java/TransformCreature/src/TransformCreatureline 58Java Problem
    The operator ! is undefined for the argument type(s) SheepcolorSheep.java/TransformCreature/src/TransformCreatureline 58Java Problem
    The method registerEvents(Listener, Plugin) in the type PluginManager is not applicable for the arguments (CommandExecutor, main)main.java/TransformCreature/src/TransformCreatureline 35Java Problem
    Syntax error, insert "EnumBody" to complete EnumDeclarationcolorSheep.java/TransformCreature/src/TransformCreatureline 62Java Problem
    Syntax error, insert "enum Identifier" to complete EnumHeaderNamecolorSheep.java/TransformCreature/src/TransformCreatureline 62Java Problem
    Syntax error, insert "}" to complete ClassBodycolorSheep.java/TransformCreature/src/TransformCreatureline 62Java Problem
    Syntax error on tokens, delete these tokenscolorSheep.java/TransformCreature/src/TransformCreatureline 62Java Problem
    
     
  5. Offline

    Mike111177

    did you install the plugin?
     
  6. Offline

    ZeusAllMighty11

    ??????????

    lolwut


    Can't tell if trolling or just....
     
  7. Offline

    Mike111177

    im just curios if it does nothing thats a symptom of forrgetting to install it lol
     
  8. Offline

    ZeusAllMighty11

    Sorry, I don't understand you very well.

    I think you're asking if I already tried the plugin on my server.


    Yes, but only the /transform creature command works, which tells me the version. The other class, is dead.
     
  9. Offline

    r0306

    Separate the code:
    Code:
    if (e.getRightClicked() instanceof Sheep) {
    Sheep1 = (Sheep)e.getRightClicked();
     
    ZeusAllMighty11 likes this.
  10. Offline

    ZeusAllMighty11



    Thanks, but finally the last errors. (main class (main.java))
    [​IMG]
     
  11. Offline

    Mike111177

    okay never mind
     
  12. Offline

    r0306

    ZeusAllMighty11
    Lolwut. You're registering your command executor instead of your listener? You might wanna change it to:
    Code:
    getServer().getPluginManager().registerEvents(sheeplistener, this);
     
  13. Offline

    ZeusAllMighty11

    Still getting these problems though.

    [​IMG]
     
  14. Offline

    r0306

    ZeusAllMighty11
    Change
    Code:
    public CommandExecutor colorsheep = new colorsheep(this);
    to
    Code:
    private colorSheep colorsheep = new colorSheep(this);
    and change the other colorsheep on the listener to colorSheep
     
  15. Offline

    ZeusAllMighty11


    Now they're undefined.
     
  16. Offline

    r0306

    ZeusAllMighty11
    Actually, change it back to CommandExecutor but keep the casing the same as below:
    Code:
    private CommandExecutor colorsheep = new colorSheep(this);
     
  17. Offline

    ZeusAllMighty11


    Still undefined o.o
     
  18. Offline

    travja

    Do this:
    public Listener sheeplistener = new colorSheep(this);
    public CommandExecutor colorsheep = new colorSheep(this);

    In the MAIN class not the listener.
     
  19. Offline

    ZeusAllMighty11

    I did that, in the MAIN class. Still undefined.

    Code:
    public class main extends JavaPlugin implements Listener{
     
    Logger log = Logger.getLogger("Minecraft"); // define logger as 'log' for console
     
     
    public Listener sheeplistener = new colorSheep(this);
    public CommandExecutor colorsheep = new colorSheep(this);
     
     
     
     
    public void onEnable(){
     
       getServer().getPluginManager().registerEvents(sheeplistener, this);
     
       getCommand("colorsheep").setExecutor(colorsheep);
     
    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
    }
    
     
  20. Offline

    r0306

    ZeusAllMighty11
    This should work now:
    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
     
    private colorSheep colorsheep;
     
    public void onEnable(){
      colorsheep = new colorSheep(this);
      getCommand("ColorSheep").setExecutor(colorsheep);
     
      getServer().getPluginManager().registerEvents(new colorSheep(), 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;
    }
    }
     
  21. Offline

    ZeusAllMighty11

  22. Offline

    r0306

  23. Offline

    ZeusAllMighty11

    r0306

    The constrcutor colorSheep(main) is still undefined
     
  24. Offline

    r0306

  25. Offline

    ZeusAllMighty11

    r0306 Still, still undefined
     
  26. Offline

    r0306

  27. Offline

    travja

    Post error line and can you post Both classes codes?
     
  28. Offline

    ZeusAllMighty11

    I used eclipse's suggestion and changed:

    colorsheep = new colorSheep(this);

    to
    colorsheep = new colorSheep();

    travja
    r0306


    Now the problem, is right clicking a sheep does nothing.
     
  29. Offline

    r0306

  30. Offline

    ZeusAllMighty11

    Code:
    package TransformCreature;
     
    import org.bukkit.ChatColor;
    import org.bukkit.DyeColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    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.Listener;
    import org.bukkit.event.entity.SheepDyeWoolEvent;
    import org.bukkit.event.player.PlayerInteractEntityEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class colorSheep extends JavaPlugin implements Listener{
     
       @Override
       public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    if(cmd.getName().equalsIgnoreCase("colorsheep")){ // If typed command is colorsheep
          System.out.println("Got this far");
          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 + ("Right click a sheep to change it's colour.")); // sends msg 
    }
    }
       return true;
       }
     
    // Time to check on things
       
       @EventHandler
    public void sheepListener(PlayerInteractEntityEvent e) { // player and entity interaction
     
    Player p = (Player) e.getPlayer(); // gets the player variable
    ItemStack inHand = p.getItemInHand(); // gets the iteminhand variable
    Sheep Sheep1;
     
     
    if (inHand != null) { // checks if item in hand is null
      return;
    }
     
    if (inHand.getType() == Material.STICK){ // checks for stick in hand
    return;
    }
     
     
    if (!(e.getPlayer() instanceof Player)) { // checks if instance is not player
       return;
    }
     
     
    if (e.getRightClicked() instanceof Sheep) {
    Sheep1 = (Sheep)e.getRightClicked();
     
    Sheep1.setColor(DyeColor.BLUE);
    }
    }
     
    }
    // finish code before handlers
     
    

    Thanks.



    And also everyone else, thanks a bunch for putting up with my stubborness...
     
Thread Status:
Not open for further replies.

Share This Page