Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.phanaticmc.whip;
- import com.projectkorra.projectkorra.command.Commands;
- import org.bukkit.block.*;
- import org.bukkit.util.*;
- import com.projectkorra.projectkorra.configuration.*;
- import com.projectkorra.projectkorra.waterbending.util.*;
- import com.projectkorra.projectkorra.ability.*;
- import org.bukkit.*;
- import org.bukkit.entity.*;
- import com.projectkorra.projectkorra.util.*;
- import org.bukkit.potion.*;
- import com.projectkorra.projectkorra.*;
- import static com.projectkorra.projectkorra.GeneralMethods.getWaterData;
- public class Whip extends WaterAbility implements AddonAbility
- {
- private long cooldown;
- private double range;
- private double damage;
- private double speed;
- private TempBlock tempBlock;
- private Location location;
- private Block sourceBlock;
- private Block above;
- private Vector direction;
- public Whip(final Player player) {
- super(player);
- if (bPlayer.isOnCooldown(this)) {
- return;
- }
- if (!player.isSneaking()) {
- return;
- }
- setFields();
- if (!WaterReturn.hasWaterBottle(player)) {
- sourceBlock = BlockSource.getWaterSourceBlock(player, 8.0, ClickType.SHIFT_DOWN, true, true, true, true, false);
- //sourceBlock = BlockSource.getWaterSourceBlock(player,5,true,true,true);
- } else {
- sourceBlock = player.getEyeLocation().clone().getBlock();
- WaterReturn.emptyWaterBottle(player);
- }
- if (sourceBlock == null) {
- return;
- }
- start();
- bPlayer.addCooldown(this);
- }
- public void setFields() {
- cooldown = ConfigManager.getConfig().getLong("ExtraAbilities.NickC1211.Whip.Cooldown");
- range = ConfigManager.getConfig().getDouble("ExtraAbilities.NickC1211.Whip.Range");
- damage = ConfigManager.getConfig().getDouble("ExtraAbilities.NickC1211.Whip.Damage");
- speed = ConfigManager.getConfig().getDouble("ExtraAbilities.NickC1211.Whip.Speed");
- location = player.getEyeLocation();
- direction = player.getEyeLocation().getDirection();
- location.add(direction.multiply(1));
- /*
- if (!WaterReturn.hasWaterBottle(player) && sourceBlock != BlockSource.getWaterSourceBlock(player, 8.0, ClickType.SHIFT_DOWN, true, true, true, true, true) && sourceBlock != player.getEyeLocation().clone().getBlock()) {
- sourceBlock = null;
- }
- if (!WaterReturn.hasWaterBottle(player) && sourceBlock != null) {
- location = sourceBlock.getLocation().clone();
- above = sourceBlock.getLocation().add(0.0, 1.0, 0.0).getBlock();
- }
- if (WaterReturn.hasWaterBottle(player) && sourceBlock != null) {
- location = sourceBlock.getLocation().clone();
- }*/
- /*if ((!WaterReturn.hasWaterBottle(player) && sourceBlock.getType() == Material.TALL_GRASS) ||
- sourceBlock.getType() == Material.TALL_GRASS ||
- sourceBlock.getType() == Material.POPPY ||
- sourceBlock.getType() == Material.DANDELION ||
- sourceBlock.getType() == Material.JUNGLE_SAPLING ||
- sourceBlock.getType() == Material.DARK_OAK_SAPLING ||
- sourceBlock.getType() == Material.BIRCH_SAPLING ||
- sourceBlock.getType() == Material.ACACIA_SAPLING ||
- sourceBlock.getType() == Material.SPRUCE_SAPLING ||
- sourceBlock.getType() == Material.OAK_SAPLING ||
- sourceBlock.getType() == Material.RED_MUSHROOM ||
- sourceBlock.getType() == Material.BROWN_MUSHROOM) {
- location = above.getLocation().clone();
- }
- if ((!WaterReturn.hasWaterBottle(player) && sourceBlock.getType() == Material.WATER) ||
- sourceBlock.getType() == Material.WATER ||
- sourceBlock.getType() == Material.ICE ||
- sourceBlock.getType() == Material.PACKED_ICE ||
- sourceBlock.getType() == Material.SNOW_BLOCK) {
- location = above.getLocation().clone();
- }*/
- }
- public void progress() {
- if (!bPlayer.canBendIgnoreCooldowns(this)) {
- remove();
- return;
- }
- if (player.getLocation().distance(location) > range) {
- remove();
- return;
- }
- if (!player.isSneaking()) {
- remove();
- return;
- }
- direction = player.getEyeLocation().getDirection();
- location.add(direction.multiply(speed));
- if (!getTransparentMaterialSet().contains(location.getBlock().getType()) && location.getBlock().getType() != Material.WATER){
- remove();
- return;
- }
- tempBlock = new TempBlock(location.getBlock(), Material.WATER, getWaterData(2));
- ParticleEffect.WATER_DROP.display(location, 5, 0.5f, 0.5f, 0.5f, 0.0f);
- playWaterbendingSound(location);
- tempBlock.setRevertTime(800L);
- /*if (WaterReturn.hasWaterBottle(player)) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.WATER, getWaterData(2));
- ParticleEffect.WATER_DROP.display(location, 5, 0.5f, 0.5f, 0.5f, 0.0f);
- playWaterbendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if (!WaterReturn.hasWaterBottle(player) && WaterReturn.isWater(sourceBlock)) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.WATER, getWaterData(8));
- ParticleEffect.WATER_DROP.display(location, 5,0.5f, 0.5f, 0.5f, 0.0f);
- playWaterbendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if (!WaterReturn.hasWaterBottle(player) && WaterReturn.isSnow(sourceBlock)) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.SNOW_BLOCK);
- location.getWorld().playSound(location, Sound.BLOCK_SNOW_BREAK, 1.0f, 1.0f);
- tempBlock.setRevertTime(1200L);
- }
- if (!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.PLANT) && WaterReturn.isLeaves(sourceBlock)) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.OAK_LEAVES);
- location.getWorld().playSound(location, Sound.BLOCK_GRASS_BREAK, 1.0f, 1.0f);
- tempBlock.setRevertTime(1200L);
- }
- if (!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.PLANT) && sourceBlock.getType() == Material.CACTUS) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.OAK_LEAVES);
- location.getWorld().playSound(location, Sound.BLOCK_GRASS_BREAK, 1.0f, 1.0f);
- tempBlock.setRevertTime(1200L);
- }
- if ((!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.PLANT)) && sourceBlock.getType() == Material.TALL_GRASS) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.TALL_GRASS);
- location.getWorld().playSound(location, Sound.BLOCK_GRASS_BREAK, 1.0f, 1.0f);
- tempBlock.setRevertTime(1200L);
- }
- if ((!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.PLANT)) && (sourceBlock.getType() == Material.POPPY || sourceBlock.getType() == Material.DANDELION)) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.WATER, getWaterData(2));
- ParticleEffect.WATER_DROP.display(location, 5, 0.5f, 0.5f, 0.5f, 0.0f);
- playWaterbendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if ((!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.PLANT)) && (sourceBlock.getType() == Material.RED_MUSHROOM || sourceBlock.getType() == Material.BROWN_MUSHROOM)) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.WATER, getWaterData(2));
- ParticleEffect.WATER_DROP.display(location, 5, 0.5f, 0.5f, 0.5f, 0.0f);
- playWaterbendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if ((!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.PLANT)) && (sourceBlock.getType() == Material.PUMPKIN || sourceBlock.getType() == Material.MELON)) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.WATER, getWaterData(8));
- ParticleEffect.WATER_DROP.display(location, 5,0.5f, 0.5f, 0.5f, 0.0f);
- playWaterbendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if ((!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.PLANT)) && (sourceBlock.getType() == Material.OAK_SAPLING || sourceBlock.getType() == Material.SPRUCE_SAPLING || sourceBlock.getType() == Material.ACACIA_SAPLING || sourceBlock.getType() == Material.BIRCH_SAPLING || sourceBlock.getType() == Material.DARK_OAK_SAPLING || sourceBlock.getType() == Material.JUNGLE_SAPLING) || sourceBlock.getType() == Material.PUMPKIN_STEM || sourceBlock.getType() == Material.MELON_STEM) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.WATER, getWaterData(2));
- ParticleEffect.WATER_DROP.display(location, 5, 0.5f, 0.5f, 0.5f, 0.0f);
- playWaterbendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if ((!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.PLANT)) && (sourceBlock.getType() == Material.VINE || sourceBlock.getType() == Material.LILY_PAD || sourceBlock.getType() == Material.WHEAT || sourceBlock.getType() == Material.POTATOES || sourceBlock.getType() == Material.CARROTS || sourceBlock.getType() == Material.BEETROOTS)) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.WATER, getWaterData(2));
- ParticleEffect.WATER_DROP.display(location, 5, 0.5f, 0.5f, 0.5f, 0.0f);
- playWaterbendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if (!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.PLANT) && sourceBlock.getType() == Material.SUGAR_CANE) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.SUGAR_CANE);
- location.getWorld().playSound(location, Sound.BLOCK_GRASS_BREAK, 1.0f, 1.0f);
- tempBlock.setRevertTime(1200L);
- }
- if ((!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.PLANT)) && (sourceBlock.getType() == Material.MUSHROOM_STEM || sourceBlock.getType() == Material.BROWN_MUSHROOM_BLOCK || sourceBlock.getType() == Material.RED_MUSHROOM_BLOCK)) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.WATER, getWaterData(8));
- ParticleEffect.WATER_DROP.display(location, 5, 0.5f, 0.5f, 0.5f, 0.0f);
- playWaterbendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if (!WaterReturn.hasWaterBottle(player) && (sourceBlock.getType() == Material.ACACIA_LOG || sourceBlock.getType() == Material.BIRCH_LOG || sourceBlock.getType() == Material.DARK_OAK_LOG || sourceBlock.getType() == Material.JUNGLE_LOG || sourceBlock.getType() == Material.OAK_LOG || sourceBlock.getType() == Material.SPRUCE_LOG)) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.WATER, getWaterData(8));
- ParticleEffect.WATER_DROP.display(location, 5,0.5f, 0.5f, 0.5f, 0.0f);
- playWaterbendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if (!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.ICE) && sourceBlock.getType() == Material.ICE) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.ICE);
- playIcebendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if (!WaterReturn.hasWaterBottle(player) && bPlayer.canUseSubElement(Element.SubElement.ICE) && sourceBlock.getType() == Material.PACKED_ICE) {
- tempBlock = new TempBlock(currentLoc.getBlock(), Material.PACKED_ICE);
- playIcebendingSound(location);
- tempBlock.setRevertTime(1200L);
- }
- if (!WaterReturn.hasWaterBottle(player) && WaterReturn.isNight(player.getWorld())) {
- damage = 5.0;
- range = 22.0;
- }
- if (!WaterReturn.hasWaterBottle(player) && WaterReturn.isFullMoon(player.getWorld())) {
- damage = 6.0;
- range = 24.0;
- }
- */
- for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 1.0)) {
- if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId()) {
- if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))){
- continue;
- }
- final Location location = player.getEyeLocation();
- final Vector vector = location.getDirection();
- entity.setVelocity(vector.normalize().multiply(0.8f));
- DamageHandler.damageEntity(entity, damage, this);
- if (!WaterReturn.hasWaterBottle(player) && WaterReturn.isIce(sourceBlock)) {
- ((LivingEntity)entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 3));
- }
- if (!WaterReturn.hasWaterBottle(player) && WaterReturn.isPlant(sourceBlock)) {
- ((LivingEntity)entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 3));
- }
- if (WaterReturn.hasWaterBottle(player) || !WaterReturn.isSnow(sourceBlock)) {
- continue;
- }
- ((LivingEntity)entity).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 60, 3));
- remove();
- return;
- }
- }
- }
- public long getCooldown() {
- return cooldown;
- }
- public Location getLocation() {
- return location;
- }
- public String getName() {
- return "Whip";
- }
- public String getDescription() {
- return "Send a whip of water, plant, ice, or snow at your opponent.";
- }
- public String getInstructions() {
- return "Hold Shift and Left Click to shoot.";
- }
- public boolean isHarmlessAbility() {
- return false;
- }
- public void remove(){
- new WaterReturn(player, location.getBlock());
- super.remove();
- }
- public boolean isSneakAbility() {
- return ConfigManager.getConfig().getBoolean("ExtraAbilities.NickC1211.Whip.Swim.Disabled");
- }
- public String getAuthor() {
- return "NickC1211";
- }
- public String getVersion() {
- return "v5.0";
- }
- public void load() {
- ProjectKorra.plugin.getServer().getPluginManager().registerEvents(new WhipListener(), ProjectKorra.plugin);
- ProjectKorra.log.info(getName() + " " + getVersion() + " by " + getAuthor() + " loaded!");
- ConfigManager.getConfig().addDefault("ExtraAbilities.NickC1211.Whip.Cooldown", 2000);
- ConfigManager.getConfig().addDefault("ExtraAbilities.NickC1211.Whip.Range", 20);
- ConfigManager.getConfig().addDefault("ExtraAbilities.NickC1211.Whip.Damage", 4);
- ConfigManager.getConfig().addDefault("ExtraAbilities.NickC1211.Whip.Speed", 1);
- ConfigManager.getConfig().addDefault("ExtraAbilities.NickC1211.Whip.Swim.Disabled", true);
- ConfigManager.defaultConfig.save();
- ProjectKorra.getCollisionInitializer().addSmallAbility(this);
- }
- public void stop() {
- ProjectKorra.log.info(getName() + " " + getVersion() + " by " + getAuthor() + " disabled!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement