Skip to content

Commit

Permalink
Merge pull request #21 from PixelOutlaw/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
UltraFaceguy authored Dec 23, 2020
2 parents 8817a90 + fb18aaa commit 1c3309d
Show file tree
Hide file tree
Showing 15 changed files with 201 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</parent>

<artifactId>strife</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<packaging>jar</packaging>

<name>strife</name>
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/land/face/strife/commands/StrifeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import land.face.strife.data.champion.ChampionSaveData;
import land.face.strife.data.champion.LifeSkillType;
import land.face.strife.data.champion.StrifeAttribute;
import land.face.strife.menus.abilities.ReturnButton;
import land.face.strife.stats.AbilitySlot;
import land.face.strife.util.EloUtil;
import land.face.strife.util.TargetingUtil;
Expand Down Expand Up @@ -116,6 +117,12 @@ public void cooldownCommand(CommandSender sender, OnlinePlayer target) {
target.getPlayer().resetCooldown();
}

@Subcommand("swing")
@CommandCompletion("@players")
public void swinfCommand(CommandSender sender, OnlinePlayer target) {
target.getPlayer().swingMainHand();
}

@Subcommand("reload")
@CommandPermission("strife.admin")
public void reloadCommand(CommandSender sender) {
Expand Down Expand Up @@ -270,13 +277,15 @@ public void removeAbilityCommand(CommandSender sender, OnlinePlayer target, int
@CommandCompletion("@players")
@CommandPermission("strife.admin")
public void menuAbilityCommand(CommandSender sender, OnlinePlayer target) {
ReturnButton.setBackButtonEnabled(target.getPlayer(), true);
plugin.getAbilityPicker().open(target.getPlayer());
}

@Subcommand("ability submenu")
@CommandCompletion("@players")
@CommandPermission("strife.admin")
public void submenuAbilityCommand(CommandSender sender, OnlinePlayer target, String menu) {
ReturnButton.setBackButtonEnabled(target.getPlayer(), false);
plugin.getSubmenu(menu).open(target.getPlayer());
}

Expand Down Expand Up @@ -359,7 +368,7 @@ public void addSkillXp(CommandSender sender, OnlinePlayer target, String skill,
}

@Subcommand("addxp")
@CommandCompletion("@players @range:1-1000000")
@CommandCompletion("@players @range:1-10")
@CommandPermission("strife.admin")
public void addXpCommand(CommandSender sender, OnlinePlayer player, double amount) {
plugin.getExperienceManager().addExperience(player.getPlayer(), amount, true);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/land/face/strife/data/DamageModifiers.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class DamageModifiers {
private boolean consumeEarthRunes = false;
private boolean scaleChancesWithAttack = false;
private boolean showPopoffs = true;
private boolean bypassBarrier = false;

public AttackType getAttackType() {
return attackType;
Expand Down Expand Up @@ -136,6 +137,14 @@ public void setShowPopoffs(boolean showPopoffs) {
this.showPopoffs = showPopoffs;
}

public boolean isBypassBarrier() {
return bypassBarrier;
}

public void setBypassBarrier(boolean bypassBarrier) {
this.bypassBarrier = bypassBarrier;
}

public boolean isConsumeEarthRunes() {
return consumeEarthRunes;
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/land/face/strife/data/StrifeMob.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ public float damageBarrier(float amount) {
BarrierTask.spawnBarrierParticles(getEntity(), amount);
return 0;
} else {
if (barrier > 0) {
BarrierTask.spawnBarrierParticles(getEntity(), barrier);
}
barrier = 0;
barrierTask.updateArmorBar(this, 0);
float damageAmount = -1 * diff;
BarrierTask.spawnBarrierParticles(getEntity(), damageAmount);
return damageAmount;
return -1 * diff;
}
}

Expand Down
17 changes: 14 additions & 3 deletions src/main/java/land/face/strife/data/effects/ChaserEffect.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package land.face.strife.data.effects;

import land.face.strife.StrifePlugin;
import land.face.strife.data.LoadedChaser;
import land.face.strife.data.StrifeMob;
import land.face.strife.util.DamageUtil.OriginLocation;
Expand All @@ -14,6 +13,7 @@ public class ChaserEffect extends Effect {
private OriginLocation originLocation;
private Location overrideLocation;
private boolean canLocationOverride;
private boolean chaseCaster;

@Override
public void apply(StrifeMob caster, StrifeMob target) {
Expand All @@ -25,13 +25,21 @@ public void apply(StrifeMob caster, StrifeMob target) {
);
Location location;
if (overrideLocation == null) {
location = TargetingUtil.getOriginLocation(caster.getEntity(), originLocation);
if (canLocationOverride) {
location = TargetingUtil.getOriginLocation(target.getEntity(), originLocation);
} else {
location = TargetingUtil.getOriginLocation(caster.getEntity(), originLocation);
}
} else {
location = overrideLocation;
overrideLocation = null;
}

StrifePlugin.getInstance().getChaserManager().createChaser(caster, getId(), vector, location, target.getEntity());
if (chaseCaster) {
getPlugin().getChaserManager().createChaser(caster, getId(), vector, location, caster.getEntity());
} else {
getPlugin().getChaserManager().createChaser(caster, getId(), vector, location, target.getEntity());
}
}

public boolean isCanLocationOverride() {
Expand All @@ -42,6 +50,9 @@ public void setCanLocationOverride(boolean canLocationOverride) {
this.canLocationOverride = canLocationOverride;
}

public void setChaseCaster(boolean chaseCaster) {
this.chaseCaster = chaseCaster;
}

public void setOverrideLocation(Location location) {
overrideLocation = location;
Expand Down
35 changes: 34 additions & 1 deletion src/main/java/land/face/strife/data/effects/Damage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import land.face.strife.StrifePlugin;
import land.face.strife.data.BonusDamage;
import land.face.strife.data.DamageModifiers;
import land.face.strife.data.StrifeMob;
import land.face.strife.data.TargetResponse;
import land.face.strife.events.StrifeDamageEvent;
import land.face.strife.stats.StrifeStat;
import land.face.strife.util.DamageUtil;
import land.face.strife.util.DamageUtil.AbilityMod;
import land.face.strife.util.DamageUtil.AttackType;
import land.face.strife.util.DamageUtil.DamageType;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;

public class Damage extends Effect {

Expand All @@ -31,6 +35,9 @@ public class Damage extends Effect {
private boolean isBlocking;
private boolean applyOnHitEffects;
private boolean showPopoffs;
private boolean bypassBarrier;
private List<Effect> hitEffects = new ArrayList<>();
private List<Effect> killEffects = new ArrayList<>();

@Override
public void apply(StrifeMob caster, StrifeMob target) {
Expand All @@ -44,6 +51,7 @@ public void apply(StrifeMob caster, StrifeMob target) {
mods.setCanBeBlocked(canBeBlocked);
mods.setApplyOnHitEffects(applyOnHitEffects);
mods.setShowPopoffs(showPopoffs);
mods.setBypassBarrier(bypassBarrier);
if (canSneakAttack && StrifePlugin.getInstance().getStealthManager().isStealthed(caster.getEntity())) {
mods.setSneakAttack(true);
}
Expand Down Expand Up @@ -78,7 +86,16 @@ public void apply(StrifeMob caster, StrifeMob target) {
}

StrifePlugin.getInstance().getDamageManager().dealDamage(caster, target,
(float) strifeDamageEvent.getFinalDamage());
(float) strifeDamageEvent.getFinalDamage(), mods);

Set<LivingEntity> entities = new HashSet<>();
entities.add(target.getEntity());
TargetResponse response = new TargetResponse(entities);

getPlugin().getEffectManager().executeEffectList(caster, response, hitEffects);
if (target.getEntity().isDead()) {
getPlugin().getEffectManager().executeEffectList(caster, response, killEffects);
}

if (damage.containsKey(DamageType.PHYSICAL)) {
DamageUtil.attemptBleed(caster, target, damage.get(DamageType.PHYSICAL), mods, false);
Expand Down Expand Up @@ -168,6 +185,22 @@ public void setShowPopoffs(boolean showPopoffs) {
this.showPopoffs = showPopoffs;
}

public boolean isBypassBarrier() {
return bypassBarrier;
}

public void setBypassBarrier(boolean bypassBarrier) {
this.bypassBarrier = bypassBarrier;
}

public List<Effect> getHitEffects() {
return hitEffects;
}

public List<Effect> getKillEffects() {
return killEffects;
}

public boolean isBlocking() {
return isBlocking;
}
Expand Down
67 changes: 67 additions & 0 deletions src/main/java/land/face/strife/events/PropertyUpdateEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* The MIT License
* Copyright (c) 2015 Teal Cube Games
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package land.face.strife.events;

import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public class PropertyUpdateEvent extends Event {

private static final HandlerList HANDLER_LIST = new HandlerList();

public static HandlerList getHandlerList() {
return HANDLER_LIST;
}

private final String id;
private final float baseValue;
private float appliedValue;

public PropertyUpdateEvent(String id, float baseValue) {
this.id = id;
this.baseValue = baseValue;
appliedValue = baseValue;
}

public String getId() {
return id;
}

public float getBaseValue() {
return baseValue;
}

public float getAppliedValue() {
return appliedValue;
}

public void setAppliedValue(float appliedValue) {
this.appliedValue = appliedValue;
}

@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}

}
5 changes: 2 additions & 3 deletions src/main/java/land/face/strife/listeners/CombatListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ public void strifeDamageHandler(EntityDamageByEntityEvent event) {
return;
}

Bukkit.getLogger().info("e1: " + strifeDamageEvent.getFinalDamage());
float eventDamage = Math.max(0.002f, defender.damageBarrier((float) strifeDamageEvent.getFinalDamage()));
Bukkit.getLogger().info("e2: " + eventDamage);
eventDamage = plugin.getDamageManager().doEnergyAbsorb(defender, eventDamage);

if (damage.containsKey(DamageType.PHYSICAL)) {
Expand All @@ -285,7 +283,8 @@ public void strifeDamageHandler(EntityDamageByEntityEvent event) {
() -> DamageUtil.postDamage(attacker, defender, damageModifiers), 0L);

if (attackEntity instanceof Bee) {
plugin.getDamageManager().dealDamage(attacker, defender, (float) strifeDamageEvent.getFinalDamage());
plugin.getDamageManager().dealDamage(attacker, defender,
(float) strifeDamageEvent.getFinalDamage(), damageModifiers);
event.setCancelled(true);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public void onPlayerArrowShoot(ProjectileLaunchEvent event) {

float attackMultiplier = plugin.getAttackSpeedManager().getAttackMultiplier(mob);
attackMultiplier = (float) Math.pow(attackMultiplier, 1.5f);
player.resetCooldown();

if (attackMultiplier < 0.1) {
event.setCancelled(true);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/land/face/strife/managers/DamageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Map;
import java.util.UUID;
import land.face.strife.StrifePlugin;
import land.face.strife.data.DamageModifiers;
import land.face.strife.data.StrifeMob;
import land.face.strife.stats.StrifeTrait;
import land.face.strife.util.StatUtil;
Expand All @@ -45,8 +46,10 @@ public double getHandledDamage(Entity entity) {
return handledDamages.getOrDefault(entity.getUniqueId(), 0D);
}

public double dealDamage(StrifeMob attacker, StrifeMob defender, float damage) {
damage = Math.max(0.002f, defender.damageBarrier(damage));
public double dealDamage(StrifeMob attacker, StrifeMob defender, float damage, DamageModifiers modifiers) {
if (!modifiers.isBypassBarrier()) {
damage = Math.max(0.002f, defender.damageBarrier(damage));
}
damage = doEnergyAbsorb(defender, damage);
if (attacker == defender) {
if (damage > defender.getEntity().getHealth()) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/land/face/strife/managers/EffectManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ public void loadEffect(String key, ConfigurationSection cs) {
((Damage) effect).setCanSneakAttack(cs.getBoolean("can-sneak-attack", false));
((Damage) effect).setApplyOnHitEffects(cs.getBoolean("apply-on-hit-effects", attackMult >= 0.7));
((Damage) effect).setShowPopoffs(cs.getBoolean("show-popoffs", true));
((Damage) effect).setBypassBarrier(cs.getBoolean("bypass-barrier", false));
List<String> hitEffects = cs.getStringList("hit-effects");
delayedSetEffects(((Damage) effect).getHitEffects(), hitEffects, key, false);
List<String> killEffects = cs.getStringList("kill-effects");
delayedSetEffects(((Damage) effect).getKillEffects(), killEffects, key, false);
((Damage) effect).setAttackType(AttackType.valueOf(cs.getString("attack-type", "OTHER")));
ConfigurationSection multCs = cs.getConfigurationSection("damage-multipliers");
Map<DamageType, Float> multMap = new HashMap<>();
Expand Down Expand Up @@ -334,6 +339,7 @@ public void loadEffect(String key, ConfigurationSection cs) {
OriginLocation.valueOf(cs.getString("origin", "HEAD")));
((ChaserEffect) effect).setLoadedChaser(data);
((ChaserEffect) effect).setCanLocationOverride(cs.getBoolean("location-override", false));
((ChaserEffect) effect).setChaseCaster(cs.getBoolean("chase-caster", false));
break;
case CONSOLE_COMMAND:
effect = new ConsoleCommand();
Expand Down
Loading

0 comments on commit 1c3309d

Please sign in to comment.