Skip to content

Commit

Permalink
Merge pull request #27 from PixelOutlaw/develop
Browse files Browse the repository at this point in the history
Release 3.4.2
  • Loading branch information
UltraFaceguy committed Jun 5, 2021
2 parents cd1be3d + edb09d0 commit 25cdf34
Show file tree
Hide file tree
Showing 49 changed files with 652 additions and 433 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.1</version>
<version>3.4.2</version>
<packaging>jar</packaging>

<name>strife</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public InspectCommand(StrifePlugin plugin) {

@Default
public void baseCommand(Player sender) {
plugin.getChampionManager().updateEquipmentStats(sender);
plugin.getStrifeMobManager().updateEquipmentStats(plugin.getStrifeMobManager().getStatMob(sender));
plugin.getChampionManager().update(sender);
plugin.getStatUpdateManager().updateVanillaAttributes(sender);
plugin.getStatsMenu().getInspectionTargetMap().put(sender, sender);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/land/face/strife/commands/StrifeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ public void bindCommand(CommandSender sender, OnlinePlayer target, String loreAb
sendMessage(sender, "<red>Invalid loreAbility ID: " + loreAbilityId);
return;
}
Champion champion = plugin.getChampionManager().getChampion(target.getPlayer());
boolean success = plugin.getChampionManager().addBoundLoreAbility(champion, ability);
StrifeMob mob = plugin.getStrifeMobManager().getStatMob(target.getPlayer());
boolean success = plugin.getChampionManager().addBoundLoreAbility(mob, ability);
if (success) {
sendMessage(sender,
"&aBound loreAbility " + loreAbilityId + " to player " + target.getPlayer().getName());
Expand All @@ -341,8 +341,8 @@ public void unbindCommand(CommandSender sender, OnlinePlayer target, String lore
sendMessage(sender, "<red>Invalid loreAbility ID: " + loreAbilityId);
return;
}
Champion champion = plugin.getChampionManager().getChampion(target.getPlayer());
boolean success = plugin.getChampionManager().removeBoundLoreAbility(champion, ability);
StrifeMob mob = plugin.getStrifeMobManager().getStatMob(target.getPlayer());
boolean success = plugin.getChampionManager().removeBoundLoreAbility(mob, ability);
if (success) {
sendMessage(sender,
"&aUnbound loreAbility " + loreAbilityId + " to player " + target.getPlayer().getName());
Expand Down
1 change: 1 addition & 0 deletions src/main/java/land/face/strife/data/DamageModifiers.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public enum ElementalStatus {
FREEZE,
SHOCK,
CORRUPT,
CRUNCH
}

}
2 changes: 1 addition & 1 deletion src/main/java/land/face/strife/data/Spawner.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Spawner(String id, UniqueEntity uniqueEntity, String uniqueId, int amount
this.leashRange = leashRange;
chunkKey = location.getChunk().getChunkKey();

runTaskTimer(StrifePlugin.getInstance(), SPAWNER_OFFSET, 40L);
runTaskTimer(StrifePlugin.getInstance(), SPAWNER_OFFSET % 20, 40L);
SPAWNER_OFFSET++;
LogUtil.printDebug("Created Spawner with taskId " + getTaskId());
}
Expand Down
81 changes: 73 additions & 8 deletions src/main/java/land/face/strife/data/StrifeMob.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
import land.face.strife.data.ability.EntityAbilitySet;
import land.face.strife.data.buff.Buff;
import land.face.strife.data.champion.Champion;
import land.face.strife.data.champion.EquipmentCache;
import land.face.strife.data.effects.FiniteUsesEffect;
import land.face.strife.managers.LoreAbilityManager.TriggerType;
import land.face.strife.managers.StatUpdateManager;
import land.face.strife.stats.StrifeStat;
import land.face.strife.stats.StrifeTrait;
Expand All @@ -33,6 +35,7 @@ public class StrifeMob {

private final static int CACHE_DELAY = 100;

private final EquipmentCache equipmentCache = new EquipmentCache();
private final Map<StrifeStat, Float> baseStats = new HashMap<>();
private final Map<StrifeStat, Float> statCache = new HashMap<>();

Expand All @@ -56,11 +59,13 @@ public class StrifeMob {
private float maxBarrier = 0;
private boolean shielded;

private boolean useEquipment;

private CombatCountdownTask combatCountdownTask = null;

private final BarrierTask barrierTask = new BarrierTask(this);
private final LifeTask lifeTask = new LifeTask(this);
private final EnergyTask energyTask = new EnergyTask(this);
private BarrierTask barrierTask = new BarrierTask(this);
private LifeTask lifeTask = new LifeTask(this);
private EnergyTask energyTask = new EnergyTask(this);
private MinionTask minionTask = null;

private final Set<StrifeMob> minions = new HashSet<>();
Expand All @@ -70,11 +75,13 @@ public class StrifeMob {
public StrifeMob(Champion champion) {
this.livingEntity = new WeakReference<>(champion.getPlayer());
this.champion = new WeakReference<>(champion);
useEquipment = true;
}

public StrifeMob(LivingEntity livingEntity) {
this.livingEntity = new WeakReference<>(livingEntity);
this.champion = new WeakReference<>(null);
useEquipment = livingEntity instanceof Player;
}

public float getBarrier() {
Expand Down Expand Up @@ -218,6 +225,14 @@ public EntityAbilitySet getAbilitySet() {
return abilitySet;
}

public boolean isUseEquipment() {
return useEquipment;
}

public void setUseEquipment(boolean useEquipment) {
this.useEquipment = useEquipment;
}

public void setAbilitySet(EntityAbilitySet abilitySet) {
this.abilitySet = abilitySet;
}
Expand Down Expand Up @@ -258,7 +273,7 @@ public Map<StrifeStat, Float> getFinalStats() {
if (getChampion() != null) {
return StatUpdateManager.combineMaps(getChampion().getCombinedCache(), getBuffStats());
}
return StatUpdateManager.combineMaps(baseStats, getBuffStats());
return StatUpdateManager.combineMaps(baseStats, getBuffStats(), equipmentCache.getCombinedStats());
}

public Map<StrifeStat, Float> getBaseStats() {
Expand Down Expand Up @@ -347,11 +362,28 @@ public boolean isMasterOf(LivingEntity entity) {
return false;
}

public boolean hasTrait(StrifeTrait trait) {
if (getChampion() == null) {
return false;
public EquipmentCache getEquipmentCache() {
return equipmentCache;
}

public Map<TriggerType, Set<LoreAbility>> getLoreAbilities() {
return equipmentCache.getCombinedAbilities();
}

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

public boolean hasTrait (StrifeTrait trait) {
if (champion.get() == null) {
return equipmentCache.getCombinedTraits().contains(trait);
}
return Objects.requireNonNull(champion.get()).hasTrait(trait);
return equipmentCache.getCombinedTraits().contains(trait) ||
Objects.requireNonNull(champion.get()).getPathTraits().contains(trait);
}

public void removeMinion(StrifeMob minion) {
Expand Down Expand Up @@ -400,6 +432,39 @@ public void setCharmImmune(boolean charmImmune) {
this.charmImmune = charmImmune;
}

public void minionDeath() {
if (minionTask == null) {
return;
}
minionTask.forceStartDeath();
}

public double getMinionRating() {
if (minionTask == null) {
// Arbitrary High Number
return 10000000;
}
if (minionTask.getLifespan() < 1) {
return 0;
}
return livingEntity.get().getHealth() * (1 + (double) minionTask.getLifespan() / 10D);
}

public void restartTimers() {
if (lifeTask != null && !lifeTask.isCancelled()) {
lifeTask.cancel();
}
lifeTask = new LifeTask(this);
if (barrierTask != null && !barrierTask.isCancelled()) {
barrierTask.cancel();
}
barrierTask = new BarrierTask(this);
if (energyTask != null && !energyTask.isCancelled()) {
energyTask.cancel();
}
energyTask = new EnergyTask(this);
}

public void bumpCombat() {
if (isInCombat()) {
combatCountdownTask.bump();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/land/face/strife/data/UniqueEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class UniqueEntity {
private boolean angry;
private boolean zombificationImmune;
private boolean armsRaised;
private boolean hasAI;
private boolean gravity;
private Profession profession;
private int size;
Expand Down Expand Up @@ -154,6 +155,15 @@ public void setArmsRaised(boolean armsRaised) {
this.armsRaised = armsRaised;
}

public boolean isHasAI() {
return hasAI;
}

public void setHasAI(boolean hasAI) {
this.hasAI = hasAI;
}


public boolean isGravity() {
return gravity;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/land/face/strife/data/buff/Buff.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Map;
import java.util.UUID;
import land.face.strife.stats.StrifeStat;
import org.bukkit.Bukkit;

public class Buff {

Expand Down Expand Up @@ -52,7 +51,7 @@ public long getEndingTimestamp() {
public void bumpBuff(double duration) {
setExpireTimeFromDuration(duration);
stacks = Math.min(stacks + 1, maxStacks);
Bukkit.getLogger().warning(" Stacks: " + stacks + "/" + maxStacks);
//Bukkit.getLogger().warning(" Stacks: " + stacks + "/" + maxStacks);
}

public int getStacks() {
Expand Down
24 changes: 0 additions & 24 deletions src/main/java/land/face/strife/data/champion/Champion.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@
import java.util.UUID;
import land.face.strife.StrifePlugin;
import land.face.strife.data.CombatDetailsContainer;
import land.face.strife.data.LoreAbility;
import land.face.strife.managers.LoreAbilityManager.TriggerType;
import land.face.strife.managers.StatUpdateManager;
import land.face.strife.stats.StrifeStat;
import land.face.strife.stats.StrifeTrait;
import org.bukkit.entity.Player;

public class Champion {

private final PlayerEquipmentCache equipmentCache;
private final ChampionSaveData saveData;
private final CombatDetailsContainer detailsContainer = new CombatDetailsContainer();

Expand All @@ -62,7 +59,6 @@ public Champion(Player player, ChampionSaveData saveData) {
levelPointStats = new HashMap<>();
combinedStatMap = new HashMap<>();
pathStats = new HashMap<>();
equipmentCache = new PlayerEquipmentCache();
pathTraits = new HashSet<>();
}

Expand All @@ -80,7 +76,6 @@ public void recombineCache() {
baseStats,
levelPointStats,
pathStats,
equipmentCache.getCombinedStats(),
StrifePlugin.getInstance().getBoostManager().getStats()
));
}
Expand Down Expand Up @@ -197,10 +192,6 @@ public CombatDetailsContainer getDetailsContainer() {
return detailsContainer;
}

public PlayerEquipmentCache getEquipmentCache() {
return equipmentCache;
}

public Map<StrifeStat, Float> getPathStats() {
return pathStats;
}
Expand All @@ -209,21 +200,6 @@ public Set<StrifeTrait> getPathTraits() {
return pathTraits;
}

public Map<TriggerType, Set<LoreAbility>> getLoreAbilities() {
return equipmentCache.getCombinedAbilities();
}

public Set<StrifeTrait> getTraits() {
Set<StrifeTrait> traits = new HashSet<>();
traits.addAll(equipmentCache.getCombinedTraits());
traits.addAll(pathTraits);
return traits;
}

public boolean hasTrait (StrifeTrait trait) {
return equipmentCache.getCombinedTraits().contains(trait) || pathTraits.contains(trait);
}

public int getUnchosenPaths() {
return getHighestReachedLevel() / 10 - saveData.getPathMap().size();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import java.util.Map;
import java.util.Set;
import land.face.strife.data.LoreAbility;
import land.face.strife.data.StrifeMob;
import land.face.strife.managers.LoreAbilityManager;
import land.face.strife.managers.LoreAbilityManager.TriggerType;
import land.face.strife.managers.StatUpdateManager;
import land.face.strife.stats.StrifeStat;
import land.face.strife.stats.StrifeTrait;
import org.bukkit.inventory.EquipmentSlot;

public class PlayerEquipmentCache {
public class EquipmentCache {

private final Map<EquipmentSlot, Integer> slotHashCodeMap = new HashMap<>();

Expand All @@ -28,7 +29,7 @@ public class PlayerEquipmentCache {

public final static EquipmentSlot[] ITEM_SLOTS = EquipmentSlot.values();

PlayerEquipmentCache() {
public EquipmentCache() {
for (EquipmentSlot slot : ITEM_SLOTS) {
slotHashCodeMap.put(slot, -1);
slotStatMap.put(slot, new HashMap<>());
Expand Down Expand Up @@ -105,11 +106,14 @@ public void recombineStats() {
));
}

public void recombineAbilities(Champion champion) {
public void recombineAbilities(StrifeMob mob) {
for (TriggerType triggerType : LoreAbilityManager.triggerTypes) {
loreAbilities.get(triggerType).clear();
}
Set<LoreAbility> newAbilities = new HashSet<>(champion.getSaveData().getBoundAbilities());
Set<LoreAbility> newAbilities = new HashSet<>();
if (mob.getChampion() != null) {
newAbilities.addAll(mob.getChampion().getSaveData().getBoundAbilities());
}
for (EquipmentSlot slot : ITEM_SLOTS) {
newAbilities.addAll(slotAbilityMap.get(slot));
}
Expand All @@ -125,9 +129,9 @@ public void recombineTraits() {
}
}

public void recombine(Champion champion) {
public void recombine(StrifeMob mob) {
recombineStats();
recombineAbilities(champion);
recombineAbilities(mob);
recombineTraits();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public enum ConditionType {
ENDLESS_EFFECT,
BLOCKING,
MOVING,
MINION,
NEARBY_ENTITIES,
IN_COMBAT,
CHANCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public LoreCondition(String loreId) {
public boolean isMet(StrifeMob attacker, StrifeMob target) {
StrifeMob actualTarget = getCompareTarget() == CompareTarget.SELF ? attacker : target;
if (actualTarget.getChampion() != null) {
for (Set<LoreAbility> las : actualTarget.getChampion().getLoreAbilities().values()) {
for (Set<LoreAbility> las : actualTarget.getLoreAbilities().values()) {
for (LoreAbility la : las) {
if (loreId.equals(la.getId())) {
return true;
Expand Down
Loading

0 comments on commit 25cdf34

Please sign in to comment.