Solved Null error

Discussion in 'Plugin Development' started by tvhee, Aug 6, 2020.

  1. Offline

    tvhee

    Hey,
    I am making a plugin and now I get an null error

    Code:
    [16:04:59 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'cr' in plugin ChatRadius v1.8
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[patched_1.16.1.jar:git-Paper-79]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.16.1.jar:git-Paper-79]
        at org.bukkit.craftbukkit.v1_16_R1.CraftServer.dispatchCommand(CraftServer.java:794) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.PlayerConnection.handleCommand(PlayerConnection.java:1908) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.PlayerConnection.a(PlayerConnection.java:1719) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.PacketPlayInChat.a(PacketPlayInChat.java:47) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:23) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.TickTask.run(SourceFile:18) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.MinecraftServer.aZ(MinecraftServer.java:1136) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.MinecraftServer.executeNext(MinecraftServer.java:1129) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.MinecraftServer.sleepForTick(MinecraftServer.java:1090) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:1004) ~[patched_1.16.1.jar:git-Paper-79]
        at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$a$0(MinecraftServer.java:177) ~[patched_1.16.1.jar:git-Paper-79]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_261]
    Caused by: java.lang.NullPointerException
        at me.tvhee.chatradius.ChatRadiusCommand.onCommand(ChatRadiusCommand.java:133) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.1.jar:git-Paper-79]
        ... 18 more
    
    The /cr reload command:
    Code:
    if (args[0].equalsIgnoreCase("reload"))
                {
                    if (sender.hasPermission("chatradius.reload"))
                    {
                        plugin.reloadConfig();
                        plugin.current_chat_radius = plugin.getConfig().getInt("chatradius");
                        final PluginManager plg = Bukkit.getPluginManager();
                        final Plugin plgname = plg.getPlugin(plugin.getName());
                        plg.disablePlugin(plgname);
                        plg.enablePlugin(plgname);
                        if(plugin.getConfig().getString("reset").equals("true"))
                        {
                            plugin.getConfig().set("reset", false);
                            plugin.getConfig().set("plugin.chatradius", 100);
                            plugin.getConfig().set("plugin.prefix", "&7[&bChatRadius&7] ");
                            plugin.getConfig().set("plugin.language", "en");
                            plugin.getConfig().set("commands.cr-help", true);
                            plugin.getConfig().set("commands.cr-radius", true);
                            plugin.getConfig().set("commands.cr-set", true);
                            plugin.getConfig().set("commands.cr-check", true);
                            plugin.getConfig().set("commands.cr-language", true);
                            plugin.saveConfig();
                            plugin.reloadConfig();
                            plugin.current_chat_radius = plugin.getConfig().getInt("chatradius");
                            plg.disablePlugin(plgname);
                            plg.enablePlugin(plgname);
                            sender.sendMessage(ChatColor.GRAY + "[" + ChatColor.AQUA + "ChatRadius" + ChatColor.GRAY + "] " + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.command.reload.default")));
                        }
                        else
                        {
                            sender.sendMessage(plugin.igprefix + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.command.reload.normal")));
                            if(plugin.getConfig().getString("plugin.chatradius") != null) {
                                try
                                {
                                    String intchatradius = plugin.getConfig().getString("plugin.chatradius");
                                    Integer.parseInt(intchatradius);
                                }
                                catch(NumberFormatException e)
                                {
                                    player.sendMessage(plugin.igprefix + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.config.3")));
                                }
                            }
                            else
                            {
                                player.sendMessage(plugin.igprefix + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.config.3.2")));
                            }
                            if((!plugin.getConfig().getString("plugin.language").equals("en") && (!plugin.getConfig().getString("plugin.language").equals("nl")) && (!plugin.getConfig().getString("plugin.language").equals("de"))))
                            {
                                sender.sendMessage(plugin.igprefix + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.config.5")));
                            }
                            if((!plugin.getConfig().getString("commands.cr-help").equals("true")) && (!plugin.getConfig().getString("commands.cr-help").equals("false")))
                            {
                                sender.sendMessage(plugin.igprefix + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.config.7")));
                            }
                        
                            if((!plugin.getConfig().getString("commands.cr-radius").equals("true")) && (!plugin.getConfig().getString("commands.cr-radius").equals("false")))
                            {
                                sender.sendMessage(plugin.igprefix + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.config.8")));
                            }
                            if((!plugin.getConfig().getString("commands.cr-set").equals("true")) && (!plugin.getConfig().getString("commands.cr-set").equals("false")))
                            {
                                sender.sendMessage(plugin.igprefix + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.config.9")));
                            }
                            if((!plugin.getConfig().getString("commands.cr-check").equals("true")) && (!plugin.getConfig().getString("commands.cr-check").equals("false")))
                            {
                                sender.sendMessage(plugin.igprefix + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.config.10")));
                            }
                            if((!plugin.getConfig().getString("commands.cr-language").equals("true")) && (!plugin.getConfig().getString("commands.cr-language").equals("false")))
                            {
                                sender.sendMessage(plugin.igprefix + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.config.11")));
                            }
                            if(plugin.getConfig().getString("plugin.language").equals("en"))
                            { line 133 starts here
                                ChatRadiusMessagesConfig.get().set("messages.commands.not-enabeled", language.cmdnotenabeledEN);
                                ChatRadiusMessagesConfig.get().set("messages.commands.not-found", language.cmdnotfoundEN);
                                ChatRadiusMessagesConfig.get().set("messages.commands.no-player", language.cmdnoplayerEN);
                                ChatRadiusMessagesConfig.get().set("messages.commands.no-permission", language.cmdnopermEN);
                                ChatRadiusMessagesConfig.get().set("messages.command.set.correct", language.crsetcorrectEN);
                                ChatRadiusMessagesConfig.get().set("messages.command.set.correct2", language.crsetcorrect2EN);
                                ChatRadiusMessagesConfig.get().set("messages.command.set.wrong", language.crsetwrongEN);
                                ChatRadiusMessagesConfig.get().set("messages.command.language.wrong", language.crlanguagewrongEN);
                                ChatRadiusMessagesConfig.get().set("messages.command.language.wrong2", language.crlanguagewrong2EN);
                                ChatRadiusMessagesConfig.get().set("messages.command.current-chatradius", language.crradiusEN);
                                ChatRadiusMessagesConfig.get().set("messages.command.current-chatradius2", language.crradius2EN);
                                ChatRadiusMessagesConfig.get().set("messages.command.reload.default", language.crreloaddefaultEN);
                                ChatRadiusMessagesConfig.get().set("messages.command.reload.normal", language.crreloadEN);
                                ChatRadiusMessagesConfig.get().set("messages.permissions-check.permission", language.crcheckpermEN);
                                ChatRadiusMessagesConfig.get().set("messages.permissions-check.no-permission", language.crchecknopermEN);
                                ChatRadiusMessagesConfig.get().set("messages.config.1", language.config1EN);
                                ChatRadiusMessagesConfig.get().set("messages.config.3", language.config3EN);
                                ChatRadiusMessagesConfig.get().set("messages.config.3.2", language.config32EN);
                                ChatRadiusMessagesConfig.get().set("messages.config.5", language.config5EN);
                                ChatRadiusMessagesConfig.get().set("messages.config.7", language.config7EN);
                                ChatRadiusMessagesConfig.get().set("messages.config.8", language.config8EN);
                                ChatRadiusMessagesConfig.get().set("messages.config.9", language.config9EN);
                                ChatRadiusMessagesConfig.get().set("messages.config.10", language.config10EN);
                                ChatRadiusMessagesConfig.get().set("messages.config.11", language.config11EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.1", language.pluginmenu1EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.2", language.pluginmenu2EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.3", language.pluginmenu3EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.4", language.pluginmenu4EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.5", language.pluginmenu5EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.1", language.helpmenu1EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.2", language.helpmenu2EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.3", language.helpmenu3EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.4", language.helpmenu4EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.5", language.helpmenu5EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.6", language.helpmenu6EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.7", language.helpmenu7EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.8", language.helpmenu8EN);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.9", language.helpmenu9EN);
                                ChatRadiusMessagesConfig.Save();
                        
                                plugin.reloadConfig();
                                plugin.current_chat_radius = plugin.getConfig().getInt("chatradius");
                                plg.disablePlugin(plgname);
                                plg.enablePlugin(plgname);
                            
                                sender.sendMessage(plugin.igprefix + ChatColor.GREEN + "English language loaded sucesfully!");
                                return true;
                            }
                            if(plugin.getConfig().getString("plugin.language").equals("nl"))
                            {
                                ChatRadiusMessagesConfig.get().set("messages.commands.not-enabeled", language.cmdnotenabeledNL);
                                ChatRadiusMessagesConfig.get().set("messages.commands.not-found", language.cmdnotfoundNL);
                                ChatRadiusMessagesConfig.get().set("messages.commands.no-player", language.cmdnoplayerNL);
                                ChatRadiusMessagesConfig.get().set("messages.commands.no-permission", language.cmdnopermNL);
                                ChatRadiusMessagesConfig.get().set("messages.command.set.correct", language.crsetcorrectNL);
                                ChatRadiusMessagesConfig.get().set("messages.command.set.correct2", language.crsetcorrect2NL);
                                ChatRadiusMessagesConfig.get().set("messages.command.set.wrong", language.crsetwrongNL);
                                ChatRadiusMessagesConfig.get().set("messages.command.language.wrong", language.crlanguagewrongNL);
                                ChatRadiusMessagesConfig.get().set("messages.command.language.wrong2", language.crlanguagewrong2NL);
                                ChatRadiusMessagesConfig.get().set("messages.command.current-chatradius", language.crradiusNL);
                                ChatRadiusMessagesConfig.get().set("messages.command.current-chatradius2", language.crradius2NL);
                                ChatRadiusMessagesConfig.get().set("messages.command.reload.default", language.crreloaddefaultNL);
                                ChatRadiusMessagesConfig.get().set("messages.command.reload.normal", language.crreloadNL);
                                ChatRadiusMessagesConfig.get().set("messages.permissions-check.permission", language.crcheckpermNL);
                                ChatRadiusMessagesConfig.get().set("messages.permissions-check.no-permission", language.crchecknopermNL);
                                ChatRadiusMessagesConfig.get().set("messages.config.1", language.config1NL);
                                ChatRadiusMessagesConfig.get().set("messages.config.3", language.config3NL);
                                ChatRadiusMessagesConfig.get().set("messages.config.3.2", language.config32NL);
                                ChatRadiusMessagesConfig.get().set("messages.config.5", language.config5NL);
                                ChatRadiusMessagesConfig.get().set("messages.config.7", language.config7NL);
                                ChatRadiusMessagesConfig.get().set("messages.config.8", language.config8NL);
                                ChatRadiusMessagesConfig.get().set("messages.config.9", language.config9NL);
                                ChatRadiusMessagesConfig.get().set("messages.config.10", language.config10NL);
                                ChatRadiusMessagesConfig.get().set("messages.config.11", language.config11NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.1", language.pluginmenu1NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.2", language.pluginmenu2NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.3", language.pluginmenu3NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.4", language.pluginmenu4NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.5", language.pluginmenu5NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.1", language.helpmenu1NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.2", language.helpmenu2NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.3", language.helpmenu3NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.4", language.helpmenu4NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.5", language.helpmenu5NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.6", language.helpmenu6NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.7", language.helpmenu7NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.8", language.helpmenu8NL);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.9", language.helpmenu9NL);
                                ChatRadiusMessagesConfig.Save();
                            
                                plugin.reloadConfig();
                                plugin.current_chat_radius = plugin.getConfig().getInt("chatradius");
                                plg.disablePlugin(plgname);
                                plg.enablePlugin(plgname);
                            
                                sender.sendMessage(plugin.igprefix + ChatColor.GREEN + "Dutch (Nederlands) language loaded sucesfully!");
                                return true;
                            }
                            if(plugin.getConfig().getString("plugin.language").equals("de"))
                            {
                                ChatRadiusMessagesConfig.get().set("messages.commands.not-enabeled", language.cmdnotenabeledDE);
                                ChatRadiusMessagesConfig.get().set("messages.commands.not-found", language.cmdnotfoundDE);
                                ChatRadiusMessagesConfig.get().set("messages.commands.no-player", language.cmdnoplayerDE);
                                ChatRadiusMessagesConfig.get().set("messages.commands.no-permission", language.cmdnopermDE);
                                ChatRadiusMessagesConfig.get().set("messages.command.set.correct", language.crsetcorrectDE);
                                ChatRadiusMessagesConfig.get().set("messages.command.set.correct2", language.crsetcorrect2DE);
                                ChatRadiusMessagesConfig.get().set("messages.command.set.wrong", language.crsetwrongDE);
                                ChatRadiusMessagesConfig.get().set("messages.command.language.wrong", language.crlanguagewrongDE);
                                ChatRadiusMessagesConfig.get().set("messages.command.language.wrong2", language.crlanguagewrong2DE);
                                ChatRadiusMessagesConfig.get().set("messages.command.current-chatradius", language.crradiusDE);
                                ChatRadiusMessagesConfig.get().set("messages.command.current-chatradius2", language.crradius2DE);
                                ChatRadiusMessagesConfig.get().set("messages.command.reload.default", language.crreloaddefaultDE);
                                ChatRadiusMessagesConfig.get().set("messages.command.reload.normal", language.crreloadDE);
                                ChatRadiusMessagesConfig.get().set("messages.permissions-check.permission", language.crcheckpermDE);
                                ChatRadiusMessagesConfig.get().set("messages.permissions-check.no-permission", language.crchecknopermDE);
                                ChatRadiusMessagesConfig.get().set("messages.config.1", language.config1DE);
                                ChatRadiusMessagesConfig.get().set("messages.config.3", language.config3DE);
                                ChatRadiusMessagesConfig.get().set("messages.config.3.2", language.config32DE);
                                ChatRadiusMessagesConfig.get().set("messages.config.5", language.config5DE);
                                ChatRadiusMessagesConfig.get().set("messages.config.7", language.config7DE);
                                ChatRadiusMessagesConfig.get().set("messages.config.8", language.config8DE);
                                ChatRadiusMessagesConfig.get().set("messages.config.9", language.config9DE);
                                ChatRadiusMessagesConfig.get().set("messages.config.10", language.config10DE);
                                ChatRadiusMessagesConfig.get().set("messages.config.11", language.config11DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.1", language.pluginmenu1DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.2", language.pluginmenu2DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.3", language.pluginmenu3DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.4", language.pluginmenu4DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.plugin.5", language.pluginmenu5DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.1", language.helpmenu1DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.2", language.helpmenu2DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.3", language.helpmenu3DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.4", language.helpmenu4DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.5", language.helpmenu5DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.6", language.helpmenu6DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.7", language.helpmenu7DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.8", language.helpmenu8DE);
                                ChatRadiusMessagesConfig.get().set("messages.plugin.menu.help.9", language.helpmenu9DE);
                                ChatRadiusMessagesConfig.Save();
                        
                                plugin.reloadConfig();
                                plugin.current_chat_radius = plugin.getConfig().getInt("chatradius");
                                plg.disablePlugin(plgname);
                                plg.enablePlugin(plgname);
                            
                                sender.sendMessage(plugin.igprefix + ChatColor.GREEN + "German (Deutsch) language loaded sucesfully!");
                                return true;
                            }
                        }
                        return true;
                    }
                    else
                    {
                        sender.sendMessage(plugin.igprefix + ChatColor.translateAlternateColorCodes('&', ChatRadiusMessagesConfig.get().getString("messages.commands.no-permission")));
                        return true;
                    }
                }
    Messages config:
    Code:
    messages:
      commands:
        not-enabeled: '&4Error: &cCommand is not enabeled in the config!'
        not-found: '&4Error: &cCommand not found, do &e/cr help &cfor a list of commands!'
        no-player: '&4Error: &cYou aren''t a player!'
        no-permission: '&4Error: &cYou don''t have permission to use this command!'
      command:
        set:
          correct: '&aThe chatradius has been set to &6 '
          correct2: ' &ablocks!'
          wrong: '&4Error: &cUsage: /cr set <radius>!'
        language:
          wrong: '&4Error: &cYou can use only en (English) or nl (Dutch, Nederlands)!'
          wrong2: '&4Error: &cUsage: /cr language <language>!'
        current-chatradius: '&bThe chatradius is currently &6 '
        current-chatradius2: ' &bblocks!'
        reload:
          default: '&aPlugin reloaded and set to default settings!'
          normal: '&aPlugin reloaded!'
      permissions-check:
        permission: '&aYou have the permission &e '
        no-permission: '&cYou don''t have the permission &e '
      config:
        '1': '&4Error: &cYou can only use true or false (line 1)!'
        '3':
          '2': '&4Error: &cThe chatradius is empty, please fill in a number (line 3)!'
        '5': '&4Error: &cYou can use only en, nl or de as language (line 5)!'
        '7': '&4Error: &cYou can only use true or false (line 7)!'
        '8': '&4Error: &cYou can only use true or false (line 8)!'
        '9': '&4Error: &cYou can only use true or false (line 9)!'
        '10': '&4Error: &cYou can only use true or false (line 10)!'
        '11': '&4Error: &cYou can only use true or false (line 11)!'
      plugin:
        menu:
          plugin:
            '1': '&3---------- &1ChatRadius &3----------'
            '2': '&2Version &aV'
            '3': '&aDo /cr help for a list of commands!'
            '4': '&2Plugin made by'
            '5': '&3------------------------------'
          help:
            '1': '&3---------- &1ChatRadius &3----------'
            '2': '&2/cr &aMain command'
            '3': '&2/cr help &aHelp menu'
            '4': '&2/cr radius &aSee the current chatradius'
            '5': '&2/cr set &aChange the current chatradius'
            '6': '&2/cr check &aCheck which permissions you have'
            '7': '&2/cr language &aChange the language of the plugin (en|nl|de)'
            '8': '&2/cr reload &aReload plugin'
            '9': '&3------------------------------'
    
     
    Last edited: Aug 6, 2020
  2. Offline

    CraftCreeper6

    @tvhee
    I have no idea why you're using a singleton in this scenario, but for the sake of it, have you initialized it correctly, and what does the get() method in the ChatRadiusMessagesConfig class return?

    I have a strong suspicion that whatever it returns is null.
     
  3. Offline

    Strahan

    To add to that... holy hell that is wildly inefficient and why for the love of God are you disabling and re-enabling the plugin? A reload does not require that. Also what's up with the crazy indentation? Switching to a negative check and return would help cut that down, that and returning when code is complete rather than branching to an unnecessary else block.

    You also are assuming all those calls to getString are going to work. You should assume the config file is hosed and that they may not be found. Calling equals on a null will crash the plugin. Also also why are you getting boolean values with getString?? getBoolean does exist you know.

    If at any time you find yourself copy and pasting blocks of code and only making slight changes, that should be a red flag that you need to stop and re-evaluate your processes. Having those three blocks for the three languages is totally unnecessary and could be done in one with proper methodology.
     
  4. Offline

    tvhee

    I got it fixed: I set the strings in my main class and now i can acces them with plugin.String, thanks for all the reactions!
     

Share This Page