2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.skills.unarmed;
|
|
|
|
|
2013-04-10 19:20:25 +02:00
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Item;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import org.bukkit.inventory.PlayerInventory;
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
|
|
|
import com.gmail.nossr50.config.Config;
|
|
|
|
|
|
|
|
public class Unarmed {
|
2013-08-18 08:38:40 +02:00
|
|
|
public static int ironArmMinBonusDamage = AdvancedConfig.getInstance().getIronArmMinBonus();
|
2013-03-01 06:52:01 +01:00
|
|
|
public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus();
|
|
|
|
public static int ironArmIncreaseLevel = AdvancedConfig.getInstance().getIronArmIncreaseLevel();
|
|
|
|
|
|
|
|
public static int disarmMaxBonusLevel = AdvancedConfig.getInstance().getDisarmMaxBonusLevel();
|
|
|
|
public static double disarmMaxChance = AdvancedConfig.getInstance().getDisarmChanceMax();
|
|
|
|
|
|
|
|
public static int deflectMaxBonusLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel();
|
|
|
|
public static double deflectMaxChance = AdvancedConfig.getInstance().getDeflectChanceMax();
|
|
|
|
|
|
|
|
public static int ironGripMaxBonusLevel = AdvancedConfig.getInstance().getIronGripMaxBonusLevel();
|
|
|
|
public static double ironGripMaxChance = AdvancedConfig.getInstance().getIronGripChanceMax();
|
|
|
|
|
|
|
|
public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked();
|
|
|
|
|
|
|
|
public static double berserkDamageModifier = 1.5;
|
2013-04-10 19:20:25 +02:00
|
|
|
|
|
|
|
public static boolean handleItemPickup(PlayerInventory inventory, Item drop) {
|
|
|
|
ItemStack dropStack = drop.getItemStack();
|
|
|
|
int firstEmpty = inventory.firstEmpty();
|
2013-08-03 17:34:55 +02:00
|
|
|
int dropAmount = dropStack.getAmount();
|
2013-04-10 19:20:25 +02:00
|
|
|
|
|
|
|
if (inventory.containsAtLeast(dropStack, 1)) {
|
|
|
|
int nextSlot = 0;
|
|
|
|
|
|
|
|
for (Iterator<ItemStack> iterator = inventory.iterator(); iterator.hasNext();) {
|
|
|
|
ItemStack itemstack = iterator.next();
|
|
|
|
|
2013-04-10 20:04:46 +02:00
|
|
|
if (dropStack.isSimilar(itemstack)) {
|
2013-04-10 19:20:25 +02:00
|
|
|
int itemAmount = itemstack.getAmount();
|
|
|
|
int itemMax = itemstack.getMaxStackSize();
|
|
|
|
|
|
|
|
ItemStack addStack = itemstack.clone();
|
|
|
|
|
2013-05-18 22:41:42 +02:00
|
|
|
if (dropAmount + itemAmount <= itemMax) {
|
2013-04-10 19:20:25 +02:00
|
|
|
drop.remove();
|
|
|
|
addStack.setAmount(dropAmount + itemAmount);
|
|
|
|
inventory.setItem(nextSlot, addStack);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
addStack.setAmount(itemMax);
|
|
|
|
dropAmount = dropAmount + itemAmount - itemMax;
|
|
|
|
inventory.setItem(nextSlot, addStack);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dropAmount == 0) {
|
|
|
|
drop.remove();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nextSlot++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (firstEmpty == inventory.getHeldItemSlot()) {
|
|
|
|
int nextSlot = firstEmpty + 1;
|
|
|
|
|
|
|
|
for (Iterator<ItemStack> iterator = inventory.iterator(nextSlot); iterator.hasNext();) {
|
|
|
|
ItemStack itemstack = iterator.next();
|
|
|
|
|
|
|
|
if (itemstack == null) {
|
|
|
|
drop.remove();
|
2013-08-03 17:34:55 +02:00
|
|
|
dropStack.setAmount(dropAmount);
|
2013-04-10 19:20:25 +02:00
|
|
|
inventory.setItem(nextSlot, dropStack);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nextSlot++;
|
|
|
|
}
|
2013-08-04 17:34:04 +02:00
|
|
|
} else if (firstEmpty != -1) {
|
2013-08-04 17:38:52 +02:00
|
|
|
drop.remove();
|
2013-08-04 17:34:04 +02:00
|
|
|
dropStack.setAmount(dropAmount);
|
|
|
|
inventory.setItem(firstEmpty, dropStack);
|
|
|
|
return true;
|
2013-04-10 19:20:25 +02:00
|
|
|
}
|
|
|
|
|
2013-08-04 17:56:37 +02:00
|
|
|
drop.remove();
|
|
|
|
return true;
|
2013-04-10 19:20:25 +02:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|