use of org.bukkit.inventory.ItemStack in project GameCore by Warvale.
the class TeamSelect method onPlayerInteract.
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Action a = event.getAction();
ItemStack is = event.getItem();
if (a == Action.PHYSICAL || is == null || is.getType() == Material.AIR)
return;
if (is.getType() == Material.ENCHANTED_BOOK)
tsGUI(event.getPlayer());
if (Main.getTeams().getSpectatorTeam().getEntries().contains(event.getPlayer().getName())) {
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_ENDERCHEST_OPEN, 1, 1);
}
}
use of org.bukkit.inventory.ItemStack in project GameCore by Warvale.
the class GlobalEvent method onBlockBreak.
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if (event.getBlock().getType().equals(Material.IRON_ORE)) {
event.getPlayer().giveExp(10);
for (int i = 0; i < NumberUtils.random(3, 1); i++) {
event.getPlayer().getInventory().addItem(new ItemStack(Material.IRON_INGOT));
}
event.setCancelled(true);
Location blockLoc = event.getBlock().getLocation();
event.getBlock().setType(Material.STONE);
List<Entity> entityList = new ArrayList<>();
for (int i = 0; i < NumberUtils.random(5, 2) + 1; i++) {
ItemStack stack = new ItemStack(Material.IRON_NUGGET);
stack.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, NumberUtils.random(100, 1));
entityList.add(event.getPlayer().getWorld().dropItemNaturally(event.getBlock().getLocation().setDirection(Vector.getRandom()).add(Vector.getRandom()), stack));
}
new BukkitRunnable() {
@Override
public void run() {
entityList.forEach(Entity::remove);
}
}.runTaskLater(Main.get(), 60L);
new BukkitRunnable() {
@Override
public void run() {
event.getPlayer().getWorld().getBlockAt(blockLoc).setType(Material.IRON_ORE);
event.getPlayer().getWorld().playSound(blockLoc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 5, 1);
}
}.runTaskLater(Main.get(), 400L);
}
if (event.getBlock().getType().equals(Material.GOLD_ORE)) {
event.getPlayer().giveExp(30);
for (int i = 0; i < NumberUtils.random(2, 0); i++) {
event.getPlayer().getInventory().addItem(new ItemStack(Material.GOLD_INGOT));
}
event.setCancelled(true);
Location blockLoc = event.getBlock().getLocation();
event.getBlock().setType(Material.STONE);
List<Entity> entityList = new ArrayList<>();
for (int i = 0; i < NumberUtils.random(5, 2) + 1; i++) {
ItemStack stack = new ItemStack(Material.GOLD_NUGGET);
stack.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, NumberUtils.random(100, 1));
entityList.add(event.getPlayer().getWorld().dropItemNaturally(event.getBlock().getLocation().setDirection(Vector.getRandom()).add(Vector.getRandom()), stack));
}
new BukkitRunnable() {
@Override
public void run() {
entityList.stream().forEach(entity -> entity.remove());
}
}.runTaskLater(Main.get(), 60L);
new BukkitRunnable() {
@Override
public void run() {
event.getPlayer().getWorld().getBlockAt(blockLoc).setType(Material.GOLD_ORE);
event.getPlayer().getWorld().playSound(blockLoc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 10, 1);
}
}.runTaskLater(Main.get(), 400L);
}
if (event.getBlock().getType().equals(Material.DIAMOND_ORE)) {
event.getPlayer().giveExp(50);
for (int i = 0; i < NumberUtils.random(1, 0); i++) {
event.getPlayer().getInventory().addItem(new ItemStack(Material.DIAMOND));
}
event.setCancelled(true);
Location blockLoc = event.getBlock().getLocation();
event.getBlock().setType(Material.STONE);
List<Entity> entityList = new ArrayList<>();
for (int i = 0; i < NumberUtils.random(5, 2) + 1; i++) {
ItemStack stack = new ItemStack(Material.PRISMARINE_CRYSTALS);
stack.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, NumberUtils.random(100, 1));
entityList.add(event.getPlayer().getWorld().dropItemNaturally(event.getBlock().getLocation().setDirection(Vector.getRandom()).add(Vector.getRandom()), stack));
}
new BukkitRunnable() {
@Override
public void run() {
entityList.stream().forEach(entity -> entity.remove());
}
}.runTaskLater(Main.get(), 60L);
new BukkitRunnable() {
@Override
public void run() {
event.getPlayer().getWorld().getBlockAt(blockLoc).setType(Material.DIAMOND_ORE);
event.getPlayer().getWorld().playSound(blockLoc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 25, 1);
}
}.runTaskLater(Main.get(), 400L);
}
if (event.getBlock().getType().equals(Material.LAPIS_ORE)) {
event.getPlayer().giveExp(50);
for (int i = 0; i < NumberUtils.random(1, 0); i++) {
event.getPlayer().getInventory().addItem(new ItemStack(Material.LAPIS_BLOCK));
}
event.setCancelled(true);
Location blockLoc = event.getBlock().getLocation();
event.getBlock().setType(Material.STONE);
List<Entity> entityList = new ArrayList<>();
for (int i = 0; i < NumberUtils.random(5, 2) + 1; i++) {
ItemStack stack = new ItemStack(Material.EYE_OF_ENDER);
stack.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, NumberUtils.random(100, 1));
entityList.add(event.getPlayer().getWorld().dropItemNaturally(event.getBlock().getLocation().setDirection(Vector.getRandom()).add(Vector.getRandom()), stack));
}
new BukkitRunnable() {
@Override
public void run() {
entityList.stream().forEach(entity -> entity.remove());
}
}.runTaskLater(Main.get(), 60L);
new BukkitRunnable() {
@Override
public void run() {
event.getPlayer().getWorld().getBlockAt(blockLoc).setType(Material.LAPIS_ORE);
event.getPlayer().getWorld().playSound(blockLoc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 15, 1);
}
}.runTaskLater(Main.get(), 400L);
}
}
use of org.bukkit.inventory.ItemStack in project GameCore by Warvale.
the class Bosses method BossWizard.
private void BossWizard(Location bossLocation) {
Skeleton Wizard = (Skeleton) bossLocation.getWorld().spawnEntity(bossLocation, EntityType.SKELETON);
Wizard.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 200, 100));
Wizard.setCustomName(ChatColor.translateAlternateColorCodes('&', "&eWizard"));
Wizard.setCustomNameVisible(true);
Wizard.setCanPickupItems(true);
ItemStack chestplate = new ItemStack(Material.IRON_CHESTPLATE);
chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
Wizard.getEquipment().setChestplate(chestplate);
Wizard.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(30);
Wizard.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false, Color.RED));
}
use of org.bukkit.inventory.ItemStack in project GameCore by Warvale.
the class Bosses method BossCruitionator.
private void BossCruitionator(Location bossLocation) {
Spider Cruitionator = (Spider) bossLocation.getWorld().spawnEntity(bossLocation, EntityType.SPIDER);
Cruitionator.setCustomNameVisible(true);
Cruitionator.setCustomName(ChatColor.translateAlternateColorCodes('&', "&eCruitionator"));
Cruitionator.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20);
Cruitionator.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.5);
Cruitionator.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 1000000, 1, false, false, Color.RED));
Cruitionator.getEquipment().setItemInMainHand(new ItemStack(Material.WOOD_SWORD));
Cruitionator.getEquipment().setItemInOffHandDropChance(0);
}
use of org.bukkit.inventory.ItemStack in project Minigames by AddstarMC.
the class MinigamePlayer method storePlayerData.
public void storePlayerData() {
ItemStack[] storedItems = player.getInventory().getContents();
ItemStack[] storedArmour = player.getInventory().getArmorContents();
int food = player.getFoodLevel();
double health = player.getHealth();
float saturation = player.getSaturation();
lastScoreboard = player.getScoreboard();
GameMode lastGM = player.getGameMode();
float exp = player.getExp();
int level = player.getLevel();
player.setSaturation(15);
player.setFoodLevel(20);
player.setHealth(player.getMaxHealth());
player.getInventory().clear();
player.getInventory().setArmorContents(null);
player.setLevel(0);
player.setExp(0);
oply = new OfflineMinigamePlayer(getPlayer().getUniqueId().toString(), storedItems, storedArmour, food, health, saturation, lastGM, exp, level, null);
player.updateInventory();
}
Aggregations