Allow the default relation between Factions to be configurable.

This commit is contained in:
drtshock 2014-12-09 16:01:20 -06:00
parent 1230803cfb
commit a01d79ef78
3 changed files with 35 additions and 8 deletions

View File

@ -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;
@ -25,11 +24,26 @@ public enum Relation {
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() {

View File

@ -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) {

View File

@ -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