Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

BossBar Charging #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/me/simplicitee/project/addons/MainListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
import me.simplicitee.project.addons.ability.earth.Bulwark;
import me.simplicitee.project.addons.ability.earth.Crumble;
import me.simplicitee.project.addons.ability.earth.Dig;
import me.simplicitee.project.addons.ability.earth.EarthKick;
import me.simplicitee.project.addons.ability.earth.EarthShove;
import me.simplicitee.project.addons.ability.earth.LavaSurge;
import me.simplicitee.project.addons.ability.earth.MagmaSlap;
import me.simplicitee.project.addons.ability.earth.QuickWeld;
Expand Down Expand Up @@ -236,8 +236,8 @@ public void onSneak(PlayerToggleSneakEvent event) {
return;
}

if (canBend(player, "EarthKick")) {
new EarthKick(player);
if (canBend(player, "EarthShove")) {
new EarthShove(player);
} else if (canBend(player, "NinjaStance")) {
if (CoreAbility.hasAbility(player, NinjaStance.class)) {
CoreAbility.getAbility(player, NinjaStance.class).beginStealth();
Expand Down Expand Up @@ -309,9 +309,9 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) {
if (e instanceof FallingBlock) {
FallingBlock fb = (FallingBlock)e;

if (EarthKick.isBlock(fb)) {
if (EarthShove.isBlock(fb)) {
event.setCancelled(true);
EarthKick.removeBlock(fb);
EarthShove.removeBlock(fb);
} else if (MagmaSlap.isBlock(fb)) {
event.setCancelled(true);
((MagmaSlap) fb.getMetadata("magmaslap").get(0).value()).turnToTempBlock(event.getBlock());
Expand Down
12 changes: 6 additions & 6 deletions src/me/simplicitee/project/addons/ProjectAddons.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ private void setupConfig() {
c.addDefault("Abilities.Earth.Dig.RevertTime", 3500);
c.addDefault("Abilities.Earth.Dig.Speed", 0.51);

// EarthKick
c.addDefault("Abilities.Earth.EarthKick.Enabled", true);
c.addDefault("Abilities.Earth.EarthKick.Cooldown", 4000);
c.addDefault("Abilities.Earth.EarthKick.Damage", 0.5);
c.addDefault("Abilities.Earth.EarthKick.MaxBlocks", 9);
c.addDefault("Abilities.Earth.EarthKick.LavaMultiplier", 1.5);
// EarthShove
c.addDefault("Abilities.Earth.EarthShove.Enabled", true);
c.addDefault("Abilities.Earth.EarthShove.Cooldown", 4000);
c.addDefault("Abilities.Earth.EarthShove.Damage", 0.5);
c.addDefault("Abilities.Earth.EarthShove.MaxBlocks", 9);
c.addDefault("Abilities.Earth.EarthShove.LavaMultiplier", 1.5);

// LavaSurge
c.addDefault("Abilities.Earth.LavaSurge.Enabled", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import me.simplicitee.project.addons.ProjectAddons;

public class EarthKick extends EarthAbility implements AddonAbility, Listener{
public class EarthShove extends EarthAbility implements AddonAbility, Listener{

private static Set<FallingBlock> BLOCKS = new HashSet<>();

Expand All @@ -42,7 +42,7 @@ public class EarthKick extends EarthAbility implements AddonAbility, Listener{
public List<FallingBlock> kick;
public long duration = 2500;

public EarthKick(Player player) {
public EarthShove(Player player) {
super(player);

if (getAbility(this.getClass()) == null) {
Expand All @@ -57,9 +57,9 @@ public EarthKick(Player player) {
}

public void setFields() {
damage = ProjectAddons.instance.getConfig().getDouble("Abilities.Earth.EarthKick.Damage");
maxBlocks = ProjectAddons.instance.getConfig().getInt("Abilities.Earth.EarthKick.MaxBlocks");
lavaMult = ProjectAddons.instance.getConfig().getDouble("Abilities.Earth.EarthKick.LavaMultiplier");
damage = ProjectAddons.instance.getConfig().getDouble("Abilities.Earth.EarthShove.Damage");
maxBlocks = ProjectAddons.instance.getConfig().getInt("Abilities.Earth.EarthShove.MaxBlocks");
lavaMult = ProjectAddons.instance.getConfig().getDouble("Abilities.Earth.EarthShove.LavaMultiplier");
kick = new ArrayList<>();
}

Expand All @@ -84,7 +84,7 @@ public List<Location> getLocations() {

@Override
public String getName() {
return "EarthKick";
return "EarthShove";
}

@Override
Expand Down Expand Up @@ -204,7 +204,7 @@ public void remove() {

@Override
public long getCooldown() {
return ProjectAddons.instance.getConfig().getLong("Abilities.Earth.EarthKick.Cooldown");
return ProjectAddons.instance.getConfig().getLong("Abilities.Earth.EarthShove.Cooldown");
}

@Override
Expand Down Expand Up @@ -246,6 +246,6 @@ public static void removeBlock(FallingBlock fb) {

@Override
public boolean isEnabled() {
return ProjectAddons.instance.getConfig().getBoolean("Abilities.Earth.EarthKick.Enabled");
return ProjectAddons.instance.getConfig().getBoolean("Abilities.Earth.EarthShove.Enabled");
}
}
31 changes: 29 additions & 2 deletions src/me/simplicitee/project/addons/ability/fire/CombustBeam.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.simplicitee.project.addons.ability.fire;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
Expand All @@ -11,6 +12,9 @@
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;

import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.AddonAbility;
Expand Down Expand Up @@ -48,6 +52,8 @@ public class CombustBeam extends CombustionAbility implements AddonAbility {
@Attribute("MinDamage")
private double minDamage;

private BossBar chargeBar;

private double power, rotation, angleCheck, damage, health;
private long chargeTime, revertTime;
private int counter;
Expand All @@ -61,6 +67,12 @@ public class CombustBeam extends CombustionAbility implements AddonAbility {
public CombustBeam(Player player) {
super(player);


this.chargeBar = Bukkit.getServer().createBossBar("CombustBeam Charging...", BarColor.WHITE, BarStyle.SEGMENTED_6);
this.chargeBar.setProgress(0);
this.chargeBar.addPlayer(player);


if (hasAbility(player, CombustBeam.class)) {
return;
}
Expand All @@ -85,6 +97,19 @@ public CombustBeam(Player player) {

start();
}

private void UpdateChargeBar() {
double spendMs = System.currentTimeMillis() - this.getStartTime();
double subtract = spendMs / (maxChargeTime);
double progress = Math.min(1, subtract);
if(chargeBar.getColor()==BarColor.WHITE&&getStartTime() + maxChargeTime <= System.currentTimeMillis()) {
this.chargeBar.setColor(BarColor.RED);
this.chargeBar.setTitle("CombustionBeam Ready");
}

this.chargeBar.setProgress(progress);
//ActionBar.sendActionBar(ChatColor.RED + (Math.round(percent * 100) + "%"), player);
}

@Override
public void progress() {
Expand Down Expand Up @@ -124,7 +149,8 @@ public void progress() {
this.charged = true;
GeneralMethods.displayColoredParticle("ff2424", player.getEyeLocation().add(player.getEyeLocation().getDirection().normalize()), 1, 0.4, 0.4, 0.4);
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 10, 5));


UpdateChargeBar();
ActionBar.sendActionBar(ChatColor.RED + "100%", player);
} else if (getStartTime() + minChargeTime <= System.currentTimeMillis()) {
this.chargeTime = System.currentTimeMillis() - getStartTime() - minChargeTime;
Expand All @@ -135,7 +161,7 @@ public void progress() {
this.power = minPower + (maxPower - minPower) * percent;
this.damage = minDamage + (maxDamage - minDamage) * percent;
this.charged = true;

UpdateChargeBar();
ActionBar.sendActionBar(ChatColor.RED + (Math.round(percent * 100) + "%"), player);

HexColor color = new HexColor((int) (255 * percent), 136, 136);
Expand Down Expand Up @@ -239,6 +265,7 @@ public void explode() {
@Override
public void remove() {
super.remove();
this.chargeBar.removePlayer(this.player);
bPlayer.addCooldown(this);
}

Expand Down