Added vanilla exp redirection

This commit is contained in:
Indyuce 2020-05-01 19:43:50 +02:00
parent b630205cef
commit 3e8a83ba5c
4 changed files with 43 additions and 11 deletions

View File

@ -62,6 +62,7 @@ import net.Indyuce.mmocore.listener.WaypointsListener;
import net.Indyuce.mmocore.listener.option.DeathExperienceLoss; import net.Indyuce.mmocore.listener.option.DeathExperienceLoss;
import net.Indyuce.mmocore.listener.option.HealthScale; import net.Indyuce.mmocore.listener.option.HealthScale;
import net.Indyuce.mmocore.listener.option.NoSpawnerEXP; import net.Indyuce.mmocore.listener.option.NoSpawnerEXP;
import net.Indyuce.mmocore.listener.option.RedirectVanillaExp;
import net.Indyuce.mmocore.listener.option.VanillaExperienceOverride; import net.Indyuce.mmocore.listener.option.VanillaExperienceOverride;
import net.Indyuce.mmocore.listener.profession.FishingListener; import net.Indyuce.mmocore.listener.profession.FishingListener;
import net.Indyuce.mmocore.listener.profession.PlayerCollectStats; import net.Indyuce.mmocore.listener.profession.PlayerCollectStats;
@ -255,6 +256,9 @@ public class MMOCore extends JavaPlugin {
if (getConfig().getBoolean("action-bar.enabled")) if (getConfig().getBoolean("action-bar.enabled"))
new PlayerActionBar(getConfig().getConfigurationSection("action-bar")); new PlayerActionBar(getConfig().getConfigurationSection("action-bar"));
if (getConfig().getBoolean("vanilla-exp-redirection.enabled"))
Bukkit.getPluginManager().registerEvents(new RedirectVanillaExp(getConfig().getDouble("vanilla-exp-redirection.ratio")), this);
/* /*
* enable debug mode for extra debug tools. * enable debug mode for extra debug tools.
*/ */

View File

@ -0,0 +1,22 @@
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.api.player.PlayerData;
public class RedirectVanillaExp implements Listener {
private final double ratio;
public RedirectVanillaExp(double ratio) {
this.ratio = ratio;
}
@EventHandler
public void a(PlayerExpChangeEvent event) {
int a = (int) (event.getAmount() * ratio);
if (a > 0)
PlayerData.get(event.getPlayer()).giveExperience(a);
}
}

View File

@ -2,6 +2,7 @@ package net.Indyuce.mmocore.listener.option;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.enchantment.EnchantItemEvent; import org.bukkit.event.enchantment.EnchantItemEvent;
import org.bukkit.event.player.PlayerExpChangeEvent; import org.bukkit.event.player.PlayerExpChangeEvent;
@ -14,7 +15,7 @@ public class VanillaExperienceOverride implements Listener {
/* /*
* when picking up exp orbs or any action like that * when picking up exp orbs or any action like that
*/ */
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void a(PlayerExpChangeEvent event) { public void a(PlayerExpChangeEvent event) {
event.setAmount(0); event.setAmount(0);
} }

View File

@ -1,11 +1,9 @@
# Auto-Save feature automatically saves # Auto-Save feature automatically saves playerdata
# playerdata (class, level, etc.) and # (class, level, etc.) and guild data
# guild data (guild names, members, etc.) # (guild names, members, etc.) at a set interval.
# at a set interval.
auto-save: auto-save:
enabled: true enabled: true
# In seconds (1800 = 30 minutes) interval: 1800 # In seconds (1800 = 30 minutes)
interval: 1800
# MySQL Support # MySQL Support
mysql: mysql:
@ -41,7 +39,8 @@ loot-chest-expire-time: 600
# Settings for the default action bar # Settings for the default action bar
action-bar: action-bar:
# Whether or not to use the default action bar. (This doesn't change any other action bars provided by MMOCore.) # Whether or not to use the default action bar.
# (This doesn't change any other action bars provided by MMOCore.)
enabled: true enabled: true
# The decimal format for stats (not including stat formats in stats.yml) # The decimal format for stats (not including stat formats in stats.yml)
@ -65,6 +64,14 @@ party:
# to talk in the party chat. # to talk in the party chat.
chat-prefix: '@' chat-prefix: '@'
# Redirects vanilla experience obtained to MMOCore
# class experience. You can define the % of the vanilla
# experience that is being transfered as MMOCore exp.
# Requires a SERVER reload when changed.
vanilla-exp-redirection:
enabled: false
ratio: 0.8
# Enable this open to override vanilla EXP and display # Enable this open to override vanilla EXP and display
# level progress on the vanilla experience bar. # level progress on the vanilla experience bar.
# Requires a SERVER reload when changed. # Requires a SERVER reload when changed.
@ -93,6 +100,7 @@ display-exp-holograms: true
# Players can swap their hotbar with the 9 inventory slots # Players can swap their hotbar with the 9 inventory slots
# right above it by pressing [swap items] while crouching. # right above it by pressing [swap items] while crouching.
# THis allows players to have two combat item sets.
hotbar-swap: true hotbar-swap: true
# Use this option if you're having issue with Anvil GUIs. # Use this option if you're having issue with Anvil GUIs.
@ -109,9 +117,6 @@ combat-log:
# Change this to the name of the color you want for # Change this to the name of the color you want for
# the different resource bar placeholders # the different resource bar placeholders
resource-bar-colors: resource-bar-colors:
mana-whole: 'BLUE'
mana-half: 'AQUA'
mana-empty: 'WHITE'
stamina-whole: 'GREEN' stamina-whole: 'GREEN'
stamina-half: 'DARK_GREEN' stamina-half: 'DARK_GREEN'
stamina-empty: 'WHITE' stamina-empty: 'WHITE'