Why i get this error

Discussion in 'Plugin Development' started by plarsootje, May 12, 2012.

Thread Status:
Not open for further replies.
  1. i get an error can someone help me

    package me.net.dracinis.Commands;
    import me.net.dracinis.dracinismain;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    public class 
    CommandOp implements CommandExecutor{
    CommandOp (dracinismain dracinismain) {
    boolean onCommand(CommandSender senderCommand cmdString labelString[] args) {
    Player player null;
            if (
    sender instanceof Player) {
    player = (Playersender;
            if (
    args.length == 1) {
    Player targetPlayer sender.getServer().getPlayer(args[0]);
    sender.sendMessage(targetPlayer "is now op");
            } else if (
    cmd.getName().equalsIgnoreCase("basic2")) {
                if (
    player == null) {
    sender.sendMessage("this command can only be run by a player");
                } else {
    // do something else...
    2012-05-12 12:09:24 [INFO] [dracinis] Disabling dracinis v1.7
    2012-05-12 12:09:24 [INFO] dracinis Has been Disabled!
    2012-05-12 12:09:24 [INFO] 182 recipes
    2012-05-12 12:09:24 [INFO] [dracinis] Loading dracinis v1.7
    2012-05-12 12:09:24 [INFO] [dracinis] Enabling dracinis v1.7
    2012-05-12 12:09:24 [INFO] dracinis version 1.7 is now enabled.
    2012-05-12 12:09:25 [INFO] Server permissions file permissions.yml is empty, ignoring it
    2012-05-12 12:09:25 [INFO] Reload complete.
    2012-05-12 12:09:27 [WARNING] Unexpected exception while parsing console command
    org.bukkit.command.CommandException: Unhandled exception executing command 'op' in plugin dracinis v1.7
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:166)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:473)
        at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.java:469)
        at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:599)
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:568)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:452)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    Caused by: java.lang.NullPointerException
        at me.net.dracinis.Commands.CommandOp.onCommand(CommandOp.java:27)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40)
        ... 7 more
  2. Maybe because the targeted player wasn't found?
  3. why can be that be
  4. There could be some reasons. But first, have you actually checked if 'targetPlayer' is null?
  5. this is my full code where i need to check it?
  6. Offline


  7. plarsootje
    You know, there's already a /op command for operators to make other people operators, and there's also /deop.
Thread Status:
Not open for further replies.

Share This Page