package me.stefvanschie.buildinggame.commands.subcommands.settings;

import org.bukkit.ChatColor;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;

import me.stefvanschie.buildinggame.commands.commandutils.CommandResult;
import me.stefvanschie.buildinggame.commands.commandutils.SubCommand;
import me.stefvanschie.buildinggame.managers.files.SettingsManager;
import me.stefvanschie.buildinggame.managers.messages.MessageManager;

public class UpdateSigns extends SubCommand {

	@Override
	public CommandResult onCommand(Player player, String[] args) {
		YamlConfiguration config = SettingsManager.getInstance().getConfig();
		
		if (args.length == 0) {
			MessageManager.getInstance().send(player, ChatColor.RED + "Please specifyt the setting");
			return CommandResult.ARGUMENTEXCEPTION;
		}
		
		if (!args[0].equalsIgnoreCase("true") || !args[0].equalsIgnoreCase("false")) {
			MessageManager.getInstance().send(player, ChatColor.RED + "That's not a valid setting");
			return CommandResult.ERROR;
		}
		
		boolean setting = Boolean.parseBoolean(args[0]);
		
		config.set("update-signs", setting);
		SettingsManager.getInstance().save();
		
		MessageManager.getInstance().send(player, ChatColor.GREEN + "Update-signs setting set to " + setting);
		
		return CommandResult.SUCCES;
	}

	@Override
	public String getName() {
		return "update-signs";
	}

	@Override
	public String[] getAliases() {
		return null;
	}

	@Override
	public String getInfo() {
		return "Edit the update signs setting";
	}

	@Override
	public String getPermission() {
		return "bg.setting.update-signs";
	}

}

@@ -762,17 +762,16 @@
  specify
-t
  the set
@@ -770,32 +770,32 @@
  the setting%22);%0A
+
 %09%09%09return Comman
@@ -872,10 +872,10 @@
 e%22) 
-%7C%7C
+&&
  !ar
@@ -1036,19 +1036,16 @@
 OR;%0A%09%09%7D%0A
-%09%09%0A
 %09%09boolea
@@ -1046,16 +1046,27 @@
 boolean 
+setting;%0A%09%09
 setting 
@@ -1101,16 +1101,19 @@
 0%5D);%0A%09%09%0A
+%09%09%0A
 %09%09config

Update UpdateSigns.java