Login Message Config

Discussion in 'Plugin Development' started by xXMaTTHDXx, Mar 8, 2013.

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

    xXMaTTHDXx

    My plugin changes the login message it works but i am trying to make it so people can go into the config and change the color and message i have the code and config below, please feel free to correct what i did wrong i do need help.

    Code:
    package me.mrc1.SweetLogin;
     
    import java.awt.Color;
    import java.io.File;
    import java.util.logging.Logger;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Villager;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.CreatureSpawnEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerLoginEvent;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class SweetLogin extends JavaPlugin implements Listener{
        public String welcomeMessage = getConfig().getString("message.path");
        public String ChatColor = getConfig().getString("color.path");
        private static final String PlayerJoinEvent = null;
        public static SweetLogin plugin;
        public    final Logger logger = Logger.getLogger("Minecraft");
       
        @Override
        public void onDisable(){
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() +"version" + pdfFile.getVersion() + "is now disabled");
            this.saveDefaultConfig();
            }
       
       
       
        @Override
        public void onEnable(){
            PluginDescriptionFile pdfFile = this.getDescription();
            this.logger.info(pdfFile.getName() +"version" + pdfFile.getVersion() + "is now enabled");
            getServer().getPluginManager().registerEvents(this, this);
           
        }
        @EventHandler
        public void onJoin(PlayerJoinEvent event)
        {
        event.setJoinMessage(ChatColor + event.getPlayer().getName() +  welcomeMessage);
        }
           
           
        }
    
    here is what my config says so far

    message:
    path: You backfliped into the game!!!
     
  2. Offline

    kreashenz

    It has to look like
    message:
    path: 'You backflipped into the game!!!'
     
  3. Offline

    xXMaTTHDXx

    um it gives me a error and i cant get rid of it

    Could not load 'plugins/SweetLogin.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: File cannot be null
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:182)
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
    at org.bukkit.craftbukkit.v1_4_R1.CraftServer.loadPlugins(CraftServer.java:239)
    at org.bukkit.craftbukkit.v1_4_R1.CraftServer.reload(CraftServer.java:594)
    at org.bukkit.Bukkit.reload(Bukkit.java:184)
    at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186)
    at org.bukkit.craftbukkit.v1_4_R1.CraftServer.dispatchCommand(CraftServer.java:514)
    at org.bukkit.craftbukkit.v1_4_R1.CraftServer.dispatchServerCommand(CraftServer.java:506)
    at net.minecraft.server.v1_4_R1.DedicatedServer.al(DedicatedServer.java:260)
    at net.minecraft.server.v1_4_R1.DedicatedServer.r(DedicatedServer.java:225)
    at net.minecraft.server.v1_4_R1.MinecraftServer.q(MinecraftServer.java:494)
    at net.minecraft.server.v1_4_R1.MinecraftServer.run(MinecraftServer.java:427)
    at net.minecraft.server.v1_4_R1.ThreadServerApplication.run(SourceFile:849)
    Caused by: java.lang.IllegalArgumentException: File cannot be null
    at org.apache.commons.lang.Validate.notNull(Validate.java:203)
    at org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(YamlConfiguration.java:170)
    at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:117)
    at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:111)
    at me.mrc1.SweetLogin.SweetLogin.<init>(SweetLogin.java:23)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:178)
    ... 14 more
     
  4. Offline

    ZeusAllMighty11

    You're defining config before it's instantiated (i think is the word)
     
  5. Offline

    xXMaTTHDXx

    Sorry i do not follow
     
  6. Offline

    ZeusAllMighty11

    Code:
    public String ChatColor = getConfig().getString("color.path");
    
    You told eclipse this before the server is even loaded
     
  7. Offline

    xXMaTTHDXx

    ah

    but when i move it it doesnt work

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  8. Offline

    ZeusAllMighty11

    You can define it, but only initialize it when you know the server is plugin loaded
     
  9. Offline

    xXMaTTHDXx

    i think i understand
     
Thread Status:
Not open for further replies.

Share This Page