Territory Titles Toggle Command

This commit is contained in:
Olof Larsson 2015-08-28 09:00:24 +02:00
parent 89b93801d0
commit 8eaf1215d2
7 changed files with 187 additions and 90 deletions

View File

@ -72,6 +72,7 @@ permissions:
factions.name: {description: set faction name, default: false}
factions.title: {description: set player title, default: false}
factions.title.color: {description: set player title with color, default: false}
factions.territorytitles: {description: toggle territory titles, default: false}
factions.unclaim: {description: unclaim faction territory, default: false}
factions.unclaim.one: {description: unclaim a single chunk, default: false}
factions.unclaim.auto: {description: unclaim as you walk around, default: false}
@ -151,6 +152,7 @@ permissions:
factions.name: true
factions.title: true
factions.title.color: true
factions.territorytitles: true
factions.unclaim: true
factions.unclaim.one: true
factions.unclaim.auto: true
@ -251,6 +253,7 @@ permissions:
factions.name: true
factions.title: true
factions.title.color: true
factions.territorytitles: true
factions.unclaim: true
factions.unclaim.one: true
factions.unclaim.auto: true

View File

@ -10,77 +10,78 @@ public enum Perm
// ENUM
// -------------------------------------------- //
ACCESS("access"),
ACCESS_VIEW("access.view"),
ACCESS_PLAYER("access.player"),
ACCESS_FACTION("access.faction"),
ADMIN("admin"),
CLAIM("claim"),
CLAIM_ONE("claim.one"),
CLAIM_AUTO("claim.auto"),
CLAIM_FILL("claim.fill"),
CLAIM_SQUARE("claim.square"),
CLAIM_CIRCLE("claim.circle"),
CLAIM_ALL("claim.all"),
CREATE("create"),
DESCRIPTION("description"),
DISBAND("disband"),
EXPANSIONS("expansions"),
FACTION("faction"),
FLAG("flag"),
FLAG_LIST("flag.list"),
FLAG_SET("flag.set"),
FLAG_SHOW("flag.show"),
HOME("home"),
INVITE("invite"),
INVITE_LIST("invite.list"),
INVITE_LIST_OTHER("invite.list.other"),
INVITE_ADD("invite.add"),
INVITE_REMOVE("invite.remove"),
JOIN("join"),
JOIN_ANY("join.any"),
JOIN_OTHERS("join.others"),
KICK("kick"),
LEAVE("leave"),
LIST("list"),
MAP("map"),
MONEY("money"),
MONEY_BALANCE("money.balance"),
MONEY_BALANCE_ANY("money.balance.any"),
MONEY_DEPOSIT("money.deposit"),
MONEY_F2F("money.f2f"),
MONEY_F2P("money.f2p"),
MONEY_P2F("money.p2f"),
MONEY_WITHDRAW("money.withdraw"),
MOTD("motd"),
OPEN("open"),
PERM("perm"),
PERM_LIST("perm.list"),
PERM_SET("perm.set"),
PERM_SHOW("perm.show"),
PLAYER("player"),
POWERBOOST("powerboost"),
RANK("rank"),
RANK_SHOW("rank.show"),
RANK_ACTION("rank.action"),
RELATION("relation"),
SEECHUNK("seechunk"),
SEECHUNKOLD("seechunkold"),
SETHOME("sethome"),
SETPOWER("setpower"),
STATUS("status"),
NAME("name"),
TITLE("title"),
TITLE_COLOR("title.color"),
UNCLAIM("unclaim"),
UNCLAIM_ONE("unclaim.one"),
UNCLAIM_AUTO("unclaim.auto"),
UNCLAIM_FILL("unclaim.fill"),
UNCLAIM_SQUARE("unclaim.square"),
UNCLAIM_CIRCLE("unclaim.circle"),
UNCLAIM_ALL("unclaim.all"),
UNSETHOME("unsethome"),
VERSION("version"),
ACCESS,
ACCESS_VIEW,
ACCESS_PLAYER,
ACCESS_FACTION,
ADMIN,
CLAIM,
CLAIM_ONE,
CLAIM_AUTO,
CLAIM_FILL,
CLAIM_SQUARE,
CLAIM_CIRCLE,
CLAIM_ALL,
CREATE,
DESCRIPTION,
DISBAND,
EXPANSIONS,
FACTION,
FLAG,
FLAG_LIST,
FLAG_SET,
FLAG_SHOW,
HOME,
INVITE,
INVITE_LIST,
INVITE_LIST_OTHER,
INVITE_ADD,
INVITE_REMOVE,
JOIN,
JOIN_ANY,
JOIN_OTHERS,
KICK,
LEAVE,
LIST,
MAP,
MONEY,
MONEY_BALANCE,
MONEY_BALANCE_ANY,
MONEY_DEPOSIT,
MONEY_F2F,
MONEY_F2P,
MONEY_P2F,
MONEY_WITHDRAW,
MOTD,
OPEN,
PERM,
PERM_LIST,
PERM_SET,
PERM_SHOW,
PLAYER,
POWERBOOST,
RANK,
RANK_SHOW,
RANK_ACTION,
RELATION,
SEECHUNK,
SEECHUNKOLD,
SETHOME,
SETPOWER,
STATUS,
NAME,
TITLE,
TITLE_COLOR,
TERRITORYTITLES,
UNCLAIM,
UNCLAIM_ONE,
UNCLAIM_AUTO,
UNCLAIM_FILL,
UNCLAIM_SQUARE,
UNCLAIM_CIRCLE,
UNCLAIM_ALL,
UNSETHOME,
VERSION,
// END OF LIST
;
@ -95,9 +96,9 @@ public enum Perm
// CONSTRUCT
// -------------------------------------------- //
Perm(final String node)
Perm()
{
this.node = "factions."+node;
this.node = "factions." + this.name().toLowerCase().replace('_', '.');
}
// -------------------------------------------- //

