Blank Config

Discussion in 'Spigot Plugin Development' started by KingDotCom, Jun 6, 2016.

  1. Hi I was wondering why my config was printing blank. Heres my code.
    Code (Text):
    package me.aaron.addons;

    import java.util.HashMap;

    import org.bukkit.Bukkit;
    import org.bukkit.GameMode;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.AsyncPlayerChatEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.md_5.bungee.api.ChatColor;

    public class Main extends JavaPlugin implements Listener {

        public boolean messages = true;
        public boolean freeze = false;
        public boolean mute = false;
        public HashMap<Player, Boolean> spec = new HashMap<Player, Boolean>();


        public void onEnable() {
            System.out.println("[Addons] has been enabled");
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents(this, this);
            getCommand("messages").setExecutor(this);
            getCommand("freeze").setExecutor(this);
            getCommand("muteall").setExecutor(this);
            getConfig().options().copyDefaults(true);
            saveConfig();

        }
       

        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (label.equalsIgnoreCase("messages")) {
                if (sender instanceof Player) {
                    if (sender.hasPermission("addons.m")) {
                        if (messages == true) {
                            messages = false;
                            Bukkit.broadcastMessage(ChatColor.DARK_RED + "Messages turned off, They should be on.");
                        } else {
                            messages = true;
                            Bukkit.broadcastMessage(ChatColor.DARK_RED + "Messages turned off, They should be on.");

                        }
                    } else {
                        sender.sendMessage(ChatColor.RED + "You do not have permission to execute this command");
                    }
                } else {
                    System.out.println("Only players can execute this command");
                }
            } else if (label.equalsIgnoreCase("muteall")) {
                if (sender instanceof Player) {
                    if (sender.hasPermission("addons.m")) {
                        if (mute == false) {
                            mute = true;
                            Bukkit.broadcastMessage(ChatColor.DARK_RED + "All players are now muted!");

                        } else {
                            Bukkit.broadcastMessage(ChatColor.DARK_RED + "All players are unmuted!");
                            mute = false;
                        }
                    } else {
                        sender.sendMessage(ChatColor.RED + "You do not have permission to execute this command");
                    }
                } else {
                    System.out.println("Players can only execute this command");
                }
            } else if (label.equalsIgnoreCase("freeze")) {
                if (sender instanceof Player) {
                    if (sender.hasPermission("addons.f")) {
                        if (freeze == false) {
                            freeze = true;
                            Bukkit.broadcastMessage(ChatColor.DARK_RED + "All players are now frozen!!");

                        } else {
                            Bukkit.broadcastMessage(ChatColor.DARK_RED + "All players are unfrozen!!");
                            freeze = false;
                        }
                    } else {
                        sender.sendMessage(ChatColor.RED + "You do not have permission to execute this command");
                    }
                } else {
                    System.out.println("Players can only execute this command");
                }
            }else if(label.equalsIgnoreCase("spec")) {
                Player p = (Player) sender;
                if(sender.hasPermission("addon.spec")){
                    if(sender instanceof Player) {
                                   
                    }
                }
               
            }
            return false;

        }

        @EventHandler
        public void move(PlayerMoveEvent e) {
            Player p = e.getPlayer();
            if (freeze == true) {
                if(!(p.hasPermission("addons.move"))){
                p.teleport(p);
                }else{
                    return;
                }
            } else {
                return;
            }

        }

        @EventHandler
        public void talk(AsyncPlayerChatEvent e) {
            Player p = e.getPlayer();
            if (mute == true) {
                if (p.hasPermission("addons.talk")) {
                    e.setCancelled(true);
                    p.sendMessage("You are muted!");

                }else{
                    return;
                }
            }

        }

        @EventHandler
        public void join(PlayerJoinEvent e) {
            if (messages == true) {
                if (e.getPlayer().hasPermission("addons.join")) {
                    e.setJoinMessage(getConfig().getString("join" + e.getPlayer().getName()));

                } else {
                    e.setJoinMessage(null);
                }
            }
        }

        @EventHandler
        public void quit(PlayerQuitEvent e) {
            if (messages == true) {
                if (e.getPlayer().hasPermission("addons.quit")) {
                    e.setQuitMessage(getConfig().getString("quit" + e.getPlayer().getName()));

                } else {
                    e.setQuitMessage(null);
                }
            }
        }

    }
     
    Heres my Config.yml in the code
    Code (Text):
    # Configuration File for FFA Addon Plugin #
    # Plugin Made by BeachiePvP #
    # Plugin Made for DBoss / Disconnected Network #

    join: &8[&2+&8] &a
    #join: &8[&2+&8] &a <-- Color of Name

    quit: &8[&4-&8] &c
    #quit: &8[&4-&8] &c <-- Color of Name
    Thank you!
     
  2. join: '&8[&2+&8] &a'
     
  3. Like he said, put the text in single quotes. 'text'
     
  4. You must use the '' in the config.
    Example:
    join: '&c[asd]'