Skip to content

Commit

Permalink
Merge pull request #28 from PixelOutlaw/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
UltraFaceguy committed Jul 11, 2021
2 parents 25cdf34 + 77e38ea commit daa449c
Show file tree
Hide file tree
Showing 64 changed files with 1,098 additions and 501 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.4.2</version>
<version>3.4.4</version>
<packaging>jar</packaging>

<name>strife</name>
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/land/face/strife/StrifePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ The MIT License Copyright (c) 2015 Teal Cube Games
import land.face.strife.data.effects.ShootBlock;
import land.face.strife.data.effects.TriggerLoreAbility;
import land.face.strife.hooks.SnazzyPartiesHook;
import land.face.strife.listeners.BullionListener;
import land.face.strife.listeners.ChatListener;
import land.face.strife.listeners.CombatListener;
import land.face.strife.listeners.CreeperExplodeListener;
Expand Down Expand Up @@ -472,7 +471,6 @@ public void enable() {
Bukkit.getPluginManager().registerEvents(new StatUpdateListener(this), this);
Bukkit.getPluginManager().registerEvents(new EntityMagicListener(this), this);
Bukkit.getPluginManager().registerEvents(new SpawnListener(this), this);
Bukkit.getPluginManager().registerEvents(new MoneyDropListener(this), this);
Bukkit.getPluginManager().registerEvents(new ShearsEquipListener(), this);
Bukkit.getPluginManager().registerEvents(new MinionListener(this), this);
Bukkit.getPluginManager().registerEvents(new TargetingListener(this), this);
Expand All @@ -486,7 +484,7 @@ public void enable() {
entityHider = new EntityHider(this, Policy.BLACKLIST);

if (Bukkit.getPluginManager().getPlugin("Bullion") != null) {
Bukkit.getPluginManager().registerEvents(new BullionListener(this), this);
Bukkit.getPluginManager().registerEvents(new MoneyDropListener(this), this);
}
if (Bukkit.getPluginManager().getPlugin("HeadDatabase") != null) {
Bukkit.getPluginManager().registerEvents(new HeadLoadListener(this), this);
Expand Down
30 changes: 9 additions & 21 deletions src/main/java/land/face/strife/data/BlockData.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,30 @@

public class BlockData {

private long lastHit;
private double storedBlock;
private long runeFalloff;
private int runes;
private final Set<Hologram> runeHolograms = new HashSet<>();

public BlockData(long lastHit, double storedBlock) {
this.lastHit = lastHit;
this.storedBlock = storedBlock;
public BlockData() {
this.runes = 0;
}

public long getLastHit() {
return lastHit;
}

public void setLastHit(long lastHit) {
this.lastHit = lastHit;
}

public double getStoredBlock() {
return storedBlock;
}

public void setStoredBlock(double storedBlock) {
this.storedBlock = storedBlock;
}

public int getRunes() {
return runes;
}

public void setRunes(int runes) {
if (runes >= this.runes) {
runeFalloff = System.currentTimeMillis() + 300000L;
}
this.runes = runes;
}

public Set<Hologram> getRuneHolograms() {
return runeHolograms;
}

public long getRuneFalloff() {
return runeFalloff;
}
}
8 changes: 7 additions & 1 deletion src/main/java/land/face/strife/data/ChaserEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ public class ChaserEntity {
private final String chaserId;
private final int lifespan;
private final float speed;
private final float maxSpeed;

private Vector velocity;
private Location location;
private LivingEntity target;
private int currentTick;

public ChaserEntity(final StrifeMob caster, String chaserId, Location location,
LivingEntity target, float speed, Vector velocity, int lifespan) {
LivingEntity target, float speed, float maxSpeed, Vector velocity, int lifespan) {
this.caster = caster;
this.chaserId = chaserId;
this.speed = speed;
this.maxSpeed = maxSpeed;
this.velocity = velocity;
this.lifespan = lifespan;
this.location = location;
Expand All @@ -44,6 +46,10 @@ public float getSpeed() {
return speed;
}

public float getMaxSpeed() {
return maxSpeed;
}

public Vector getVelocity() {
return velocity;
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/land/face/strife/data/Spawner.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ public static void spawnSpawner(Spawner s) {
if (maxMobs - existingMobs < 1) {
return;
}
StrifeMob mob = StrifePlugin.getInstance().getUniqueEntityManager()
.spawnUnique(s.getUniqueEntity(), s.getLocation());
StrifeMob mob = StrifePlugin.getInstance().getStrifeMobManager().getStatMob(
(LivingEntity) StrifePlugin.getInstance().getUniqueEntityManager()
.spawnUnique(s.getUniqueEntity(), s.getLocation()));

if (mob == null || mob.getEntity() == null || !mob.getEntity().isValid()) {
Bukkit.getLogger().warning("Spawner failed to spawn unique! " + s.getId());
Expand Down
96 changes: 88 additions & 8 deletions src/main/java/land/face/strife/data/StrifeMob.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import land.face.strife.util.SpecialStatusUtil;
import land.face.strife.util.StatUtil;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;

Expand Down Expand Up @@ -57,6 +59,7 @@ public class StrifeMob {
private float maxEnergy = 0;
private float barrier = 0;
private float maxBarrier = 0;
private float block = 0;
private boolean shielded;

private boolean useEquipment;
Expand All @@ -71,6 +74,7 @@ public class StrifeMob {
private final Set<StrifeMob> minions = new HashSet<>();

private long cacheStamp = 1L;
private long globalCooldownStamp = 1L;

public StrifeMob(Champion champion) {
this.livingEntity = new WeakReference<>(champion.getPlayer());
Expand All @@ -84,6 +88,14 @@ public StrifeMob(LivingEntity livingEntity) {
useEquipment = livingEntity instanceof Player;
}

public void bumpGlobalCooldown(int millis) {
globalCooldownStamp = System.currentTimeMillis() + millis;
}

public boolean isGlobalCooldownReady() {
return globalCooldownStamp < System.currentTimeMillis();
}

public float getBarrier() {
return barrier;
}
Expand All @@ -92,6 +104,31 @@ public float getMaxBarrier() {
return maxBarrier;
}

public float getBlock() {
return block;
}

public void setBlock(float block) {
this.block = block;
if (getEntity() instanceof Player) {
Player player = (Player) getEntity();
for (AttributeModifier mod : player.getAttribute(Attribute.GENERIC_ARMOR).getModifiers()) {
player.getAttribute(Attribute.GENERIC_ARMOR).removeModifier(mod);
}
float maxBlock = getMaxBlock();
float percent = maxBlock > 0 ? block / maxBlock : 1;
if (percent > 0.99) {
player.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(-20);
} else {
player.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(Math.max(1, 20 * percent));
}
}
}

public float getMaxBlock() {
return statCache.getOrDefault(StrifeStat.BLOCK, 0f);
}

public void setMaxBarrier(float maxBarrier) {
this.maxBarrier = maxBarrier;
}
Expand All @@ -103,7 +140,9 @@ public void restoreBarrier(float amount) {
}
float maxBarrier = StatUtil.getMaximumBarrier(this);
barrier = Math.min(barrier + amount, maxBarrier);
barrierTask.updateArmorBar(this, barrier, maxBarrier);
if (barrierTask != null) {
barrierTask.forceAbsorbHearts();
}
}

public float damageBarrier(float amount) {
Expand All @@ -115,19 +154,29 @@ public float damageBarrier(float amount) {
float diff = barrier - amount;
if (diff > 0) {
barrier -= amount;
barrierTask.updateArmorBar(this, barrier, StatUtil.getMaximumBarrier(this));
if (barrierTask != null) {
barrierTask.forceAbsorbHearts();
}
BarrierTask.spawnBarrierParticles(getEntity(), amount);
return 0;
} else {
if (barrier > 0) {
BarrierTask.spawnBarrierParticles(getEntity(), barrier);
}
barrier = 0;
barrierTask.updateArmorBar(this, 0);
if (barrierTask != null) {
barrierTask.forceAbsorbHearts();
}
return -1 * diff;
}
}

public void updateBarrierScale() {
if (getEntity() instanceof Player && barrierTask != null) {
barrierTask.updateBarrierScale();
}
}

public float getEnergy() {
return energy;
}
Expand Down Expand Up @@ -269,11 +318,18 @@ public Champion getChampion() {
return champion == null ? null : champion.get();
}

public void clearBuffs() {
runningBuffs.clear();
cacheStamp = 1L;
}

public Map<StrifeStat, Float> getFinalStats() {
if (getChampion() != null) {
return StatUpdateManager.combineMaps(getChampion().getCombinedCache(), getBuffStats());
return StatUpdateManager.combineMaps(getChampion().getCombinedCache(),
getBuffStats(), equipmentCache.getCombinedStats());
}
return StatUpdateManager.combineMaps(baseStats, getBuffStats(), equipmentCache.getCombinedStats());
return StatUpdateManager.combineMaps(baseStats, getBuffStats(),
equipmentCache.getCombinedStats());
}

public Map<StrifeStat, Float> getBaseStats() {
Expand Down Expand Up @@ -372,13 +428,13 @@ public Map<TriggerType, Set<LoreAbility>> getLoreAbilities() {

public Set<StrifeTrait> getTraits() {
Set<StrifeTrait> traits = new HashSet<>(equipmentCache.getCombinedTraits());
if (champion.get() == null) {
if (champion.get() != null) {
traits.addAll(Objects.requireNonNull(champion.get()).getPathTraits());
}
return traits;
}

public boolean hasTrait (StrifeTrait trait) {
public boolean hasTrait(StrifeTrait trait) {
if (champion.get() == null) {
return equipmentCache.getCombinedTraits().contains(trait);
}
Expand Down Expand Up @@ -440,7 +496,7 @@ public void minionDeath() {
}

public double getMinionRating() {
if (minionTask == null) {
if (minionTask == null || !getEntity().getPassengers().isEmpty()) {
// Arbitrary High Number
return 10000000;
}
Expand All @@ -466,14 +522,30 @@ public void restartTimers() {
}

public void bumpCombat() {
bumpCombat(false);
}

public void bumpCombat(boolean pvp) {
if (isInCombat()) {
combatCountdownTask.bump();
if (pvp) {
combatCountdownTask.setPvp();
}
return;
}
combatCountdownTask = new CombatCountdownTask(this);
if (pvp) {
combatCountdownTask.setPvp();
}
combatCountdownTask.runTaskTimer(StrifePlugin.getInstance(), 0L, 10L);
}

public void flagPvp() {
if (livingEntity.get() instanceof Player && isInCombat()) {
combatCountdownTask.setPvp();
}
}

public void endCombat() {
if (!combatCountdownTask.isCancelled()) {
combatCountdownTask.cancel();
Expand All @@ -485,6 +557,14 @@ public boolean isInCombat() {
return combatCountdownTask != null;
}

public boolean isInPvp() {
return combatCountdownTask != null && combatCountdownTask.isPvp();
}

public boolean diedFromPvp() {
return getEntity() instanceof Player && getEntity().getKiller() != null || isInPvp();
}

public Map<StrifeStat, Float> getBuffStats() {
Map<StrifeStat, Float> stats = new HashMap<>();
Iterator<Buff> iterator = runningBuffs.iterator();
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/land/face/strife/data/TargetResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import java.util.HashSet;
import java.util.Set;
import land.face.strife.timers.SoulTimer;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;

public class TargetResponse {

private final Set<LivingEntity> entities = new HashSet<>();
private final Set<SoulTimer> souls = new HashSet<>();
private Location location = null;
private boolean cancelOnCasterDeath = false;
private boolean force = false;

public TargetResponse(Set<LivingEntity> entities, Location location) {
this.entities.addAll(entities);
Expand All @@ -25,6 +28,14 @@ public TargetResponse(Set<LivingEntity> entities, boolean cancelOnCasterDeath) {
this.cancelOnCasterDeath = cancelOnCasterDeath;
}

public boolean isForce() {
return force;
}

public void setForce(boolean force) {
this.force = force;
}

public boolean isCancelOnCasterDeath() {
return cancelOnCasterDeath;
}
Expand Down
Loading

0 comments on commit daa449c

Please sign in to comment.