From df90260030d756d5eb4279e68f7368c226206021 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Mon, 2 Feb 2015 23:33:19 +0100 Subject: [PATCH] Territory info using 1.8 Titles. --- .../factions/engine/EngineMain.java | 33 ++++++++++++++++--- .../massivecraft/factions/entity/MConf.java | 14 ++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/com/massivecraft/factions/engine/EngineMain.java b/src/com/massivecraft/factions/engine/EngineMain.java index c469f752..573520b3 100644 --- a/src/com/massivecraft/factions/engine/EngineMain.java +++ b/src/com/massivecraft/factions/engine/EngineMain.java @@ -691,12 +691,17 @@ public class EngineMain extends EngineAbstract } else if (factionFrom != factionTo) { - String msg = Txt.parse("") + " ~ " + factionTo.getName(mplayer); - if (factionTo.hasDescription()) + if (this.isTerritoryInfoUsingScreen()) { - msg += " - " + factionTo.getDescription(); + String maintitle = parseTerritoryInfo(MConf.get().territoryInfoScreenMaintitle, mplayer, factionTo); + String subtitle = parseTerritoryInfo(MConf.get().territoryInfoScreenSubtitle, mplayer, factionTo); + Mixin.sendTitleMessage(player, MConf.get().territoryInfoScreenTicksIn, MConf.get().territoryInfoScreenTicksStay, MConf.get().territoryInfoScreenTicksOut, maintitle, subtitle); + } + else + { + String message = parseTerritoryInfo(MConf.get().territoryInfoChat, mplayer, factionTo); + player.sendMessage(message); } - player.sendMessage(msg); } // Show access level message if it changed. @@ -706,7 +711,7 @@ public class EngineMain extends EngineAbstract TerritoryAccess accessTo = BoardColl.get().getTerritoryAccessAt(chunkTo); Boolean hasTerritoryAccessTo = accessTo.hasTerritoryAccess(mplayer); - if (!MUtil.equals(hasTerritoryAccessFrom, hasTerritoryAccessTo)) + if ( ! MUtil.equals(hasTerritoryAccessFrom, hasTerritoryAccessTo)) { if (hasTerritoryAccessTo == null) { @@ -723,6 +728,24 @@ public class EngineMain extends EngineAbstract } } + public String parseTerritoryInfo(String string, MPlayer mplayer, Faction faction) + { + string = Txt.parse(string); + + string = string.replace("{name}", faction.getName()); + string = string.replace("{relcolor}", faction.getColorTo(mplayer).toString()); + string = string.replace("{desc}", faction.getDescription()); + + return string; + } + + public boolean isTerritoryInfoUsingScreen() + { + if ( ! MConf.get().territoryInfoUseScreen) return false; + if ( ! Mixin.isTitlesAvailable()) return false; + return true; + } + // -------------------------------------------- // // CHUNK CHANGE: AUTO CLAIM // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/entity/MConf.java b/src/com/massivecraft/factions/entity/MConf.java index 4ff166f3..472ac0a7 100644 --- a/src/com/massivecraft/factions/entity/MConf.java +++ b/src/com/massivecraft/factions/entity/MConf.java @@ -266,6 +266,20 @@ public class MConf extends Entity // Choose between: LOWEST, LOW, NORMAL, HIGH, HIGHEST and MONITOR. public EventPriority homesTeleportToOnDeathPriority = EventPriority.NORMAL; + // -------------------------------------------- // + // TERRITORY INFO + // -------------------------------------------- // + + public boolean territoryInfoUseScreen = true; + + public String territoryInfoScreenMaintitle = "{relcolor}{name}"; + public String territoryInfoScreenSubtitle = "{desc}"; + public int territoryInfoScreenTicksIn = 5; + public int territoryInfoScreenTicksStay = 60; + public int territoryInfoScreenTicksOut = 5; + + public String territoryInfoChat = " ~ {relcolor}{name} {desc}"; + // -------------------------------------------- // // ASSORTED // -------------------------------------------- //