diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index 7aca21d8..1b7e9a50 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -16,12 +16,12 @@ public class Conf { // Colors public static ChatColor colorMember = ChatColor.GREEN; public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE; + public static ChatColor colorTruce = ChatColor.DARK_PURPLE; public static ChatColor colorNeutral = ChatColor.WHITE; public static ChatColor colorEnemy = ChatColor.RED; public static ChatColor colorPeaceful = ChatColor.GOLD; public static ChatColor colorWar = ChatColor.DARK_RED; - //public static ChatColor colorWilderness = ChatColor.DARK_GREEN; // Power public static double powerPlayerMax = 10.0; @@ -71,6 +71,7 @@ public class Conf { public static String chatTagFormat = "%s" + ChatColor.WHITE; public static String factionChatFormat = "%s:" + ChatColor.WHITE + " %s"; public static String allianceChatFormat = ChatColor.LIGHT_PURPLE + "%s:" + ChatColor.WHITE + " %s"; + public static String truceChatFormat = ChatColor.DARK_PURPLE + "%s:" + ChatColor.WHITE + " %s"; public static boolean broadcastDescriptionChanges = false; @@ -163,6 +164,12 @@ public class Conf { public static boolean territoryAllyPainBuildWhenOffline = false; public static boolean territoryAllyDenyUseage = true; public static boolean territoryAllyProtectMaterials = true; + public static boolean territoryTruceDenyBuild = true; + public static boolean territoryTruceDenyBuildWhenOffline = true; + public static boolean territoryTrucePainBuild = false; + public static boolean territoryTrucePainBuildWhenOffline = false; + public static boolean territoryTruceDenyUseage = true; + public static boolean territoryTruceProtectMaterials = true; public static boolean territoryBlockCreepers = false; public static boolean territoryBlockCreepersWhenOffline = false; public static boolean territoryBlockFireballs = false; @@ -242,6 +249,7 @@ public class Conf { public static double econCostShow = 0.0; public static double econCostOpen = 0.0; public static double econCostAlly = 0.0; + public static double econCostTruce = 0.0; public static double econCostEnemy = 0.0; public static double econCostNeutral = 0.0; public static double econCostNoBoom = 0.0; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java index c374490d..9b47a740 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java @@ -42,6 +42,8 @@ public class CmdChat extends FCommand { modeTarget = ChatMode.ALLIANCE; } else if (modeString.startsWith("f")) { modeTarget = ChatMode.FACTION; + } else if (modeString.startsWith("t")) { + modeTarget = ChatMode.TRUCE; } else { msg(TL.COMMAND_CHAT_INVALIDMODE); return; @@ -54,6 +56,8 @@ public class CmdChat extends FCommand { msg(TL.COMMAND_CHAT_MODE_PUBLIC); } else if (fme.getChatMode() == ChatMode.ALLIANCE) { msg(TL.COMMAND_CHAT_MODE_ALLIANCE); + } else if (fme.getChatMode() == ChatMode.TRUCE) { + msg(TL.COMMAND_CHAT_MODE_TRUCE); } else { msg(TL.COMMAND_CHAT_MODE_FACTION); } diff --git a/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java b/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java index 59487988..cd3cb846 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java @@ -77,10 +77,8 @@ public abstract class FRelationCommand extends FCommand { them.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + myFaction.getTag()); myFaction.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + them.getTag()); - } - // inform the other faction of your request - else { - + } else { + // inform the other faction of your request them.msg(TL.COMMAND_RELATIONS_PROPOSAL_1, currentRelationColor + myFaction.getTag(), targetRelation.getColor() + targetRelation.getTranslation()); them.msg(TL.COMMAND_RELATIONS_PROPOSAL_2, Conf.baseCommandAliases.get(0), targetRelation, myFaction.getTag()); myFaction.msg(TL.COMMAND_RELATIONS_PROPOSAL_SENT, currentRelationColor + them.getTag(), "" + targetRelation.getColor() + targetRelation); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java index 34ccc4ec..686589ad 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java @@ -74,6 +74,28 @@ public class FactionsChatListener implements Listener { Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("AllianceChat: " + message)); + event.setCancelled(true); + } else if (chat == ChatMode.TRUCE) { + Faction myFaction = me.getFaction(); + + String message = String.format(Conf.truceChatFormat, ChatColor.stripColor(me.getNameAndTag()), msg); + + //Send message to our own faction + myFaction.sendMessage(message); + + //Send to all our truces + for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { + if (myFaction.getRelationTo(fplayer) == Relation.TRUCE) { + fplayer.sendMessage(message); + } + + //Send to any players who are spying chat + else if (fplayer.isSpyingChat()) { + fplayer.sendMessage("[TCspy]: " + message); + } + } + + Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("TruceChat: " + message)); event.setCancelled(true); } } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 9d7b508d..8754afc3 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -398,7 +398,7 @@ public class FactionsPlayerListener implements Listener { } // You may use any block unless it is another faction's territory... - if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials)) { + if (rel.isNeutral() || (rel.isEnemy() && Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && Conf.territoryAllyProtectMaterials) || (rel.isTruce() && Conf.territoryTruceProtectMaterials)) { if (!justCheck) { me.msg("You can't %s %s in the territory of %s.", (material == Material.SOIL ? "trample" : "use"), TextUtil.getMaterialName(material), otherFaction.getTag(myFaction)); } diff --git a/src/main/java/com/massivecraft/factions/struct/ChatMode.java b/src/main/java/com/massivecraft/factions/struct/ChatMode.java index a522013e..020dfb27 100644 --- a/src/main/java/com/massivecraft/factions/struct/ChatMode.java +++ b/src/main/java/com/massivecraft/factions/struct/ChatMode.java @@ -3,8 +3,9 @@ package com.massivecraft.factions.struct; import com.massivecraft.factions.zcore.util.TL; public enum ChatMode { - FACTION(2, TL.CHAT_FACTION), - ALLIANCE(1, TL.CHAT_ALLIANCE), + FACTION(3, TL.CHAT_FACTION), + ALLIANCE(2, TL.CHAT_ALLIANCE), + TRUCE(1, TL.CHAT_TRUCE), PUBLIC(0, TL.CHAT_PUBLIC); public final int value; diff --git a/src/main/java/com/massivecraft/factions/struct/Relation.java b/src/main/java/com/massivecraft/factions/struct/Relation.java index 2012eada..8401e9fc 100644 --- a/src/main/java/com/massivecraft/factions/struct/Relation.java +++ b/src/main/java/com/massivecraft/factions/struct/Relation.java @@ -6,8 +6,9 @@ import org.bukkit.ChatColor; public enum Relation { - MEMBER(3, "member"), - ALLY(2, "ally"), + MEMBER(4, "member"), + ALLY(3, "ally"), + TRUCE(2, "truce"), NEUTRAL(1, "neutral"), ENEMY(0, "enemy"); @@ -27,13 +28,15 @@ public enum Relation { public static Relation fromString(String s) { // Because Java 6 doesn't allow String switches :( if (s.equalsIgnoreCase("member")) { - return Relation.MEMBER; + return MEMBER; } else if (s.equalsIgnoreCase("ally")) { - return Relation.ALLY; + return ALLY; + } else if(s.equalsIgnoreCase("truce")) { + return TRUCE; } else if (s.equalsIgnoreCase("enemy")) { - return Relation.ENEMY; + return ENEMY; } else { - return Relation.NEUTRAL; // If they somehow mess things up, go back to default behavior. + return NEUTRAL; // If they somehow mess things up, go back to default behavior. } } @@ -54,6 +57,10 @@ public enum Relation { return this == ALLY; } + public boolean isTruce() { + return this == TRUCE; + } + public boolean isNeutral() { return this == NEUTRAL; } @@ -77,6 +84,8 @@ public enum Relation { return Conf.colorAlly; } else if (this == NEUTRAL) { return Conf.colorNeutral; + } else if (this == TRUCE) { + return Conf.colorTruce; } else { return Conf.colorEnemy; } @@ -93,6 +102,8 @@ public enum Relation { return Conf.territoryEnemyDenyBuild; } else if (isAlly()) { return Conf.territoryAllyDenyBuild; + } else if (isTruce()) { + return Conf.territoryTruceDenyBuild; } else { return Conf.territoryDenyBuild; } @@ -101,6 +112,8 @@ public enum Relation { return Conf.territoryEnemyDenyBuildWhenOffline; } else if (isAlly()) { return Conf.territoryAllyDenyBuildWhenOffline; + } else if (isTruce()) { + return Conf.territoryTruceDenyBuildWhenOffline; } else { return Conf.territoryDenyBuildWhenOffline; } @@ -118,6 +131,8 @@ public enum Relation { return Conf.territoryEnemyPainBuild; } else if (isAlly()) { return Conf.territoryAllyPainBuild; + } else if (isTruce()) { + return Conf.territoryTrucePainBuild; } else { return Conf.territoryPainBuild; } @@ -126,6 +141,8 @@ public enum Relation { return Conf.territoryEnemyPainBuildWhenOffline; } else if (isAlly()) { return Conf.territoryAllyPainBuildWhenOffline; + } else if (isTruce()) { + return Conf.territoryTrucePainBuildWhenOffline; } else { return Conf.territoryPainBuildWhenOffline; } @@ -140,6 +157,8 @@ public enum Relation { return Conf.territoryEnemyDenyUseage; } else if (isAlly()) { return Conf.territoryAllyDenyUseage; + } else if (isTruce()) { + return Conf.territoryTruceDenyUseage; } else { return Conf.territoryDenyUseage; } @@ -150,6 +169,8 @@ public enum Relation { return Conf.econCostEnemy; } else if (isAlly()) { return Conf.econCostAlly; + } else if (isTruce()) { + return Conf.econCostTruce; } else { return Conf.econCostNeutral; } diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java index 6e17c1c9..b14754f2 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -85,6 +85,7 @@ public enum TL { COMMAND_CHAT_MODE_PUBLIC("Public chat mode."), COMMAND_CHAT_MODE_ALLIANCE("Alliance only chat mode."), + COMMAND_CHAT_MODE_TRUCE("Truce only chat mode."), COMMAND_CHAT_MODE_FACTION("Faction only chat mode."), COMMAND_CHATSPY_ENABLE("You have enabled chat spying mode."), @@ -564,6 +565,7 @@ public enum TL { */ CHAT_FACTION("faction chat"), CHAT_ALLIANCE("alliance chat"), + CHAT_TRUCE("truce chat"), CHAT_PUBLIC("public chat"), /** @@ -571,6 +573,7 @@ public enum TL { */ RELATION_MEMBER("member"), RELATION_ALLY("ally"), + RELATION_TRUCE("truce"), RELATION_NEUTRAL("neutral"), RELATION_ENEMY("enemy"),