use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class SoulShackle method onActivate.
@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
SoulShackle tempSoulShackle = new SoulShackle();
for (WarlordsPlayer shackleTarget : PlayerFilter.entitiesAround(wp, shackleRange, shackleRange, shackleRange).aliveEnemiesOf(wp).requireLineOfSight(wp).limit(maxShackleTargets)) {
wp.getSpeed().addSpeedModifier("Shacke Speed", 40, 30, "BASE");
wp.subtractEnergy(energyCost);
wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You shackled " + ChatColor.YELLOW + shackleTarget.getName() + ChatColor.GRAY + "!");
int silenceDuration = minSilenceDurationInTicks + (int) (shacklePool / 1000) * 20;
if (silenceDuration > maxSilenceDurationInTicks) {
silenceDuration = maxSilenceDurationInTicks;
}
System.out.println(minSilenceDurationInTicks);
System.out.println(maxSilenceDurationInTicks);
System.out.println(silenceDuration);
shackleTarget.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
shackleTarget.getCooldownManager().removeCooldown(SoulShackle.class);
shackleTarget.getCooldownManager().addRegularCooldown("Shackle Silence", "SILENCE", SoulShackle.class, tempSoulShackle, wp, CooldownTypes.DEBUFF, cooldownManager -> {
}, silenceDuration);
shacklePool = 0;
Utils.playGlobalSound(player.getLocation(), "warrior.intervene.impact", 1.5f, 0.45f);
Utils.playGlobalSound(player.getLocation(), "mage.fireball.activation", 1.5f, 0.3f);
EffectUtils.playChainAnimation(wp, shackleTarget, new ItemStack(Material.PUMPKIN), 20);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (shackleTarget.getCooldownManager().hasCooldown(tempSoulShackle)) {
Location playerLoc = shackleTarget.getLocation();
Location particleLoc = playerLoc.clone();
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
double angle = j / 10D * Math.PI * 2;
double width = 1.075;
particleLoc.setX(playerLoc.getX() + Math.sin(angle) * width);
particleLoc.setY(playerLoc.getY() + i / 5D);
particleLoc.setZ(playerLoc.getZ() + Math.cos(angle) * width);
ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(25, 25, 25), particleLoc, 500);
}
}
Utils.playGlobalSound(shackleTarget.getLocation(), Sound.DIG_SAND, 2, 2);
} else {
this.cancel();
}
}
}.runTaskTimer(0, 10);
return true;
}
return false;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class Soulbinding method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
wp.subtractEnergy(energyCost);
Soulbinding tempSoulBinding = new Soulbinding();
wp.getCooldownManager().addPersistentCooldown(name, "SOUL", Soulbinding.class, tempSoulBinding, wp, CooldownTypes.ABILITY, cooldownManager -> {
if (new CooldownFilter<>(cooldownManager, PersistentCooldown.class).filterCooldownClass(Soulbinding.class).stream().count() == 1) {
if (wp.getEntity() instanceof Player) {
((Player) wp.getEntity()).getInventory().getItem(0).removeEnchantment(Enchantment.OXYGEN);
}
}
}, duration * 20, soulbinding -> soulbinding.getSoulBindedPlayers().isEmpty());
ItemMeta newItemMeta = player.getInventory().getItem(0).getItemMeta();
newItemMeta.addEnchant(Enchantment.OXYGEN, 1, true);
player.getInventory().getItem(0).setItemMeta(newItemMeta);
Utils.playGlobalSound(player.getLocation(), "paladin.consecrate.activation", 2, 2);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (wp.getCooldownManager().hasCooldown(tempSoulBinding)) {
Location location = wp.getLocation();
location.add(0, 1.2, 0);
ParticleEffect.SPELL_WITCH.display(0.2F, 0F, 0.2F, 0.1F, 1, location, 500);
} else {
this.cancel();
}
}
}.runTaskTimer(0, 4);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class VitalityLiquor method onActivate.
@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
VitalityLiquor tempVitalityLiquor = new VitalityLiquor();
wp.subtractEnergy(energyCost);
wp.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
Utils.playGlobalSound(player.getLocation(), Sound.GLASS, 2, 0.1f);
Utils.playGlobalSound(player.getLocation(), Sound.BLAZE_DEATH, 2, 0.7f);
new FallingBlockWaveEffect(player.getLocation(), 7, 1, Material.SAPLING, (byte) 2).play();
for (WarlordsPlayer acuTarget : PlayerFilter.entitiesAround(player, acuRange, acuRange, acuRange).aliveTeammatesOfExcludingSelf(wp)) {
acuTarget.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
}
for (WarlordsPlayer enemyTarget : PlayerFilter.entitiesAround(player, acuRange, acuRange, acuRange).aliveEnemiesOf(wp)) {
new CooldownFilter<>(enemyTarget, RegularCooldown.class).filterCooldownClass(ImpalingStrike.class).filterCooldownFrom(wp).findAny().ifPresent(regularCooldown -> {
Utils.playGlobalSound(enemyTarget.getLocation(), Sound.GLASS, 2, 0.6f);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
for (WarlordsPlayer allyTarget : PlayerFilter.entitiesAround(player, 6, 6, 6).aliveTeammatesOf(wp).limit(2)) {
allyTarget.addHealingInstance(wp, name, minWaveHealing, maxWaveHealing, critChance, critMultiplier, false, false);
allyTarget.getCooldownManager().removeCooldown(VitalityLiquor.class);
allyTarget.getCooldownManager().addRegularCooldown("Vitality Liquor", "VITAL", VitalityLiquor.class, tempVitalityLiquor, wp, CooldownTypes.BUFF, cooldownManager -> {
}, duration * 20);
}
}
}.runTaskLater(5);
FireWorkEffectPlayer.playFirework(enemyTarget.getLocation(), FireworkEffect.builder().withColor(Color.ORANGE).with(FireworkEffect.Type.STAR).build());
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (wp.getCooldownManager().hasCooldown(tempVitalityLiquor)) {
EffectUtils.playParticleLinkAnimation(wp.getLocation(), enemyTarget.getLocation(), 255, 170, 0, 1);
} else {
this.cancel();
}
}
}.runTaskTimer(0, 5);
});
}
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class Game method start.
public void start() {
if (state != null) {
throw new IllegalStateException("Game already started");
}
for (GameAddon addon : addons) {
addon.modifyGame(this);
}
this.options = Collections.unmodifiableList(options);
state = this.map.initialState(this);
for (Option option : options) {
option.register(this);
}
for (Team team : TeamMarker.getTeams(this)) {
this.points.put(team, 0);
}
state.begin();
for (GameAddon addon : addons) {
addon.stateHasChanged(this, null, state);
}
new GameRunnable(this) {
@Override
public void run() {
Game.this.run();
}
}.runTaskTimer(0, 1);
// this.printDebuggingInformation();
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class BasicScoreboardOption method getDateScoreboard.
private static SimpleScoreboardHandler getDateScoreboard(Game game) {
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy - kk:mm");
format.setTimeZone(TimeZone.getTimeZone("EST"));
SimpleScoreboardHandler simpleScoreboardHandler = new SimpleScoreboardHandler(0, "date") {
@Nonnull
@Override
public List<String> computeLines(@Nullable WarlordsPlayer player) {
return Collections.singletonList(ChatColor.GRAY + format.format(new Date()));
}
};
new GameRunnable(game) {
@Override
public void run() {
simpleScoreboardHandler.markChanged();
}
}.runTaskTimer(GameRunnable.SECOND, GameRunnable.SECOND);
return simpleScoreboardHandler;
}
Aggregations