Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.herocraftonline.heroes.characters.skill.skills;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Block;
- import org.bukkit.configuration.ConfigurationSection;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.FallingBlock;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.EntityChangeBlockEvent;
- import org.bukkit.event.entity.EntityDamageEvent;
- import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
- import org.bukkit.metadata.FixedMetadataValue;
- import org.bukkit.scheduler.BukkitRunnable;
- import org.bukkit.scheduler.BukkitTask;
- import org.bukkit.util.Vector;
- import com.herocraftonline.heroes.Heroes;
- import com.herocraftonline.heroes.api.SkillResult;
- import com.herocraftonline.heroes.characters.Hero;
- import com.herocraftonline.heroes.characters.skill.ActiveSkill;
- import com.herocraftonline.heroes.characters.skill.SkillConfigManager;
- import com.herocraftonline.heroes.characters.skill.SkillSetting;
- import com.herocraftonline.heroes.characters.skill.SkillType;
- public class SkillEarthToss
- extends ActiveSkill
- implements Listener
- {
- public SkillEarthToss(Heroes plugin)
- {
- super(plugin, "EarthToss");
- setDescription("Throw the earth under you");
- setUsage("/skill earthtoss");
- setArgumentRange(0, 0);
- setIdentifiers(new String[] { "skill earthtoss" });
- Bukkit.getPluginManager().registerEvents(this, plugin);
- setTypes(new SkillType[] { SkillType.PHYSICAL, SkillType.HARMFUL,SkillType.SILENCABLE });
- }
- public String getDescription(Hero hero)
- {
- String description = getDescription();
- int cooldown = (SkillConfigManager.getUseSetting(hero, this, SkillSetting.COOLDOWN.node(), 0, false) - SkillConfigManager.getUseSetting(hero, this, SkillSetting.COOLDOWN_REDUCE.node(), 0, false) * hero.getSkillLevel(this)) / 1000;
- if (cooldown > 0) {
- description = description + " CD:" + cooldown + "s";
- }
- int mana = SkillConfigManager.getUseSetting(hero, this, SkillSetting.MANA.node(), 10, false) - SkillConfigManager.getUseSetting(hero, this, SkillSetting.MANA_REDUCE.node(), 0, false) * hero.getSkillLevel(this);
- if (mana > 0) {
- description = description + " M:" + mana;
- }
- int healthCost = SkillConfigManager.getUseSetting(hero, this, SkillSetting.HEALTH_COST, 0, false) - SkillConfigManager.getUseSetting(hero, this, SkillSetting.HEALTH_COST_REDUCE, mana, true) * hero.getSkillLevel(this);
- if (healthCost > 0) {
- description = description + " HP:" + healthCost;
- }
- int staminaCost = SkillConfigManager.getUseSetting(hero, this, SkillSetting.STAMINA.node(), 0, false) - SkillConfigManager.getUseSetting(hero, this, SkillSetting.STAMINA_REDUCE.node(), 0, false) * hero.getSkillLevel(this);
- if (staminaCost > 0) {
- description = description + " FP:" + staminaCost;
- }
- int delay = SkillConfigManager.getUseSetting(hero, this, SkillSetting.DELAY.node(), 0, false) / 1000;
- if (delay > 0) {
- description = description + " W:" + delay + "s";
- }
- int exp = SkillConfigManager.getUseSetting(hero, this, SkillSetting.EXP.node(), 0, false);
- if (exp > 0) {
- description = description + " XP:" + exp;
- }
- return description;
- }
- public ConfigurationSection getDefaultConfig()
- {
- ConfigurationSection node = super.getDefaultConfig();
- return node;
- }
- public void init()
- {
- super.init();
- }
- public SkillResult use(Hero hero, String[] args)
- {
- final double damage = 50000.0;
- final DamageCause cause = EntityDamageEvent.DamageCause.MAGIC;
- final Player p = hero.getPlayer();
- Vector animation = new Vector(0,.7,0);
- Location starter = p.getLocation().add(new Vector(p.getEyeLocation().getDirection().getX()*2, -1, p.getEyeLocation().getDirection().getZ()*2));
- Block bottom = (Block) starter.getBlock();
- final Vector direction = p.getEyeLocation().getDirection().multiply(1.5);
- @SuppressWarnings("deprecation")
- final FallingBlock proj = p.getWorld().spawnFallingBlock(starter,bottom.getType(), (byte) bottom.getData());
- proj.setMetadata("RemoveBlock", new FixedMetadataValue(plugin, true));
- if(proj.getMaterial() == (Material.AIR))
- {
- return SkillResult.FAIL;
- }else{
- proj.setDropItem(false);
- proj.setVelocity(animation);
- Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
- public void run() {
- proj.setVelocity(direction);
- } },5L);
- new Damager(proj, p, damage, cause).runTaskTimer(plugin, 1, 1);
- broadcastExecuteText(hero);
- return SkillResult.NORMAL;
- }
- }
- @EventHandler
- public void onLand(EntityChangeBlockEvent e)
- {
- if(e.getEntity().hasMetadata("RemoveBlock"))
- {
- e.setCancelled(true);
- e.getEntity().remove();
- e.getBlock().setType(Material.AIR);
- }
- }
- public class Damager extends BukkitRunnable{
- private FallingBlock proj;
- private Player p;
- private double damage;
- private DamageCause cause;
- public Damager(FallingBlock projectile, Player player, double damage, DamageCause cause)
- {
- this.proj = projectile;
- this.p = player;
- this.damage = damage;
- this.cause = cause;
- }
- public void run() {
- for(Entity e : proj.getNearbyEntities(0, 2, 0))
- {
- if(e != p && e instanceof LivingEntity)
- {
- if(damageCheck(p, (LivingEntity) e))
- damageEntity((LivingEntity) e, p, damage, cause);
- this.cancel();
- }
- if(e!=p && e instanceof LivingEntity)
- proj.remove();
- this.cancel();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement