Giveaway tweaks

This commit is contained in:
Shaun Bennett 2015-11-07 01:10:27 -05:00
parent 4add7449eb
commit ec7600a4a2
6 changed files with 26 additions and 10 deletions

View File

@ -24,7 +24,7 @@
</profile> </profile>
<profile default="false" name="Annotation profile for bungee" enabled="true"> <profile default="false" name="Annotation profile for bungee" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" /> <sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> <sourceTestOutputDir name="target\generated-test-sources\test-annotations" />
<outputRelativeToContentRoot value="true" /> <outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" /> <processorPath useClasspath="true" />
</profile> </profile>

View File

@ -32,7 +32,7 @@ public class GiveawayManager extends MiniPlugin
ServerCommandManager.getInstance().registerCommandType("GiveawayMessage", GiveawayMessage.class, new GiveawayMessageHandler()); ServerCommandManager.getInstance().registerCommandType("GiveawayMessage", GiveawayMessage.class, new GiveawayMessageHandler());
} }
public void attemptToGiveaway(final String giveawayName, final String cooldownName, Player player, final Callback<GiveawayResponse> callback) public void attemptToGiveaway(final String giveawayName, final String cooldownName, final Player player, final Callback<GiveawayResponse> callback)
{ {
final int accountId = _clientManager.getAccountId(player); final int accountId = _clientManager.getAccountId(player);
@ -63,7 +63,7 @@ public class GiveawayManager extends MiniPlugin
{ {
final GiveawayResponse response; final GiveawayResponse response;
if (_repository.canGiveaway(accountId, giveawayName)) if (_repository.canGiveaway(accountId, giveawayName, cooldownName))
{ {
UUID uuid = UUID.randomUUID(); UUID uuid = UUID.randomUUID();
if (_repository.addGiveaway(accountId, giveaway.getId(), cooldown.getId(), Region.US, "", uuid)) if (_repository.addGiveaway(accountId, giveaway.getId(), cooldown.getId(), Region.US, "", uuid))
@ -85,6 +85,19 @@ public class GiveawayManager extends MiniPlugin
@Override @Override
public void run() 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); if (callback != null) callback.run(response);
} }
}); });

View File

@ -8,6 +8,7 @@ import java.sql.Types;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool; import mineplex.core.database.DBPool;
@ -28,17 +29,18 @@ public class GiveawayRepository extends RepositoryBase
super(plugin, DBPool.ACCOUNT); super(plugin, DBPool.ACCOUNT);
} }
public boolean canGiveaway(int accountId, String giveawayName) public boolean canGiveaway(int accountId, String giveawayName, String cooldownName)
{ {
try (Connection connection = getConnection(); try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_giveaway(?, ?, ?)}")) CallableStatement callableStatement = connection.prepareCall("{call check_giveaway(?, ?, ?, ?)}"))
{ {
callableStatement.setInt(1, accountId); callableStatement.setInt(1, accountId);
callableStatement.setString(2, giveawayName); callableStatement.setString(2, giveawayName);
callableStatement.registerOutParameter(3, Types.BOOLEAN); callableStatement.setString(3, cooldownName);
callableStatement.registerOutParameter(4, Types.BOOLEAN);
callableStatement.executeUpdate(); callableStatement.executeUpdate();
boolean pass = callableStatement.getBoolean(3); boolean pass = callableStatement.getBoolean(4);
return pass; return pass;
} }
catch (Exception e) catch (Exception e)

View File

@ -398,7 +398,7 @@ public class RewardManager
RewardRarity rarity = type.generateRarity(requiresUncommon); RewardRarity rarity = type.generateRarity(requiresUncommon);
//Dont give Rank Upgrade if already has Titan //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*/) if (canGiveMythical && type == RewardType.MythicalChest/* && Math.random() <= 0.1*/)
{ {

View File

@ -57,6 +57,8 @@ public class GiveawayReward extends Reward
} }
else else
{ {
System.out.println("GIVEAWAY FAILED: " + data.getFailReason().name());
// Dang, I guess we failed! // Dang, I guess we failed!
if (!_clientManager.hasRank(player, Rank.TITAN)) if (!_clientManager.hasRank(player, Rank.TITAN))
{ {

View File

@ -202,13 +202,12 @@ public class Treasure
{ {
final Reward reward = _rewards[_currentReward]; final Reward reward = _rewards[_currentReward];
data.setOpened(true); data.setOpened(true);
_currentReward++;
reward.giveReward(_rewardType, _player, new Callback<RewardData>() reward.giveReward(_rewardType, _player, new Callback<RewardData>()
{ {
@Override @Override
public void run(RewardData rewardData) public void run(RewardData rewardData)
{ {
_currentReward++;
if (swapList) if (swapList)
{ {
BlockInfo info = getBlockInfo(block); BlockInfo info = getBlockInfo(block);