Skip to content

Commit

Permalink
Merge pull request #11 from PixelOutlaw/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
UltraFaceguy authored Jun 7, 2020
2 parents 9ac7862 + 062f472 commit fae215f
Show file tree
Hide file tree
Showing 47 changed files with 701 additions and 242 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.0.7</version>
<version>3.0.9</version>
<packaging>jar</packaging>

<name>strife</name>
Expand Down
31 changes: 27 additions & 4 deletions src/main/java/land/face/strife/StrifePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@
import land.face.strife.listeners.DataListener;
import land.face.strife.listeners.DeathListener;
import land.face.strife.listeners.DogeListener;
import land.face.strife.listeners.DoubleJumpListener;
import land.face.strife.listeners.EndermanListener;
import land.face.strife.listeners.EntityMagicListener;
import land.face.strife.listeners.EvokerFangEffectListener;
import land.face.strife.listeners.ExperienceListener;
import land.face.strife.listeners.FallListener;
import land.face.strife.listeners.HeadDropListener;
import land.face.strife.listeners.HeadLoadListener;
import land.face.strife.listeners.HealingListener;
import land.face.strife.listeners.InventoryListener;
import land.face.strife.listeners.LaunchAndLandListener;
Expand Down Expand Up @@ -156,6 +158,7 @@
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.event.HandlerList;
import org.bukkit.scheduler.BukkitTask;
import se.ranzdo.bukkit.methodcommand.CommandHandler;
Expand Down Expand Up @@ -231,6 +234,7 @@ public class StrifePlugin extends FacePlugin {
private LevelingRate levelingRate;

private AbilityPickerPickerMenu abilitySubcategoryMenu;
private Map<String, AbilityPickerMenu> abilitySubmenus;
private LevelupMenu levelupMenu;
private ConfirmationMenu confirmMenu;
private StatsMenu statsMenu;
Expand Down Expand Up @@ -458,7 +462,7 @@ public void enable() {
taskList.add(Bukkit.getScheduler().runTaskTimer(this,
() -> boostManager.checkBoostSchedule(),
60L,
20L * 900
20L * 1860
));

agilityManager.loadAgilityContainers();
Expand Down Expand Up @@ -491,15 +495,21 @@ public void enable() {
Bukkit.getPluginManager().registerEvents(new TargetingListener(this), this);
Bukkit.getPluginManager().registerEvents(new FallListener(this), this);
Bukkit.getPluginManager().registerEvents(new LaunchAndLandListener(this), this);
Bukkit.getPluginManager().registerEvents(new DoubleJumpListener(this), this);
Bukkit.getPluginManager().registerEvents(new DogeListener(strifeMobManager), this);
Bukkit.getPluginManager()
.registerEvents(new LoreAbilityListener(strifeMobManager, loreAbilityManager), this);
Bukkit.getPluginManager().registerEvents(new InventoryListener(this), this);

if (Bukkit.getPluginManager().getPlugin("Bullion") != null) {
Bukkit.getPluginManager().registerEvents(new BullionListener(this), this);
}
if (Bukkit.getPluginManager().getPlugin("HeadDatabase") != null) {
Bukkit.getPluginManager().registerEvents(new HeadLoadListener(this), this);
}

ConfigurationSection abilityMenus = configYAML.getConfigurationSection("ability-menus");
abilitySubmenus = new HashMap<>();
List<AbilityPickerPickerItem> pickerItems = new ArrayList<>();
for (String menuId : abilityMenus.getKeys(false)) {
List<String> abilities = abilityMenus.getStringList(menuId + ".abilities");
Expand All @@ -508,6 +518,7 @@ public void enable() {
.collect(Collectors.toList());
AbilityPickerMenu menu = new AbilityPickerMenu(this, title, abilityList);
menu.setId(menuId);
abilitySubmenus.put(menuId, menu);

String name = abilityMenus.getString(menuId + ".name", "CONFIGURE ME");
List<String> lore = abilityMenus.getStringList(menuId + ".lore");
Expand Down Expand Up @@ -621,7 +632,7 @@ private void buildLoreAbilities() {
}
}

private void buildEquipment() {
public void buildEquipment() {
for (String itemStackKey : equipmentYAML.getKeys(false)) {
if (!equipmentYAML.isConfigurationSection(itemStackKey)) {
continue;
Expand Down Expand Up @@ -721,6 +732,14 @@ private void buildUniqueEnemies() {
uniqueEntity.getFactions().addAll(cs.getStringList("factions"));
uniqueEntity.setBaby(cs.getBoolean("baby", false));
uniqueEntity.setAngry(cs.getBoolean("angry", false));
uniqueEntity.setArmsRaised(cs.getBoolean("arms-raised", true));
if (uniqueEntity.getType() == EntityType.VILLAGER
|| uniqueEntity.getType() == EntityType.ZOMBIE_VILLAGER) {
String prof = cs.getString("profession");
if (prof != null) {
uniqueEntity.setProfession(Profession.valueOf(prof.toUpperCase()));
}
}
uniqueEntity.setBaseLevel(cs.getInt("base-level", -1));

Disguise disguise = PlayerDataUtil.parseDisguise(cs.getConfigurationSection("disguise"),
Expand All @@ -734,8 +753,8 @@ private void buildUniqueEnemies() {
Map<StrifeStat, Float> attributeMap = StatUtil.getStatMapFromSection(statCs);
uniqueEntity.setAttributeMap(attributeMap);

ConfigurationSection equipmentCS = cs.getConfigurationSection("equipment");
uniqueEntity.setEquipment(equipmentManager.buildEquipmentFromConfigSection(equipmentCS));
uniqueEntity.setEquipment(equipmentManager
.buildEquipmentFromConfigSection(cs.getConfigurationSection("equipment")));

String passengerItem = cs.getString("item-passenger", "");
if (StringUtils.isNotBlank(passengerItem)) {
Expand Down Expand Up @@ -994,6 +1013,10 @@ public AbilityPickerPickerMenu getAbilityPicker() {
return abilitySubcategoryMenu;
}

public AbilityPickerMenu getSubmenu(String name) {
return abilitySubmenus.get(name);
}

public StatsMenu getStatsMenu() {
return statsMenu;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/land/face/strife/commands/SpawnerCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void spawnerList(Player sender) {
sendMessage(sender, "&2&lList of loaded spawners:");
StringBuilder listString = new StringBuilder();
List<Spawner> spawners = new ArrayList<>(plugin.getSpawnerManager().getSpawnerMap().values());
spawners.removeIf(s -> s.getLocation().getWorld() != sender.getWorld());
SpawnerComparator comparator = new SpawnerComparator();
comparator.setLoc(sender.getLocation());
spawners.sort(comparator);
Expand All @@ -95,6 +96,7 @@ public void spawnerListNearest(Player sender) {
sendMessage(sender, "&2&lList of loaded spawners:");
StringBuilder listString = new StringBuilder();
List<Spawner> spawners = new ArrayList<>(plugin.getSpawnerManager().getSpawnerMap().values());
spawners.removeIf(s -> s.getLocation().getWorld() != sender.getWorld());
SpawnerComparator comparator = new SpawnerComparator();
comparator.setLoc(sender.getLocation());
spawners.sort(comparator);
Expand Down
24 changes: 14 additions & 10 deletions src/main/java/land/face/strife/commands/StrifeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import org.bukkit.inventory.ItemStack;
import se.ranzdo.bukkit.methodcommand.Arg;
import se.ranzdo.bukkit.methodcommand.Command;
import se.ranzdo.bukkit.methodcommand.FlagArg;
import se.ranzdo.bukkit.methodcommand.Flags;

public class StrifeCommand {

Expand Down Expand Up @@ -240,6 +242,12 @@ public void menuAbilityCommand(CommandSender sender, @Arg(name = "target") Playe
plugin.getAbilityPicker().open(target);
}

@Command(identifier = "strife ability submenu", permissions = "strife.command.strife.binding", onlyPlayers = false)
public void submenuAbilityCommand(CommandSender sender, @Arg(name = "target") Player target,
@Arg(name = "menu") String menu) {
plugin.getSubmenu(menu).open(target);
}

@Command(identifier = "strife bind", permissions = "strife.command.strife.binding", onlyPlayers = false)
public void bindCommand(CommandSender sender, @Arg(name = "target") Player target,
@Arg(name = "loreAbility") String id) {
Expand Down Expand Up @@ -301,8 +309,12 @@ public void skillCommand(CommandSender sender, @Arg(name = "target") Player targ
}

@Command(identifier = "strife addskillxp", permissions = "strife.command.strife.setskill", onlyPlayers = false)
@Flags(identifier = {"s", "d"},
description = {"scale experience with stats", "silent xp display"})
public void addSkillXp(CommandSender sender, @Arg(name = "target") Player target,
@Arg(name = "skill") String skill, @Arg(name = "xpAmount") int amount) {
@Arg(name = "skill") String skill, @Arg(name = "xpAmount") int amount,
@FlagArg("s") boolean scaleXp,
@FlagArg("d") boolean silentDisplay) {
String skillName = skill.toUpperCase();
LifeSkillType type;
try {
Expand All @@ -311,15 +323,7 @@ public void addSkillXp(CommandSender sender, @Arg(name = "target") Player target
sendMessage(sender, "<red>Unknown skill " + skill + "???");
return;
}
ChatColor color = type.getColor();
String name = type.getName();

plugin.getSkillExperienceManager().addExperience(target, type, amount, true);
sendMessage(target, XP_MSG
.replace("{c}", "" + color)
.replace("{n}", name)
.replace("{a}", Integer.toString(amount))
);
plugin.getSkillExperienceManager().addExperience(target, type, amount, !scaleXp, !silentDisplay);
}

@Command(identifier = "strife addxp", permissions = "strife.command.strife.addxp", onlyPlayers = false)
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/land/face/strife/data/DamageModifiers.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class DamageModifiers {
private float attackMultiplier = 1f;
private float healMultiplier = 1f;
private float damageReductionRatio = 1f;
private final Map<DamageType, Float> damageModifiers = new HashMap<>(baseDamageMults);
private final Map<DamageType, Float> damageMultipliers = new HashMap<>(baseDamageMults);
private final List<BonusDamage> bonusDamages = new ArrayList<>();
private final Map<AbilityMod, Float> abilityMods = new HashMap<>();
private final Set<ElementalStatus> elementalStatuses = new HashSet<>();
Expand Down Expand Up @@ -63,8 +63,8 @@ public void setHealMultiplier(float healMultiplier) {
this.healMultiplier = healMultiplier;
}

public Map<DamageType, Float> getDamageModifiers() {
return damageModifiers;
public Map<DamageType, Float> getDamageMultipliers() {
return damageMultipliers;
}

public List<BonusDamage> getBonusDamages() {
Expand Down
71 changes: 42 additions & 29 deletions src/main/java/land/face/strife/data/StrifeMob.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import land.face.strife.data.ability.EntityAbilitySet;
import land.face.strife.data.buff.Buff;
import land.face.strife.data.champion.Champion;
Expand Down Expand Up @@ -47,7 +46,7 @@ public class StrifeMob {
private WeakReference<LivingEntity> master;

private final Set<StrifeMob> minions = new HashSet<>();
private final Map<String, Buff> runningBuffs = new ConcurrentHashMap<>();
private final Set<Buff> runningBuffs = new HashSet<>();

private final Map<UUID, Float> takenDamage = new HashMap<>();

Expand Down Expand Up @@ -172,33 +171,45 @@ public void setStats(Map<StrifeStat, Float> stats) {
baseStats.putAll(stats);
}

public boolean hasBuff(String buffId) {
if (runningBuffs.containsKey(buffId)) {
if (runningBuffs.get(buffId).isExpired()) {
runningBuffs.remove(buffId);
return false;
public Buff hasBuff(String buffId, UUID source) {
Iterator iterator = runningBuffs.iterator();
while (iterator.hasNext()) {
Buff buff = (Buff) iterator.next();
if (buff == null || buff.isExpired()) {
iterator.remove();
} else {
if (source == null) {
if (buffId.equals(buff.getId()) && buff.getSource() == null) {
return buff;
}
} else {
if (buffId.equals(buff.getId()) && source.equals(buff.getSource())) {
return buff;
}
}
}
return true;
}
return false;
return null;
}

public int getBuffStacks(String buffId) {
if (hasBuff(buffId)) {
return runningBuffs.get(buffId).getStacks();
public int getBuffStacks(String buffId, UUID source) {
Buff buff = hasBuff(buffId, source);
if (buff == null) {
return 0;
}
return 0;
return buff.getStacks();
}

public void addBuff(String buffId, Buff buff, double duration) {
if (runningBuffs.get(buffId) == null || runningBuffs.get(buffId).isExpired()) {
buff.setExpireTimeFromDuration(duration);
runningBuffs.put(buffId, buff);
public void addBuff(String buffId, UUID source, Buff buff, double duration) {
Buff oldBuff = hasBuff(buffId, source);
if (oldBuff == null) {
LogUtil.printDebug("Adding new buff: " + buffId + " to " + livingEntity.get().getName());
buff.setExpireTimeFromDuration(duration);
runningBuffs.add(buff);
return;
}
runningBuffs.get(buffId).bumpBuff(duration);
LogUtil.printDebug("Bumping buff: " + buffId + " for " + livingEntity.get().getName());
buff.bumpBuff(duration);
}

public boolean isMinionOf(StrifeMob strifeMob) {
Expand Down Expand Up @@ -273,18 +284,20 @@ public void setCharmImmune(boolean charmImmune) {
this.charmImmune = charmImmune;
}

private Map<StrifeStat, Float> getBuffStats() {
public Map<StrifeStat, Float> getBuffStats() {
Map<StrifeStat, Float> stats = new HashMap<>();
for (Buff buff : runningBuffs.values()) {
if (buff.isExpired()) {
runningBuffs.remove(buff.getId());
continue;
}
for (StrifeStat stat : buff.getTotalStats().keySet()) {
if (stats.containsKey(stat)) {
stats.put(stat, stats.get(stat) + buff.getTotalStats().get(stat));
} else {
stats.put(stat, buff.getTotalStats().get(stat));
Iterator iterator = runningBuffs.iterator();
while (iterator.hasNext()) {
Buff buff = (Buff) iterator.next();
if (buff == null || buff.isExpired()) {
iterator.remove();
} else {
for (StrifeStat stat : buff.getTotalStats().keySet()) {
if (stats.containsKey(stat)) {
stats.put(stat, stats.get(stat) + buff.getTotalStats().get(stat));
} else {
stats.put(stat, buff.getTotalStats().get(stat));
}
}
}
}
Expand Down
27 changes: 23 additions & 4 deletions src/main/java/land/face/strife/data/UniqueEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import land.face.strife.data.effects.StrifeParticle;
import land.face.strife.stats.StrifeStat;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;

Expand All @@ -25,6 +26,8 @@ public class UniqueEntity {
private boolean showName;
private boolean baby;
private boolean angry;
private boolean armsRaised;
private Profession profession;
private int size;
private int followRange = -1;
private boolean knockbackImmune;
Expand All @@ -37,7 +40,7 @@ public class UniqueEntity {
private boolean powered;
private double displaceMultiplier;
private String mount;
private Map<EquipmentSlot, ItemStack> equipment = new HashMap<>();
private Map<EquipmentSlot, String> equipment = new HashMap<>();
private ItemStack itemPassenger = null;
private StrifeParticle strifeParticle;

Expand Down Expand Up @@ -133,6 +136,22 @@ public void setAngry(boolean angry) {
this.angry = angry;
}

public boolean isArmsRaised() {
return armsRaised;
}

public void setArmsRaised(boolean armsRaised) {
this.armsRaised = armsRaised;
}

public Profession getProfession() {
return profession;
}

public void setProfession(Profession profession) {
this.profession = profession;
}

public int getSize() {
return size;
}
Expand Down Expand Up @@ -229,15 +248,15 @@ public void setCharmImmune(boolean charmImmune) {
this.charmImmune = charmImmune;
}

public Map<EquipmentSlot, ItemStack> getEquipment() {
public Map<EquipmentSlot, String> getEquipment() {
return equipment;
}

public ItemStack getEquipmentItem(EquipmentSlot slot) {
public String getEquipmentItem(EquipmentSlot slot) {
return equipment.get(slot);
}

public void setEquipment(Map<EquipmentSlot, ItemStack> equipment) {
public void setEquipment(Map<EquipmentSlot, String> equipment) {
this.equipment = equipment;
}

Expand Down
Loading

0 comments on commit fae215f

Please sign in to comment.