Solved java.lang.IllegalArgumentException cannot set to an empty path

Discussion in 'Plugin Development' started by 14manj01, May 27, 2017.

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

    14manj01

    Hello, I was trying to configure my config and it seems to not work anymore. It is a simple new join message, with a command which allows people to see the new join message, if they are not new players (for testing purposes).




    This is the error the console gives,

    Code:
    INFO New Join MSG: Visit mc.beyondhorizonmc.net for support
    27.05 19:55:35 [Server] ERROR Error occurred while enabling newjoinmessage v1.0 (Is it up to date?)
    27.05 19:55:35 [Server] INFO java.lang.IllegalArgumentException: Cannot set to an empty path
    27.05 19:55:35 [Server] INFO at org.apache.commons.lang.Validate.notEmpty(Validate.java:321) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
    27.05 19:55:35 [Server] INFO at org.bukkit.configuration.MemorySection.set(MemorySection.java:167) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
    27.05 19:55:35 [Server] INFO at me.myip.newjoinmessage.newjoinmessage.onEnable(newjoinmessage.java:24) ~[?:?]
    27.05 19:55:35 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:271) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
    27.05 19:55:35 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]
    27.05 19:55:35 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]

    This is my plugin class note I have // some stuff to try to troubleshoot and its still not working...
    Code:
    package me.myip.newjoinmessage;
    //imports craftbukkit for usage, this will allways be needed
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    public class newjoinmessage extends JavaPlugin implements Listener {
    
    //All stuff I forgot
    FileConfiguration config = getConfig();
     
        public void onEnable(){
            //getServer().getLogger().info("New Join MSG: Visit mc.beyondhorizonmc.net for support");
         
            //default string for new join message
            String newjoinmessage = "";
         
            //creates a config file, sets a default line of text for the config file.
            config.set(newjoinmessage, "Configure");
            config.options().copyDefaults(true);
            saveConfig();
            //checking for new people
            getServer().getPluginManager().registerEvents(this, this);
        }
        public void onDisable(){
            getServer().getLogger().info("New Join MSG Disabled");
        }
    //MAIN BODY OF PLUGIN 
     
        @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event){
            Player player = event.getPlayer();
        if (config.getBoolean("Welcome to the Server, visit mc.beyondhorizonmc.net for help")){
                player.sendMessage("Welcome to the Server, visit mc.beyondhorizonmc.net for help ");
     
        }else {
         
        }
     
     
     
        }
     
     
     
     
     
     
     
        @EventHandler
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] arguments){
            // /help label would - help argument would be empty list
            if (cmd.getName().equalsIgnoreCase("newjoinmessage")){
            //    config.getString("newjoinmessage");
            //    sender.sendMessage("newjoinmessage");
                //below may need to be returned false as it will send a player a default message, stating cmd
                return true;
            }
         
            return false;
        }
    }
    //:
    //;
    This is my plugin.yml
    Code:
    main: me.myip.newjoinmessage.newjoinmessage
    name: newjoinmessage
    version: 1.0
    author: James
    description: Custom New Join Message
    commands:
       newjoinmessage:
          description: This retreives the default new join message.
          usage: /newjoinmessage [player]
          permission: newjoinmessage.newjoinmessage
          permission-message: You don't have <permission>
    Any help would be much appreciated. Additonally i have tried google however, all posts using the 2nd line of the error code relate to other problems.
     
    Last edited: May 27, 2017
  2. Offline

    Zombie_Striker

    @14manj01
    newJoinmessage is empty. It needs to be equal to a string with atleast one character.
     
  3. Offline

    MrGriefer_

    Take a look at this video:

    It kinda does the same as you want! Just change couple of stuff :p
     
  4. Offline

    14manj01

    Also I figured out it was in part to the plugin.yml not having the correct setup for commands.
     
Thread Status:
Not open for further replies.

Share This Page