From ec7600a4a262876ce02127400762c6e096bd7837 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Sat, 7 Nov 2015 01:10:27 -0500 Subject: [PATCH] Giveaway tweaks --- Plugins/.idea/compiler.xml | 2 +- .../mineplex/core/giveaway/GiveawayManager.java | 17 +++++++++++++++-- .../core/giveaway/GiveawayRepository.java | 10 ++++++---- .../src/mineplex/core/reward/RewardManager.java | 2 +- .../core/reward/rewards/GiveawayReward.java | 2 ++ .../src/mineplex/core/treasure/Treasure.java | 3 +-- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Plugins/.idea/compiler.xml b/Plugins/.idea/compiler.xml index 37717d4dc..28bb49b4f 100644 --- a/Plugins/.idea/compiler.xml +++ b/Plugins/.idea/compiler.xml @@ -24,7 +24,7 @@ - + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java index 03e912133..0ad5344f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayManager.java @@ -32,7 +32,7 @@ public class GiveawayManager extends MiniPlugin ServerCommandManager.getInstance().registerCommandType("GiveawayMessage", GiveawayMessage.class, new GiveawayMessageHandler()); } - public void attemptToGiveaway(final String giveawayName, final String cooldownName, Player player, final Callback callback) + public void attemptToGiveaway(final String giveawayName, final String cooldownName, final Player player, final Callback callback) { final int accountId = _clientManager.getAccountId(player); @@ -63,7 +63,7 @@ public class GiveawayManager extends MiniPlugin { final GiveawayResponse response; - if (_repository.canGiveaway(accountId, giveawayName)) + if (_repository.canGiveaway(accountId, giveawayName, cooldownName)) { UUID uuid = UUID.randomUUID(); if (_repository.addGiveaway(accountId, giveaway.getId(), cooldown.getId(), Region.US, "", uuid)) @@ -85,6 +85,19 @@ public class GiveawayManager extends MiniPlugin @Override public void run() { + try + { + if (response.isSuccess()) + { + GiveawayMessage message = new GiveawayMessage(giveawayName, player.getName(), giveaway.getMessage(), giveaway.getHeader()); + message.publish(); + } + } + catch (Exception e) + { + + } + if (callback != null) callback.run(response); } }); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java index 6564882ab..7025f2f04 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/giveaway/GiveawayRepository.java @@ -8,6 +8,7 @@ import java.sql.Types; import java.util.HashMap; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.database.DBPool; @@ -28,17 +29,18 @@ public class GiveawayRepository extends RepositoryBase super(plugin, DBPool.ACCOUNT); } - public boolean canGiveaway(int accountId, String giveawayName) + public boolean canGiveaway(int accountId, String giveawayName, String cooldownName) { try (Connection connection = getConnection(); - CallableStatement callableStatement = connection.prepareCall("{call check_giveaway(?, ?, ?)}")) + CallableStatement callableStatement = connection.prepareCall("{call check_giveaway(?, ?, ?, ?)}")) { callableStatement.setInt(1, accountId); callableStatement.setString(2, giveawayName); - callableStatement.registerOutParameter(3, Types.BOOLEAN); + callableStatement.setString(3, cooldownName); + callableStatement.registerOutParameter(4, Types.BOOLEAN); callableStatement.executeUpdate(); - boolean pass = callableStatement.getBoolean(3); + boolean pass = callableStatement.getBoolean(4); return pass; } catch (Exception e) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 591788557..217b994c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -398,7 +398,7 @@ public class RewardManager RewardRarity rarity = type.generateRarity(requiresUncommon); //Dont give Rank Upgrade if already has Titan - if (rarity == RewardRarity.MYTHICAL) + if (true || rarity == RewardRarity.MYTHICAL) { if (canGiveMythical && type == RewardType.MythicalChest/* && Math.random() <= 0.1*/) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GiveawayReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GiveawayReward.java index ef5b439fe..438124d54 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GiveawayReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/GiveawayReward.java @@ -57,6 +57,8 @@ public class GiveawayReward extends Reward } else { + System.out.println("GIVEAWAY FAILED: " + data.getFailReason().name()); + // Dang, I guess we failed! if (!_clientManager.hasRank(player, Rank.TITAN)) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java index 1e7f103ed..d1b19508b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java @@ -202,13 +202,12 @@ public class Treasure { final Reward reward = _rewards[_currentReward]; data.setOpened(true); + _currentReward++; reward.giveReward(_rewardType, _player, new Callback() { @Override public void run(RewardData rewardData) { - _currentReward++; - if (swapList) { BlockInfo info = getBlockInfo(block);