@EventHandler(priority = EventPriority.NORMAL) public void onChunkLoad(ChunkLoadEvent event) { for (Entity e : event.getChunk().getEntities()) { if (e instanceof Monster) { e.remove(); return; } if (e instanceof IronGolem) { e.remove(); return; } } }
@EventHandler public void onHit(EntityDamageEvent event) { if (event.getEntity() instanceof IronGolem) { final IronGolem g = (IronGolem) event.getEntity(); if (g.getCustomName() == null) return; final Boss b = plugin.getBossManager().bossNames.get(g .getCustomName()); if (b == null) return; if (event.getCause() == DamageCause.VOID) { event.getEntity().remove(); Bukkit.getScheduler().runTask(plugin, new Runnable() { public void run() { Boss n = plugin.getBossManager().newBoss(b); plugin.getBossManager().spawn(n); } }); return; } } }
@EventHandler public void onHit(EntityDamageByEntityEvent event) { if (event.getEntity() instanceof IronGolem) { if (!(event.getDamager() instanceof Player)) event.setCancelled(true); final IronGolem g = (IronGolem) event.getEntity(); if (g.getCustomName() == null) return; final Boss b = plugin.getBossManager().bossNames.get(g .getCustomName()); if (b == null) return; Bukkit.getScheduler().runTask(plugin, new Runnable() { public void run() { plugin.getBossManager().update(b, g); } }); } }
@EventHandler public void onDeath(EntityDeathEvent event) { if (event.getEntity() instanceof IronGolem) { IronGolem g = (IronGolem) event.getEntity(); if (g.getCustomName() == null) return; Boss b = plugin.getBossManager().bossNames.get(g.getCustomName()); if (b == null) return; event.getDrops().clear(); b.spawnLootChest(); if (g.getKiller() != null) { Player killer = g.getKiller(); ChatUtil.bossDeath(b, killer, PlayerMeta.getMeta(killer) .getTeam()); respawn(b); Util.spawnFirework(event.getEntity().getLocation(), PlayerMeta.getMeta(killer).getTeam().getColor(PlayerMeta.getMeta(killer).getTeam()), PlayerMeta.getMeta(killer).getTeam().getColor(PlayerMeta.getMeta(killer).getTeam())); } else { g.teleport(b.getSpawn()); } } }
@EventHandler public void onHit(EntityDamageEvent event) { if (event.getEntity() instanceof IronGolem) { final IronGolem g = (IronGolem) event.getEntity(); if (g.getCustomName() == null) return; final Golem b = plugin.getBossManager().bossNames.get(g .getCustomName()); if (b == null) return; if (event.getCause() == DamageCause.VOID) { event.getEntity().remove(); Bukkit.getScheduler().runTask(plugin, new Runnable() { @Override public void run() { Golem n = plugin.getBossManager().newBoss(b); plugin.getBossManager().spawn(n); } }); } } }
@EventHandler public void onHit(EntityDamageByEntityEvent event) { if (event.getEntity() instanceof IronGolem) { if (!(event.getDamager() instanceof Player)) event.setCancelled(true); final IronGolem g = (IronGolem) event.getEntity(); if (g.getCustomName() == null) return; final Golem b = plugin.getBossManager().bossNames.get(g .getCustomName()); if (b == null) return; Bukkit.getScheduler().runTask(plugin, new Runnable() { @Override public void run() { plugin.getBossManager().update(b, g); } }); } }
@EventHandler public void onDeath(EntityDeathEvent event) { if (event.getEntity() instanceof IronGolem) { IronGolem g = (IronGolem) event.getEntity(); if (g.getCustomName() == null) return; Golem b = plugin.getBossManager().bossNames.get(g.getCustomName()); if (b == null) return; event.getDrops().clear(); b.LootChest(); if (g.getKiller() != null) { Player killer = g.getKiller(); ChatUtil.bossDeath(b, killer, PlayerMeta.getMeta(killer) .getTeam()); respawn(b); Util.spawnFirework(event.getEntity().getLocation(), PlayerMeta.getMeta(killer).getTeam().getColor(PlayerMeta.getMeta(killer).getTeam()), PlayerMeta.getMeta(killer).getTeam().getColor(PlayerMeta.getMeta(killer).getTeam())); } else { g.teleport(b.getSpawn()); } } }
public void update(Boss boss, IronGolem g) { boss.setHealth((int) g.getHealth()); g.setCustomName(ChatColor.translateAlternateColorCodes('&', boss.getBossName() + " &8» &a" + (int) boss.getHealth() + " HP")); bossNames.put(g.getCustomName(), boss); bosses.put(boss.getConfigName(), boss); }
public static boolean inTitan(IronGolem ironGolem, Player player) { if (ironGolem != null && player != null) { if (ironGolem.getPassenger() != null && ironGolem.getPassenger() instanceof Player) { return ((Player) ironGolem.getPassenger()).getName().equalsIgnoreCase(player.getName()); } } return false; }
@Deprecated /** * Use Main.getInstance().inTitan(player); */ public static boolean inTitan(Player player) { if (player != null) { if (Main.getInstance().hasTitan(player)) { return inTitan((IronGolem) Main.getInstance().getTitan(player).getBukkitEntity().getHandle(), player); } } return false; }
/** * Get the titan by the owner. * * @param player - The owner. * @return The titan. */ public IronGolem getTitanEntity(Player player) { if (this.playerGolems.containsKey(player.getName())) { UUID playerUUID = this.getTitanUUID(player); for (IronGolem ironGolem : player.getWorld().getEntitiesByClass(IronGolem.class)) { if (ironGolem.getUniqueId().equals(playerUUID)) return ironGolem; } } return null; }
public void update(Golem boss, IronGolem g) { boss.setHealth((int) g.getHealth()); g.setCustomName(ChatColor.translateAlternateColorCodes('&', boss.getBossName() + " &8» &a" + (int) boss.getHealth() + " HP")); bossNames.put(g.getCustomName(), boss); bosses.put(boss.getConfigName(), boss); }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) { if (DEBUG) { plugin.getLogger().info("1.9 lingering potion damage " + e.getEventName()); plugin.getLogger().info("1.9 lingering potion entity = " + e.getEntity()); plugin.getLogger().info("1.9 lingering potion entity type = " + e.getEntityType()); plugin.getLogger().info("1.9 lingering potion cause = " + e.getCause()); plugin.getLogger().info("1.9 lingering potion damager = " + e.getDamager()); } if (!Util.inWorld(e.getEntity().getLocation())) { return; } if (e.getEntity() == null || e.getEntity().getUniqueId() == null) { return; } if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) { UUID attacker = thrownPotions.get(e.getDamager().getEntityId()); // Self damage if (attacker.equals(e.getEntity().getUniqueId())) { if (DEBUG) plugin.getLogger().info("DEBUG: Self damage from lingering potion!"); return; } Island island = plugin.getIslands().getIslandAt(e.getEntity().getLocation()); boolean inNether = false; if (e.getEntity().getWorld().equals(IslandWorld.getNetherWorld())) { inNether = true; } // Monsters being hurt if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) { // Normal island check if (island != null && island.getMembers().contains(attacker)) { // Members always allowed return; } if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) { return; } // Not allowed e.setCancelled(true); return; } // Mobs being hurt if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman || e.getEntity() instanceof Villager) { if (island != null && (island.getFlag(SettingsFlag.HURT_ANIMALS) || island.getMembers().contains(attacker))) { return; } if (DEBUG) plugin.getLogger().info("DEBUG: Mobs not allowed to be hurt. Blocking"); e.setCancelled(true); return; } // Establish whether PVP is allowed or not. boolean pvp = false; if ((inNether && island != null && island.getFlag(SettingsFlag.PVP_NETHER) || (!inNether && island != null && island.getFlag(SettingsFlag.PVP_OVERWORLD)))) { if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed"); pvp = true; } // Players being hurt PvP if (e.getEntity() instanceof Player) { if (!pvp) { if (DEBUG) plugin.getLogger().info("DEBUG: PVP not allowed"); e.setCancelled(true); } } } }
public CanaryIronGolem(net.canarymod.api.entity.living.IronGolem entity) { super(entity); }
@Override protected net.canarymod.api.entity.living.IronGolem getHandle() { return (net.canarymod.api.entity.living.IronGolem) super.getHandle(); }
/** * Assembles an ArrayList of the properties for the specified Entity that * is to be used for a spawn egg. All instanceof checks are done internally * by the LorePackager, so no type checking is required prior to calling * this method. Null Entities will throw an IllegalArgumentException. <b>The * actual ArrayList is returned by {@link #getLore() LorePacker.getLore()}. * </b> * @param livingEntity - The Entity to assemble a lore for. * @return An ArrayList of Strings * @throws IllegalArgumentException If entity parameter is null */ public LorePacker(LivingEntity livingEntity) throws IllegalArgumentException { if (livingEntity == null) { throw new IllegalArgumentException("Can't assemble lore for a null entity!"); } lore = new ArrayList<String>(); // This needs to always be on top of an egg's lore lore.add("Identifier: SimpleEgg." + livingEntity.getType().getEntityClass().getSimpleName() + "." + Main.getSelf().getDescription().getVersion()); lore.addAll(livingEntity(livingEntity)); if (livingEntity instanceof Ageable) { lore.addAll(ageable((Ageable) livingEntity)); if (livingEntity instanceof Sheep) { lore.addAll(sheep((Sheep) livingEntity)); } else if (livingEntity instanceof Pig) { lore.addAll(pig((Pig) livingEntity)); } else if (livingEntity instanceof Rabbit) { lore.addAll(rabbit((Rabbit) livingEntity)); } else if (livingEntity instanceof Villager) { lore.addAll(villager((Villager) livingEntity)); } else if (livingEntity instanceof Tameable) { lore.addAll(tameable((Tameable) livingEntity)); if (livingEntity instanceof AbstractHorse) { lore.addAll(abstractHorse((AbstractHorse) livingEntity)); if (livingEntity instanceof Horse) { lore.addAll(horse((Horse) livingEntity)); } else if (livingEntity instanceof ChestedHorse) { lore.addAll(chestedHorse((ChestedHorse) livingEntity)); if (livingEntity instanceof Llama) { lore.addAll(llama((Llama) livingEntity)); } } } else if (livingEntity instanceof Sittable) { lore.addAll(sittable((Sittable) livingEntity)); if (livingEntity instanceof Wolf) { lore.addAll(wolf((Wolf) livingEntity)); } else if (livingEntity instanceof Ocelot) { lore.addAll(ocelot((Ocelot) livingEntity)); } else if (livingEntity instanceof Parrot) { lore.addAll(parrot((Parrot) livingEntity)); } } } } else if (livingEntity instanceof Slime) { lore.addAll(slime((Slime) livingEntity)); } else if (livingEntity instanceof Creeper) { lore.addAll(creeper((Creeper) livingEntity)); } else if (livingEntity instanceof Zombie) { lore.addAll(zombie((Zombie) livingEntity)); if (livingEntity instanceof PigZombie) { lore.addAll(pigZombie((PigZombie) livingEntity)); } else if (livingEntity instanceof ZombieVillager) { lore.addAll(zombieVillager((ZombieVillager) livingEntity)); } } else if (livingEntity instanceof Spellcaster) { lore.addAll(spellCaster((Spellcaster) livingEntity)); } else if (livingEntity instanceof IronGolem) { lore.addAll(ironGolem((IronGolem) livingEntity)); } else if (livingEntity instanceof Snowman) { lore.addAll(snowman((Snowman) livingEntity)); } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) { if (DEBUG) { plugin.getLogger().info("1.9 lingering potion damage " + e.getEventName()); plugin.getLogger().info("1.9 lingering potion entity = " + e.getEntity()); plugin.getLogger().info("1.9 lingering potion entity type = " + e.getEntityType()); plugin.getLogger().info("1.9 lingering potion cause = " + e.getCause()); plugin.getLogger().info("1.9 lingering potion damager = " + e.getDamager()); } if (!IslandGuard.inWorld(e.getEntity().getLocation())) { return; } if (e.getEntity() == null || e.getEntity().getUniqueId() == null) { return; } if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) { UUID attacker = thrownPotions.get(e.getDamager().getEntityId()); // Self damage if (attacker.equals(e.getEntity().getUniqueId())) { if (DEBUG) plugin.getLogger().info("DEBUG: Self damage from lingering potion!"); return; } Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation()); boolean inNether = false; if (e.getEntity().getWorld().equals(ASkyBlock.getNetherWorld())) { inNether = true; } // Monsters being hurt if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) { // Normal island check if (island != null && island.getMembers().contains(attacker)) { // Members always allowed return; } if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) { return; } // Not allowed e.setCancelled(true); return; } // Mobs being hurt if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman || e.getEntity() instanceof Villager) { if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker))) { return; } if (DEBUG) plugin.getLogger().info("DEBUG: Mobs not allowed to be hurt. Blocking"); e.setCancelled(true); return; } // Establish whether PVP is allowed or not. boolean pvp = false; if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) { if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed"); pvp = true; } // Players being hurt PvP if (e.getEntity() instanceof Player) { if (pvp) { if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed"); return; } else { if (DEBUG) plugin.getLogger().info("DEBUG: PVP not allowed"); e.setCancelled(true); return; } } } }
public RemoteIronGolem(int inID, RemoteIronGolemEntity inEntity, EntityManager inManager) { super(inID, RemoteEntityType.IronGolem, inManager); this.m_entity = inEntity; }
/** * Get the titan by the owner. * * @param player - The owner. * @return The titan. */ public CustomIronGolem getTitan(Player player) { IronGolem ironGolem = this.getTitanEntity(player); return ironGolem != null ? (CustomIronGolem) ((CraftIronGolem) ironGolem).getHandle() : null; }