Change any command (: also refixed tntfill

This commit is contained in:
DroppingAnvil
2020-01-01 19:59:31 -06:00
committed by droppinganvil
parent 4c90bae87c
commit 05e1a7297c
135 changed files with 342 additions and 234 deletions

View File

@@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd.tnt;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.Aliases;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand;
@@ -28,7 +29,7 @@ public class CmdTntFill extends FCommand {
public CmdTntFill() {
super();
this.aliases.add("tntfill");
this.aliases.addAll(Aliases.tnt_tntfill);
this.requiredArgs.add("radius");
this.requiredArgs.add("amount");
@@ -110,7 +111,7 @@ public class CmdTntFill extends FCommand {
}
// Take TNT from the bank.
removeFromBank(context, getFactionTnt);
context.faction.takeTnt(getFactionTnt);
}
fillDispensers(context.fPlayer, opDispensers, amount);
// Remove used TNT from player inventory.
@@ -119,8 +120,9 @@ public class CmdTntFill extends FCommand {
// Actually fill every dispenser with the precise amount.
private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) {
for (Dispenser dispenser : dispensers) {
takeTnt(fPlayer, count);
dispenser.getInventory().addItem(new ItemStack(Material.TNT, count));
if (takeTnt(fPlayer, count)) {
dispenser.getInventory().addItem(new ItemStack(Material.TNT, count));
} else {return;}
}
}
@@ -161,7 +163,7 @@ public class CmdTntFill extends FCommand {
context.player.updateInventory();
}
private void takeTnt(FPlayer fme, int amount) {
private boolean takeTnt(FPlayer fme, int amount) {
Inventory inv = fme.getPlayer().getInventory();
int invTnt = 0;
for (int i = 0; i <= inv.getSize(); i++) {
@@ -174,14 +176,15 @@ public class CmdTntFill extends FCommand {
}
if (amount > invTnt) {
fme.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
return;
return false;
}
ItemStack tnt = new ItemStack(Material.TNT, amount);
if (fme.getFaction().getTnt() + amount > FactionsPlugin.instance.getConfig().getInt("ftnt.Bank-Limit")) {
if (fme.getFaction().getTnt() + amount > FactionsPlugin.getInstance().getConfig().getInt("ftnt.Bank-Limit")) {
fme.msg(TL.COMMAND_TNT_EXCEEDLIMIT.toString());
return;
return false;
}
removeFromInventory(fme.getPlayer().getInventory(), tnt);
return true;
}
// Counts the item type available in the inventory.