From 1e36c9f744b75e757072bf1b9fc15ba7a92279de Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Sat, 19 Jan 2019 12:21:28 +0100 Subject: [PATCH] Make accidental faction disbanding more difficult --- .../factions/cmd/CmdFactionsDisband.java | 13 +++++++++---- src/com/massivecraft/factions/entity/MConf.java | 5 ++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java b/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java index 1bb02233..60a9421f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java @@ -12,6 +12,8 @@ import com.massivecraft.factions.event.EventFactionsDisband; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.massivecore.MassiveException; +import com.massivecraft.massivecore.command.type.primitive.TypeStringConfirmation; +import com.massivecraft.massivecore.util.ConfirmationUtil; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.Txt; @@ -24,7 +26,8 @@ public class CmdFactionsDisband extends FactionsCommand public CmdFactionsDisband() { // Parameters - this.addParameter(TypeFaction.get(), "faction", "you"); + this.addParameter(TypeFaction.get(), "faction"); + this.addParameter(TypeStringConfirmation.get(), "confirmation", ""); } // -------------------------------------------- // @@ -35,7 +38,10 @@ public class CmdFactionsDisband extends FactionsCommand public void perform() throws MassiveException { // Args - Faction faction = this.readArg(msenderFaction); + Faction faction = this.readArg(); + String confirmationString = this.readArg(null); + + if(MConf.get().requireConfirmationForFactionDisbanding) ConfirmationUtil.tryConfirm(this); // MPerm if ( ! MPerm.getPermDisband().has(msender, faction, true)) return; @@ -43,8 +49,7 @@ public class CmdFactionsDisband extends FactionsCommand // Verify if (faction.getFlag(MFlag.getFlagPermanent())) { - msg("This faction is designated as permanent, so you cannot disband it."); - return; + throw new MassiveException().addMsg("This faction is designated as permanent, so you cannot disband it."); } // Event diff --git a/src/com/massivecraft/factions/entity/MConf.java b/src/com/massivecraft/factions/entity/MConf.java index 17c5e605..26d64555 100644 --- a/src/com/massivecraft/factions/entity/MConf.java +++ b/src/com/massivecraft/factions/entity/MConf.java @@ -335,6 +335,9 @@ public class MConf extends Entity // Protects the faction land from piston extending/retracting // through the denying of MPerm build public boolean handlePistonProtectionThroughDenyBuild = true; + + // Make faction disbanding a confirmation thing + public boolean requireConfirmationForFactionDisbanding = true; // -------------------------------------------- // // DENY COMMANDS @@ -474,7 +477,7 @@ public class MConf extends Entity // -------------------------------------------- // // PREFIXES // -------------------------------------------- // - + // Here you may edit the name prefixes associated with different faction ranks. public String prefixLeader = "**"; public String prefixOfficer = "*";