Territory Titles Toggle Command
This commit is contained in:
parent
89b93801d0
commit
8eaf1215d2
@ -72,6 +72,7 @@ permissions:
|
|||||||
factions.name: {description: set faction name, default: false}
|
factions.name: {description: set faction name, default: false}
|
||||||
factions.title: {description: set player title, default: false}
|
factions.title: {description: set player title, default: false}
|
||||||
factions.title.color: {description: set player title with color, 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: {description: unclaim faction territory, default: false}
|
||||||
factions.unclaim.one: {description: unclaim a single chunk, default: false}
|
factions.unclaim.one: {description: unclaim a single chunk, default: false}
|
||||||
factions.unclaim.auto: {description: unclaim as you walk around, default: false}
|
factions.unclaim.auto: {description: unclaim as you walk around, default: false}
|
||||||
@ -151,6 +152,7 @@ permissions:
|
|||||||
factions.name: true
|
factions.name: true
|
||||||
factions.title: true
|
factions.title: true
|
||||||
factions.title.color: true
|
factions.title.color: true
|
||||||
|
factions.territorytitles: true
|
||||||
factions.unclaim: true
|
factions.unclaim: true
|
||||||
factions.unclaim.one: true
|
factions.unclaim.one: true
|
||||||
factions.unclaim.auto: true
|
factions.unclaim.auto: true
|
||||||
@ -251,6 +253,7 @@ permissions:
|
|||||||
factions.name: true
|
factions.name: true
|
||||||
factions.title: true
|
factions.title: true
|
||||||
factions.title.color: true
|
factions.title.color: true
|
||||||
|
factions.territorytitles: true
|
||||||
factions.unclaim: true
|
factions.unclaim: true
|
||||||
factions.unclaim.one: true
|
factions.unclaim.one: true
|
||||||
factions.unclaim.auto: true
|
factions.unclaim.auto: true
|
||||||
|
@ -10,77 +10,78 @@ public enum Perm
|
|||||||
// ENUM
|
// ENUM
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
ACCESS("access"),
|
ACCESS,
|
||||||
ACCESS_VIEW("access.view"),
|
ACCESS_VIEW,
|
||||||
ACCESS_PLAYER("access.player"),
|
ACCESS_PLAYER,
|
||||||
ACCESS_FACTION("access.faction"),
|
ACCESS_FACTION,
|
||||||
ADMIN("admin"),
|
ADMIN,
|
||||||
CLAIM("claim"),
|
CLAIM,
|
||||||
CLAIM_ONE("claim.one"),
|
CLAIM_ONE,
|
||||||
CLAIM_AUTO("claim.auto"),
|
CLAIM_AUTO,
|
||||||
CLAIM_FILL("claim.fill"),
|
CLAIM_FILL,
|
||||||
CLAIM_SQUARE("claim.square"),
|
CLAIM_SQUARE,
|
||||||
CLAIM_CIRCLE("claim.circle"),
|
CLAIM_CIRCLE,
|
||||||
CLAIM_ALL("claim.all"),
|
CLAIM_ALL,
|
||||||
CREATE("create"),
|
CREATE,
|
||||||
DESCRIPTION("description"),
|
DESCRIPTION,
|
||||||
DISBAND("disband"),
|
DISBAND,
|
||||||
EXPANSIONS("expansions"),
|
EXPANSIONS,
|
||||||
FACTION("faction"),
|
FACTION,
|
||||||
FLAG("flag"),
|
FLAG,
|
||||||
FLAG_LIST("flag.list"),
|
FLAG_LIST,
|
||||||
FLAG_SET("flag.set"),
|
FLAG_SET,
|
||||||
FLAG_SHOW("flag.show"),
|
FLAG_SHOW,
|
||||||
HOME("home"),
|
HOME,
|
||||||
INVITE("invite"),
|
INVITE,
|
||||||
INVITE_LIST("invite.list"),
|
INVITE_LIST,
|
||||||
INVITE_LIST_OTHER("invite.list.other"),
|
INVITE_LIST_OTHER,
|
||||||
INVITE_ADD("invite.add"),
|
INVITE_ADD,
|
||||||
INVITE_REMOVE("invite.remove"),
|
INVITE_REMOVE,
|
||||||
JOIN("join"),
|
JOIN,
|
||||||
JOIN_ANY("join.any"),
|
JOIN_ANY,
|
||||||
JOIN_OTHERS("join.others"),
|
JOIN_OTHERS,
|
||||||
KICK("kick"),
|
KICK,
|
||||||
LEAVE("leave"),
|
LEAVE,
|
||||||
LIST("list"),
|
LIST,
|
||||||
MAP("map"),
|
MAP,
|
||||||
MONEY("money"),
|
MONEY,
|
||||||
MONEY_BALANCE("money.balance"),
|
MONEY_BALANCE,
|
||||||
MONEY_BALANCE_ANY("money.balance.any"),
|
MONEY_BALANCE_ANY,
|
||||||
MONEY_DEPOSIT("money.deposit"),
|
MONEY_DEPOSIT,
|
||||||
MONEY_F2F("money.f2f"),
|
MONEY_F2F,
|
||||||
MONEY_F2P("money.f2p"),
|
MONEY_F2P,
|
||||||
MONEY_P2F("money.p2f"),
|
MONEY_P2F,
|
||||||
MONEY_WITHDRAW("money.withdraw"),
|
MONEY_WITHDRAW,
|
||||||
MOTD("motd"),
|
MOTD,
|
||||||
OPEN("open"),
|
OPEN,
|
||||||
PERM("perm"),
|
PERM,
|
||||||
PERM_LIST("perm.list"),
|
PERM_LIST,
|
||||||
PERM_SET("perm.set"),
|
PERM_SET,
|
||||||
PERM_SHOW("perm.show"),
|
PERM_SHOW,
|
||||||
PLAYER("player"),
|
PLAYER,
|
||||||
POWERBOOST("powerboost"),
|
POWERBOOST,
|
||||||
RANK("rank"),
|
RANK,
|
||||||
RANK_SHOW("rank.show"),
|
RANK_SHOW,
|
||||||
RANK_ACTION("rank.action"),
|
RANK_ACTION,
|
||||||
RELATION("relation"),
|
RELATION,
|
||||||
SEECHUNK("seechunk"),
|
SEECHUNK,
|
||||||
SEECHUNKOLD("seechunkold"),
|
SEECHUNKOLD,
|
||||||
SETHOME("sethome"),
|
SETHOME,
|
||||||
SETPOWER("setpower"),
|
SETPOWER,
|
||||||
STATUS("status"),
|
STATUS,
|
||||||
NAME("name"),
|
NAME,
|
||||||
TITLE("title"),
|
TITLE,
|
||||||
TITLE_COLOR("title.color"),
|
TITLE_COLOR,
|
||||||
UNCLAIM("unclaim"),
|
TERRITORYTITLES,
|
||||||
UNCLAIM_ONE("unclaim.one"),
|
UNCLAIM,
|
||||||
UNCLAIM_AUTO("unclaim.auto"),
|
UNCLAIM_ONE,
|
||||||
UNCLAIM_FILL("unclaim.fill"),
|
UNCLAIM_AUTO,
|
||||||
UNCLAIM_SQUARE("unclaim.square"),
|
UNCLAIM_FILL,
|
||||||
UNCLAIM_CIRCLE("unclaim.circle"),
|
UNCLAIM_SQUARE,
|
||||||
UNCLAIM_ALL("unclaim.all"),
|
UNCLAIM_CIRCLE,
|
||||||
UNSETHOME("unsethome"),
|
UNCLAIM_ALL,
|
||||||
VERSION("version"),
|
UNSETHOME,
|
||||||
|
VERSION,
|
||||||
|
|
||||||
// END OF LIST
|
// END OF LIST
|
||||||
;
|
;
|
||||||
@ -95,9 +96,9 @@ public enum Perm
|
|||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
Perm(final String node)
|
Perm()
|
||||||
{
|
{
|
||||||
this.node = "factions."+node;
|
this.node = "factions." + this.name().toLowerCase().replace('_', '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -39,6 +39,7 @@ public class CmdFactions extends FactionsCommand
|
|||||||
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
|
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
|
||||||
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
|
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
|
||||||
public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
|
public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
|
||||||
|
public CmdFactionsTerritorytitles cmdFactionsTerritorytitles = new CmdFactionsTerritorytitles();
|
||||||
public CmdFactionsStatus cmdFactionsStatus = new CmdFactionsStatus();
|
public CmdFactionsStatus cmdFactionsStatus = new CmdFactionsStatus();
|
||||||
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
|
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
|
||||||
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
|
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
|
||||||
@ -91,6 +92,7 @@ public class CmdFactions extends FactionsCommand
|
|||||||
this.addSubCommand(this.cmdFactionsMoney);
|
this.addSubCommand(this.cmdFactionsMoney);
|
||||||
this.addSubCommand(this.cmdFactionsSeeChunk);
|
this.addSubCommand(this.cmdFactionsSeeChunk);
|
||||||
this.addSubCommand(this.cmdFactionsSeeChunkOld);
|
this.addSubCommand(this.cmdFactionsSeeChunkOld);
|
||||||
|
this.addSubCommand(this.cmdFactionsTerritorytitles);
|
||||||
this.addSubCommand(this.cmdFactionsClaim);
|
this.addSubCommand(this.cmdFactionsClaim);
|
||||||
this.addSubCommand(this.cmdFactionsUnclaim);
|
this.addSubCommand(this.cmdFactionsUnclaim);
|
||||||
this.addSubCommand(this.cmdFactionsAccess);
|
this.addSubCommand(this.cmdFactionsAccess);
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -695,11 +695,11 @@ public class EngineMain extends EngineAbstract
|
|||||||
}
|
}
|
||||||
else if (factionFrom != factionTo)
|
else if (factionFrom != factionTo)
|
||||||
{
|
{
|
||||||
if (this.isTerritoryInfoUsingScreen())
|
if (mplayer.isTerritoryInfoTitles())
|
||||||
{
|
{
|
||||||
String maintitle = parseTerritoryInfo(MConf.get().territoryInfoScreenMaintitle, mplayer, factionTo);
|
String maintitle = parseTerritoryInfo(MConf.get().territoryInfoTitlesMain, mplayer, factionTo);
|
||||||
String subtitle = parseTerritoryInfo(MConf.get().territoryInfoScreenSubtitle, mplayer, factionTo);
|
String subtitle = parseTerritoryInfo(MConf.get().territoryInfoTitlesSub, mplayer, factionTo);
|
||||||
Mixin.sendTitleMessage(player, MConf.get().territoryInfoScreenTicksIn, MConf.get().territoryInfoScreenTicksStay, MConf.get().territoryInfoScreenTicksOut, maintitle, subtitle);
|
Mixin.sendTitleMessage(player, MConf.get().territoryInfoTitlesTicksIn, MConf.get().territoryInfoTitlesTicksStay, MConf.get().territoryInfoTitleTicksOut, maintitle, subtitle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -743,13 +743,6 @@ public class EngineMain extends EngineAbstract
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTerritoryInfoUsingScreen()
|
|
||||||
{
|
|
||||||
if ( ! MConf.get().territoryInfoUseScreen) return false;
|
|
||||||
if ( ! Mixin.isTitlesAvailable()) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// CHUNK CHANGE: AUTO CLAIM
|
// CHUNK CHANGE: AUTO CLAIM
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -270,13 +270,13 @@ public class MConf extends Entity<MConf>
|
|||||||
// TERRITORY INFO
|
// TERRITORY INFO
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public boolean territoryInfoUseScreen = true;
|
public boolean territoryInfoTitlesDefault = true;
|
||||||
|
|
||||||
public String territoryInfoScreenMaintitle = "{relcolor}{name}";
|
public String territoryInfoTitlesMain = "{relcolor}{name}";
|
||||||
public String territoryInfoScreenSubtitle = "<i>{desc}";
|
public String territoryInfoTitlesSub = "<i>{desc}";
|
||||||
public int territoryInfoScreenTicksIn = 5;
|
public int territoryInfoTitlesTicksIn = 5;
|
||||||
public int territoryInfoScreenTicksStay = 60;
|
public int territoryInfoTitlesTicksStay = 60;
|
||||||
public int territoryInfoScreenTicksOut = 5;
|
public int territoryInfoTitleTicksOut = 5;
|
||||||
|
|
||||||
public String territoryInfoChat = "<i> ~ {relcolor}{name} <i>{desc}";
|
public String territoryInfoChat = "<i> ~ {relcolor}{name} <i>{desc}";
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
|||||||
this.setPower(that.power);
|
this.setPower(that.power);
|
||||||
this.setMapAutoUpdating(that.mapAutoUpdating);
|
this.setMapAutoUpdating(that.mapAutoUpdating);
|
||||||
this.setUsingAdminMode(that.usingAdminMode);
|
this.setUsingAdminMode(that.usingAdminMode);
|
||||||
|
this.setTerritoryInfoTitles(that.territoryInfoTitles);
|
||||||
|
|
||||||
return this;
|
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.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.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.isUsingAdminMode()) return false;
|
||||||
|
if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -158,6 +160,10 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
|||||||
// Null means false
|
// Null means false
|
||||||
private Boolean usingAdminMode = null;
|
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.
|
// The id for the faction this player is currently autoclaiming for.
|
||||||
// Null means the player isn't auto claiming.
|
// Null means the player isn't auto claiming.
|
||||||
// NOTE: This field will not be saved to the database ever.
|
// 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();
|
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
|
// TITLE, NAME, FACTION NAME AND CHAT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
Loading…
Reference in New Issue
Block a user