use of org.bukkit.inventory.ItemStack in project EliteMobs by MagmaGuy.
the class GetLootCommandHandler method getLootHandler.
public boolean getLootHandler(Player player, String args1) {
for (ItemStack itemStack : lootList) {
String itemRawName = itemStack.getItemMeta().getDisplayName();
//TODO: shouldn't happen, weird
if (itemRawName == null) {
return false;
}
String itemProcessedName = itemRawName.replaceAll(" ", "_").toLowerCase();
if (itemProcessedName.equalsIgnoreCase(args1) && player.isValid()) {
player.getInventory().addItem(itemStack);
return true;
}
}
return false;
}
use of org.bukkit.inventory.ItemStack in project EliteMobs by MagmaGuy.
the class LootGUI method lootNavigationConstructor.
private void lootNavigationConstructor(Inventory inventory) {
ItemStack arrowLeft = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta arrowLeftSkullMeta = (SkullMeta) arrowLeft.getItemMeta();
arrowLeftSkullMeta.setOwner("MHF_ArrowLeft");
arrowLeftSkullMeta.setDisplayName("Previous Loot Page");
arrowLeft.setItemMeta(arrowLeftSkullMeta);
inventory.setItem(27, arrowLeft);
ItemStack arrowRight = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta arrowRightSkullMeta = (SkullMeta) arrowRight.getItemMeta();
arrowRightSkullMeta.setOwner("MHF_ArrowRight");
arrowRightSkullMeta.setDisplayName("Next Loot Page");
arrowRight.setItemMeta(arrowRightSkullMeta);
inventory.setItem(35, arrowRight);
}
use of org.bukkit.inventory.ItemStack in project EliteMobs by MagmaGuy.
the class MinorPowerPowerStance method itemEffect.
//Secondary effect particle processing
// private void particleEffect(Entity entity, Particle particle, int particleAmount, double v, double v1, double v2, double v3) {
// if (ConfigValues.defaultConfig.getBoolean("Turn on visual effects for natural or plugin-spawned EliteMobs")) {
//
// if (ConfigValues.defaultConfig.getBoolean("Turn off visual effects for non-natural or non-plugin-spawned EliteMobs")
// && !entity.hasMetadata(MetadataHandler.NATURAL_MOB_MD)) {
//
// return;
//
// }
//
// processID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
//
// float counter = 0;
//
// public void run() {
//
// List<Location> particleLocations = powerStanceMath.cylindricalPowerStance(entity, radiusHorizontal, radiusVertical, speedHorizontal, speedVertical, counter);
//
// Location location1 = particleLocations.get(0);
// Location location2 = particleLocations.get(1);
//
// entity.getWorld().spawnParticle(particle, location1, particleAmount, v, v1, v2, v3);
// entity.getWorld().spawnParticle(particle, location2, particleAmount, v, v1, v2, v3);
//
// if (!entity.isValid()) {
//
// Bukkit.getScheduler().cancelTask(processID);
//
// }
//
// counter++;
//
// }
//
// }, 1L, 1L);
//
// }
//
// }
// public void attackConfusing(Entity entity) {
//
// particleEffect(entity, Particle.SPELL_MOB, 5, 0, 0, 0, 0.01);
//
// }
//
// public void invulnerabilityFireEffect(Entity entity) {
//
// particleEffect(entity, Particle.FLAME, 5, 0, 0, 0, 0.01);
//
// }
//Secondary effect item processing
public void itemEffect(Entity entity) {
if (ConfigValues.defaultConfig.getBoolean("Turn on visual effects for natural or plugin-spawned EliteMobs")) {
if (ConfigValues.defaultConfig.getBoolean("Turn off visual effects for non-natural or non-plugin-spawned EliteMobs") && !entity.hasMetadata(MetadataHandler.NATURAL_MOB_MD)) {
return;
}
if (entity.hasMetadata(MetadataHandler.VISUAL_EFFECT_MD)) {
return;
}
entity.setMetadata("VisualEffect", new FixedMetadataValue(plugin, true));
//contains all items around a given entity
HashMap<Integer, HashMap<Integer, List<Item>>> powerItemLocationTracker = new HashMap<>();
new BukkitRunnable() {
int attackArrowCounter = 0;
int attackBlindingCounter = 0;
int attackFireCounter = 0;
int attackFireballCounter = 0;
int attackFreezeCounter = 0;
int attackGravityCounter = 0;
int attackPoisonCounter = 0;
int attackPushCounter = 0;
int attackWeaknessCounter = 0;
int attackWebCounter = 0;
int attackWitherCounter = 0;
int bonusLootCounter = 0;
int doubleDamageCounter = 0;
int doubleHealthCounter = 0;
int invisibilityCounter = 0;
int invulnerabilityArrowCounter = 0;
int invulnerabilityFallDamageCounter = 0;
int invulnerabilityKnockbackCounter = 0;
int movementSpeedCounter = 0;
int tauntCounter = 0;
public void run() {
// int effectQuantity = 0;
int effectIteration = 0;
//apply new positioning
if (entity.hasMetadata(MetadataHandler.ATTACK_ARROW_MD)) {
ItemStack itemStack = new ItemStack(Material.ARROW, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackArrowCounter);
effectIteration++;
attackArrowCounter++;
if (attackArrowCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackArrowCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.ATTACK_BLINDING_MD)) {
ItemStack itemStack = new ItemStack(Material.EYE_OF_ENDER, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackBlindingCounter);
effectIteration++;
attackBlindingCounter++;
if (attackBlindingCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackBlindingCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.ATTACK_FIRE_MD)) {
ItemStack itemStack = new ItemStack(Material.LAVA_BUCKET, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackFireCounter);
effectIteration++;
attackFireCounter++;
if (attackFireCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackFireCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.ATTACK_FIREBALL_MD)) {
ItemStack itemStack = new ItemStack(Material.FIREBALL, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackFireballCounter);
effectIteration++;
attackFireballCounter++;
if (attackFireballCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackFireballCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.ATTACK_FREEZE_MD)) {
ItemStack itemStack = new ItemStack(Material.PACKED_ICE, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackFreezeCounter);
effectIteration++;
attackFreezeCounter++;
if (attackFreezeCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackFreezeCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.ATTACK_GRAVITY_MD)) {
ItemStack itemStack = new ItemStack(Material.ELYTRA, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackGravityCounter);
effectIteration++;
attackGravityCounter++;
if (attackGravityCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackGravityCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.ATTACK_POISON_MD)) {
ItemStack itemStack = new ItemStack(Material.EMERALD, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackPoisonCounter);
effectIteration++;
attackPoisonCounter++;
if (attackPoisonCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackPoisonCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.ATTACK_PUSH_MD)) {
ItemStack itemStack = new ItemStack(Material.PISTON_BASE, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackPushCounter);
effectIteration++;
attackPushCounter++;
if (attackPushCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackPushCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.ATTACK_WEAKNESS_MD)) {
ItemStack itemStack = new ItemStack(Material.TOTEM, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackWeaknessCounter);
effectIteration++;
attackWeaknessCounter++;
if (attackWeaknessCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackWeaknessCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.ATTACK_WEB_MD)) {
ItemStack itemStack = new ItemStack(Material.WEB, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackWebCounter);
effectIteration++;
attackWebCounter++;
if (attackWebCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackWebCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.ATTACK_WITHER_MD)) {
ItemStack itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, attackWitherCounter);
effectIteration++;
attackWitherCounter++;
if (attackWitherCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
attackWitherCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.BONUS_LOOT_MD)) {
ItemStack itemStack = new ItemStack(Material.CHEST, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, bonusLootCounter);
effectIteration++;
bonusLootCounter++;
if (bonusLootCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
bonusLootCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.DOUBLE_DAMAGE_MD)) {
ItemStack itemStack = new ItemStack(Material.GOLD_SWORD, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, doubleDamageCounter);
effectIteration++;
doubleDamageCounter++;
if (doubleDamageCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
doubleDamageCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.DOUBLE_HEALTH_MD)) {
ItemStack itemStack = new ItemStack(Material.SHIELD, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, doubleHealthCounter);
effectIteration++;
doubleHealthCounter++;
if (doubleHealthCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
doubleHealthCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.INVISIBILITY_MD)) {
ItemStack itemStack = new ItemStack(Material.THIN_GLASS, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invisibilityCounter);
effectIteration++;
invisibilityCounter++;
if (invisibilityCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
invisibilityCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.INVULNERABILITY_ARROW_MD)) {
ItemStack itemStack = new ItemStack(Material.SPECTRAL_ARROW, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invulnerabilityArrowCounter);
effectIteration++;
invulnerabilityArrowCounter++;
if (invulnerabilityArrowCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
invulnerabilityArrowCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.INVULNERABILITY_FALL_DAMAGE_MD)) {
ItemStack itemStack = new ItemStack(Material.FEATHER, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invulnerabilityFallDamageCounter);
effectIteration++;
invulnerabilityFallDamageCounter++;
if (invulnerabilityFallDamageCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
invulnerabilityFallDamageCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.INVULNERABILITY_KNOCKBACK_MD)) {
ItemStack itemStack = new ItemStack(Material.ANVIL, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, invulnerabilityKnockbackCounter);
effectIteration++;
invulnerabilityKnockbackCounter++;
if (invulnerabilityKnockbackCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
invulnerabilityKnockbackCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.MOVEMENT_SPEED_MD)) {
ItemStack itemStack = new ItemStack(Material.GOLD_BOOTS, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, movementSpeedCounter);
effectIteration++;
movementSpeedCounter++;
if (movementSpeedCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
movementSpeedCounter = 0;
}
}
if (entity.hasMetadata(MetadataHandler.TAUNT_MD)) {
ItemStack itemStack = new ItemStack(Material.JUKEBOX, 1);
itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, tauntCounter);
effectIteration++;
tauntCounter++;
if (tauntCounter >= MinorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
tauntCounter = 0;
}
}
if (!entity.isValid() || entity.isDead()) {
for (int i = 0; i < powerItemLocationTracker.size(); i++) {
for (int j = 0; j < trackAmount; j++) {
for (int h = 0; h < itemsPerTrack; h++) {
powerItemLocationTracker.get(i).get(j).get(h).remove();
powerItemLocationTracker.get(i).get(j).get(h).removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
}
}
}
entity.removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
cancel();
return;
}
}
}.runTaskTimer(plugin, 0, 5);
}
}
use of org.bukkit.inventory.ItemStack in project EliteMobs by MagmaGuy.
the class ZombieNecronomicon method necronomiconVisualEffect.
private void necronomiconVisualEffect(Zombie zombie) {
summoningEffectOn = true;
nameScroller(zombie);
if (!ConfigValues.defaultConfig.getBoolean("Turn on visual effects that indicate an attack is about to happen")) {
return;
}
new BukkitRunnable() {
int counter = 0;
HashMap<Integer, List<Item>> fourTrack = new HashMap();
@Override
public void run() {
if (!zombie.isValid() || zombie.hasAI()) {
for (List<Item> itemList : fourTrack.values()) {
for (Item item : itemList) {
item.removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
item.remove();
}
}
if (zombie.isValid()) {
zombie.setCustomName(NameHandler.customAggressiveName(zombie));
}
summoningEffectOn = false;
cancel();
return;
}
if (counter == 0) {
//establish 4tracks
for (int i = 0; i < 8; i++) {
List<Item> itemList = new ArrayList<>();
for (int j = 0; j < 4; j++) {
ItemStack itemStack = new ItemStack(Material.WRITTEN_BOOK, 1);
Item item = zombie.getWorld().dropItem(zombie.getLocation(), itemStack);
item.setGravity(false);
item.setPickupDelay(Integer.MAX_VALUE);
item.setMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, new FixedMetadataValue(plugin, true));
itemList.add(item);
}
fourTrack.put(i, itemList);
}
} else {
itemMover(fourTrack, zombie, counter);
}
counter++;
}
}.runTaskTimer(plugin, 5, 5);
}
use of org.bukkit.inventory.ItemStack in project Glowstone by GlowstoneMC.
the class GlowInventory method all.
////////////////////////////////////////////////////////////////////////////
// Find all
@Override
public HashMap<Integer, ItemStack> all(int materialId) {
HashMap<Integer, ItemStack> result = new HashMap<>();
int i = 0;
for (ItemStack slotItem : this) {
if (!InventoryUtil.isEmpty(slotItem) && slotItem.getTypeId() == materialId) {
result.put(i, InventoryUtil.itemOrEmpty(slotItem));
}
i++;
}
return result;
}
Aggregations