Plugin loading but not functioning

Discussion in 'Plugin Development' started by tyler53, Nov 2, 2013.

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

    tyler53

    Hey guys, I am getting very frustrated :((

    I have never had this problem before, and now all of a sudden every new plugin I export from eclipse won't work!

    It says that it is enabled correctly on the console, but nothing in the code actually works in the plugin. Commands don't work, event listeners don't work (Yes I register the events correctly and add @EventHandlers where needed)

    I've even tried creating the simplest little plugin to try to fix this and I'm still having this problem.

    Here's the main (Main.java):
    Code:java
    1. package com.SplitCell.main;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8. public class Main extends JavaPlugin{
    9.  
    10. public void onEnable(){
    11.  
    12. }
    13.  
    14. public void onDisable(){
    15.  
    16. }
    17.  
    18. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    19.  
    20. if(label.equalsIgnoreCase("Fix")){
    21. Player player = (Player) sender;
    22. player.sendMessage("Hey");
    23. }
    24.  
    25. return false;
    26. }
    27.  
    28. }


    And here is my plugin.yml:
    Code:
    name: Fix
    author: SplitCell
    version: 1.0
    main: com.SplitCell.main.Main
    commands:
      fix:
        description: tests the fix plugin
    please help, I have no idea what I'm doing wrong!

    There is no response whatsoever when I use the command /fix in the game. It doesn't say anything in the console, it doesn't say "Unknown command" in the game, it literally does nothing. Which leads me to believe that it DOES recognize the plugin it just hates me for some reason :/

    EDIT: I am using CB 1.6.4 the latest recommended build
     
  2. Offline

    xTrollxDudex

    tyler53
    Lrn2returntrue

    Casting to player, again is completely redundant. Use CommandSender#sendMessage(String)
     
  3. Offline

    tyler53

    @xTrollxDudex
    I have no idea what you just said... except for the casting to player part obviously I got That

    But what do you mean Lrn2returntrue and whats with the CommandSender#sendMessage(String)

    I don't think that's the problem because my EventHandlers and listeners don't work at all either..
     
  4. Offline

    Goblom

    tyler53
    You are returning false event if command is successful. You are also casting player to sender before you check to see if sender is actually a player. And is also not needed. Remove the casting of player and just do this...
    Code:java
    1. sender.sendMessage("Hey");
     
    xTrollxDudex likes this.
  5. Offline

    CraftBang

    Idk what bukkit is doing but changing my letters to white color code or something -.- (That's why I'm not using code tags right now, sorry.




    Player player = (Player) sender;
    player.sendMessage("Hey");

    Should be
    sender.sendMessage("Hey");

    And if you want to teleport him

    Player player = (Player) sender;
    sender.sendMessage("Hey");
    player.teleport(<a Location>);


    Maybe add this onEnable():
    public final Logger logger = Logger.getLogger("Minecraft");


    this.logger.info("MyTestPlugin has been enabled");
     
  6. Offline

    Goblom

    CraftBang Please watch the language. This is a public forums and people of all ages come on here.
     
  7. Offline

    CraftBang


    Sorry that's true, but I'm trying to help people, and make responses to threads, and it's not really going fast if my post gets automaticly edited, very annoying, so I got irritated but sorry, I will not do it again.
     
  8. Offline

    Cirno

    Use "cmd.getName()" instead of label.
     
  9. Offline

    tyler53

    why is that?

    Also, changing this did nothing. I didn't think it would either, because NOTHING in the plugin is working :(( EventHandlers aren't working, nothing is registering


    Returning true didnt change anything, and getting rid of the cast didn't fix anything either.



    I've tried loggers and also using Bukkit.getServer().getConsoleSender().sendMessage("Plugin Working properly"); doesn't get called either

    Also, for another frame of reference, this is also not working.

    Code for an event handler I have
    Code:java
    1. @EventHandler
    2. public void onJoin(PlayerLoginEvent event){
    3. Player player = event.getPlayer();
    4.  
    5. if(!player.getInventory().contains(Material.CARROT_ITEM) && !player.getInventory().contains(Material.GOLDEN_CARROT)){
    6. for(int i = 0; i < player.getInventory().getSize(); i++){
    7. if(player.getInventory().getItem(i) == null){
    8.  
    9. ItemStack item = new ItemStack(Material.CARROT_ITEM);
    10. ItemMeta im = item.getItemMeta();
    11. im.setDisplayName(ChatColor.AQUA + "Toggle Boost");
    12.  
    13. item.setItemMeta(im);
    14.  
    15. player.getInventory().setItem(i, item);
    16. break;
    17. }
    18. }
    19. }
    20. }


    Doesn't even call when I've tried testing with console messages and player messages, nothing. Yes I've correctly set up the listener in the main class yes I've done all that, It worked great before and now for seemingly no reason its not working anymore...

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

    tyler53

  11. Offline

    Ranil


    Is this Event in a seperate class? If so, have you registered the events in that class from your main class? Have you implemented listener in the class? There's not much we can help you with with that little information.
     
  12. Offline

    tyler53

    Quoting myself here on the post that you quoted...
    "Doesn't even call when I've tried testing with console messages and player messages, nothing. Yes I've correctly set up the listener in the main class yes I've done all that, It worked great before and now for seemingly no reason its not working anymore..."


    Also, the original question was just about the command, there weren't even any listeners involved. That last post to this thread was to emphasize that no part of the plugins are working, listeners, commands, nothing, not even the onEnables are being called, but the plugin says its enabled correctly
     
  13. Offline

    lol768

    Label includes aliases.
     
  14. Offline

    Xyaren

    I'm not experienced with java but isn't it better to use an "@override" annotation before the onCommand method?
     
Thread Status:
Not open for further replies.

Share This Page