diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 482412108..59a9d1590 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -37,6 +37,7 @@ import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.scoreboard.NameTagVisibility; @@ -149,6 +150,7 @@ public abstract class Game implements Listener // Player Data private NautHashMap> _gemCount = new NautHashMap>(); private NautHashMap> _stats = new NautHashMap>(); + private NautHashMap _playerInTime = new NautHashMap<>(); // Player Location Store private NautHashMap _playerLocationStore = new NautHashMap(); @@ -2117,6 +2119,31 @@ public abstract class Game implements Listener } + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (!IsLive()) + return; + + if (!JoinInProgress) + return; + + _playerInTime.put(event.getPlayer(), System.currentTimeMillis()); + } + + public long getPlayerIngameTime(Player player) + { + if (_playerInTime.containsKey(player)) + return _playerInTime.get(player); + + return 0; + } + + public void addPlayerInTime(Player player) + { + _playerInTime.put(player, System.currentTimeMillis()); + } + private void addRelativeSpawns(ArrayList spawns, Location location) { //Gather Extra Spawns diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index 58c56f8f7..4e3f110ac 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -757,6 +757,8 @@ public class GameManager implements Listener //Teleport team.SpawnTeleport(player); + game.addPlayerInTime(player); + Manager.Clear(player); UtilInv.Clear(player); @@ -820,7 +822,7 @@ public class GameManager implements Listener player.eject(); player.leaveVehicle(); - player.teleport(Manager.GetLobby().GetSpawn()); + player.teleport(Manager.GetLobby().GetSpawn()); } }, i); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java index 1d7b53978..fe50f41b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/IdleManager.java @@ -1,8 +1,18 @@ package nautilus.game.arcade.managers; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import org.bukkit.Bukkit; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerTeleportEvent; + import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilPlayer; @@ -13,20 +23,13 @@ import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.Game.GameState; -import org.bukkit.Bukkit; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.bukkit.event.player.PlayerQuitEvent; - public class IdleManager implements Listener { private final ArcadeManager _arcadeManager; private final Map _yaw = new HashMap<>(); private final Map _idle = new HashMap<>(); private final Map _beep = new HashMap<>(); + private final HashSet _teleported = new HashSet(); public IdleManager(ArcadeManager manager) { @@ -65,6 +68,9 @@ public class IdleManager implements Listener for (Player player : UtilServer.getPlayers()) { + if (_teleported.contains(player)) + continue; + if (!_yaw.containsKey(player) || !_idle.containsKey(player)) { _yaw.put(player, player.getLocation().getYaw()); @@ -121,12 +127,28 @@ public class IdleManager implements Listener } } + @EventHandler + public void playerTeleport(PlayerTeleportEvent event) + { + _teleported.add(event.getPlayer()); + _arcadeManager.runSyncLater(new Runnable() + { + @Override + public void run() + { + _yaw.put(event.getPlayer(), event.getPlayer().getLocation().getYaw()); + _teleported.remove(event.getPlayer()); + } + }, 5); + } + @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { _yaw.remove(event.getPlayer()); _idle.remove(event.getPlayer()); _beep.remove(event.getPlayer()); + _teleported.remove(event.getPlayer()); } public ArcadeManager getArcadeManager() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java index 111fe229e..6ecf5b229 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ExperienceStatTracker.java @@ -68,6 +68,10 @@ public class ExperienceStatTracker extends StatTracker //Game Time = 1 Exp per 3 Seconds long time = System.currentTimeMillis(); + long playerJoin = getGame().getPlayerIngameTime(player); + + if (playerJoin == 0) + playerJoin = _startTime; //Exp Until They Quit if (!player.isOnline()) @@ -80,9 +84,9 @@ public class ExperienceStatTracker extends StatTracker { time = _startTime; } - } + } - double timeExp = (time - _startTime)/1500d; + double timeExp = (time - playerJoin)/1500d; //Mult double mult = 1;