View File

@ -39,6 +39,7 @@ public class CmdFactions extends FactionsCommand
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
public CmdFactionsTerritorytitles cmdFactionsTerritorytitles = new CmdFactionsTerritorytitles();
public CmdFactionsStatus cmdFactionsStatus = new CmdFactionsStatus();
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
@ -91,6 +92,7 @@ public class CmdFactions extends FactionsCommand
this.addSubCommand(this.cmdFactionsMoney);
this.addSubCommand(this.cmdFactionsSeeChunk);
this.addSubCommand(this.cmdFactionsSeeChunkOld);
this.addSubCommand(this.cmdFactionsTerritorytitles);
this.addSubCommand(this.cmdFactionsClaim);
this.addSubCommand(this.cmdFactionsUnclaim);
this.addSubCommand(this.cmdFactionsAccess);

View File

@ -0,0 +1,65 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.VisibilityMode;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqTitlesAvailable;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsTerritorytitles extends FactionsCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsTerritorytitles()
{
// Aliases
this.addAliases("tt", "territorytitles");
// Args
this.addArg(ARBoolean.get(), "on|off", "toggle");
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.TERRITORYTITLES.node));
this.addRequirements(ReqTitlesAvailable.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public VisibilityMode getVisibilityMode()
{
// We hide the command if titles aren't available.
if ( ! Mixin.isTitlesAvailable()) return VisibilityMode.INVISIBLE;
return super.getVisibilityMode();
}
@Override
public void perform() throws MassiveException
{
// Args
boolean before = msender.isTerritoryInfoTitles();
boolean after = this.readArg(!before);
String desc = Txt.parse(after ? "<g>ON" : "<b>OFF");
// NoChange
if (after == before)
{
msg("<i>Territory titles is already %s<i>.", desc);
return;
}
// Apply
msender.setTerritoryInfoTitles(after);
// Inform
msg("<i>Territory titles is now %s<i>.", desc);
}
}

View File

@ -695,11 +695,11 @@ public class EngineMain extends EngineAbstract
}
else if (factionFrom != factionTo)
{
if (this.isTerritoryInfoUsingScreen())
if (mplayer.isTerritoryInfoTitles())
{
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);
String maintitle = parseTerritoryInfo(MConf.get().territoryInfoTitlesMain, mplayer, factionTo);
String subtitle = parseTerritoryInfo(MConf.get().territoryInfoTitlesSub, mplayer, factionTo);
Mixin.sendTitleMessage(player, MConf.get().territoryInfoTitlesTicksIn, MConf.get().territoryInfoTitlesTicksStay, MConf.get().territoryInfoTitleTicksOut, maintitle, subtitle);
}
else
{
@ -743,13 +743,6 @@ public class EngineMain extends EngineAbstract
return string;
}
public boolean isTerritoryInfoUsingScreen()
{
if ( ! MConf.get().territoryInfoUseScreen) return false;
if ( ! Mixin.isTitlesAvailable()) return false;
return true;
}
// -------------------------------------------- //
// CHUNK CHANGE: AUTO CLAIM
// -------------------------------------------- //

View File

@ -270,13 +270,13 @@ public class MConf extends Entity<MConf>
// TERRITORY INFO
// -------------------------------------------- //
public boolean territoryInfoUseScreen = true;
public boolean territoryInfoTitlesDefault = 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 territoryInfoTitlesMain = "{relcolor}{name}";
public String territoryInfoTitlesSub = "<i>{desc}";
public int territoryInfoTitlesTicksIn = 5;
public int territoryInfoTitlesTicksStay = 60;
public int territoryInfoTitleTicksOut = 5;
public String territoryInfoChat = "<i> ~ {relcolor}{name} <i>{desc}";

View File

@ -58,6 +58,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
this.setPower(that.power);
this.setMapAutoUpdating(that.mapAutoUpdating);
this.setUsingAdminMode(that.usingAdminMode);
this.setTerritoryInfoTitles(that.territoryInfoTitles);
return this;
}
@ -73,6 +74,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) return false;
// if (this.isMapAutoUpdating()) return false; // Just having an auto updating map is not in itself reason enough for database storage.
if (this.isUsingAdminMode()) return false;
if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) return false;
return true;
}
@ -158,6 +160,10 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
// Null means false
private Boolean usingAdminMode = null;
// Does this player use titles for territory info?
// Null means default specified in MConf.
private Boolean territoryInfoTitles = null;
// The id for the faction this player is currently autoclaiming for.
// Null means the player isn't auto claiming.
// NOTE: This field will not be saved to the database ever.
@ -561,6 +567,33 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
this.changed();
}
// -------------------------------------------- //
// FIELD: territoryInfoTitles
// -------------------------------------------- //
public boolean isTerritoryInfoTitles()
{
if ( ! Mixin.isTitlesAvailable()) return false;
if (this.territoryInfoTitles == null) return MConf.get().territoryInfoTitlesDefault;
return this.territoryInfoTitles;
}
public void setTerritoryInfoTitles(Boolean territoryInfoTitles)
{
// Clean input
Boolean target = territoryInfoTitles;
if (MUtil.equals(target, MConf.get().territoryInfoTitlesDefault)) target = null;
// Detect Nochange
if (MUtil.equals(this.territoryInfoTitles, target)) return;
// Apply
this.territoryInfoTitles = target;
// Mark as changed
this.changed();
}
// -------------------------------------------- //
// TITLE, NAME, FACTION NAME AND CHAT
// -------------------------------------------- //