Added the ability to toggle titles when entering claims of a different faction
Signed-off-by: DroppingAnvil <dr0pping.4nvi1@gmail.com>
This commit is contained in:
parent
f5e9ce3d90
commit
36f22262c6
@ -30,6 +30,18 @@ public interface FPlayer extends EconomyParticipator {
|
||||
|
||||
boolean hasNotificationsEnabled();
|
||||
|
||||
/**
|
||||
* Used to check if this player should be served titles
|
||||
* @return if this FPlayer has titles enabled as a boolean
|
||||
*/
|
||||
boolean hasTitlesEnabled();
|
||||
|
||||
/**
|
||||
* Used to set if player should be served titles
|
||||
* @param b Boolean to titlesEnabled to
|
||||
*/
|
||||
void setTitlesEnabled(Boolean b);
|
||||
|
||||
/**
|
||||
* Used to determine if a player is in their faction's chest
|
||||
* @return if player is in their faction's as a boolean
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdPlayerTitleToggle extends FCommand {
|
||||
public CmdPlayerTitleToggle() {
|
||||
super();
|
||||
this.aliases.add("titles");
|
||||
this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_TITLES)
|
||||
.build();
|
||||
}
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
context.fPlayer.setTitlesEnabled(!context.fPlayer.hasTitlesEnabled());
|
||||
context.msg(TL.COMMAND_TITLETOGGLE_TOGGLED, context.fPlayer.hasTitlesEnabled() ? FactionsPlugin.getInstance().color("&dEnabled") : FactionsPlugin.getInstance().color("&dDisabled"));
|
||||
}
|
||||
@Override
|
||||
public TL getUsageTranslation() {return TL.COMMAND_TITLETOGGLE_DESCRIPTION;}
|
||||
}
|
@ -87,6 +87,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
public CmdStuck cmdStuck = new CmdStuck();
|
||||
public CmdTag cmdTag = new CmdTag();
|
||||
public CmdTitle cmdTitle = new CmdTitle();
|
||||
public CmdPlayerTitleToggle cmdPlayerTitleToggle = new CmdPlayerTitleToggle();
|
||||
public CmdToggleAllianceChat cmdToggleAllianceChat = new CmdToggleAllianceChat();
|
||||
public CmdUnclaim cmdUnclaim = new CmdUnclaim();
|
||||
public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall();
|
||||
@ -215,6 +216,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
this.addSubCommand(this.cmdLogout);
|
||||
this.addSubCommand(this.cmdTag);
|
||||
this.addSubCommand(this.cmdTitle);
|
||||
this.addSubCommand(this.cmdPlayerTitleToggle);
|
||||
this.addSubCommand(this.cmdUnclaim);
|
||||
this.addSubCommand(this.cmdUnclaimall);
|
||||
this.addSubCommand(this.cmdVersion);
|
||||
|
@ -714,7 +714,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
if (changedFaction) {
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> Bukkit.getServer().getPluginManager().callEvent(new FPlayerEnteredFactionEvent(factionTo, factionFrom, me)));
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("Title.Show-Title")) {
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("Title.Show-Title") && me.hasTitlesEnabled()) {
|
||||
String title = FactionsPlugin.instance.getConfig().getString("Title.Format.Title");
|
||||
title = title.replace("{Faction}", factionTo.getColorTo(me) + factionTo.getTag());
|
||||
title = parseAllPlaceholders(title, factionTo, player);
|
||||
|
@ -108,6 +108,7 @@ public enum Permission {
|
||||
STEALTH("stealth"),
|
||||
STUCK("stuck"),
|
||||
TAG("tag"),
|
||||
TOGGLE_TITLES("toggletitles"),
|
||||
TNT("tnt"),
|
||||
TITLE("title"),
|
||||
TITLE_COLOR("title.color"),
|
||||
|
@ -78,6 +78,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
protected transient boolean shouldTakeFallDamage = true;
|
||||
protected boolean isStealthEnabled = false;
|
||||
protected boolean notificationsEnabled = true;
|
||||
protected boolean titlesEnabled = true;
|
||||
protected boolean isAlt = false;
|
||||
boolean inspectMode = false;
|
||||
|
||||
@ -217,7 +218,12 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
public boolean hasNotificationsEnabled() {
|
||||
return this.notificationsEnabled;
|
||||
}
|
||||
|
||||
public boolean hasTitlesEnabled() {
|
||||
return this.titlesEnabled;
|
||||
}
|
||||
public void setTitlesEnabled(Boolean b) {
|
||||
this.titlesEnabled = b;
|
||||
}
|
||||
public String getFactionId() {
|
||||
return this.factionId;
|
||||
}
|
||||
|
@ -867,6 +867,10 @@ public enum TL {
|
||||
COMMAND_TITLE_CHANGED("%1$s changed a title: %2$s"),
|
||||
COMMAND_TITLE_DESCRIPTION("Set or remove a players title"),
|
||||
|
||||
COMMAND_TITLETOGGLE_TOGGLED("You have changed your title setting to &c%1$s"),
|
||||
COMMAND_TITLETOGGLE_DESCRIPTION("Toggle titles to be served to you"),
|
||||
|
||||
|
||||
COMMAND_TOGGLEALLIANCECHAT_DESCRIPTION("Toggles whether or not you will see alliance chat"),
|
||||
COMMAND_TOGGLEALLIANCECHAT_IGNORE("Alliance chat is now ignored"),
|
||||
COMMAND_TOGGLEALLIANCECHAT_UNIGNORE("Alliance chat is no longer ignored"),
|
||||
|
@ -104,6 +104,7 @@ permissions:
|
||||
factions.show: true
|
||||
factions.stuck: true
|
||||
factions.tag: true
|
||||
factions.toggletitles: true
|
||||
factions.title: true
|
||||
factions.version: true
|
||||
factions.unclaim: true
|
||||
|
Loading…
Reference in New Issue
Block a user