diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/AddCommand.java index f7efe7c69..a938b2d20 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/AddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/AddCommand.java @@ -49,6 +49,6 @@ public class AddCommand extends CommandBase private void help(Player caller) { - UtilPlayer.message(caller, F.help("booster add ", "Add a booster to that server group", Rank.ALL)); + UtilPlayer.message(caller, F.help("booster add ", "Add a booster to that server group", Rank.DEVELOPER)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java index 65775fcef..95d6cd706 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/boosters/command/BoosterCommand.java @@ -23,6 +23,6 @@ public class BoosterCommand extends MultiCommandBase @Override protected void Help(Player caller, String[] args) { - UtilPlayer.message(caller, F.help("booster add ", "Add a booster to that server group", Rank.ALL)); + UtilPlayer.message(caller, F.help("booster add ", "Add a booster to that server group", Rank.DEVELOPER)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BrawlShopProvider.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BrawlShopProvider.java new file mode 100644 index 000000000..89635b062 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/BrawlShopProvider.java @@ -0,0 +1,11 @@ +package mineplex.core.brawl.fountain; + +import mineplex.core.shop.ShopBase; + +/** + * @author Shaun Bennett + */ +public interface BrawlShopProvider +{ + public ShopBase getBrawlShop(); +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java index 9e89b87c9..a7efd950b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/Fountain.java @@ -11,6 +11,8 @@ import mineplex.core.donation.DonationManager; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.stats.StatsManager; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.serverdata.redis.counter.GoalCounter; import mineplex.serverdata.redis.counter.GoalCounterListener; import org.bukkit.Bukkit; @@ -18,9 +20,13 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.TimeZone; /** * Represents a fountain that players can add gems to, with a reward for reaching specific goals @@ -32,6 +38,7 @@ public class Fountain implements GoalCounterListener private final HologramManager _hologramManager; private final StatsManager _statsManager; + private boolean _brawlActive; private final String _name; private final String _dataKey; private final Location _location; @@ -55,6 +62,7 @@ public class Fountain implements GoalCounterListener _hologram = new Hologram(hologramManager, location.clone().add(4, 3, -3), name).start(); _counter = new GoalCounter(dataKey, 5000, goal); _counter.addListener(this); + _brawlActive = false; // _blockProgressBar = new BlockProgressBar(_lavaLocation.getBlock(), Material.LAVA, BlockFace.UP); _schematicLoader = new SortedSchematicLoader<>(pasteLocation); loadSchematics(); @@ -86,43 +94,74 @@ public class Fountain implements GoalCounterListener protected void updateVisuals() { - double percent = getFillPercent(); - double flatPercent = percent - (int) percent; + double fillPercent = getFillPercent(); - String fillColor; - String emptyColor; - String goalMessage; + if (isBrawlActive()) + { + ArrayList text = new ArrayList<>(); + if (fillPercent >= 1) + { + text.add(C.cRed + C.Bold + "Weekend Brawl is Active!"); + if (fillPercent >= 2) + { + text.add("Bonus Reward Unlocked:"); + if (fillPercent >= 3) + { + text.add(C.cGreen + "3X Experience in Brawl"); + } + else + { + text.add(C.cGreen + "2X Experience in Brawl"); + } + } + text.add(" "); + text.add("Speak to the Fountain Keeper to Join!"); + } + else + { + text.add(C.cRed + "Brawl goal was not met"); + text.add("Come back next week"); + } - if (percent < 1) - { - fillColor = C.cGreen; - emptyColor = C.cRed; - goalMessage = "100% to Unlock Weekend Brawl"; - } - else if (percent < 2) - { - fillColor = C.cYellow; - emptyColor = C.cGreen; - goalMessage = "200% to Unlock 2x XP for Weekend Brawl"; - } - else if (percent < 3) - { - fillColor = C.cAqua; - emptyColor = C.cYellow; - goalMessage = "300% to Unlock 3x XP for Weekend Brawl"; + _hologram.setText(text.toArray(new String[text.size()])); + _schematicLoader.update(fillPercent); } else { - fillColor = C.cAqua; - emptyColor = C.cYellow; - goalMessage = "All Rewards Unlocked!"; - flatPercent = 1; - } + double flatPercent = fillPercent - (int) fillPercent; - int intPercent = (int) (percent * 100); - String progressBar = UtilText.getProgress(null, flatPercent, null, false, 30, emptyColor, fillColor); - _hologram.setText(_name + C.Reset + " " + intPercent + "%", goalMessage, progressBar); - _schematicLoader.update(percent); + String fillColor; + String emptyColor; + String goalMessage; + + if (fillPercent < 1) + { + fillColor = C.cGreen; + emptyColor = C.cRed; + goalMessage = "100% to Unlock Weekend Brawl"; + } else if (fillPercent < 2) + { + fillColor = C.cYellow; + emptyColor = C.cGreen; + goalMessage = "200% to Unlock 2x XP for Weekend Brawl"; + } else if (fillPercent < 3) + { + fillColor = C.cAqua; + emptyColor = C.cYellow; + goalMessage = "300% to Unlock 3x XP for Weekend Brawl"; + } else + { + fillColor = C.cAqua; + emptyColor = C.cYellow; + goalMessage = "All Rewards Unlocked!"; + flatPercent = 1; + } + + int intPercent = (int) (fillPercent * 100); + String progressBar = UtilText.getProgress(null, flatPercent, null, false, 30, emptyColor, fillColor); + _hologram.setText(_name + C.Reset + " " + intPercent + "%", goalMessage, progressBar); + _schematicLoader.update(fillPercent); + } } public void increment(Player player, long amount) @@ -189,4 +228,23 @@ public class Fountain implements GoalCounterListener break; } } + + public void updateBrawlActive() + { + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("PST")); + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); + if (dayOfWeek == Calendar.FRIDAY || dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) + { + _brawlActive = true; + } + else + { + _brawlActive = false; + } + } + + public boolean isBrawlActive() + { + return _brawlActive; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java index ab4283079..b0b956f10 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/FountainManager.java @@ -16,8 +16,12 @@ import mineplex.serverdata.redis.counter.Counter; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.plugin.java.JavaPlugin; /** @@ -28,20 +32,23 @@ public class FountainManager extends MiniPlugin private HologramManager _hologramManager; private StatsManager _statsManager; private DonationManager _donationManager; + // used so we can inject the brawl shop (only on hub) into fountain code + private BrawlShopProvider _brawlShopProvider; private Fountain _gemFountain; - public FountainManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, HologramManager hologramManager, StatsManager statsManager) + public FountainManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, HologramManager hologramManager, StatsManager statsManager, BrawlShopProvider shopProvider) { super("Counter", plugin); _hologramManager = hologramManager; _statsManager = statsManager; _donationManager = donationManager; + _brawlShopProvider = shopProvider; World world = Bukkit.getWorlds().get(0);//-43.5, 66, -38.5 _gemFountain = new Fountain(new Location(world, -32.5, 72, -23.5), new Location(world, -43.5, 67, -38.5), - C.cGreen + "Gem Fountain", "GemFountain_01", 1000000, this, clientManager, donationManager, _hologramManager, _statsManager); + C.cGreen + "Gem Fountain", "GemFountain_01", 10000000, this, clientManager, donationManager, _hologramManager, _statsManager); } @Override @@ -56,9 +63,39 @@ public class FountainManager extends MiniPlugin if (event.getType() != UpdateType.SEC) return; + _gemFountain.updateBrawlActive(); _gemFountain.updateVisuals(); } + @EventHandler + public void onInteractAtEntity(PlayerInteractAtEntityEvent event) + { + Entity entity = event.getRightClicked(); + if (entity.getCustomName() != null && entity.isCustomNameVisible()) + { + if (entity.getCustomName().contains("Weekend Brawl") && getBrawlShopProvider() != null) + { + getBrawlShopProvider().getBrawlShop().attemptShopOpen(event.getPlayer()); + } + } + } + + @EventHandler + public void onDamage(EntityDamageByEntityEvent event) + { + if (!(event.getDamager() instanceof Player)) + return; + + Entity entity = event.getEntity(); + if (entity.getCustomName() != null && entity.isCustomNameVisible()) + { + if (entity.getCustomName().contains("Weekend Brawl") && getBrawlShopProvider() != null) + { + getBrawlShopProvider().getBrawlShop().attemptShopOpen(((Player) event.getDamager())); + } + } + } + public Fountain getGemFountain() { return _gemFountain; @@ -68,4 +105,9 @@ public class FountainManager extends MiniPlugin { return _donationManager; } + + public BrawlShopProvider getBrawlShopProvider() + { + return _brawlShopProvider; + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java index de474dbad..1be61d068 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/command/AddCommand.java @@ -63,6 +63,6 @@ public class AddCommand extends CommandBase private void help(Player player) { - UtilPlayer.message(player, F.help("/fountain add", "", Rank.ADMIN)); + UtilPlayer.message(player, F.help("/fountain add", "", Rank.DEVELOPER)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainShop.java b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainShop.java index 3776f080c..a8cade6e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainShop.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/brawl/fountain/gui/FountainShop.java @@ -32,4 +32,17 @@ public class FountainShop extends ShopBase { return _fountain; } + + @Override + public boolean attemptShopOpen(Player player) + { + if (_fountain.isBrawlActive() && getPlugin().getBrawlShopProvider() != null) + { + return getPlugin().getBrawlShopProvider().getBrawlShop().attemptShopOpen(player); + } + else + { + return super.attemptShopOpen(player); + } + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 3c4b5acbc..49897d995 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -1,5 +1,6 @@ package mineplex.hub; +import mineplex.core.brawl.fountain.FountainManager; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -155,11 +156,13 @@ public class Hub extends JavaPlugin implements IRelation PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager); BoosterManager boosterManager = new BoosterManager(this, clientManager, donationManager, inventoryManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, boosterManager); + HologramManager hologramManager = new HologramManager(this, packetHandler); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, hologramManager, npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, boosterManager); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); + ServerManager serverManager = new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager, boosterManager); + new FountainManager(this, clientManager, donationManager, hologramManager, statsManager, serverManager); - new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager), queueManager, boosterManager); Chat chat = new Chat(this, incognito, clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); new MessageManager(this, incognito, clientManager, preferenceManager, ignoreManager, punish, friendManager, chat); new MemoryFix(this); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index bb9d446c1..c9f4c0bd1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -235,8 +235,6 @@ public class HubManager extends MiniClientPlugin new SoccerManager(this, _gadgetManager); new KothManager(this, _gadgetManager); - new FountainManager(plugin, clientManager, donationManager, hologramManager, statsManager); - //new TrickOrTreatManager(_plugin, this, taskManager, donationManager, clientManager); _petManager = petManager; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index a04ee64c1..da26f23fd 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -12,6 +12,7 @@ import java.util.Random; import java.util.Set; import mineplex.core.boosters.BoosterManager; +import mineplex.core.brawl.fountain.BrawlShopProvider; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -64,7 +65,7 @@ import mineplex.serverdata.Region; import mineplex.serverdata.data.MinecraftServer; import mineplex.serverdata.data.ServerGroup; -public class ServerManager extends MiniDbClientPlugin +public class ServerManager extends MiniDbClientPlugin implements BrawlShopProvider { private static final Long FREE_PORTAL_TIMER = 20000L; private static final Long BETA_PORTAL_TIMER = 120000L; @@ -918,6 +919,11 @@ public class ServerManager extends MiniDbClientPlugin return _serverNpcShopMap.get("Valentines Vendetta"); } + public ShopBase getBrawlShop() + { + return _serverNpcShopMap.get("Weekend Brawl"); + } + @Override public String getQuery(int accountId, String uuid, String name) { 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/game/games/quiver/Quiver.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java index c96891602..eb581769f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/Quiver.java @@ -4,8 +4,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; -import java.util.UUID; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -50,7 +48,6 @@ public class Quiver extends SoloGame private HashMap _combo = new HashMap(); private HashMap _bestCombo = new HashMap(); private HashMap _deathTime = new HashMap(); - private HashMap _bowTime = new HashMap<>(); private Objective _scoreObj; @@ -119,26 +116,6 @@ public class Quiver extends SoloGame { player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item("Super Arrow"))); player.playSound(player.getLocation(), Sound.PISTON_EXTEND, 3f, 2f); - _bowTime.put(player.getUniqueId(), 0); - } - } - - - @EventHandler - public void onUpdate(UpdateEvent event) - { - if(event.getType() != UpdateType.TICK) - return; - for(Player player : GetPlayers(true)) - { - if(UtilPlayer.isChargingBow(player)) - { - _bowTime.put(player.getUniqueId(), _bowTime.get(player.getUniqueId()) + 1); - } - else - { - _bowTime.put(player.getUniqueId(), 0); - } } } @@ -156,14 +133,6 @@ public class Quiver extends SoloGame if (!(arrow.getShooter() instanceof Player)) return; - Player shooter = (Player) arrow.getShooter(); - //If the player has a full charge but they haven't been holding the bow for more than 20 ticks - if(_bowTime.get(shooter.getUniqueId()) < 20 && event.getForce() == 1) - { - event.setCancelled(true); - return; - } - if (!_deathTime.containsKey(arrow.getShooter())) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitLeaper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitLeaper.java index 5642d9653..c963e3f13 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitLeaper.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/quiver/kits/KitLeaper.java @@ -32,14 +32,14 @@ public class KitLeaper extends Kit new PerkDoubleJump("Double Jump", 0.9, 0.9, true) }, EntityType.ZOMBIE, - new ItemStack(Material.IRON_AXE)); + new ItemStack(Material.STONE_SWORD)); } @Override public void GiveItems(Player player) { - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE)); + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD)); player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW)); if (Manager.GetGame().GetState() == GameState.Live) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java index ef80000d0..281d33288 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameGemManager.java @@ -217,6 +217,7 @@ public class GameGemManager implements Listener total += earned; Rank rank = Manager.GetClients().Get(player).GetRank(); + int accountId = Manager.GetClients().getAccountId(player); if (rank == rank.ULTRA) shards *= 1.5; @@ -228,7 +229,10 @@ public class GameGemManager implements Listener shards *= 3; Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), player.getUniqueId(), total); - Manager.GetDonation().RewardCoins(null, "Earned", player.getName(), Manager.GetClients().getAccountId(player), shards); + if (accountId != -1) + { + Manager.GetDonation().rewardCoinsUntilSuccess(null, "Earned", player.getName(), accountId, shards); + } //Stats Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", total); 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;