Moved one of the checks in Exp Upgrade up to improve performance

This commit is contained in:
ProSavage 2018-07-23 12:00:01 -05:00
parent 6a1072b935
commit f0e99674c6

View File

@ -11,15 +11,15 @@ import org.bukkit.event.entity.EntityDeathEvent;
public class EXPUpgrade implements Listener { public class EXPUpgrade implements Listener {
@EventHandler @EventHandler
public void onDeath(EntityDeathEvent e) { public void onDeath(EntityDeathEvent e) {
Location loc = e.getEntity().getLocation();
Faction wild = Factions.getInstance().getWilderness();
FLocation floc = new FLocation(loc);
Faction faction = Board.getInstance().getFactionAt(floc);
Entity killer = e.getEntity().getKiller(); Entity killer = e.getEntity().getKiller();
Player player = (Player) killer; Player player = (Player) killer;
if (player == null) { if (player == null) {
return; return;
} }
Location loc = e.getEntity().getLocation();
Faction wild = Factions.getInstance().getWilderness();
FLocation floc = new FLocation(loc);
Faction faction = Board.getInstance().getFactionAt(floc);
if (faction != wild) { if (faction != wild) {
int level = faction.getUpgrade("Exp"); int level = faction.getUpgrade("Exp");
if (level != 0) { if (level != 0) {
@ -35,12 +35,11 @@ public class EXPUpgrade implements Listener {
double multiplier = P.p.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-3"); double multiplier = P.p.getConfig().getDouble("fupgrades.MainMenu.EXP.EXP-Boost.level-3");
spawnMoreExp(e, multiplier); spawnMoreExp(e, multiplier);
} }
} }
} }
} }
public void spawnMoreExp(EntityDeathEvent e, double multiplier) { private void spawnMoreExp(EntityDeathEvent e, double multiplier) {
double newExp = e.getDroppedExp() * multiplier; double newExp = e.getDroppedExp() * multiplier;
int newExpInt = (int) newExp; int newExpInt = (int) newExp;
e.setDroppedExp(newExpInt); e.setDroppedExp(newExpInt);