mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-27 00:45:40 +01:00
death exp loss, moved listeners off configManager
This commit is contained in:
parent
ba34e76b37
commit
f62c91e59c
@ -0,0 +1,22 @@
|
||||
package net.Indyuce.mmocore.listener.option;
|
||||
|
||||
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;
|
||||
|
||||
@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);
|
||||
new ConfigMessage("death-exp-loss").addPlaceholders("loss", "" + loss).send(data.getPlayer());
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package net.Indyuce.mmocore.listener.option;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
||||
public class HealthScale implements Listener {
|
||||
private final double scale = MMOCore.plugin.getConfig().getDouble("health-scale.scale");
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
player.setHealthScaled(true);
|
||||
player.setHealthScale(scale);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package net.Indyuce.mmocore.listener.option;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerExpChangeEvent;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
||||
public class VanillaExperienceOverride implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerExpChangeEvent event) {
|
||||
if (MMOCore.plugin.configManager.overrideVanillaExp)
|
||||
event.setAmount(0);
|
||||
}
|
||||
}
|
@ -13,10 +13,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerExpChangeEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.util.Consumer;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
@ -25,6 +21,9 @@ import net.Indyuce.mmocore.api.input.AnvilGUI;
|
||||
import net.Indyuce.mmocore.api.input.ChatInput;
|
||||
import net.Indyuce.mmocore.api.input.PlayerInput;
|
||||
import net.Indyuce.mmocore.api.input.PlayerInput.InputType;
|
||||
import net.Indyuce.mmocore.listener.option.DeathExperienceLoss;
|
||||
import net.Indyuce.mmocore.listener.option.HealthScale;
|
||||
import net.Indyuce.mmocore.listener.option.VanillaExperienceOverride;
|
||||
|
||||
public class ConfigManager {
|
||||
|
||||
@ -99,26 +98,13 @@ public class ConfigManager {
|
||||
partyChatPrefix = MMOCore.plugin.getConfig().getString("party.chat-prefix");
|
||||
|
||||
if (overrideVanillaExp = MMOCore.plugin.getConfig().getBoolean("override-vanilla-exp"))
|
||||
Bukkit.getPluginManager().registerEvents(new Listener() {
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerExpChangeEvent event) {
|
||||
if (MMOCore.plugin.configManager.overrideVanillaExp)
|
||||
event.setAmount(0);
|
||||
}
|
||||
}, MMOCore.plugin);
|
||||
Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), MMOCore.plugin);
|
||||
|
||||
if (MMOCore.plugin.getConfig().getBoolean("health-scale.enabled"))
|
||||
Bukkit.getPluginManager().registerEvents(new Listener() {
|
||||
private final double scale = MMOCore.plugin.getConfig().getDouble("health-scale.scale");
|
||||
Bukkit.getPluginManager().registerEvents(new HealthScale(), MMOCore.plugin);
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
player.setHealthScaled(true);
|
||||
player.setHealthScale(scale);
|
||||
}
|
||||
}, MMOCore.plugin);
|
||||
if (MMOCore.plugin.getConfig().getBoolean("death-exp-loss.enabled"))
|
||||
Bukkit.getPluginManager().registerEvents(new DeathExperienceLoss(), MMOCore.plugin);
|
||||
|
||||
neededExp.clear();
|
||||
int line = 0;
|
||||
|
@ -53,6 +53,13 @@ party:
|
||||
# Requires a SERVER reload when changed.
|
||||
override-vanilla-exp: true
|
||||
|
||||
# Requires a SERVER reload when changed.
|
||||
death-exp-loss:
|
||||
enabled: false
|
||||
|
||||
# Percentage of current EXP you lose when dying.
|
||||
percent: 30
|
||||
|
||||
# Allows to scale health up/down to a specific
|
||||
# amount so extra health does not fill up the screen.
|
||||
# Requires a SERVER reload when changed.
|
||||
|
@ -11,6 +11,10 @@ exp-notification: '&f{profession} &e{progress} &e{ratio}%'
|
||||
exp-hologram: '&e+{exp} EXP!'
|
||||
class-select: '&eYou are now a &6{class}&e!'
|
||||
already-on-class: '&cYou are already a {class}.'
|
||||
death-exp-loss:
|
||||
- ''
|
||||
- '&7You died and lost {loss} experience.'
|
||||
- ''
|
||||
|
||||
# General
|
||||
booster-main:
|
||||
|
Loading…
Reference in New Issue
Block a user