From ff41ad248a6410333009f0050cdb7d85eb311559 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 2 Apr 2016 02:47:17 -0500 Subject: [PATCH] Removed PvpTimer Fixed issue where StatManager and FriendManager were created twice. --- .../core/account/CoreClientManager.java | 1 + .../src/mineplex/game/clans/Clans.java | 5 +- .../game/clans/clans/ClansManager.java | 13 +- .../game/clans/clans/playtime/Playtime.java | 1 - .../clans/clans/playtime/command/cemde.java | 30 -- .../game/clans/clans/pvptimer/PvpTimer.java | 364 ------------------ .../clans/clans/pvptimer/PvpTimerClient.java | 24 -- .../pvptimer/command/PvPTimerCommand.java | 69 ---- .../repository/PvpTimerRepository.java | 83 ---- .../pvptimer/repository/TimerClientToken.java | 7 - .../game/clans/clans/siege/SiegeManager.java | 2 +- .../clans/clans/siege/outpost/Outpost.java | 4 +- .../clans/siege/outpost/OutpostManager.java | 2 +- .../game/clans/clans/siege/weapon/Cannon.java | 8 +- .../items/legendaries/MeridianScepter.java | 4 +- .../tutorials/clans/ClansMainTutorial.java | 4 +- 16 files changed, 21 insertions(+), 600 deletions(-) delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimerClient.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/repository/PvpTimerRepository.java delete mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/repository/TimerClientToken.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 2f33620bb..6b6e119ca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -375,6 +375,7 @@ public class CoreClientManager extends MiniPlugin runAsync(new Runnable() { + @Override public void run() { client.setAccountId(_repository.login(_loginProcessors, uuid, client.GetPlayerName())); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 8f0a2a99c..da284f3b5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -121,7 +121,7 @@ public class Clans extends JavaPlugin IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); - IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler); + new IncognitoManager(this, _clientManager, packetHandler); StatsManager statsManager = new StatsManager(this, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); @@ -131,7 +131,6 @@ public class Clans extends JavaPlugin new MemoryFix(this); new FoodDupeFix(this); new Explosion(this, blockRestore); - new FriendManager(this, _clientManager, preferenceManager, portal); new InventoryManager(this, _clientManager); ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal); resourcePackManager.setResourcePack("http://garblox.com/files/b/ResClans.zip", "http://garblox.com/files/b/ResClans19.zip", true); @@ -141,7 +140,7 @@ public class Clans extends JavaPlugin GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); HologramManager hologram = new HologramManager(this, packetHandler); - _clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, teleport, chat, customGear, hologram, webServerAddress); + _clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress); new Recipes(this); new Farming(this); new BuildingShop(_clansManager, _clientManager, _donationManager); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 61e8b9390..d3532185b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -93,7 +93,6 @@ import mineplex.game.clans.clans.nether.NetherManager; import mineplex.game.clans.clans.observer.ObserverManager; import mineplex.game.clans.clans.playtime.Playtime; import mineplex.game.clans.clans.potato.PotatoManager; -import mineplex.game.clans.clans.pvptimer.PvpTimer; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.regions.ClansRegions; @@ -198,7 +197,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati private WarPointEvasion _warPointEvasion; private ObserverManager _observerManager; private Punish _punish; - private PvpTimer _pvpTimer; private int _inviteExpire = 2; private int _nameMin = 3; @@ -224,7 +222,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati // Spawn area - public ClansManager(JavaPlugin plugin, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) + public ClansManager(JavaPlugin plugin, String serverName, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) { super("Clans Manager", plugin); @@ -327,8 +325,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati // Register redis based server commands ServerCommandManager.getInstance().registerCommandType(ClanDeleteCommand.class, new ClanDeleteCommandHandler()); ServerCommandManager.getInstance().registerCommandType(ClanLoadCommand.class, new ClanLoadCommandHandler()); - - StatsManager statsManager = new StatsManager(plugin, _clientManager); + AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager); ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); _classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop"); @@ -336,7 +333,6 @@ public class ClansManager extends MiniClientPluginimplements IRelati new ClanEnergyManager(plugin, this, clientManager, donationManager); _playTracker = new Playtime(this, statsManager); - _pvpTimer = new PvpTimer(this, statsManager); _tutorialManager = new mineplex.game.clans.legacytutorial.TutorialManager(plugin, _playTracker, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler); @@ -1326,7 +1322,10 @@ public class ClansManager extends MiniClientPluginimplements IRelati return _damageManager; } - public PvpTimer getPvpTimer() { return _pvpTimer; } + public boolean hasTimer(Player player) + { + return false; + } public ClansBlacklist getBlacklist() { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java index 806a00fa1..52c3dfeba 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/Playtime.java @@ -13,7 +13,6 @@ import mineplex.core.task.TaskManager; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansPlayerStats; import mineplex.game.clans.clans.playtime.command.PlayTimeCommand; -import mineplex.game.clans.clans.playtime.command.cemde; public class Playtime extends MiniClientPlugin { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java deleted file mode 100644 index 8a0f36609..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/playtime/command/cemde.java +++ /dev/null @@ -1,30 +0,0 @@ -package mineplex.game.clans.clans.playtime.command; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.stats.StatsManager; -import mineplex.game.clans.clans.ClansPlayerStats; -import mineplex.game.clans.clans.pvptimer.PvpTimer; - -public class cemde extends CommandBase -{ - PvpTimer _timer; - public cemde(StatsManager plugin, PvpTimer timer) - { - super(plugin, Rank.SNR_MODERATOR, "rstime"); - _timer = timer; - } - - @Override - public void Execute(final Player caller, final String[] args) - { - Plugin.Get(caller).setStat(ClansPlayerStats.PLAY_TIME.id(), args.length == 0 ? 0 : Integer.parseInt(args[0])); - _timer.Get(caller).Skipped = false; - _timer.Get(caller).InformedTimes.clear(); - - UtilPlayer.message(caller, "Reset time."); - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java deleted file mode 100644 index 3118d76f7..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimer.java +++ /dev/null @@ -1,364 +0,0 @@ -package mineplex.game.clans.clans.pvptimer; - -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.EntityShootBowEvent; -import org.bukkit.event.player.AsyncPlayerPreLoginEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import mineplex.core.MiniClientPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextMiddle; -import mineplex.core.common.util.UtilTime; -import mineplex.core.stats.StatsManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.game.clans.clans.ClanTips.TipType; -import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.clans.event.ClanTipEvent; -import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; -import mineplex.game.clans.clans.playtime.command.cemde; -import mineplex.game.clans.clans.pvptimer.command.PvPTimerCommand; -import mineplex.game.clans.clans.pvptimer.repository.PvpTimerRepository; -import mineplex.game.clans.clans.pvptimer.repository.TimerClientToken; -import mineplex.game.clans.core.repository.ClanTerritory; -import mineplex.game.clans.spawn.Spawn; -import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; -import mineplex.minecraft.game.classcombat.event.FireballHitEntityEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - -public class PvpTimer extends MiniClientPlugin -{ - private final int[] DISPLAY_TIMES = { - 5, - 10, - 30, - 1 * 60, - 2 * 60, - 5 * 60, - 10 * 60, - 20 * 60 - }; - - private PvpTimerRepository _repository; - private CoreClientManager _clientManager; - - private ClansManager _clansManager; - - private static long TIMER_LENGTH = 30 * 60; - - public PvpTimer(ClansManager clans, StatsManager statsManager) - { - super("PvP Timer", clans.getPlugin()); - _clansManager = clans; - - _clientManager = clans.getClientManager(); - - _repository = new PvpTimerRepository(this, clans.getClientManager()); - - addCommand(new cemde(statsManager, this)); - } - - @Override - public void addCommands() - { - addCommand(new PvPTimerCommand(this)); - } - - public void disableFor(final Player caller) - { - Get(caller).Skipped = true; - caller.playSound(caller.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f); - - _repository.Save(_clientManager.getAccountId(caller), Get(caller).Skipped, Get(caller).Elapsed); - } - - @EventHandler - public void fireBow(EntityShootBowEvent event) - { - if (!(event.getEntity() instanceof Player)) - { - return; - } - - if (hasTimer((Player) event.getEntity())) - { - UtilPlayer.message(event.getEntity(), F.main("Clans", "You may not fire bows while on a PvP timer.")); - UtilPlayer.message(event.getEntity(), C.cGoldB + "> " + C.cGold + "To permanently disable PvP Safety, type " + C.cGreen + "/pvp" + C.cGold + "."); - - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) - { - runAsync(() -> _repository.Save(_clientManager.getAccountId(event.getPlayer()), Get(event.getPlayer()).Skipped, Get(event.getPlayer()).Elapsed + (int) (elapsed(event.getPlayer()) / 1000))); - } - - @EventHandler - public void outYouGo(UpdateEvent event) - { - if (event.getType() == UpdateType.SLOWER) - { - UtilServer.getPlayersCollection().forEach(player -> { - PvpTimerClient client = Get(player); - - runAsync(() -> { - _repository.Save(_clientManager.getAccountId(player), client.Skipped, client.Elapsed += (int) (elapsed(player) / 1000)); - - client.StartTime = System.currentTimeMillis(); - }); - }); - } - - if (event.getType() == UpdateType.SEC) - { - for (Player player : Bukkit.getOnlinePlayers()) - { - if (!hasTimer(player)) continue; - - ClanTerritory territory = _clansManager.getClanUtility().getClaim(player.getLocation()); - - if (territory != null && territory.Owner.equals("Borderlands")) - { - UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), Spawn.ORIGIN), 2.6, true, 0.5, .2, 1.35, true); - player.playSound(player.getLocation(), Sound.NOTE_BASS, 1.0f, 1.0f); - - UtilPlayer.message(player, " "); - - UtilPlayer.message(player, C.cDRedB + ">>" + C.cRed + " You are not permitted to enter the Borderlands while under PvP Safety."); - UtilPlayer.message(player, C.cGoldB + "> " + C.cGold + "To permanently disable PvP Safety, type " + C.cGreen + "/pvp" + C.cGold + "."); - - UtilPlayer.message(player, " "); - } - } - } - } - - @EventHandler - public void territoryEnter(PlayerEnterTerritoryEvent event) - { - String from = event.getLastTerritory(); - String to = event.getNewTerritory(); - - if (from == null && "Borderlands".equals(to) - || to == null && "Borderlands".equals(from)) - { - event.setSendMessage(false); - } - } - - @EventHandler - public void clanTip(ClanTipEvent event) - { - event.setCancelled(hasTimer(event.getPlayer()) && event.getTip() == TipType.ENTER_BORDERLANDS); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) - { - final Player player = event.getPlayer(); - - if (hasTimer(player)) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { - public void run() - { - UtilTextMiddle.display(C.cGreen + "PvP Safety", C.cGray + "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player); - - UtilPlayer.message(player, C.cAqua + "You are currently safe from PvP because you are a new player. This safety will end in " + F.time(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000))); - UtilPlayer.message(player, C.cAqua + "Until it ends, you are immune to, and are unable to deal PvP damage."); - UtilPlayer.message(player, C.cAqua + "To disable the PvP safety permanently, then type " + F.elem("/pvp") + "."); - } - }, 3); - } - } - - @EventHandler - public void inform(UpdateEvent event) - { - if (event.getType() == UpdateType.FAST) - { - GetValues().forEach(client -> { - if (client.Paused) - { - client.StartTime = System.currentTimeMillis(); - } - }); - } - - if (event.getType() == UpdateType.TWOSEC) - { - for (Player player : Bukkit.getOnlinePlayers()) - { - if (hasTimer(player)) - { - long time = getPvPTimerLeft(player); - PvpTimerClient client = Get(player); - - if (time <= 2) - { - UtilPlayer.message(player, F.main("Clans", "PvP Safety has ended!")); - UtilPlayer.message(player, F.main("Clans", "You are now completely open to attacks, and you can also attack others.")); - player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 0.2f, 0.75f); - continue; - } - - for (int unit : DISPLAY_TIMES) - { - if (time <= unit && !client.InformedTimes.contains(Integer.valueOf(unit))) - { - if (!_clansManager.getTutorials().isInTutorial(player)) - { - // Only inform if not in tutorial. - UtilPlayer.message(player, F.main("Clans", "PvP Safety will end in " + F.time(UtilTime.MakeStr(unit * 1000)))); - UtilTextMiddle.display(C.cGreen + "Pvp Safety", C.cGray + "ending in " + UtilTime.MakeStr(unit * 1000), 20, 80, 20, player); - } - - client.InformedTimes.add(Integer.valueOf(unit)); - } - } - } - } - } - } - - @EventHandler - public void onSkill(SkillTriggerEvent event) - { - if (event.GetTargets() == null) - { - return; - } - - if (event.GetTargets().size() == 1 - && event.GetTargets().get(0) instanceof Player - && hasTimer((Player) event.GetTargets().get(0))) - { - event.SetCancelled(true); - } - - for (Iterator iterator = event.GetTargets().iterator(); iterator.hasNext();) - { - Entity entity = iterator.next(); - - if (entity instanceof Player && hasTimer((Player) entity)) - { - iterator.remove(); - } - } - } - - @EventHandler - public void onFireballHit(FireballHitEntityEvent event) - { - event.setCancelled(event.getHitEntity() instanceof Player && hasTimer((Player) event.getHitEntity())); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerAttack(CustomDamageEvent event) - { - if (event.GetDamageePlayer() == null || event.GetDamagerEntity(true) == null) - { - return; - } - - Player victim = event.GetDamageePlayer(); - Player damager = event.GetDamagerPlayer(true); - - boolean victimTimer = victim != null && hasTimer(victim); - boolean damagerTimer = damager != null && hasTimer(damager); - boolean bothMsg = false; - - if (victimTimer) - { - if (damagerTimer) - { - UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still protected from PvP. Type " + F.elem("/pvp") + " to disable.")); - bothMsg = true; - } - else if (damager != null) - { - UtilPlayer.message(damager, F.main("Clans", F.name(victim.getName()) + " is still protected from PvP.")); - } - - event.SetCancelled("Pvp Timer"); - } - - if (damagerTimer) - { - if (victimTimer) - { - if (!bothMsg) - { - UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still under PvP Safety. Type " + F.elem("/pvp") + " to disable.")); - } - } - else if (damager != null) - { - UtilPlayer.message(damager, F.main("Clans", "You are still under PvP Safety.")); - } - - event.SetCancelled("PvP Timer"); - } - - } - - @EventHandler(priority = EventPriority.LOWEST) - public void ClientLoad(AsyncPlayerPreLoginEvent event) - { - _clientManager.getRepository().getAccountId(event.getUniqueId(), accountId -> { - TimerClientToken token = _repository.Get(accountId.intValue()); - - Get(event.getName()).Skipped = token.Skipped; - Get(event.getName()).Elapsed = token.Elapsed; - }); - } - - public long getPvPTimerLeft(Player player) - { - long time = Get(player).Elapsed + (elapsed(player) / 1000); - - return (TIMER_LENGTH <= time ? 0 : TIMER_LENGTH - time); - } - - public long elapsed(Player player) - { - return System.currentTimeMillis() - Get(player).StartTime; - } - - public boolean hasTimer(Player player) - { - return player != null && getPvPTimerLeft(player) > 0 && !Get(player).Skipped && !Get(player).Paused; - } - - @Override - protected PvpTimerClient AddPlayer(String player) - { - return new PvpTimerClient(); - } - - public void pause(Player player) - { - Get(player).Paused = true; - } - - public void unpause(Player player) - { - Get(player).Paused = false; - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimerClient.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimerClient.java deleted file mode 100644 index b21bade4b..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/PvpTimerClient.java +++ /dev/null @@ -1,24 +0,0 @@ -package mineplex.game.clans.clans.pvptimer; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.entity.Player; - -import mineplex.core.task.TaskManager; -import mineplex.game.clans.clans.ClansPlayerTasks; - -public class PvpTimerClient -{ - public boolean Skipped; - public List InformedTimes; - public long StartTime; - public int Elapsed; - public boolean Paused; - - public PvpTimerClient() - { - StartTime = System.currentTimeMillis(); - InformedTimes = new ArrayList<>(); - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java deleted file mode 100644 index 7d396f4fd..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/command/PvPTimerCommand.java +++ /dev/null @@ -1,69 +0,0 @@ -package mineplex.game.clans.clans.pvptimer.command; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.common.jsonchat.ClickEvent; -import mineplex.core.common.jsonchat.JsonMessage; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import mineplex.game.clans.clans.pvptimer.PvpTimer; - -public class PvPTimerCommand extends CommandBase -{ - public PvPTimerCommand(PvpTimer plugin) - { - super(plugin, Rank.ALL, "pvptimer", "timer", "pvp"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args.length == 0) - { - if (Plugin.Get(caller).Skipped) - { - UtilPlayer.message(caller, F.main("Clans", "You have permanently disabled PvP Safety.")); - return; - } - - long pvpTimerLeft = Plugin.getPvPTimerLeft(caller); - - if (pvpTimerLeft == 0) - { - UtilPlayer.message(caller, F.main("Clans", "PvP Safety has already ended.")); - } - else - { - UtilPlayer.message(caller, F.main("Clans", "You have " + F.time(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before PvP Safety runs out for you.")); - new JsonMessage(F.main("Clans", "If you would like to permanently disable " + C.mBody + "PvP Safety, click ")) - .extra("here") - .color("green") - .click(ClickEvent.RUN_COMMAND, "/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever") - .extra(".") - .color("gray") - - .sendToPlayer(caller); - } - } - else - { - if (Plugin.Get(caller).Skipped) - { - UtilPlayer.message(caller, F.main("Clans", "You have already disabled PvP Safety.")); - return; - } - - if (args[0].equalsIgnoreCase("yesiconfirmthatiwouldliketodisablemypvptimerforever")) - { - Plugin.disableFor(caller); - UtilPlayer.message(caller, F.main("Clans", "You have disabled PvP Safety.")); - UtilPlayer.message(caller, F.main("Clans", "You are now completely open to attacks, and you can also attack others.")); - } - } - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/repository/PvpTimerRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/repository/PvpTimerRepository.java deleted file mode 100644 index 775e1831d..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/repository/PvpTimerRepository.java +++ /dev/null @@ -1,83 +0,0 @@ -package mineplex.game.clans.clans.pvptimer.repository; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.util.EnclosedObject; -import mineplex.core.common.util.UUIDFetcher; -import mineplex.core.database.MinecraftRepository; -import mineplex.core.incognito.IncognitoManager; -import mineplex.game.clans.clans.pvptimer.PvpTimer; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.column.ColumnInt; - -public class PvpTimerRepository extends MinecraftRepository -{ - private static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS clansPvpTimer (accountId INT NOT NULL, timerElapsed INT NOT NULL DEFAULT '1', hasSkipped TINYINT(1) DEFAULT '0', PRIMARY KEY (accountId));"; - private static final String GET_STATUS = "SELECT * FROM clansPvpTimer WHERE accountId = ?;"; - private static final String INSERT_STATUS = "INSERT INTO clansPvpTimer (accountId, timerElapsed, hasSkipped) VALUES (?, ?, ?);"; - private static final String UPDATE_STATUS = "UPDATE clansPvpTimer SET timerElapsed=?, hasSkipped=? WHERE accountId=?;"; - - private PvpTimer _pvpTimer; - - private CoreClientManager _clientManager; - - public PvpTimerRepository(PvpTimer pvpTimer, CoreClientManager clientManager) - { - super(pvpTimer.getPlugin(), DBPool.getAccount()); - - _clientManager = clientManager; - - _pvpTimer = pvpTimer; - } - - public void Save(int accountId, boolean skipped, int timerElapsed) - { - // Prevent duplicate entries for individuals - executeQuery(GET_STATUS, result -> { - if (result.next()) - executeUpdate(UPDATE_STATUS, new ColumnInt("timerElapsed", timerElapsed), new ColumnInt("hasSkipped", skipped ? 1 : 0), new ColumnInt("accountId", accountId)); - else - executeUpdate(INSERT_STATUS, new ColumnInt("accountId", accountId), new ColumnInt("timerElapsed", timerElapsed), new ColumnInt("hasSkipped", skipped ? 1 : 0)); - }, new ColumnInt("accountId", accountId)); - } - - public TimerClientToken Get(int accountId) - { - final TimerClientToken token = new TimerClientToken(); - - executeQuery(GET_STATUS, result -> { - if (result.next()) - { - token.Elapsed = result.getInt("timerElapsed"); - token.Skipped = result.getInt("hasSkipped") == 1; - } - else - { - token.Elapsed = 1; - token.Skipped = false; - } - }, new ColumnInt("accountId", accountId)); - - return token; - } - - public TimerClientToken Get(String name) - { - EnclosedObject accountId = new EnclosedObject<>(); - - _clientManager.getRepository().getAccountId(UUIDFetcher.getUUIDOf(name), id -> - accountId.Set(id) - ); - - return Get(accountId.Get().intValue()); - } - - protected void initialize() - { - executeUpdate(CREATE_TABLE); - } - - protected void update() - { - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/repository/TimerClientToken.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/repository/TimerClientToken.java deleted file mode 100644 index 3b4a18811..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/pvptimer/repository/TimerClientToken.java +++ /dev/null @@ -1,7 +0,0 @@ -package mineplex.game.clans.clans.pvptimer.repository; - -public class TimerClientToken -{ - public int Elapsed; - public boolean Skipped; -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java index 7b0b73b01..13188fcc9 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/SiegeManager.java @@ -269,7 +269,7 @@ public class SiegeManager extends MiniPlugin return false; } - if(_clansManager.getPvpTimer().hasTimer(player)) + if (_clansManager.hasTimer(player)) { UtilPlayer.message(player, F.main("Clans", "You cannot place a Cannon whilst protected from pvp.")); return false; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java index 4c7668e43..552ba15b8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/Outpost.java @@ -267,7 +267,7 @@ public class Outpost implements Listener return; - if(_outpostManager.getClansManager().getPvpTimer().hasTimer(event.getPlayer())) + if(_outpostManager.getClansManager().hasTimer(event.getPlayer())) { UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot activate an Outpost whilst protected from pvp.")); return; @@ -295,7 +295,7 @@ public class Outpost implements Listener if (event.getBlock().getLocation().equals(_core) && getState() == OutpostState.LIVE) { - if(_outpostManager.getClansManager().getPvpTimer().hasTimer(event.getPlayer())) + if(_outpostManager.getClansManager().hasTimer(event.getPlayer())) { UtilPlayer.message(event.getPlayer(), F.main("Clans", "You cannot destroy an Outpost whilst on protected from pvp.")); event.setCancelled(true); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java index c71a49329..60ed47729 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/outpost/OutpostManager.java @@ -83,7 +83,7 @@ public class OutpostManager extends MiniPlugin return false; } - if(_clansManager.getPvpTimer().hasTimer(player)) + if(_clansManager.hasTimer(player)) { UtilPlayer.message(player, F.main("Clans", "You place an Outpost whilst protected from pvp.")); return false; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java index cd9c28f64..bff70a1f6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/siege/weapon/Cannon.java @@ -82,7 +82,7 @@ public class Cannon extends SiegeWeapon return false; } - if(_clans.getPvpTimer().hasTimer(player)) + if(_clans.hasTimer(player)) { UtilPlayer.message(player, F.main("Clans", "You cannot fire a cannon whilst on PvPTimer")); return false; @@ -118,7 +118,7 @@ public class Cannon extends SiegeWeapon return false; } - if(_clans.getPvpTimer().hasTimer(player)) { + if(_clans.hasTimer(player)) { UtilPlayer.message(player, F.main("Clans", "You cannot ride on a Cannon whilst on PvPTimer")); return false; } @@ -165,7 +165,7 @@ public class Cannon extends SiegeWeapon return false; } - if (_clans.getPvpTimer().hasTimer(player)) + if (_clans.hasTimer(player)) { UtilPlayer.message(player, F.main("Clans", "You cannot fire a Cannon whilst protected from pvp.")); return false; @@ -201,7 +201,7 @@ public class Cannon extends SiegeWeapon return false; } - if(_clans.getPvpTimer().hasTimer(player)) + if(_clans.hasTimer(player)) { UtilPlayer.message(player, F.main("Clans", "You cannot ride on a Cannon whilst protected from pvp.")); return false; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java index 58198f46e..d29c7a9c1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/legendaries/MeridianScepter.java @@ -52,7 +52,7 @@ public class MeridianScepter extends LegendaryItem { if ((System.currentTimeMillis() - _lastBlock) < 98 && (System.currentTimeMillis() - _interactWait) >= 98) { - if (ClansManager.getInstance().getPvpTimer().hasTimer(wielder)) + if (ClansManager.getInstance().hasTimer(wielder)) { UtilPlayer.message(wielder, F.main("Clans", "You are not allowed to fire the Meridian Scepter whilst under pvp protection.")); return; @@ -137,7 +137,7 @@ public class MeridianScepter extends LegendaryItem continue; } - if (ClansManager.getInstance().getPvpTimer().hasTimer(closest)) + if (ClansManager.getInstance().hasTimer(closest)) { continue; } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index 4fdc7a84c..5791c2a6a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -95,7 +95,7 @@ public class ClansMainTutorial extends Tutorial UtilInv.Clear(player); ClansManager.getInstance().getItemMapManager().setMap(player); - ClansManager.getInstance().getPvpTimer().unpause(player); + //ClansManager.getInstance().getPvpTimer().unpause(player); /* ClansManager.getInstance().runAsync(() -> { @@ -132,7 +132,7 @@ public class ClansMainTutorial extends Tutorial player.setGameMode(GameMode.SURVIVAL); player.getInventory().clear(); - ClansManager.getInstance().getPvpTimer().pause(player); + //ClansManager.getInstance().getPvpTimer().pause(player); // Spawn Holograms addHologram(player,