package com.bukkit.mcteam.factions; import java.io.File; import java.io.IOException; import java.util.*; import org.bukkit.*; import com.bukkit.mcteam.util.DiscUtil; public class Conf { public static transient File file = new File(Factions.instance.getDataFolder(), "conf.json"); // Colors public static ChatColor colorMember = ChatColor.GREEN; public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE; public static ChatColor colorNeutral = ChatColor.WHITE; public static ChatColor colorEnemy = ChatColor.RED; public static ChatColor colorSystem = ChatColor.YELLOW; public static ChatColor colorChrome = ChatColor.GOLD; public static ChatColor colorCommand = ChatColor.AQUA; public static ChatColor colorParameter = ChatColor.DARK_AQUA; // Power public static double powerPlayerMax = 10; public static double powerPlayerMin = -10; public static double powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power public static double powerPerDeath = 2; //A death makes you loose 2 power public static String prefixAdmin = "**"; public static String prefixMod = "*"; public static int factionTagLengthMin = 3; public static int factionTagLengthMax = 10; public static boolean factionTagForceUpperCase = false; // Configuration on the Faction tag in chat messages. public static boolean chatTagEnabled = true; public static boolean chatTagRelationColored = true; public static int chatTagInsertIndex = 1; public static String chatTagFormat = "%s"+ChatColor.WHITE+" "; public static String factionChatFormat = "%s"+ChatColor.WHITE+" %s"; public static int mapHeight = 8; public static int mapWidth = 49; public static double territoryShieldFactor = 0.5; public static boolean territoryBlockCreepers = false; public static boolean territoryBlockFireballs = false; public static List territoryProtectedMaterials = new ArrayList(); // Command names / aliases public static List aliasBase = new ArrayList(); public static List aliasHelp = new ArrayList(); public static List aliasList = new ArrayList(); public static List aliasShow = new ArrayList(); public static List aliasMap = new ArrayList(); public static List aliasJoin = new ArrayList(); public static List aliasLeave = new ArrayList(); public static List aliasCreate = new ArrayList(); public static List aliasTag = new ArrayList(); public static List aliasDescription = new ArrayList(); public static List aliasChat = new ArrayList(); public static List aliasTitle = new ArrayList(); public static List aliasInvite = new ArrayList(); public static List aliasDeinvite = new ArrayList(); public static List aliasOpen = new ArrayList(); public static List aliasKick = new ArrayList(); public static List aliasModerator = new ArrayList(); public static List aliasAdmin = new ArrayList(); public static List aliasClaim = new ArrayList(); public static List aliasUnclaim = new ArrayList(); public static List aliasRelationAlly = new ArrayList(); public static List aliasRelationNeutral = new ArrayList(); public static List aliasRelationEnemy = new ArrayList(); public static List aliasVersion = new ArrayList(); // Value aliases public static List aliasTrue = new ArrayList(); static { territoryProtectedMaterials.add(Material.WOODEN_DOOR); territoryProtectedMaterials.add(Material.DISPENSER); territoryProtectedMaterials.add(Material.CHEST); territoryProtectedMaterials.add(Material.FURNACE); aliasBase.add("/f"); aliasBase.add("f"); aliasHelp.add("help"); aliasHelp.add("h"); aliasHelp.add("?"); aliasList.add("list"); aliasList.add("ls"); aliasShow.add("show"); aliasShow.add("who"); aliasMap.add("map"); aliasJoin.add("join"); aliasLeave.add("leave"); aliasCreate.add("create"); aliasCreate.add("new"); aliasTag.add("tag"); aliasDescription.add("desc"); aliasChat.add("chat"); aliasChat.add("c"); aliasTitle.add("title"); aliasInvite.add("invite"); aliasInvite.add("inv"); aliasDeinvite.add("deinvite"); aliasDeinvite.add("deinv"); aliasOpen.add("open"); aliasOpen.add("close"); aliasKick.add("kick"); aliasModerator.add("mod"); aliasAdmin.add("admin"); aliasClaim.add("claim"); aliasUnclaim.add("unclaim"); aliasUnclaim.add("declaim"); aliasRelationAlly.add("ally"); aliasRelationNeutral.add("neutral"); aliasRelationEnemy.add("enemy"); aliasVersion.add("version"); aliasTrue.add("true"); aliasTrue.add("yes"); aliasTrue.add("y"); aliasTrue.add("ok"); aliasTrue.add("on"); aliasTrue.add("+"); } // -------------------------------------------- // // Persistance // -------------------------------------------- // public static boolean save() { Factions.log("Saving config to disk."); try { DiscUtil.write(file, Factions.gson.toJson(new Conf())); } catch (IOException e) { e.printStackTrace(); Factions.log("Failed to save the config to disk."); return false; } return true; } public static boolean load() { if ( ! file.exists()) { Factions.log("No conf to load from disk. Creating new file."); save(); return true; } try { Factions.gson.fromJson(DiscUtil.read(file), Conf.class); } catch (IOException e) { e.printStackTrace(); Factions.log("Failed to load the config from disk."); return false; } return true; } }