message bug

Discussion in 'Spigot Plugin Help' started by optischTV, Apr 17, 2019.

  1. I have made my Prefix editable by config.yml (sorry for my bad English I'm from Germany!) but now I can not run my commands here is the log:

    [21:11:08 INFO]: ByGoalZ issued server command: /skull
    [21:11:08 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'skull' in plugin EssentialsRelPlus v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_201]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_201]
    at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]
    Caused by: java.lang.NullPointerException
    at org.bukkit.ChatColor.translateAlternateColorCodes(ChatColor.java:324) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    at de.bygoalz.system.main.data.getPrefix(data.java:10) ~[?:?]
    at de.bygoalz.system.commands.cmd_skull.onCommand(cmd_skull.java:21) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    ... 15 more
    >





    Here is the command class:

    package de.bygoalz.system.commands;

    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.SkullMeta;

    import de.bygoalz.system.main.Main;
    import de.bygoalz.system.main.data;

    public class cmd_skull implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if(sender instanceof Player) {
    Bukkit.getConsoleSender().sendMessage(data.getPrefix() + "§cDu bist kein Spieler!");

    }
    Player p = (Player) sender;

    if(!p.hasPermission("system.skull")) {
    p.sendMessage(data.getPrefix() + data.getnoPerm());
    return true;
    }
    if(args.length == 1) {
    ItemStack is = new ItemStack(Material.SKULL_ITEM, 1 , (short) 3);
    SkullMeta im = (SkullMeta)is.getItemMeta();
    im.setOwner(args[0]);
    im.setDisplayName("§aKopf von§7: §6" + args[0]);
    is.setItemMeta(im);
    p.getInventory().addItem(new ItemStack[] {is});
    p.updateInventory();
    return true;
    } else {
    p.sendMessage(data.getPrefix() + "§cBitte verwende: /skull <Spieler>");
    }

    return false;
    }


    }



    Here is the data class (there is my prefix):


    package de.bygoalz.system.main;

    import org.bukkit.ChatColor;

    public class data {

    public static String getPrefix() {

    String p;
    p = ChatColor.translateAlternateColorCodes('&', Main.cfg.getString("prefix"));



    return p;

    }

    public static String getnoPerm() {

    String n;
    n = ChatColor.translateAlternateColorCodes('&', Main.cfg.getString("noperm"));




    return n;
    }
    }

    I know at give's code variables but I don't know these.

    I hope you can help me fast. Thanks!