Players who quit early do not get full game worth of EXP.

This commit is contained in:
Cheese 2015-06-27 12:38:04 +10:00
parent 754026f403
commit d0368a19d8

View File

@ -5,7 +5,9 @@ import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.NautHashMap;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.GemData;
@ -14,6 +16,8 @@ public class ExperienceStatTracker extends StatTracker<Game>
{ {
private long _startTime = -1; private long _startTime = -1;
private NautHashMap<String, Long> _playerQuitTime = new NautHashMap<String, Long>();
public ExperienceStatTracker(Game game) public ExperienceStatTracker(Game game)
{ {
super(game); super(game);
@ -26,6 +30,12 @@ public class ExperienceStatTracker extends StatTracker<Game>
_startTime = System.currentTimeMillis(); _startTime = System.currentTimeMillis();
} }
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
_playerQuitTime.put(event.getPlayer().getName(), System.currentTimeMillis());
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onGameEnd(GameStateChangeEvent event) public void onGameEnd(GameStateChangeEvent event)
{ {
@ -57,7 +67,15 @@ public class ExperienceStatTracker extends StatTracker<Game>
gemExp = Math.min(gemExp, 250) * 6; gemExp = Math.min(gemExp, 250) * 6;
//Game Time = 1 Exp per 3 Seconds //Game Time = 1 Exp per 3 Seconds
double timeExp = (System.currentTimeMillis() - _startTime)/1500d; long time = System.currentTimeMillis();
//Exp Until They Quit
if (!player.isOnline() && _playerQuitTime.containsKey(player.getName()))
time = _playerQuitTime.get(player.getName());
//No Time Exp
else
time = _startTime;
double timeExp = (time - _startTime)/1500d;
//Mult //Mult
double mult = 1; double mult = 1;