Fehler | Error

Discussion in 'Spigot Help' started by KeineConnection, Jun 10, 2018.

?

Was mache ich falsch

  1. Fehler in Config

    4 vote(s)
    66.7%
  2. Fehler in der Main

    3 vote(s)
    50.0%
  3. Fehler im Command

    3 vote(s)
    50.0%
Multiple votes are allowed.
  1. Guten Tag.
    Ich habe angefangen mit Configs zu programmieren.
    Und wollte zum Test einen Heal Command machen bei dem die Message in der Config gespeichert wird.
    Aber ich bekomme einen Fehler:

    Fehler:
    org.bukkit.command.CommandException: Unhandled exception executing command 'heal' in plugin OurEssentials v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_171]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_171]
    at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_171]
    Caused by: java.lang.NullPointerException
    at de.keineconnection.commands.HealCommand.onCommand(HealCommand.java:18) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
    ... 15 more

    Main:
    package de.keineconnection.main;

    import de.keineconnection.commands.HealCommand;
    import de.keineconnection.commands.testcmd;
    import org.bukkit.Bukkit;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin {

    private static Main plugin;

    @Override
    public void onEnable(){

    loadConfig();

    PluginManager pm = Bukkit.getPluginManager();

    getCommand("heal").setExecutor(new HealCommand());
    getCommand("test").setExecutor(new testcmd());

    }

    public void loadConfig(){
    getConfig().options().copyDefaults(true);
    saveConfig();
    }

    public static Main getPlugin() {
    return plugin;
    }

    }

    Command (Heal):
    package de.keineconnection.commands;

    import de.keineconnection.main.Main;
    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 HealCommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
    if(sender instanceof Player){
    Player p = (Player) sender;
    if(p.hasPermission("our.heal")){
    if(args.length == 0){
    String msg = Main.getPlugin().getConfig().getString("config.healmessage");
    msg = msg.replace("[Player]", p.getName());
    p.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
    int herzen = Main.getPlugin().getConfig().getInt("config.heallives");
    p.setHealth(herzen);
    return true;
    } else {
    p.sendMessage("Bitte benutze /heal");
    }
    } else {
    p.sendMessage("Keine Rechte");
    }
    }
    return false;
    }

    }

    LG. Moritz
     
  2. Guten tag lol,

    As I know, this forum is ENGLISH, there are probably German ones too, so... At least use some kind of translator, if you still living in the 21st century haven't learned English.
     
    #2 TheIronMinerLv, Jun 10, 2018
    Last edited: Jun 10, 2018
    • Agree Agree x 1

  3. Here for you in English

    Good day. I started programming with configs. And wanted to test a heal command make in which the message is stored in the config. But I get an error: