!Removed unused method, fixed Heroes hook

This commit is contained in:
Indyuce 2020-04-12 17:31:21 +02:00
parent e51c369757
commit af98a76001
4 changed files with 50 additions and 37 deletions

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level;
import org.bukkit.configuration.ConfigurationSection;
@ -26,7 +27,10 @@ public class CraftingStatus {
for (String stationId : config.getKeys(false)) {
if (!MMOItems.plugin.getCrafting().hasStation(stationId)) {
data.log("Could not find crafting station ID " + stationId + ", not loading started recipes.", "Make sure you backup that player data file before the user logs off.");
MMOItems.plugin.getLogger().log(Level.WARNING,
"An error occured while trying to load crafting station recipe data of '" + data.getPlayer().getName() + "': "
+ "could not find crafting station with ID '" + stationId
+ "', make sure you backup that player data file before the user logs off.");
continue;
}
@ -37,17 +41,22 @@ public class CraftingStatus {
for (String recipeConfigId : config.getConfigurationSection(stationId).getKeys(false)) {
String recipeId = config.getString(stationId + "." + recipeConfigId + ".recipe");
if (recipeId == null || !station.hasRecipe(recipeId)) {
data.log("Could not find recipe ID '" + recipeId + "', not loading this recipe.", "Make sure you backup that player data file before the user logs off.");
MMOItems.plugin.getLogger().log(Level.WARNING,
"An error occured while trying to load crafting station recipe data of '" + data.getPlayer().getName() + "': "
+ "could not find recipe with ID '" + recipeId
+ "', make sure you backup that player data file before the user logs off.");
continue;
}
Recipe recipe = station.getRecipe(recipeId);
if (!(recipe instanceof CraftingRecipe)) {
data.log("Could not load recipe " + recipeId + ", it is not a CRAFTING recipe!?");
MMOItems.plugin.getLogger().log(Level.WARNING, "An error occured while trying to load crafting station recipe data of '"
+ data.getPlayer().getName() + "': " + "recipe '" + recipe.getId() + "' is not a CRAFTING recipe.");
continue;
}
queue.add((CraftingRecipe) recipe, config.getLong(stationId + "." + recipeConfigId + ".started"), config.getLong(stationId + "." + recipeConfigId + ".delay"));
queue.add((CraftingRecipe) recipe, config.getLong(stationId + "." + recipeConfigId + ".started"),
config.getLong(stationId + "." + recipeConfigId + ".delay"));
}
}
}
@ -103,10 +112,11 @@ public class CraftingStatus {
/*
* when adding a crafting recipe, the delay is the actual crafting time
* PLUS the delay of the previous item since it's a queue.
* PLUS the delay left for the previous item since it's a queue.
*/
public void add(CraftingRecipe recipe) {
add(recipe, System.currentTimeMillis(), (crafts.size() == 0 ? 0 : crafts.get(crafts.size() - 1).getLeft()) + (long) recipe.getCraftingTime() * 1000);
add(recipe, System.currentTimeMillis(),
(crafts.size() == 0 ? 0 : crafts.get(crafts.size() - 1).getLeft()) + (long) recipe.getCraftingTime() * 1000);
}
private void add(CraftingRecipe recipe, long started, long delay) {

View File

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
@ -66,7 +65,7 @@ public class PlayerData {
/*
* the inventory is all the items the player can actually use. items are
* cached here to check if the player's items changed, if so just update
* inventory
* inventory TODO improve player inventory checkup method
*/
private ItemStack helmet = null, chestplate = null, leggings = null, boots = null, hand = null, offhand = null;
private List<VolatileMMOItem> playerInventory = new ArrayList<>();
@ -78,7 +77,8 @@ public class PlayerData {
private Map<CooldownType, Long> extraCooldowns = new HashMap<>();
/*
* specific stat calculation
* specific stat calculation TODO compress it in Map<ItemStat,
* DynamicStatData>
*/
private Map<PotionEffectType, PotionEffect> permanentEffects = new HashMap<>();
private Set<ParticleRunnable> itemParticles = new HashSet<>();
@ -427,11 +427,6 @@ public class PlayerData {
ability.getAbility().whenCast(stats, abilityResult, attack);
}
public void log(String... lines) {
for (String line : lines)
MMOItems.plugin.getLogger().log(Level.WARNING, "[Data] " + player.getName() + ": " + line);
}
public boolean isOnCooldown(CooldownType type) {
return extraCooldowns.containsKey(type) && extraCooldowns.get(type) > System.currentTimeMillis();
}

View File

@ -6,14 +6,12 @@ import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import com.herocraftonline.heroes.Heroes;
import com.herocraftonline.heroes.api.SkillUseInfo;
import com.herocraftonline.heroes.api.events.HeroChangeLevelEvent;
import com.herocraftonline.heroes.api.events.SkillDamageEvent;
import com.herocraftonline.heroes.characters.Hero;
import com.herocraftonline.heroes.characters.skill.SkillType;
@ -70,27 +68,27 @@ public class HeroesHook implements RPGHandler, Listener, DamageHandler {
PlayerData.get(event.getHero().getPlayer()).scheduleDelayedInventoryUpdate();
}
@EventHandler
public void b(SkillDamageEvent event) {
/*
* apply the 'Magic Damage' and 'Magic Damage Reduction' item option to
* Heroes skills
*/
if (event.getSkill().isType(SkillType.ABILITY_PROPERTY_MAGICAL)) {
if (event.getDamager().getEntity() instanceof Player)
event.setDamage(event.getDamage() * (1 + PlayerData.get((Player) event.getDamager().getEntity()).getStats().getStat(ItemStat.MAGIC_DAMAGE) / 100));
if (event.getEntity() instanceof Player)
event.setDamage(event.getDamage() * (1 - PlayerData.get((Player) event.getDamager().getEntity()).getStats().getStat(ItemStat.MAGIC_DAMAGE_REDUCTION) / 100));
}
/*
* apply 'Physical Damage Reduction' to physical skills
*/
if (event.getSkill().isType(SkillType.ABILITY_PROPERTY_PHYSICAL))
if (event.getEntity() instanceof Player)
event.setDamage(event.getDamage() * (1 - PlayerData.get((Player) event.getDamager().getEntity()).getStats().getStat(ItemStat.PHYSICAL_DAMAGE_REDUCTION) / 100));
}
// @EventHandler
// public void b(SkillDamageEvent event) {
//
// /*
// * apply the 'Magic Damage' and 'Magic Damage Reduction' item option to
// * Heroes skills
// */
// if (event.getSkill().isType(SkillType.ABILITY_PROPERTY_MAGICAL)) {
// if (event.getDamager().getEntity() instanceof Player)
// event.setDamage(event.getDamage() * (1 + PlayerData.get((Player) event.getDamager().getEntity()).getStats().getStat(ItemStat.MAGIC_DAMAGE) / 100));
// if (event.getEntity() instanceof Player)
// event.setDamage(event.getDamage() * (1 - PlayerData.get((Player) event.getDamager().getEntity()).getStats().getStat(ItemStat.MAGIC_DAMAGE_REDUCTION) / 100));
// }
//
// /*
// * apply 'Physical Damage Reduction' to physical skills
// */
// if (event.getSkill().isType(SkillType.ABILITY_PROPERTY_PHYSICAL))
// if (event.getEntity() instanceof Player)
// event.setDamage(event.getDamage() * (1 - PlayerData.get((Player) event.getDamager().getEntity()).getStats().getStat(ItemStat.PHYSICAL_DAMAGE_REDUCTION) / 100));
// }
public class HeroesPlayer extends RPGPlayer {
private final Hero hero;

View File

@ -0,0 +1,10 @@
package net.Indyuce.mmoitems.stat.data.dynamic;
public interface DynamicStatData {
/*
* dynamic stat data is used when all the mmoitems are in the player
* inventory and when MMOItems calculates all passive effects which the
* items must apply on the player
*/
}