@EventHandler public void onEntityBendingDeath(EntityBendingDeathEvent event) { Entity v = event.getVictim(); Element e = CoreAbility.getAbility(event.getAbility()).getElement(); int xp; if(v == null || e == null) return; if(v instanceof Player) { xp = 25 + (int)(Math.random() * ((35 - 25) + 1)); } else if(v instanceof Zombie || v instanceof Creeper || v instanceof Witch || v instanceof Skeleton || v instanceof Guardian || v instanceof Spider) { xp = 13 + (int)(Math.random() * ((22 - 13) + 1)); } else { xp = 3 + (int)(Math.random() * ((8 - 3) + 1)); } BendingExp.addExp(event.getAttacker(), e, xp); }
@SuppressWarnings("null") @Override protected boolean init(Class<? extends Guardian> c, Guardian e) { if(e != null) isElder = e.isElder(); return true; }
@Override public RequirementState getState() { YamlConfiguration myState = new YamlConfiguration(); myState.set("type", "vr"); ConfigurationSection foeSection = myState.createSection("foe"); foeSection.set("type", foe.getType().name()); foeSection.set("maxhp", foe.getMaxHealth()); foeSection.set("hp", foe.getHealth()); foeSection.set("name", foe.getCustomName()); foeSection.set("location", foe.getLocation()); if (foe instanceof Guardian) { foeSection.set("elder", ((Guardian) foe).isElder()); } if (foe instanceof Slime) { foeSection.set("size", ((Slime) foe).getSize()); } if (foe instanceof Skeleton) { foeSection.set("wither", ((Skeleton) foe).getSkeletonType() == SkeletonType.WITHER); } EquipmentConfiguration econ = new EquipmentConfiguration(foe.getEquipment()); foeSection.set("equipment", econ.getConfiguration()); return new RequirementState(myState); }
@Override public void set(Guardian entity) { if(isElder) entity.setElder(true); }
@Override protected boolean match(Guardian entity) { return entity.isElder() == isElder; }
@Override public Class<? extends Guardian> getType() { return Guardian.class; }
@Override public void activate() { ConfigurationSection myState = foeStateRecord.getConfig(); //get rid of any entities we already have if (foe != null && !foe.isDead()) { foe.remove(); } ConfigurationSection foeState = myState.getConfigurationSection("foe"); Location loc = ((LocationState) foeState.get("location")).getLocation(); //load chunk before creating foe loc.getChunk(); foe = (LivingEntity) loc.getWorld().spawnEntity(loc, EntityType.valueOf(foeState.getString("type"))); this.id = foe.getUniqueId(); foe.setMaxHealth(foeState.getDouble("maxhp")); foe.setHealth(foeState.getDouble("hp")); foe.setCustomName(foeState.getString("name")); foe.setRemoveWhenFarAway(false); EntityEquipment equipment = foe.getEquipment(); EquipmentConfiguration econ = new EquipmentConfiguration(); try { econ.load( foeState.getConfigurationSection("equipment")); } catch (InvalidConfigurationException e) { e.printStackTrace(); } equipment.setHelmet(econ.getHead()); equipment.setChestplate(econ.getChest()); equipment.setLeggings(econ.getLegs()); equipment.setBoots(econ.getBoots()); equipment.setItemInMainHand(econ.getHeldMain()); equipment.setItemInOffHand(econ.getHeldOff()); //special checks if (foe instanceof Guardian) { if (foeState.getBoolean("elder", false)) { ((Guardian) foe).setElder(true); } } if (foe instanceof Slime) { if (foeState.getInt("size", 1) > 1) { ((Slime) foe).setSize(foeState.getInt("size")); } } if (foe instanceof Skeleton) { if (foeState.getBoolean("wither", false)) { ((Skeleton) foe).setSkeletonType(SkeletonType.WITHER); } } if (desc == null) { desc = foeState.getString("description", "Slay " + foe.getCustomName()); } //add as NPC for non-removal foeNPC = new QuestMonsterNPC(); foeNPC.setEntity(foe); QuestManagerPlugin.questManagerPlugin.getManager().registerNPC(foeNPC); update(); Bukkit.getPluginManager().registerEvents(this, QuestManagerPlugin.questManagerPlugin); }
@Override Guardian getBukkitEntity();
@Override public boolean isElderGuardian(Entity entity) { return entity instanceof Guardian && ((Guardian) entity).isElder(); }
/** * Runs repeating tasks to deliver acid damage to mobs, etc. * @param plugin */ public AcidTask(final ASkyBlock plugin) { this.plugin = plugin; // Initialize water item list itemsInWater = new HashSet<UUID>(); // This part will kill monsters if they fall into the water // because it // is acid if (Settings.mobAcidDamage > 0D || Settings.animalAcidDamage > 0D) { plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { @Override public void run() { List<Entity> entList = ASkyBlock.getIslandWorld().getEntities(); for (Entity current : entList) { if (plugin.isOnePointEight() && current instanceof Guardian) { // Guardians are immune to acid too continue; } if ((current instanceof Monster) && Settings.mobAcidDamage > 0D) { if ((current.getLocation().getBlock().getType() == Material.WATER) || (current.getLocation().getBlock().getType() == Material.STATIONARY_WATER)) { ((Monster) current).damage(Settings.mobAcidDamage); // getLogger().info("Killing monster"); } } else if ((current instanceof Animals) && Settings.animalAcidDamage > 0D) { if ((current.getLocation().getBlock().getType() == Material.WATER) || (current.getLocation().getBlock().getType() == Material.STATIONARY_WATER)) { if (!current.getType().equals(EntityType.CHICKEN)) { ((Animals) current).damage(Settings.animalAcidDamage); } else if (Settings.damageChickens) { ((Animals) current).damage(Settings.animalAcidDamage); } // getLogger().info("Killing animal"); } } } } }, 0L, 20L); } runAcidItemRemovalTask(); }