From e845f7fca91388ac4e2c20bb47bef1a9ed8e2288 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Thu, 17 Nov 2016 02:13:48 -0500 Subject: [PATCH] Disable Fated giveaway tools for now --- .../fatedgiveaway/FatedGiveawayAnimation.java | 61 ---------- .../fatedgiveaway/FatedGiveawayManager.java | 111 ------------------ .../FatedGiveawayRepository.java | 71 ----------- .../redis/FatedGiveawayMessage.java | 32 ----- .../redis/GiveawayMessageHandler.java | 17 --- .../nautilus/game/arcade/ArcadeManager.java | 6 +- .../game/arcade/managers/HolidayManager.java | 19 +-- 7 files changed, 3 insertions(+), 314 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java deleted file mode 100644 index 3b4a0b021..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayAnimation.java +++ /dev/null @@ -1,61 +0,0 @@ -package mineplex.core.rankGiveaway.fatedgiveaway; - -import org.bukkit.Bukkit; -import org.bukkit.Color; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; - -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - -public class FatedGiveawayAnimation implements Listener -{ - private Location _location; - private Long _duration, _startTime, _worldTime; - - public FatedGiveawayAnimation(FatedGiveawayManager manager, Location start, Long duration) - { - _location = start.clone(); - _duration = duration; - _startTime = System.currentTimeMillis(); - Bukkit.getPluginManager().registerEvents(this, manager.getPlugin()); - } - - public FatedGiveawayAnimation(FatedGiveawayManager manager, Location start) - { - this(manager, start, 11111L); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void tick(UpdateEvent event) - { - if (event.getType() != UpdateType.TICK) - return; - - if (UtilTime.elapsed(_startTime, _duration)) - { - remove(); - return; - } - - for (Player player : UtilServer.getPlayers()) - { - player.playSound(_location, Sound.ORB_PICKUP, 5, 5); - UtilFirework.packetPlayFirework(player, _location, Type.BURST, Color.fromRGB(255, 105, 180), true, false); - } - } - - private void remove() - { - HandlerList.unregisterAll(this); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java deleted file mode 100644 index d3ec0e8d0..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayManager.java +++ /dev/null @@ -1,111 +0,0 @@ -package mineplex.core.rankGiveaway.fatedgiveaway; - -import java.util.Random; - -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; -import mineplex.core.common.util.Callback; -import mineplex.core.rankGiveaway.redis.FatedGiveawayMessage; -import mineplex.core.rankGiveaway.redis.GiveawayMessageHandler; -import mineplex.core.status.ServerStatusManager; -import mineplex.serverdata.Region; -import mineplex.serverdata.commands.ServerCommandManager; - -public class FatedGiveawayManager extends MiniPlugin -{ - - private static final double RANK_FIND_CHANCE = 0.001; - - private FatedGiveawayRepository _repository; - private CoreClientManager _clientManager; - private ServerStatusManager _statusManager; - private Random _random; - - public FatedGiveawayManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager) - { - super("Fated Giveaway", plugin); - - _repository = new FatedGiveawayRepository(plugin); - _clientManager = clientManager; - _statusManager = statusManager; - _random = new Random(); - - ServerCommandManager.getInstance().registerCommandType("FatedGiveawayMessage", FatedGiveawayMessage.class, new GiveawayMessageHandler(plugin)); - } - - public void openPumpkin(final Player player, final Runnable onSuccess) - { - double rand = _random.nextDouble(); - if (!hasFated(player) && rand < RANK_FIND_CHANCE) - { - final int accountId = _clientManager.getAccountId(player); - final Region region = getRegion(); - final String serverName = getServerName(); - - // Need to check database that we can give away a rank - runAsync(new Runnable() - { - @Override - public void run() - { - final boolean pass = _repository.canGiveaway(region); - - if (pass && _repository.addFated(accountId, region, serverName)) - { - runSync(new Runnable() - { - @Override - public void run() - { - giveRank(new Callback() - { - @Override - public void run(Rank rank) - { - // TODO CHANGE RANK - if (rank == Rank.TITAN) - { - FatedGiveawayMessage message = new FatedGiveawayMessage(player.getName(), _repository.getFatedCount() + 1); - message.publish(); - if (onSuccess != null) onSuccess.run(); - } - } - // TODO CHANGE RANK - }, Rank.TITAN, player); - } - }); - } - } - }); - } - } - - /** - * Confirm that the player doesn't already have FATED rank - */ - private boolean hasFated(Player player) - { - // TODO CHANGE RANK - return _clientManager.hasRank(player, Rank.TITAN); - } - - public Region getRegion() - { - return _statusManager.getRegion(); - } - - public String getServerName() - { - return _statusManager.getCurrentServerName(); - } - - private void giveRank(Callback callback, Rank rank, Player player) - { - _clientManager.Get(player).SetRank(rank, false); - _clientManager.getRepository().saveRank(callback, player.getName(), player.getUniqueId(), rank, true); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java deleted file mode 100644 index cd5d09c9d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/fatedgiveaway/FatedGiveawayRepository.java +++ /dev/null @@ -1,71 +0,0 @@ -package mineplex.core.rankGiveaway.fatedgiveaway; - -import java.sql.CallableStatement; -import java.sql.Connection; -import java.sql.Types; - -import org.bukkit.plugin.java.JavaPlugin; - -import mineplex.core.database.MinecraftRepository; -import mineplex.serverdata.Region; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.column.ColumnInt; -import mineplex.serverdata.database.column.ColumnVarChar; - -public class FatedGiveawayRepository extends MinecraftRepository -{ - private static final String ADD_FATED = "INSERT INTO fatedGiveaway (accountId, region, serverName) VALUES (?, ?, ?)"; - - private int _fatedCount; - - public FatedGiveawayRepository(JavaPlugin plugin) - { - super(plugin, DBPool.getAccount()); - _fatedCount = 0; - } - - @Override - protected void initialize() - { - - } - - @Override - protected void update() - { - - } - - public boolean addFated(int accountId, Region region, String serverName) - { - return 1 == executeUpdate(ADD_FATED, new ColumnInt("accountId", accountId), new ColumnVarChar("region", 10, region.name()), new ColumnVarChar("serverName", 64, serverName)); - } - - public boolean canGiveaway(Region region) - { - try (Connection connection = getConnection(); - CallableStatement callableStatement = connection.prepareCall("{call check_fatedGiveaway(?, ?, ?)}")) - { - callableStatement.setString(1, region.name()); - callableStatement.registerOutParameter(2, Types.BOOLEAN); - callableStatement.registerOutParameter(3, Types.INTEGER); - callableStatement.executeUpdate(); - - boolean pass = callableStatement.getBoolean(2); - int fatedCount = callableStatement.getInt(3); - - _fatedCount = fatedCount; - return pass; - } - catch (Exception e) - { - e.printStackTrace(); - } - return false; - } - - public int getFatedCount() - { - return _fatedCount; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java deleted file mode 100644 index e3f77e888..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/FatedGiveawayMessage.java +++ /dev/null @@ -1,32 +0,0 @@ -package mineplex.core.rankGiveaway.redis; - -import mineplex.serverdata.commands.ServerCommand; - -public class FatedGiveawayMessage extends ServerCommand -{ - private String _playerName; - private int _fatedCount; - - public FatedGiveawayMessage(String playerName, int fatedCount) - { - _playerName = playerName; - _fatedCount = fatedCount; - } - - public String getPlayerName() - { - return _playerName; - } - - public int getFatedCount() - { - return _fatedCount; - } - - @Override - public void run() - { - // Handled in Command Callback - } -} - diff --git a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java index ac994929f..557b227e1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/rankGiveaway/redis/GiveawayMessageHandler.java @@ -44,22 +44,5 @@ public class GiveawayMessageHandler implements CommandCallback player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1); } } - else if (command instanceof FatedGiveawayMessage) - { - FatedGiveawayMessage message = ((FatedGiveawayMessage) command); - String playerName = message.getPlayerName(); - int count = message.getFatedCount(); - String countString = count + UtilTime.getDayOfMonthSuffix(count); - String chatMessage = C.cPurple + playerName + C.cWhite + " found Fated in a " + C.cPurple + "Thanksgiving Chicken"; - UtilTextMiddle.display(C.cDPurple + C.Bold + "FATED", chatMessage, 20, 80, 20, UtilServer.getPlayers()); - World world = UtilServer.getPlayers().length > 0 ? UtilServer.getPlayers()[0].getWorld() : Bukkit.getWorlds().get(0); - LightFlicker lightFlicker = new LightFlicker(world); - lightFlicker.runTaskTimer(_plugin, 1, 1); - - for (Player player : UtilServer.getPlayers()) - { - player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1); - } - } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index e0bd8ed06..4c4272685 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -89,7 +89,6 @@ import mineplex.core.preferences.PreferencesManager; import mineplex.core.progression.KitProgressionManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; -import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayManager; import mineplex.core.resourcepack.ResourcePackManager; import mineplex.core.scoreboard.MineplexScoreboard; import mineplex.core.scoreboard.ScoreboardManager; @@ -345,9 +344,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation _hologramManager = hologramManager; _idleManager = new IdleManager(this); TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager); - FatedGiveawayManager fatedGiveaway = new FatedGiveawayManager(getPlugin(), clientManager, serverStatusManager); - - new HolidayManager(this, titanGiveaway, fatedGiveaway); + + new HolidayManager(this, titanGiveaway); IsHolidayEnabled = true; new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java index aa48f5d45..3aa7d7131 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/HolidayManager.java @@ -45,8 +45,6 @@ import mineplex.core.common.util.UtilWorld; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.particleeffects.HalloweenSmashedEffect; -import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayAnimation; -import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayManager; import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager; import mineplex.core.reward.RewardPool; import mineplex.core.reward.RewardRarity; @@ -102,7 +100,6 @@ public class HolidayManager implements Listener private ArcadeManager _arcadeManager; private TitanGiveawayManager _titanManager; - private FatedGiveawayManager _fatedManager; public HashSet _active = new HashSet<>(); public HashSet _activeEntities = new HashSet<>(); @@ -120,11 +117,10 @@ public class HolidayManager implements Listener private EnumMap _rewardPools; - public HolidayManager(ArcadeManager arcadeManager, TitanGiveawayManager titanManager, FatedGiveawayManager fatedManager) + public HolidayManager(ArcadeManager arcadeManager, TitanGiveawayManager titanManager) { _arcadeManager = arcadeManager; _titanManager = titanManager; - _fatedManager = fatedManager; _rewardPools = new EnumMap<>(RewardPool.Type.class); for (RewardPool.Type type : RewardPool.Type.values()) @@ -617,19 +613,6 @@ public class HolidayManager implements Listener _gems.add(gem); } - // Fated Giveaway - if (player != null) - { - _fatedManager.openPumpkin(player, new Runnable() - { - @Override - public void run() - { - Location location = entity.getLocation().add(0.5, 0.5, 0.5); - new FatedGiveawayAnimation(_fatedManager, location, 3000L); - } - }); - } } @EventHandler