F TNT Take Fix

This commit is contained in:
Driftay
2019-07-27 22:49:45 -04:00
parent 4a794fe706
commit 11fb6dcd7d
17 changed files with 649 additions and 34 deletions

View File

@@ -0,0 +1,26 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.shop.ShopGUI;
import com.massivecraft.factions.zcore.util.TL;
public class CmdShop extends FCommand {
public CmdShop() {
this.aliases.add("shop");
this.senderMustBePlayer = true;
this.senderMustBeColeader = true;
}
@Override
public void perform() {
ShopGUI shopGUI = new ShopGUI(p, fme);
shopGUI.build();
fme.getPlayer().openInventory(shopGUI.getInventory());
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_SHOP_DESCRIPTION;
}
}

View File

@@ -102,8 +102,8 @@ public class CmdTnt extends FCommand {
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH);
return;
}
int fullStacks = amount / 64;
int remainderAmt = amount % 64;
int fullStacks = Math.round(amount / 6);
int remainderAmt = amount - (fullStacks * 64);
if ((remainderAmt == 0 && !hasAvaliableSlot(me, fullStacks))) {
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE);
return;
@@ -112,14 +112,10 @@ public class CmdTnt extends FCommand {
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE);
return;
}
ItemStack tnt64 = new ItemStack(Material.TNT, 64);
for (int i = 0; i <= fullStacks - 1; i++) {
me.getInventory().addItem(tnt64);
}
if (remainderAmt != 0) {
ItemStack tnt = new ItemStack(Material.TNT, remainderAmt);
me.getInventory().addItem(tnt);
}
for (int i = 0; i <= fullStacks - 1; i++) me.getPlayer().getInventory().addItem(new ItemStack(Material.TNT, 64));
if (remainderAmt != 0) me.getPlayer().getInventory().addItem(new ItemStack(Material.TNT, remainderAmt));
fme.getFaction().takeTnt(amount);
me.updateInventory();
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_SUCCESS);
@@ -132,22 +128,8 @@ public class CmdTnt extends FCommand {
}
public boolean inventoryContains(Inventory inventory, ItemStack item) {
int count = 0;
ItemStack[] items = inventory.getContents();
for (int i = 0; i < items.length; i++) {
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
count += items[i].getAmount();
}
if (count >= item.getAmount()) {
return true;
}
}
return false;
}
public boolean hasAvaliableSlot(Player player, int howmany) {
Integer check = 0;
int check = 0;
for (ItemStack item : player.getInventory().getContents()) {
if (item == null) {
check++;

View File

@@ -34,9 +34,7 @@ public class CmdViewChest extends FCommand {
if (faction == null) {
return;
}
me.openInventory(faction.getChestInventory());
}
@Override

View File

@@ -124,6 +124,7 @@ public class FCmdRoot extends FCommand {
public CmdFGlobal cmdFGlobal = new CmdFGlobal();
public CmdViewChest cmdViewChest = new CmdViewChest();
public CmdPoints cmdPoints = new CmdPoints();
public CmdShop cmdShop = new CmdShop();
@@ -242,7 +243,7 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdCorner);
this.addSubCommand(this.cmdFGlobal);
this.addSubCommand(this.cmdViewChest);
this.addSubCommand(this.cmdShop);
if (SaberFactions.plugin.getConfig().getBoolean("f-inventory-see.Enabled")) {
this.addSubCommand(this.cmdInventorySee);