Showing Dropping Anvil Something (Ignore)
This commit is contained in:
@@ -17,85 +17,85 @@ import java.util.HashMap;
|
||||
public class CmdDisband extends FCommand {
|
||||
|
||||
|
||||
private static HashMap<String, String> disbandMap = new HashMap<>();
|
||||
private static HashMap<String, String> disbandMap = new HashMap<>();
|
||||
|
||||
|
||||
public CmdDisband() {
|
||||
super();
|
||||
this.aliases.add("disband");
|
||||
public CmdDisband() {
|
||||
super();
|
||||
this.aliases.add("disband");
|
||||
|
||||
this.optionalArgs.put("faction tag", "yours");
|
||||
this.optionalArgs.put("faction tag", "yours");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.DISBAND)
|
||||
.build();
|
||||
this.requirements = new CommandRequirements.Builder(Permission.DISBAND)
|
||||
.build();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
// The faction, default to your own.. but null if console sender.
|
||||
Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : context.faction);
|
||||
if (faction == null) return;
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
// The faction, default to your own.. but null if console sender.
|
||||
Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : context.faction);
|
||||
if (faction == null) return;
|
||||
|
||||
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
|
||||
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
|
||||
|
||||
if (!isMyFaction) {
|
||||
if (!Permission.DISBAND_ANY.has(context.sender, true)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!isMyFaction) {
|
||||
if (!Permission.DISBAND_ANY.has(context.sender, true)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (context.fPlayer != null && !context.fPlayer.isAdminBypassing()) {
|
||||
Access access = faction.getAccess(context.fPlayer, PermissableAction.DISBAND);
|
||||
if (context.fPlayer.getRole() != Role.LEADER && faction.getFPlayerLeader() != context.fPlayer && access != Access.ALLOW) {
|
||||
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (context.fPlayer != null && !context.fPlayer.isAdminBypassing()) {
|
||||
Access access = faction.getAccess(context.fPlayer, PermissableAction.DISBAND);
|
||||
if (context.fPlayer.getRole() != Role.LEADER && faction.getFPlayerLeader() != context.fPlayer && access != Access.ALLOW) {
|
||||
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!faction.isNormal()) {
|
||||
context.msg(TL.COMMAND_DISBAND_IMMUTABLE.toString());
|
||||
return;
|
||||
}
|
||||
if (faction.isPermanent()) {
|
||||
context.msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString());
|
||||
return;
|
||||
}
|
||||
if (!faction.isNormal()) {
|
||||
context.msg(TL.COMMAND_DISBAND_IMMUTABLE.toString());
|
||||
return;
|
||||
}
|
||||
if (faction.isPermanent()) {
|
||||
context.msg(TL.COMMAND_DISBAND_MARKEDPERMANENT.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
// THis means they are a console command sender.
|
||||
if (context.player == null) {
|
||||
faction.disband(null, PlayerDisbandReason.PLUGIN);
|
||||
return;
|
||||
}
|
||||
// THis means they are a console command sender.
|
||||
if (context.player == null) {
|
||||
faction.disband(null, PlayerDisbandReason.PLUGIN);
|
||||
return;
|
||||
}
|
||||
|
||||
// check for tnt before disbanding.
|
||||
if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) {
|
||||
context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
|
||||
disbandMap.put(context.player.getUniqueId().toString(), faction.getId());
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.getInstance(), () -> disbandMap.remove(context.player.getUniqueId().toString()), 200L);
|
||||
} else if (faction.getId().equals(disbandMap.get(context.player.getUniqueId().toString())) || faction.getTnt() == 0) {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast", true)) {
|
||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
|
||||
UtilFly.checkFly(context.fPlayer, Board.getInstance().getFactionAt(new FLocation(follower)));
|
||||
if (follower.getFaction() == faction) {
|
||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
|
||||
} else {
|
||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
||||
// check for tnt before disbanding.
|
||||
if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) {
|
||||
context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
|
||||
disbandMap.put(context.player.getUniqueId().toString(), faction.getId());
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.getInstance(), () -> disbandMap.remove(context.player.getUniqueId().toString()), 200L);
|
||||
} else if (faction.getId().equals(disbandMap.get(context.player.getUniqueId().toString())) || faction.getTnt() == 0) {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast", true)) {
|
||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
|
||||
UtilFly.checkFly(context.fPlayer, Board.getInstance().getFactionAt(new FLocation(follower)));
|
||||
if (follower.getFaction() == faction) {
|
||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
|
||||
} else {
|
||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
||||
}
|
||||
}
|
||||
}
|
||||
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||
} else {
|
||||
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
|
||||
}
|
||||
}
|
||||
}
|
||||
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||
} else {
|
||||
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_DISBAND_DESCRIPTION;
|
||||
}
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_DISBAND_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user