2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-05-08 17:44:00 +02:00
|
|
|
|
2018-07-20 18:42:47 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
2018-10-23 01:42:57 +02:00
|
|
|
import com.massivecraft.factions.SavageFactions;
|
2018-12-09 03:13:18 +01:00
|
|
|
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
|
2011-10-09 14:53:38 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2011-09-13 05:23:44 +02:00
|
|
|
import com.massivecraft.factions.struct.Role;
|
2018-08-05 03:32:36 +02:00
|
|
|
import com.massivecraft.factions.zcore.fperms.Access;
|
|
|
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2018-07-21 03:32:46 +02:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
public class CmdDisband extends FCommand {
|
2014-08-05 17:17:27 +02:00
|
|
|
|
2018-07-21 03:32:46 +02:00
|
|
|
|
|
|
|
private static HashMap<String, String> disbandMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public CmdDisband() {
|
2014-07-01 22:10:18 +02:00
|
|
|
super();
|
|
|
|
this.aliases.add("disband");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
|
|
|
this.optionalArgs.put("faction tag", "yours");
|
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.permission = Permission.DISBAND.node;
|
|
|
|
this.disableOnLock = true;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
senderMustBePlayer = false;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = false;
|
2018-03-26 23:43:15 +02:00
|
|
|
senderMustBeColeader = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
senderMustBeAdmin = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
|
|
|
// The faction, default to your own.. but null if console sender.
|
2014-07-01 22:10:18 +02:00
|
|
|
Faction faction = this.argAsFaction(0, fme == null ? null : myFaction);
|
|
|
|
if (faction == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2018-11-07 17:14:42 +01:00
|
|
|
if (!fme.isAdminBypassing()) {
|
2018-10-01 23:53:10 +02:00
|
|
|
Access access = faction.getAccess(fme, PermissableAction.DISBAND);
|
2018-11-07 06:38:59 +01:00
|
|
|
if (fme.getRole() != Role.LEADER && access != Access.ALLOW) {
|
2018-10-01 23:53:10 +02:00
|
|
|
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag());
|
2018-09-09 00:28:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2018-10-01 23:53:10 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
if (!faction.isNormal()) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_DISBAND_IMMUTABLE.toString());
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (faction.isPermanent()) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString());
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2018-07-21 03:32:46 +02:00
|
|
|
|
|
|
|
// check for tnt before disbanding.
|
|
|
|
|
2018-11-07 17:14:42 +01:00
|
|
|
if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) {
|
2018-07-21 03:32:46 +02:00
|
|
|
msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
|
|
|
|
disbandMap.put(me.getUniqueId().toString(), faction.getId());
|
2018-11-07 06:38:59 +01:00
|
|
|
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() {
|
2018-07-21 03:32:46 +02:00
|
|
|
@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) {
|
2018-12-09 03:13:18 +01:00
|
|
|
faction.disband(me, PlayerDisbandReason.COMMAND);
|
2018-07-21 03:32:46 +02:00
|
|
|
}
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_DISBAND_DESCRIPTION;
|
|
|
|
}
|
2011-05-08 17:44:00 +02:00
|
|
|
}
|