Solved Player cannot be resolved?

Discussion in 'Plugin Development' started by Tecno_Wizard, Jul 3, 2014.

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

    Tecno_Wizard

    Hi,
    My friend wanted a command block friendly command to set someone on fire (for a trap), and i keep getting this error

    Code:
    [21:24:38] [Server thread/INFO]: Starting minecraft server version 1.7.9
    [21:24:38] [Server thread/INFO]: Loading properties
    [21:24:38] [Server thread/INFO]: Default game type: SURVIVAL
    [21:24:38] [Server thread/INFO]: Generating keypair
    [21:24:38] [Server thread/INFO]: Starting Minecraft server on *:25565
    [21:24:38] [Server thread/INFO]: This server is running CraftBukkit version git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks (MC: 1.7.9) (Implementing API version 1.7.9-R0.3-SNAPSHOT)
    [21:24:38] [Server thread/INFO]: [Practice] Loading Practice v1.0
    [21:24:38] [Server thread/INFO]: [Ablaze] Loading Ablaze v1.0
    [21:24:38] [Server thread/INFO]: Preparing level "world"
    [21:24:39] [Server thread/INFO]: Preparing start region for level 0 (Seed: -1580440507216941901)
    [21:24:39] [Thread-7/INFO]: ----- Bukkit Auto Updater -----
    [21:24:39] [Thread-7/INFO]: It appears that you're running a Development Build, when you've specified in bukkit.yml that you prefer to run Recommended Builds.
    [21:24:39] [Thread-7/INFO]: If you would like to be kept informed about new Development Build releases, it is recommended that you change 'preferred-channel' in your bukkit.yml to 'dev'.
    [21:24:39] [Thread-7/INFO]: With that set, you will be told whenever a new version is available for download, so that you can always keep up to date and secure with the latest fixes.
    [21:24:39] [Thread-7/INFO]: If you would like to disable this warning, simply set 'suggest-channels' to false in bukkit.yml.
    [21:24:39] [Thread-7/INFO]: ----- ------------------- -----
    [21:24:40] [Server thread/INFO]: Preparing spawn area: 57%
    [21:24:40] [Server thread/INFO]: Preparing start region for level 1 (Seed: -1580440507216941901)
    [21:24:41] [Server thread/INFO]: Preparing start region for level 2 (Seed: -1580440507216941901)
    [21:24:41] [Server thread/INFO]: [Practice] Enabling Practice v1.0
    [21:24:41] [Server thread/INFO]: [Ablaze] Enabling Ablaze v1.0
    [21:24:41] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [21:24:41] [Server thread/INFO]: Done (2.752s)! For help, type "help" or "?"
    [21:24:46] [User Authenticator #1/INFO]: UUID of player Tecno_Wizard is ff0e7beb-affa-41cf-9fbc-d9d53aca2027
    [21:24:46] [Server thread/INFO]: Tecno_Wizard[/127.0.0.1:51659] logged in with entity id 229 at ([world] 275.73786582403903, 64.0, 226.48231654035771)
    [21:24:49] [Server thread/WARN]: CommandBlock at (275,64,228) failed to handle command
    org.bukkit.command.CommandException: Unhandled exception executing command 'ablaze' in plugin Ablaze v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.CommandBlockListenerAbstract.a(CommandBlockListenerAbstract.java:164) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.BlockCommand.a(BlockCommand.java:47) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.WorldServer.a(WorldServer.java:533) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.WorldServer.doTick(WorldServer.java:206) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:641) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
    Caused by: java.lang.Error: Unresolved compilation problem:
        player cannot be resolved
     
        at me.Tecno_Wizard.Ablaze.MainClass.onCommand(MainClass.java:43) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.2-1-ga6e0bfd-b3095jnks]
        ... 10 more
    [21:24:54] [Server thread/INFO]: Tecno_Wizard lost connection: Disconnected
    [21:24:54] [Server thread/INFO]: Tecno_Wizard left the game.
    [21:25:05] [Server thread/INFO]: CONSOLE: Stopping the server..
    [21:25:06] [Server thread/INFO]: Stopping server
    [21:25:06] [Server thread/INFO]: [Ablaze] Disabling Ablaze v1.0
    [21:25:06] [Server thread/INFO]: [Practice] Disabling Practice v1.0
    [21:25:06] [Server thread/INFO]: Saving players
    [21:25:06] [Server thread/INFO]: Saving worlds
    [21:25:06] [Server thread/INFO]: Saving chunks for level 'world'/Overworld
    [21:25:07] [Server thread/INFO]: Saving chunks for level 'world_nether'/Nether
    [21:25:07] [Server thread/INFO]: Saving chunks for level 'world_the_end'/The End
    [21:25:07] [Thread-4/INFO]: Stopping server
    [21:25:07] [Thread-4/INFO]: Saving players
    [21:25:07] [Thread-4/INFO]: Saving worlds
    [21:25:07] [Thread-4/INFO]: Saving chunks for level 'world'/Overworld
    Here is the only class in the plugin


    Code:java
    1. package me.Tecno_Wizard.Ablaze;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class MainClass extends JavaPlugin
    10. {
    11. @Override
    12. public boolean onCommand(CommandSender sender, Command cmd, String label, String[]args)
    13. {
    14. if(label.equalsIgnoreCase("ablaze"))
    15. {
    16. if(sender instanceof Player)
    17. {
    18. Player player=(Player)sender;
    19. if(args.length==0)
    20. {
    21. player.setFireTicks(400);
    22. }
    23. else if(args.length>0 && args.length<2)
    24. {
    25. loop:
    26. for(Player currentPlayer: Bukkit.getOnlinePlayers())
    27. {
    28. if(player.getName().equalsIgnoreCase(args[0]))
    29. {
    30. currentPlayer.setFireTicks(400);
    31. currentPlayer.sendMessage("Probably want some ice for that...");
    32. break loop;
    33. }
    34. }
    35. }//end bracket for arg# check
    36. }//end bracket for if Player sent
    37.  
    38. else//if commandblock
    39. {
    40. loop:
    41. for(Player currentPlayer: Bukkit.getOnlinePlayers())
    42. {
    43. if(player.getName().equalsIgnoreCase(args[0]))
    44. {
    45. currentPlayer.setFireTicks(400);
    46. currentPlayer.sendMessage("Probably want some ice for that...");
    47. break loop;
    48. }
    49. }
    50. }//end of if commandblock sent
    51. }
    52. return true;
    53. }
    54. }


    Does anyone know what is going on here? It's likely a really dumb mistake on my part, but I'm somewhat new to java programming, and I do not understand what that error exactly means.
    Sorry if my incompetence is aggravating.
     
  2. Offline

    adam753

    On line 43, you're using a variable called "player", but no such variable exists in that context. I think you meant "currentPlayer". (How on earth did you get that to compile?)
     
    AoH_Ruthless likes this.
  3. where is your onEnable and onDisable methods?

    Code:java
    1. @Override
    2. public void onEnable() {
    3. getCommand("ablaze").setExecuter(this, this);
    4. }
    5.  
    6. @Override
    7. public void onDisable() {
    8.  
    9. }


    also add implements CommandExecuter after extends JavaPlugin.
     
  4. Offline

    adam753

    teozfrank
    The main class is its own executor by default.
     
  5. lol

    I know :p Guess im just used to using seperate classes for each of my commands.

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

    AoH_Ruthless

    adam753
    Only in the case of using the inherited command method, however.

    Tecno_Wizard
    One of the first things you do is cast Player to sender. How can a command block execute a command if you are automatically defining the sender as a player? Player =/= Command Block. I believe it is CommandBlockSender, not sure though. Never mind.
     
  7. Offline

    Xyplo

    It doesn't need to 'implement CommandExecutor' if it's in his main class..
     
  8. Offline

    Necrodoom

    What is the 'loop:' line supposed to be?
     
    unrealdesign likes this.
  9. Offline

    Tecno_Wizard

    adam753
    I just now caught that. And I agree, how on earth did eclipse miss that?
    Edit: went and changed one letter and put it back, THEN eclipse registered it as a problem. Pff, computers...
     
Thread Status:
Not open for further replies.

Share This Page