Made a check for tnt when disbanding.
This commit is contained in:
parent
408725c1d7
commit
e9b080bc9e
@ -1,13 +1,22 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
|
||||||
public class CmdDisband extends FCommand {
|
public class CmdDisband extends FCommand {
|
||||||
|
|
||||||
|
|
||||||
|
private static HashMap<String, String> disbandMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CmdDisband() {
|
public CmdDisband() {
|
||||||
super();
|
super();
|
||||||
this.aliases.add("disband");
|
this.aliases.add("disband");
|
||||||
@ -54,9 +63,27 @@ public class CmdDisband extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Success
|
|
||||||
|
// check for tnt before disbanding.
|
||||||
|
|
||||||
|
if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) {
|
||||||
|
msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
|
||||||
|
disbandMap.put(me.getUniqueId().toString(), faction.getId());
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
disbandMap.remove(me.getUniqueId().toString());
|
||||||
|
}
|
||||||
|
}, 200L);
|
||||||
|
} else {
|
||||||
|
//Check if the faction we asked confirmation for is the one being disbanded.
|
||||||
|
if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) {
|
||||||
faction.disband(me);
|
faction.disband(me);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TL getUsageTranslation() {
|
public TL getUsageTranslation() {
|
||||||
|
@ -278,6 +278,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_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"),
|
||||||
|
|
||||||
COMMAND_FLY_DISABLED("&c&l[!]&7 Sorry, Faction flight is &cdisabled &7on this server"),
|
COMMAND_FLY_DISABLED("&c&l[!]&7 Sorry, Faction flight is &cdisabled &7on this server"),
|
||||||
|
Loading…
Reference in New Issue
Block a user