Added Configurable Option to Broadcast Disband and Create Messages For Factions

**More Coming Soon**
This commit is contained in:
Driftay 2019-02-09 13:33:02 -05:00
parent ce98d68518
commit 3559a9f090
7 changed files with 50 additions and 23 deletions

View File

@ -90,11 +90,11 @@ public class CmdCreate extends FCommand {
// That way we don't have to mess up deleting more stuff. // That way we don't have to mess up deleting more stuff.
// And prevent the user from being returned to NORMAL after deleting his old faction. // And prevent the user from being returned to NORMAL after deleting his old faction.
fme.setRole(Role.LEADER); fme.setRole(Role.LEADER);
if (SavageFactions.plugin.getConfig().getBoolean("faction-creation-broadcast", true)) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) { for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
follower.msg(TL.COMMAND_CREATE_CREATED, fme.describeTo(follower, true), faction.getTag(follower)); follower.msg(TL.COMMAND_CREATE_CREATED, fme.describeTo(follower, true), faction.getTag(follower));
} }
}
msg(TL.COMMAND_CREATE_YOUSHOULD, p.cmdBase.cmdDescription.getUseageTemplate()); msg(TL.COMMAND_CREATE_YOUSHOULD, p.cmdBase.cmdDescription.getUseageTemplate());
if (Conf.logFactionCreate) { if (Conf.logFactionCreate) {

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.SavageFactions; import com.massivecraft.factions.SavageFactions;
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason; import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
@ -76,7 +78,6 @@ public class CmdDisband extends FCommand {
return; return;
} }
// check for tnt before disbanding. // check for tnt before disbanding.
if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) { if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) {
@ -88,14 +89,25 @@ public class CmdDisband extends FCommand {
disbandMap.remove(me.getUniqueId().toString()); disbandMap.remove(me.getUniqueId().toString());
} }
}, 200L); }, 200L);
} else if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) {
if (SavageFactions.plugin.getConfig().getBoolean("faction-disband-broadcast", true)) {
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
String amountString = senderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fme.describeTo(follower);
if (follower.getFaction() == faction) {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
} else { } else {
//Check if the faction we asked confirmation for is the one being disbanded. follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) { }
}
faction.disband(me, PlayerDisbandReason.COMMAND); faction.disband(me, PlayerDisbandReason.COMMAND);
} else {
faction.disband(me, PlayerDisbandReason.COMMAND);
me.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
} }
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.COMMAND_DISBAND_DESCRIPTION; return TL.COMMAND_DISBAND_DESCRIPTION;

View File

@ -99,7 +99,7 @@ public class CmdTnt extends FCommand {
return; return;
} }
if (fme.getFaction().getTnt() < amount) { if (fme.getFaction().getTnt() < amount) {
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH.toString()); fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH);
return; return;
} }
int fullStacks = amount / 64; int fullStacks = amount / 64;

View File

