2011-07-18 22:06:02 +02:00
package com.massivecraft.factions ;
2011-02-06 13:36:11 +01:00
2011-03-18 17:33:23 +01:00
import java.io.File ;
2011-02-06 13:36:11 +01:00
import java.util.* ;
import org.bukkit.* ;
2011-03-23 17:39:56 +01:00
import org.bukkit.entity.CreatureType ;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.util.DiscUtil ;
2011-02-06 13:36:11 +01:00
2011-03-18 17:33:23 +01:00
2011-02-06 13:36:11 +01:00
public class Conf {
2011-07-09 04:28:53 +02:00
public static final transient File file = new File ( Factions . instance . getDataFolder ( ) , " conf.json " ) ;
2011-03-18 17:33:23 +01:00
2011-02-12 18:05:05 +01:00
// 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 ;
2011-02-06 13:36:11 +01:00
2011-02-12 18:05:05 +01:00
// 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
2011-06-01 13:54:00 +02:00
public static double powerPerDeath = 4 ; // A death makes you lose 4 power
public static boolean powerRegenOffline = false ; // does player power regenerate even while they're offline?
2011-07-24 13:10:48 +02:00
public static double powerFactionMax = 0 ; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts)
2011-02-06 13:36:11 +01:00
2011-02-12 18:05:05 +01:00
public static String prefixAdmin = " ** " ;
public static String prefixMod = " * " ;
2011-02-06 13:36:11 +01:00
2011-02-12 18:05:05 +01:00
public static int factionTagLengthMin = 3 ;
2011-02-13 16:37:21 +01:00
public static int factionTagLengthMax = 10 ;
public static boolean factionTagForceUpperCase = false ;
2011-02-06 13:36:11 +01:00
2011-05-29 23:28:29 +02:00
public static boolean newFactionsDefaultOpen = true ;
public static boolean showMapFactionKey = true ;
2011-05-29 23:41:50 +02:00
// Disallow joining/leaving/kicking while power is negative
public static boolean CanLeaveWithNegativePower = true ;
2011-02-12 18:05:05 +01:00
// Configuration on the Faction tag in chat messages.
public static boolean chatTagEnabled = true ;
2011-06-12 02:02:57 +02:00
public static transient boolean chatTagHandledByAnotherPlugin = false ;
2011-02-12 18:05:05 +01:00
public static boolean chatTagRelationColored = true ;
2011-06-03 20:06:41 +02:00
public static String chatTagReplaceString = " {FACTION} " ;
public static String chatTagInsertAfterString = " " ;
public static String chatTagInsertBeforeString = " " ;
2011-02-12 18:05:05 +01:00
public static int chatTagInsertIndex = 1 ;
2011-06-03 20:06:41 +02:00
public static boolean chatTagPadBefore = false ;
public static boolean chatTagPadAfter = true ;
public static String chatTagFormat = " %s " + ChatColor . WHITE ;
2011-02-12 18:52:45 +01:00
public static String factionChatFormat = " %s " + ChatColor . WHITE + " %s " ;
2011-02-12 18:05:05 +01:00
2011-03-23 17:39:56 +01:00
public static boolean allowNoSlashCommand = true ;
public static double autoLeaveAfterDaysOfInactivity = 14 ;
public static boolean homesEnabled = true ;
2011-06-19 10:56:21 +02:00
public static boolean homesMustBeInClaimedTerritory = true ;
2011-03-23 17:39:56 +01:00
public static boolean homesTeleportToOnDeath = true ;
2011-06-30 12:15:16 +02:00
public static boolean homesRespawnFromNoPowerLossWorlds = true ;
2011-06-29 01:29:14 +02:00
public static boolean homesTeleportCommandEnabled = true ;
2011-06-19 10:56:21 +02:00
public static boolean homesTeleportAllowedFromEnemyTerritory = true ;
2011-07-09 14:21:47 +02:00
public static boolean homesTeleportAllowedFromDifferentWorld = true ;
2011-05-29 23:28:29 +02:00
public static double homesTeleportAllowedEnemyDistance = 32 ;
2011-07-20 22:45:36 +02:00
public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true ;
2011-06-21 04:15:41 +02:00
2011-07-29 12:12:14 +02:00
public static boolean disablePVPBetweenNeutralFactions = false ;
2011-06-19 10:49:46 +02:00
public static boolean disablePVPForFactionlessPlayers = false ;
2011-06-23 03:10:42 +02:00
public static int noPVPDamageToOthersForXSecondsAfterLogin = 3 ;
2011-06-21 04:15:41 +02:00
public static boolean claimsMustBeConnected = false ;
2011-07-20 21:45:18 +02:00
public static boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = true ;
2011-07-25 20:16:32 +02:00
public static int claimsRequireMinFactionMembers = 1 ;
2011-06-21 04:15:41 +02:00
2011-06-21 07:20:36 +02:00
public static double considerFactionsReallyOfflineAfterXMinutes = 0 ;
2011-06-02 01:32:09 +02:00
public static double territoryShieldFactor = 0 . 3 ;
2011-06-02 01:13:56 +02:00
public static boolean territoryDenyBuild = true ;
2011-06-10 21:14:02 +02:00
public static boolean territoryDenyBuildWhenOffline = true ;
2011-06-02 01:13:56 +02:00
public static boolean territoryDenyUseage = true ;
2011-07-09 08:36:18 +02:00
public static boolean territoryEnemyDenyBuild = true ;
public static boolean territoryEnemyDenyBuildWhenOffline = true ;
public static boolean territoryEnemyDenyUseage = true ;
public static boolean territoryEnemyProtectMaterials = true ;
2011-03-06 21:13:48 +01:00
public static boolean territoryBlockCreepers = false ;
2011-06-11 01:47:39 +02:00
public static boolean territoryBlockCreepersWhenOffline = false ;
2011-03-18 00:02:29 +01:00
public static boolean territoryBlockFireballs = false ;
2011-06-11 01:47:39 +02:00
public static boolean territoryBlockFireballsWhenOffline = false ;
New boolean config options territoryBlockTNT (default false), safeZoneDenyBuild (default true), safeZoneDenyUseage (default true), safeZoneBlockTNT (default true). territoryBlockTNT prevents TNT explosions inside faction territory, which defaults to false (same as before). It prevents TNT cannons from being a viable tactic, and I think for most people it would be an undesirable option. safeZoneBlockTNT prevents TNT explosions inside safe zone areas, which defaults to true (new behavior). I think most server operators would prefer safe zones to be safe from TNT, from TNT cannons or otherwise. safeZoneDenyBuild prevents players from building inside safe zone areas, which defaults to true (same as before). This option is added for server admins who, for whatever reason, want to let their players build and break inside safe zone areas. safeZoneDenyUseage prevents players from using items in the territoryDenyUseageMaterials list, which defaults to true (new behavior). This will (with the default list) prevent players from dumping/using buckets inside safe zone areas.
2011-04-04 13:31:48 +02:00
public static boolean territoryBlockTNT = false ;
2011-06-11 01:47:39 +02:00
public static boolean territoryBlockTNTWhenOffline = false ;
New boolean config options territoryBlockTNT (default false), safeZoneDenyBuild (default true), safeZoneDenyUseage (default true), safeZoneBlockTNT (default true). territoryBlockTNT prevents TNT explosions inside faction territory, which defaults to false (same as before). It prevents TNT cannons from being a viable tactic, and I think for most people it would be an undesirable option. safeZoneBlockTNT prevents TNT explosions inside safe zone areas, which defaults to true (new behavior). I think most server operators would prefer safe zones to be safe from TNT, from TNT cannons or otherwise. safeZoneDenyBuild prevents players from building inside safe zone areas, which defaults to true (same as before). This option is added for server admins who, for whatever reason, want to let their players build and break inside safe zone areas. safeZoneDenyUseage prevents players from using items in the territoryDenyUseageMaterials list, which defaults to true (new behavior). This will (with the default list) prevent players from dumping/using buckets inside safe zone areas.
2011-04-04 13:31:48 +02:00
Faction admins can now mark already claimed areas as owned by specific faction members. Ownership can include multiple members. New command /f owner *[player name], to set/remove ownership. This command is only available to the faction admin and optionally the faction moderators. If no player name is specified, it will either set ownership to the player running the command (if no owner is currently set) or completely clear ownership of the territory. New command /f ownerlist, to view a list of owners for the current area. Only works inside your own faction's territory. New conf.json options "ownedAreasEnabled", "ownedAreasModeratorsCanSet", "ownedAreaModeratorsBypass", "ownedAreaDenyBuild", "ownedAreaProtectMaterials", and "ownedAreaDenyUseage" (all defaulting to true) to determine whether faction moderators can set or bypass ownership (faction admin always can), and what sort of protection these owned areas have against normal members of the faction (members other than the owner(s), faction admin, and probably faction moderators). New conf.json option "ownedAreasLimitPerFaction" to limit how many owned areas can be set. New permission node "factions.ownershipBypass" which allows a player to bypass ownership protection, but only within the person's own faction.
various little tweaks and improvements to other code
moderate speed boost to FLocation code
made commandDisable permissions work for any command alias of a command, instead of just the first one
2011-07-31 03:17:00 +02:00
// for claimed areas where further faction-member ownership can be defined
public static boolean ownedAreasEnabled = true ;
public static int ownedAreasLimitPerFaction = 0 ;
public static boolean ownedAreasModeratorsCanSet = false ;
public static boolean ownedAreaModeratorsBypass = true ;
public static boolean ownedAreaDenyBuild = true ;
public static boolean ownedAreaProtectMaterials = true ;
public static boolean ownedAreaDenyUseage = true ;
New boolean config options territoryBlockTNT (default false), safeZoneDenyBuild (default true), safeZoneDenyUseage (default true), safeZoneBlockTNT (default true). territoryBlockTNT prevents TNT explosions inside faction territory, which defaults to false (same as before). It prevents TNT cannons from being a viable tactic, and I think for most people it would be an undesirable option. safeZoneBlockTNT prevents TNT explosions inside safe zone areas, which defaults to true (new behavior). I think most server operators would prefer safe zones to be safe from TNT, from TNT cannons or otherwise. safeZoneDenyBuild prevents players from building inside safe zone areas, which defaults to true (same as before). This option is added for server admins who, for whatever reason, want to let their players build and break inside safe zone areas. safeZoneDenyUseage prevents players from using items in the territoryDenyUseageMaterials list, which defaults to true (new behavior). This will (with the default list) prevent players from dumping/using buckets inside safe zone areas.
2011-04-04 13:31:48 +02:00
public static boolean safeZoneDenyBuild = true ;
public static boolean safeZoneDenyUseage = true ;
public static boolean safeZoneBlockTNT = true ;
2011-07-29 13:39:20 +02:00
public static boolean safeZonePreventAllDamageToPlayers = false ;
2011-03-18 00:02:29 +01:00
2011-06-01 13:39:25 +02:00
public static boolean warZoneDenyBuild = true ;
public static boolean warZoneDenyUseage = true ;
2011-05-29 23:28:29 +02:00
public static boolean warZoneBlockCreepers = false ;
public static boolean warZoneBlockFireballs = false ;
public static boolean warZoneBlockTNT = true ;
public static boolean warZonePowerLoss = true ;
2011-06-10 14:38:14 +02:00
public static boolean warZoneFriendlyFire = false ;
2011-05-29 23:28:29 +02:00
2011-06-02 01:32:09 +02:00
public static boolean wildernessDenyBuild = false ;
public static boolean wildernessDenyUseage = false ;
public static boolean wildernessBlockCreepers = false ;
public static boolean wildernessBlockFireballs = false ;
public static boolean wildernessBlockTNT = false ;
public static boolean wildernessPowerLoss = true ;
2011-07-20 19:22:03 +02:00
public static boolean pistonProtectionThroughDenyBuild = true ;
2011-06-11 01:45:11 +02:00
public static Set < Material > territoryProtectedMaterials = EnumSet . noneOf ( Material . class ) ;
public static Set < Material > territoryDenyUseageMaterials = EnumSet . noneOf ( Material . class ) ;
public static Set < Material > territoryProtectedMaterialsWhenOffline = EnumSet . noneOf ( Material . class ) ;
public static Set < Material > territoryDenyUseageMaterialsWhenOffline = EnumSet . noneOf ( Material . class ) ;
2011-03-22 20:36:33 +01:00
2011-06-11 01:45:11 +02:00
public static transient Set < CreatureType > safeZoneNerfedCreatureTypes = EnumSet . noneOf ( CreatureType . class ) ;
2011-03-23 17:39:56 +01:00
2011-05-29 23:28:29 +02:00
public static Set < String > worldsNoClaiming = new HashSet < String > ( ) ;
public static Set < String > worldsNoPowerLoss = new HashSet < String > ( ) ;
2011-03-23 17:39:56 +01:00
public static transient int mapHeight = 8 ;
2011-04-28 22:45:43 +02:00
public static transient int mapWidth = 39 ;
2011-05-29 23:28:29 +02:00
public static transient char [ ] mapKeyChrs = " \\ /#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz " . toCharArray ( ) ;
2011-02-06 13:36:11 +01:00
static {
2011-02-07 21:42:14 +01:00
territoryProtectedMaterials . add ( Material . WOODEN_DOOR ) ;
2011-06-02 01:13:56 +02:00
territoryProtectedMaterials . add ( Material . TRAP_DOOR ) ;
2011-02-07 21:42:14 +01:00
territoryProtectedMaterials . add ( Material . DISPENSER ) ;
territoryProtectedMaterials . add ( Material . CHEST ) ;
territoryProtectedMaterials . add ( Material . FURNACE ) ;
2011-07-09 04:28:53 +02:00
territoryProtectedMaterials . add ( Material . BURNING_FURNACE ) ;
2011-07-20 21:59:10 +02:00
territoryProtectedMaterials . add ( Material . DIODE_BLOCK_OFF ) ;
territoryProtectedMaterials . add ( Material . DIODE_BLOCK_ON ) ;
2011-03-30 06:37:32 +02:00
2011-03-23 12:00:38 +01:00
territoryDenyUseageMaterials . add ( Material . FLINT_AND_STEEL ) ;
territoryDenyUseageMaterials . add ( Material . BUCKET ) ;
territoryDenyUseageMaterials . add ( Material . WATER_BUCKET ) ;
2011-03-30 06:37:32 +02:00
territoryDenyUseageMaterials . add ( Material . LAVA_BUCKET ) ;
2011-06-04 11:36:03 +02:00
territoryProtectedMaterialsWhenOffline . add ( Material . WOODEN_DOOR ) ;
territoryProtectedMaterialsWhenOffline . add ( Material . TRAP_DOOR ) ;
territoryProtectedMaterialsWhenOffline . add ( Material . DISPENSER ) ;
territoryProtectedMaterialsWhenOffline . add ( Material . CHEST ) ;
territoryProtectedMaterialsWhenOffline . add ( Material . FURNACE ) ;
2011-07-09 04:28:53 +02:00
territoryProtectedMaterialsWhenOffline . add ( Material . BURNING_FURNACE ) ;
2011-07-20 21:59:10 +02:00
territoryProtectedMaterialsWhenOffline . add ( Material . DIODE_BLOCK_OFF ) ;
territoryProtectedMaterialsWhenOffline . add ( Material . DIODE_BLOCK_ON ) ;
2011-06-04 11:36:03 +02:00
territoryDenyUseageMaterialsWhenOffline . add ( Material . FLINT_AND_STEEL ) ;
territoryDenyUseageMaterialsWhenOffline . add ( Material . BUCKET ) ;
territoryDenyUseageMaterialsWhenOffline . add ( Material . WATER_BUCKET ) ;
territoryDenyUseageMaterialsWhenOffline . add ( Material . LAVA_BUCKET ) ;
2011-03-30 06:37:32 +02:00
2011-03-23 17:39:56 +01:00
safeZoneNerfedCreatureTypes . add ( CreatureType . CREEPER ) ;
safeZoneNerfedCreatureTypes . add ( CreatureType . GHAST ) ;
safeZoneNerfedCreatureTypes . add ( CreatureType . PIG_ZOMBIE ) ;
safeZoneNerfedCreatureTypes . add ( CreatureType . SKELETON ) ;
safeZoneNerfedCreatureTypes . add ( CreatureType . SPIDER ) ;
safeZoneNerfedCreatureTypes . add ( CreatureType . SLIME ) ;
safeZoneNerfedCreatureTypes . add ( CreatureType . ZOMBIE ) ;
2011-02-06 13:36:11 +01:00
}
2011-04-06 12:04:57 +02:00
// track players with admin access who have enabled "admin bypass" mode, and should therefore be able to build anywhere
// not worth saving between server restarts, I think
public static transient Set < String > adminBypassPlayers = Collections . synchronizedSet ( new HashSet < String > ( ) ) ;
2011-02-06 13:36:11 +01:00
2011-03-18 17:33:23 +01:00
// -------------------------------------------- //
2011-02-06 13:36:11 +01:00
// Persistance
2011-03-18 17:33:23 +01:00
// -------------------------------------------- //
2011-02-06 13:36:11 +01:00
public static boolean save ( ) {
2011-03-22 22:31:04 +01:00
//Factions.log("Saving config to disk.");
2011-03-18 17:33:23 +01:00
try {
2011-07-27 22:56:45 +02:00
DiscUtil . write ( file , Factions . instance . gson . toJson ( new Conf ( ) ) ) ;
2011-04-06 11:08:08 +02:00
} catch ( Exception e ) {
2011-03-18 17:33:23 +01:00
e . printStackTrace ( ) ;
Factions . log ( " Failed to save the config to disk. " ) ;
return false ;
}
return true ;
}
public static boolean load ( ) {
2011-03-23 12:00:38 +01:00
Factions . log ( " Loading conf from disk " ) ;
2011-03-18 17:33:23 +01:00
if ( ! file . exists ( ) ) {
Factions . log ( " No conf to load from disk. Creating new file. " ) ;
save ( ) ;
return true ;
}
try {
2011-07-27 22:56:45 +02:00
Factions . instance . gson . fromJson ( DiscUtil . read ( file ) , Conf . class ) ;
2011-04-06 11:08:08 +02:00
} catch ( Exception e ) {
2011-03-18 17:33:23 +01:00
e . printStackTrace ( ) ;
Factions . log ( " Failed to load the config from disk. " ) ;
return false ;
}
return true ;
2011-02-06 13:36:11 +01:00
}
}
2011-03-23 12:00:38 +01:00