Help w/ my plugin!

Discussion in 'Plugin Development' started by tooncool64, May 6, 2014.

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

    Drkmaster83

    There isn't, he's saying recompile the plugin as a JAR file and run that one on your server, then copy your latest.log into a pastebin.
     
  2. Offline

    Drew1080

    tooncool64
    Yes I know there shouldn't. However since the console is giving you that error and in your new class file you are doing no casting it means that the version running on the server is outdated. Recompile the latest version you have now in your IDE and run it.
     
  3. Offline

    tooncool64

    Look at my pastebin,
    Thats the latest one i got.

    So, change my craftbukkit file to 1.7.9?
    I will do it!

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

    Drkmaster83

    *rubs temples*, no, he's saying re-export your plugin with the code with no errors in it, and restart your server.
     
  5. Offline

    Drew1080

    tooncool64
    No. That's not what I said at all.
    I said the plugin your running on your server now, is not the latest one like your using in your IDE.

    RECOMPILE your plugin then run it on your server.
     
  6. Offline

    tooncool64

    Ok.

    Drkmaster83
    Here is my log:
    http://pastebin.com/XuksJ3iw
    Here is my .class file:
    Code:java
    1. package name.testplugin;
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7.  
    8. public class Main extends JavaPlugin{
    9.  
    10. public void onEnable(){
    11. getLogger().info("Enabled!");
    12. }
    13.  
    14. public void onDisable(){
    15. getLogger().info("Disabled!");
    16. }
    17. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    18. if(cmd.getName().equalsIgnoreCase("hello")){
    19. sender.sendMessage("Hello Minecraft!");
    20. }
    21. return true;
    22. }
    23. }


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

    Europia79

    tooncool64

    just an FYI: the LOG FILES are much easier to read than the console screen.

    please don't copy the console screen.
     
  8. Offline

    Drkmaster83

  9. Offline

    tooncool64

    I am using the log files...
    Drkmaster83
    We need a Dev.
     
  10. Offline

    Drkmaster83

    I think it's more your error than ours, sorry. But it's true. You don't by chance have two instances of the plugin's .jar file in your plugins folder, do you?

    Would you perhaps be interested in me remote-controlling your desktop so that I can do the process for you? It's safe and free.

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

    tooncool64

    Only one, i just checked
    mbaxter

    Um, no ty!
    I know my computer well!

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

    Drkmaster83

    Like I said, it has to be you, because it's sure as heck not us. The error is that you're casting a Player object to a ConsoleColourSender object. The code we've provided does not do that, so it is evident you're not running the code we gave you.
     
  13. Offline

    tooncool64

    Can you please give me the complete edited code you have?
    Then i will change it and show you.
    Here is my .class file:
    Code:java
    1. package name.testplugin;
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7.  
    8. public class Main extends JavaPlugin{
    9.  
    10. public void onEnable(){
    11. getLogger().info("Enabled!");
    12. }
    13.  
    14. public void onDisable(){
    15. getLogger().info("Disabled!");
    16. }
    17. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    18. if(cmd.getName().equalsIgnoreCase("hello")){
    19. sender.sendMessage("Hello Minecraft!");
    20. }
    21. return true;
    22. }
    23. }
     
  14. Offline

    Drkmaster83

    Code:
    package name.testplugin;
     
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
     
    public class Main extends JavaPlugin{
      @Override
      public void onEnable(){
        getLogger().info("Enabled!");
      }
     
      @Override
      public void onDisable(){
        getLogger().info("Disabled!");
      }
     
      public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if(cmd.getName().equalsIgnoreCase("hello")){
          sender.sendMessage("Hello Minecraft!");
        }
        return true;
      }
    }
    
    plugin.yml:
    Code:
    name: TestPlugin
    main: name.testplugin.Main
    version: 1
    author: tooncool64
    commands:
      hello:
        description: HelloMinecraft
    
    Step 1: Shut down your server.
    Step 2: Go into "logs" and delete "latest.log"
    Step 3: Export your plugin
    Step 4: Check for duplicate plugins in your plugins folder
    Step 5: Launch server
    Step 6: If error is thrown in the console, shut down server and proceed to Step 7.
    Step 7: Go into the "logs" folder and open "latest.log". Press "CTRL + A" and "CTRL + C", then proceed to press "CTRL + V" into a pastebin.
     
  15. Offline

    tooncool64

  16. Offline

    Drkmaster83

    The only way this is possible is if you have a second plugin listening to 'hello' on your server, otherwise, let's hope for some dev to help us.
    ZeusAllMighty11
     
  17. Offline

    RZeroX

    [quote uid=90942873 name="tooncool64" post=2470758]Drkmaster83
    Here:
    http://pastebin.com/zVqjMyT6
    I did all the steps you said.[/quote]
    You replaced the .jar with the updated one right
    because I'm pretty sure you would only get that error if you use player.sendMessage
    try this as it seems to work fine for me :D
    <Edit by Moderator: Redacted mediafire url>
    You must be Stuffing something up when you compile it or something
     
    Last edited by a moderator: Nov 2, 2016
  18. Offline

    ZeusAllMighty11

    tooncool64

    Please don't tag bukkit staff as they are very busy!
     
  19. Offline

    MCMatters

    I know the error!
    Hint:
    Show Spoiler

    [16:21:07] [Server thread/WARN]: Unexpected exception while parsing console command "hello"
    org.bukkit.command.CommandException: Unhandled exception executing command 'hello' in plugin TestPlugin v1

    Um? U need a command executor duh!
    U can revert all your changes to plugin.yml
    And instead add this code:
    (Ill Correct All Your Mistakes)
    (Dont Recorrect Or You May Get Error)
    Show Spoiler

    Main Class:
    Code:java
    1. package name.testplugin;
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4. import org.bukkit.ChatColor; // <--- I dont see any colors being used
    5. import org.bukkit.entity.Player; // <--- This Is Not Needed
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.event.Listener; // <--- This Is Not Needed
    9.  
    10. public class Main extends JavaPlugin{
    11.  
    12. public void onEnable(){
    13. getLogger().info("Enabled!");
    14. getCommand("hello").setExecutor(new CommandExecutor());
    15. }
    16.  
    17. public void onDisable(){
    18. getLogger().info("Disabled!");
    19. }
    20. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    21. Player player = (Player) sender;
    22. if(cmd.getName().equalsIgnoreCase("hello")){
    23. player.sendMessage(ChatColor.AQUA + "Hello Minecraft!"); // <--- This Goes In CommandExecutor
    24. }
    25. return true;
    26. }
    27. }
    28.  
    29.  

    And You Would Need A New Command Executor, So Create A Class And Name It CommandExecutor
    Put The Following Code In It
    Code:java
    1. package name.testplugin
    2.  
    3. import org.bukkit.command.Command; // <--- The Command Executor Still Sends (Handles) Commands
    4. import org.bukkit.command.CommandExecutor; // <--- This Is A Command Executor Lol Duh
    5. import org.bukkit.command.CommandSender; // <--- The Command Executor Still Sends (Handles) Commands
    6. import org.bukkit.GameMode;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.Bukkit;
    9.  
    10. public class CommandExecutor implements CommandExecutor {
    11. @Override
    12. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    13. sender.sendMessage("Hello Minecraft")
    14. }


    Your Welcome.

    Yes There Is Lol

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

    Drew1080

    Actually theres nothing wrong with the code he posted us. The problem is he's not compiling it properly and there forth not running the most recent build of his plugin on his server instead he is using a previous build were he was trying to cast a Player to a sender when the sender is a not a console without doing any checking.

    Also to go back to the code you pasted above. He does not need to use the getCommand method to register a CommandExecutor since JavaPlugin already inherits CommandExecutor http://jd.bukkit.org/rb/apidocs/org/bukkit/plugin/java/JavaPlugin.html
    So if you put the command in the main class you don't need to register it like your showed. You only have todo that if you put the command in a different class like your example showed.
     
  21. Offline

    Schaakmatth

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if(cmd.getName().equalsIgnoreCase("hello")) {
    Player player = (Player) sender;
    player.sendMessage("Hello Minecraft!");

    Look at the changes
     
  22. Offline

    Zacky1

    I don't get what the fuss is all about here. It's not that complicated, MCMatters had it spot it (I cant believe it took 7 replies) for someone to finally notice he didn't set a command executor (which should be the way he does it don't start putting c**p in his mind that its okay consistency is key).

    Code:java
    1. public class Main extends JavaPlugin{
    2.  
    3. public void onEnable(){
    4. getLogger().info("Enabled!");
    5. getCommand("hello").setExecutor(new CommandExecutor());
    6. }


    Code:java
    1.  
    2. public class CommandExecutor implements CommandExecutor {
    3. @Override
    4. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    5. sender.sendMessage("Hello Minecraft");
    6. }
    7. }


    Compiling is easy if you use bukkit, right click your project, select export, select java -> jar file, select EXPORT .class files, put that jar in your server plugins directory, start server.

    Works.
     
  23. MCMatters Zacky1 Do you fully understand what you're actually saying? Yes you can (and in a bigger plugin should) set a CommandExecutor, and you've a lovely example of that (although I would disagree with calling your CommandExecutor CommandExecutor) but you don't have to. Commands in the main class works too. So don't come here with your condescending attitude, because your suggestion does not solve the main issue - which at this point can only be that he's running an outdated version.

    Europia79 His namespace isn't actually wrong, it just doesn't follow the standard naming convention.
     
  24. Offline

    Zacky1

    You are 100% right Adam :) I was just wrapping all the ideas together because it seemed everywhere. Anywho gluck mr.
     
    AdamQpzm likes this.
  25. Offline

    Europia79


    I was thinking the exact same thing... Even Skype has a screen sharing option that we could use to quickly resolve the issue... then post back here what the problem + solution was.
     
Thread Status:
Not open for further replies.

Share This Page