Fixed an issue with citizens

This commit is contained in:
Indyuce 2022-04-03 01:10:25 +02:00
parent ab177461d4
commit 966ef01b36

View File

@ -1,23 +1,25 @@
package net.Indyuce.mmocore.listener.option;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.ConfigMessage;
import net.Indyuce.mmocore.api.player.PlayerData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.ConfigMessage;
import net.Indyuce.mmocore.api.player.PlayerData;
public class DeathExperienceLoss implements Listener {
private final double loss = MMOCore.plugin.getConfig().getDouble("death-exp-loss.percent") / 100;
private final double loss = MMOCore.plugin.getConfig().getDouble("death-exp-loss.percent") / 100;
@EventHandler(priority = EventPriority.HIGH)
public void a(PlayerDeathEvent event) {
PlayerData data = PlayerData.get(event.getEntity());
int loss = (int) (data.getExperience() * this.loss);
data.setExperience(data.getExperience() - loss);
if(data.isOnline())
new ConfigMessage("death-exp-loss").addPlaceholders("loss", "" + loss).send(data.getPlayer());
}
@EventHandler(priority = EventPriority.HIGH)
public void a(PlayerDeathEvent event) {
if (!PlayerData.has(event.getEntity()))
return;
PlayerData data = PlayerData.get(event.getEntity());
int loss = (int) (data.getExperience() * this.loss);
data.setExperience(data.getExperience() - loss);
if (data.isOnline())
new ConfigMessage("death-exp-loss").addPlaceholders("loss", "" + loss).send(data.getPlayer());
}
}