diff --git a/pom.xml b/pom.xml index e4040879..94ffa2ac 100644 --- a/pom.xml +++ b/pom.xml @@ -81,6 +81,10 @@ + + phoenix + http://la-grange-evasion.pro.dns-orange.fr:8081/ + lumine @@ -143,7 +147,7 @@ io.lumine MythicLib-dist - 1.3.4 + 1.3.4 provided diff --git a/src/main/java/net/Indyuce/mmocore/experience/source/KillMobExperienceSource.java b/src/main/java/net/Indyuce/mmocore/experience/source/KillMobExperienceSource.java index 96c3a7be..a1c28452 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/source/KillMobExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/experience/source/KillMobExperienceSource.java @@ -1,5 +1,6 @@ package net.Indyuce.mmocore.experience.source; +import com.guillaumevdn.questcreator.lib.event.PlayerKillEntityEvent; import io.lumine.mythic.lib.api.MMOLineConfig; import io.lumine.mythic.lib.api.event.PlayerKillEntityEvent; import net.Indyuce.mmocore.MMOCore; @@ -9,10 +10,12 @@ import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import net.Indyuce.mmocore.api.player.PlayerData; import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.persistence.PersistentDataType; public class KillMobExperienceSource extends SpecificExperienceSource { public final EntityType type; @@ -30,12 +33,12 @@ public class KillMobExperienceSource extends SpecificExperienceSource { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void a(PlayerKillEntityEvent event) { Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> { - if (event.getTarget().isDead() && !event.getTarget().hasMetadata("spawner_spawned")) { + if (event.getKilled().isDead() && !event.getKilled().getPersistentDataContainer().has(new NamespacedKey(MMOCore.plugin,"spawner_spawned"),PersistentDataType.STRING)) { PlayerData data = PlayerData.get(event.getPlayer()); for (KillMobExperienceSource source : getSources()) - if (source.matches(data, event.getTarget())) - source.giveExperience(data, 1, MMOCoreUtils.getCenterLocation(event.getTarget())); + if (source.matches(data, event.getKilled())) + source.giveExperience(data, 1, MMOCoreUtils.getCenterLocation(event.getKilled())); } }, 2); } diff --git a/src/main/java/net/Indyuce/mmocore/listener/option/NoSpawnerEXP.java b/src/main/java/net/Indyuce/mmocore/listener/option/NoSpawnerEXP.java index d5382c8c..e819b9ba 100644 --- a/src/main/java/net/Indyuce/mmocore/listener/option/NoSpawnerEXP.java +++ b/src/main/java/net/Indyuce/mmocore/listener/option/NoSpawnerEXP.java @@ -1,16 +1,19 @@ package net.Indyuce.mmocore.listener.option; import net.Indyuce.mmocore.MMOCore; +import org.bukkit.NamespacedKey; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.persistence.PersistentDataType; public class NoSpawnerEXP implements Listener { @EventHandler public void a(CreatureSpawnEvent event) { if(event.getSpawnReason() == SpawnReason.SPAWNER) + event.getEntity().getPersistentDataContainer().set(new NamespacedKey(MMOCore.plugin,"spawner_spawned"), PersistentDataType.STRING,"true"); event.getEntity().setMetadata("spawner_spawned", new FixedMetadataValue(MMOCore.plugin, true)); } } diff --git a/src/main/java/net/Indyuce/mmocore/loot/droptable/dropitem/DropItem.java b/src/main/java/net/Indyuce/mmocore/loot/droptable/dropitem/DropItem.java index b84e5cc3..17f10cb6 100644 --- a/src/main/java/net/Indyuce/mmocore/loot/droptable/dropitem/DropItem.java +++ b/src/main/java/net/Indyuce/mmocore/loot/droptable/dropitem/DropItem.java @@ -10,6 +10,7 @@ import io.lumine.mythic.lib.api.MMOLineConfig; public abstract class DropItem { protected static final Random random = new Random(); + private static final double CHANCE_COEFFICIENT = 7. / 100; private final double chance, weight; private final RandomAmount amount; @@ -35,11 +36,19 @@ public abstract class DropItem { return amount.calculateInt(); } + /** + * CHANCE stat = 0 | tier chances are unchanged + * CHANCE stat = +inf | uniform law for any drop item + * CHANCE stat = 100 | all tier chances are taken their square root + * + * @return The real weight of an item considering the player's CHANCE stat. + */ /** * If the player chance is 0 the random value will remain the same. When he get lucks the chance gets closer to one. */ public boolean rollChance(PlayerData player) { - return Math.pow(random.nextDouble(), 1 / Math.log(1 + player.getStats().getStat("CHANCE"))) < chance; + double value=random.nextDouble(); + return value< Math.pow(chance, 1 / Math.pow(1 + CHANCE_COEFFICIENT * player.getStats().getStat("CHANCE"), 1.0 / 3.0)); } public abstract void collect(LootBuilder builder);