@ -39,7 +39,7 @@ public class FTeamWrapper {
return; return;
} }
if (!SavageFactions.plugin.getConfig().getBoolean("scoreboard.default-prefixes", false)) { if (!SavageFactions.plugin.getConfig().getBoolean("scoreboard.default-prefixes", false) || SavageFactions.plugin.getConfig().getBoolean("See-Invisible-Faction-Members")) {
return; return;
} }
@ -64,7 +64,7 @@ public class FTeamWrapper {
return; return;
} }
if (!SavageFactions.plugin.getConfig().getBoolean("scoreboard.default-prefixes", false)) { if (!SavageFactions.plugin.getConfig().getBoolean("scoreboard.default-prefixes", false) || SavageFactions.plugin.getConfig().getBoolean("See-Invisible-Faction-Members")) {
return; return;
} }
@ -168,8 +168,13 @@ public class FTeamWrapper {
FPlayer fplayer = fboard.getFPlayer(); FPlayer fplayer = fboard.getFPlayer();
Team team = teams.get(fboard); Team team = teams.get(fboard);
boolean focused = false; boolean focused = false;
if (SavageFactions.plugin.getConfig().getBoolean("See-Invisible-Faction-Members", false)) {
team.setCanSeeFriendlyInvisibles(true);
}
if ((SavageFactions.plugin.getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) { if ((SavageFactions.plugin.getConfig().getBoolean("ffocus.Enabled")) && (fplayer.getFaction() != null) && (fplayer.getFaction().getFocused() != null)) {
for (FPlayer fp : this.faction.getFPlayersWhereOnline(true)) { for (FPlayer fp : faction.getFPlayersWhereOnline(true)) {
if (fplayer.getFaction().getFocused().equalsIgnoreCase(fp.getName())) { if (fplayer.getFaction().getFocused().equalsIgnoreCase(fp.getName())) {
team.setPrefix(ChatColor.translateAlternateColorCodes('&', SavageFactions.plugin.getConfig().getString("ffocus.Prefix", "&7»&b"))); team.setPrefix(ChatColor.translateAlternateColorCodes('&', SavageFactions.plugin.getConfig().getString("ffocus.Prefix", "&7»&b")));
focused = true; focused = true;
@ -181,9 +186,9 @@ public class FTeamWrapper {
prefix = PlaceholderAPI.setPlaceholders(fplayer.getPlayer(), prefix); prefix = PlaceholderAPI.setPlaceholders(fplayer.getPlayer(), prefix);
prefix = PlaceholderAPI.setBracketPlaceholders(fplayer.getPlayer(), prefix); prefix = PlaceholderAPI.setBracketPlaceholders(fplayer.getPlayer(), prefix);
prefix = prefix.replace("{relationcolor}", this.faction.getRelationTo(fplayer).getColor().toString()); prefix = prefix.replace("{relationcolor}", faction.getRelationTo(fplayer).getColor().toString());
prefix = prefix.replace("{faction}", prefix = prefix.replace("{faction}",
this.faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), this.faction.getTag().length()))); faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length())));
if ((team.getPrefix() == null) || (!team.getPrefix().equals(prefix))) { if ((team.getPrefix() == null) || (!team.getPrefix().equals(prefix))) {
team.setPrefix(prefix); team.setPrefix(prefix);
} }

View File

@ -260,15 +260,6 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
Bukkit.getServer().getPluginManager().callEvent(new FPlayerLeaveEvent(fplayer, this, FPlayerLeaveEvent.PlayerLeaveReason.DISBAND)); Bukkit.getServer().getPluginManager().callEvent(new FPlayerLeaveEvent(fplayer, this, FPlayerLeaveEvent.PlayerLeaveReason.DISBAND));
} }
// Inform all players
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
String who = disbanderIsConsole ? TL.GENERIC_SERVERADMIN.toString() : fdisbander.describeTo(fplayer);
if (fplayer.getFaction() == this) {
fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, who);
} else {
fplayer.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, who, this.getTag(fplayer));
}
}
if (Conf.logFactionDisband) { if (Conf.logFactionDisband) {
//TODO: Format this correctly and translate. //TODO: Format this correctly and translate.
SavageFactions.plugin.log("The faction " + this.getTag() + " (" + this.getId() + ") was disbanded by " + (disbanderIsConsole ? "console command" : fdisbander.getName()) + "."); SavageFactions.plugin.log("The faction " + this.getTag() + " (" + this.getId() + ") was disbanded by " + (disbanderIsConsole ? "console command" : fdisbander.getName()) + ".");

View File

@ -276,6 +276,7 @@ public enum TL {
COMMAND_DISBAND_BROADCAST_YOURS("&c&l[!]&7 &c%1$s&7 disbanded your &cfaction."), COMMAND_DISBAND_BROADCAST_YOURS("&c&l[!]&7 &c%1$s&7 disbanded your &cfaction."),
COMMAND_DISBAND_BROADCAST_NOTYOURS("&c&l[!]&7 &c%1$s<i> &7disbanded the faction &c%2$s."), COMMAND_DISBAND_BROADCAST_NOTYOURS("&c&l[!]&7 &c%1$s<i> &7disbanded the faction &c%2$s."),
COMMAND_DISBAND_HOLDINGS("&c&l[!]&7 &7You have been given the disbanded &cfaction's bank&7, totaling &c%1$s."), COMMAND_DISBAND_HOLDINGS("&c&l[!]&7 &7You have been given the disbanded &cfaction's bank&7, totaling &c%1$s."),
COMMAND_DISBAND_PLAYER("&c&l[!] &7You have disbanded your &cfaction"),
COMMAND_DISBAND_CONFIRM("&c&l[!]&7 Your Faction has&c {tnt} &7tnt left in the bank, it will be &clost&7 if the faction is &cdisbanded&7. Type&c /f disband &7again within &c10&7 seconds to&c disband&7."), COMMAND_DISBAND_CONFIRM("&c&l[!]&7 Your Faction has&c {tnt} &7tnt left in the bank, it will be &clost&7 if the faction is &cdisbanded&7. Type&c /f disband &7again within &c10&7 seconds to&c disband&7."),
COMMAND_DISBAND_DESCRIPTION("Disband a faction"), COMMAND_DISBAND_DESCRIPTION("Disband a faction"),

View File

@ -691,6 +691,22 @@ fwarp-gui:
name: ' ' name: ' '
lore: lore:
- -
############################################################
# +------------------------------------------------------+ #
# | Faction Creation/Disband Broadcast | #
# +------------------------------------------------------+ #
############################################################
faction-creation-broadcast: true
faction-disband-broadcast: true
############################################################
# +------------------------------------------------------+ #
# | Faction Invisibility | #
# +------------------------------------------------------+ #
############################################################
See-Invisible-Faction-Members: false
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction Rules | # # | Faction Rules | #
@ -749,6 +765,7 @@ ffocus:
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction Vault | # # | Faction Vault | #
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
############################################################
fvault: fvault:
Enabled: true Enabled: true
No-Hoppers-near-vault: true No-Hoppers-near-vault: true
@ -766,6 +783,7 @@ fvault:
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction Chest | # # | Faction Chest | #
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
############################################################
fchest: fchest:
Enabled: true Enabled: true
Inventory-Title: '&2&lFaction Chest' Inventory-Title: '&2&lFaction Chest'