use of org.bukkit.inventory.ItemStack in project EliteMobs by MagmaGuy.
the class ChickenHandler method superEggs.
public static void superEggs(Entity entity, int passiveStackAmount) {
List<Chicken> tempChickenList = new ArrayList<>();
if (entity instanceof Chicken && entity.hasMetadata(MetadataHandler.PASSIVE_ELITE_MOB_MD)) {
tempChickenList.add((Chicken) entity);
}
if (tempChickenList.size() > 0) {
Random random = new Random();
int eggChance = random.nextInt(12000 / passiveStackAmount);
//should spawn 1 by 1 but the odds of it spawning are scaled to fit config passivemob stack size
if (eggChance == 1) {
for (Chicken chicken : tempChickenList) {
ItemStack eggStack = new ItemStack(EGG, 1);
chicken.getWorld().dropItem(chicken.getLocation(), eggStack).setVelocity(ItemDropVelocity.ItemDropVelocity());
}
}
}
}
use of org.bukkit.inventory.ItemStack in project EliteMobs by MagmaGuy.
the class DropsHandler method onDeath.
@EventHandler
public void onDeath(EntityDeathEvent event) {
if (event.getEntity().hasMetadata(MetadataHandler.ELITE_MOB_MD) && !event.getEntity().hasMetadata(MetadataHandler.FORBIDDEN_MD) && event.getEntity().getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() > 1) {
List<ItemStack> droppedItems = event.getDrops();
int mobLevel = (int) (event.getEntity().getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() * ConfigValues.defaultConfig.getDouble("Aggressive EliteMob default loot multiplier"));
for (ItemStack itemStack : droppedItems) {
for (int i = 0; i < mobLevel; i++) {
event.getEntity().getLocation().getWorld().dropItem(event.getEntity().getLocation(), itemStack);
}
}
int droppedXP = event.getDroppedExp();
event.setDroppedExp(droppedXP * mobLevel);
}
}
use of org.bukkit.inventory.ItemStack in project Essentials by drtshock.
the class Commandhat method run.
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
if (args.length > 0 && (args[0].contains("rem") || args[0].contains("off") || args[0].equalsIgnoreCase("0"))) {
final PlayerInventory inv = user.getBase().getInventory();
final ItemStack head = inv.getHelmet();
if (head == null || head.getType() == Material.AIR) {
user.sendMessage(tl("hatEmpty"));
} else {
final ItemStack air = new ItemStack(Material.AIR);
inv.setHelmet(air);
InventoryWorkaround.addItems(user.getBase().getInventory(), head);
user.sendMessage(tl("hatRemoved"));
}
} else {
if (user.getBase().getItemInHand().getType() != Material.AIR) {
final ItemStack hand = user.getBase().getItemInHand();
if (hand.getType().getMaxDurability() == 0) {
final PlayerInventory inv = user.getBase().getInventory();
final ItemStack head = inv.getHelmet();
inv.setHelmet(hand);
inv.setItemInHand(head);
user.sendMessage(tl("hatPlaced"));
} else {
user.sendMessage(tl("hatArmor"));
}
} else {
user.sendMessage(tl("hatFail"));
}
}
}
use of org.bukkit.inventory.ItemStack in project Essentials by drtshock.
the class Commanditemdb method run.
@Override
protected void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception {
ItemStack itemStack = null;
boolean itemHeld = false;
if (args.length < 1) {
if (sender.isPlayer()) {
itemHeld = true;
itemStack = sender.getPlayer().getItemInHand();
}
if (itemStack == null) {
throw new NotEnoughArgumentsException();
}
} else {
itemStack = ess.getItemDb().get(args[0]);
}
sender.sendMessage(tl("itemType", itemStack.getType().toString(), itemStack.getTypeId() + ":" + Integer.toString(itemStack.getDurability())));
if (itemHeld && itemStack.getType() != Material.AIR) {
int maxuses = itemStack.getType().getMaxDurability();
int durability = ((maxuses + 1) - itemStack.getDurability());
if (maxuses != 0) {
sender.sendMessage(tl("durability", Integer.toString(durability)));
}
}
final String itemNameList = ess.getItemDb().names(itemStack);
if (itemNameList != null) {
sender.sendMessage(tl("itemNames", ess.getItemDb().names(itemStack)));
}
}
use of org.bukkit.inventory.ItemStack in project Essentials by drtshock.
the class Commandpowertool method run.
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
final String command = getFinalArg(args, 0);
final ItemStack itemStack = user.getBase().getItemInHand();
powertool(server, user.getSource(), user, commandLabel, itemStack, command);
}
Aggregations