From a01d79ef786e550e36305f647c059dc045682dc2 Mon Sep 17 00:00:00 2001 From: drtshock Date: Tue, 9 Dec 2014 16:01:20 -0600 Subject: [PATCH] Allow the default relation between Factions to be configurable. --- .../factions/struct/Relation.java | 28 ++++++++++++++----- .../factions/zcore/persist/MemoryFaction.java | 2 +- src/main/resources/config.yml | 13 +++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/struct/Relation.java b/src/main/java/com/massivecraft/factions/struct/Relation.java index a1c7a4e2..2012eada 100644 --- a/src/main/java/com/massivecraft/factions/struct/Relation.java +++ b/src/main/java/com/massivecraft/factions/struct/Relation.java @@ -2,7 +2,6 @@ package com.massivecraft.factions.struct; import com.massivecraft.factions.Conf; import com.massivecraft.factions.zcore.util.TL; - import org.bukkit.ChatColor; @@ -24,12 +23,27 @@ public enum Relation { public String toString() { return this.nicename; } - - public String getTranslation(){ - for(TL t:TL.values()){ - if(t.name().equals("RELATION_" + name())) return t.toString(); - } - return toString(); + + public static Relation fromString(String s) { + // Because Java 6 doesn't allow String switches :( + if (s.equalsIgnoreCase("member")) { + return Relation.MEMBER; + } else if (s.equalsIgnoreCase("ally")) { + return Relation.ALLY; + } else if (s.equalsIgnoreCase("enemy")) { + return Relation.ENEMY; + } else { + return Relation.NEUTRAL; // If they somehow mess things up, go back to default behavior. + } + } + + public String getTranslation() { + for (TL t : TL.values()) { + if (t.name().equals("RELATION_" + name())) { + return t.toString(); + } + } + return toString(); } public boolean isMember() { diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index 5ee3ba82..e0f15eaf 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -367,7 +367,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { if (this.relationWish.containsKey(otherFaction.getId())) { return this.relationWish.get(otherFaction.getId()); } - return Relation.NEUTRAL; + return Relation.fromString(P.p.getConfig().getString("default-relation", "neutral")); // Always default to old behavior. } public void setRelationWish(Faction otherFaction, Relation relation) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e01bc011..8749c3d3 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -19,6 +19,19 @@ findfactionsexploit: cooldown: 2000 # in miliseconds. 2000 = 2 seconds. log: false +### Hard Core Settings ### +# Many of the features that are / are to come in this section have been requested by +# people in relation to HCF servers. All settings are set to the normal Factions +# behavior by default. + +# Default Relation allows you to change the default relation for Factions. +# Example usage would be so people can't leave then make a new Faction while Raiding +# in order to be able to execute commands if the default relation is neutral. +# This has always been neutral. +default-relation: "neutral" + +### Hard Core Settings ### + # Warps # What should be the max amount of warps that a Factoin can set? max-warps: 5