Territory info using 1.8 Titles.

This commit is contained in:
Olof Larsson 2015-02-02 23:33:19 +01:00
parent 15dab6e5f7
commit df90260030
2 changed files with 42 additions and 5 deletions

View File

@ -691,12 +691,17 @@ public class EngineMain extends EngineAbstract
}
else if (factionFrom != factionTo)
{
String msg = Txt.parse("<i>") + " ~ " + 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
// -------------------------------------------- //

View File

@ -266,6 +266,20 @@ public class MConf extends Entity<MConf>
// 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 = "<i>{desc}";
public int territoryInfoScreenTicksIn = 5;
public int territoryInfoScreenTicksStay = 60;
public int territoryInfoScreenTicksOut = 5;
public String territoryInfoChat = "<i> ~ {relcolor}{name} <i>{desc}";
// -------------------------------------------- //
// ASSORTED
// -------------------------------------------- //