Logitech Giveaway (still needs testing)

This commit is contained in:
Shaun Bennett 2015-11-06 21:15:37 -05:00
parent 55d028d706
commit 3893617d58
21 changed files with 767 additions and 113 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" hash="1293212710">
<component name="DataSourceManagerImpl" format="xml" hash="4268976312">
<data-source source="LOCAL" name="Mineplex" uuid="14dfc55d-5343-47c4-ab24-76a055b8059e">
<driver-ref>mysql</driver-ref>
<synchronize>true</synchronize>
@ -13,7 +13,6 @@
<property name="characterSetResults" value="utf8" />
<property name="yearIsDateType" value="false" />
</driver-properties>
<libraries />
</data-source>
</component>
</project>

View File

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@ -32,6 +32,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.database.DBPool;
import mineplex.core.donation.DonationManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
@ -165,7 +166,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
updateOffSet();
}
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager)
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, GiveawayManager giveawayManager)
{
super("Bonus", plugin);
_repository = new BonusRepository(plugin, this, donationManager);
@ -174,7 +175,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_npcManager = npcManager;
_hologramManager = hologramManager;
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager,
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager, giveawayManager,
100, 250,
500, 1000,
4000, 6000,

View File

@ -3,6 +3,7 @@ package mineplex.core.bonuses.gui;
import java.util.ArrayList;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gui.DisplayItem;
@ -109,7 +110,14 @@ public class SpinGui extends SimpleGui
}
}
_rewardData = _reward.giveReward(RewardType.SpinnerReal, getPlayer());
_reward.giveReward(RewardType.SpinnerReal, getPlayer(), new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
_rewardData = data;
}
});
}
private void tick()

View File

@ -0,0 +1,51 @@
package mineplex.core.giveaway;
public class Giveaway
{
private int _id;
private String _name;
private String _header;
private String _message;
private boolean _notifyNetwork;
private int _notifyCooldown;
public Giveaway(int id, String name, String header, String message, boolean notifyNetwork, int notifyCooldown)
{
_id = id;
_name = name;
_header = header;
_message = message;
_notifyNetwork = notifyNetwork;
_notifyCooldown = notifyCooldown;
}
public int getId()
{
return _id;
}
public String getName()
{
return _name;
}
public String getMessage()
{
return _message;
}
public String getHeader()
{
return _header;
}
public boolean isNotifyNetwork()
{
return _notifyNetwork;
}
public int getNotifyCooldown()
{
return _notifyCooldown;
}
}

View File

@ -0,0 +1,30 @@
package mineplex.core.giveaway;
public class GiveawayCooldown
{
private int _id;
private String _name;
private int _cooldown;
public GiveawayCooldown(int id, String name, int cooldown)
{
_id = id;
_name = name;
_cooldown = cooldown;
}
public int getId()
{
return _id;
}
public String getName()
{
return _name;
}
public int getCooldown()
{
return _cooldown;
}
}

View File

@ -0,0 +1,104 @@
package mineplex.core.giveaway;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.Callback;
import mineplex.core.giveaway.redis.GiveawayMessage;
import mineplex.core.giveaway.redis.GiveawayMessageHandler;
import mineplex.serverdata.Region;
import mineplex.serverdata.commands.ServerCommandManager;
public class GiveawayManager extends MiniPlugin
{
private CoreClientManager _clientManager;
private GiveawayRepository _repository;
private HashMap<String, Giveaway> _giveawayMap;
private HashMap<String, GiveawayCooldown> _cooldownMap;
public GiveawayManager(JavaPlugin plugin, CoreClientManager clientManager)
{
super("Giveaway Manager", plugin);
_clientManager = clientManager;
_repository = new GiveawayRepository(plugin);
_giveawayMap = _repository.loadGiveaways();
_cooldownMap = _repository.loadCooldowns();
ServerCommandManager.getInstance().registerCommandType("GiveawayMessage", GiveawayMessage.class, new GiveawayMessageHandler());
}
public void attemptToGiveaway(final String giveawayName, final String cooldownName, Player player, final Callback<GiveawayResponse> callback)
{
final int accountId = _clientManager.getAccountId(player);
if (accountId == -1)
{
callback.run(new GiveawayResponse(GiveawayResponse.FailReason.INVALID_ACCOUNT_ID));
return;
}
if (!hasGiveaway(giveawayName))
{
callback.run(new GiveawayResponse(GiveawayResponse.FailReason.INVALID_GIVEAWAY));
return;
}
if (!hasCooldown(cooldownName))
{
callback.run(new GiveawayResponse(GiveawayResponse.FailReason.INVALID_COOLDOWN));
return;
}
final Giveaway giveaway = _giveawayMap.get(giveawayName);
final GiveawayCooldown cooldown = _cooldownMap.get(cooldownName);
runAsync(new Runnable()
{
@Override
public void run()
{
final GiveawayResponse response;
if (_repository.canGiveaway(accountId, giveawayName))
{
UUID uuid = UUID.randomUUID();
if (_repository.addGiveaway(accountId, giveaway.getId(), cooldown.getId(), Region.US, "", uuid))
{
response = new GiveawayResponse(uuid);
}
else
{
response = new GiveawayResponse(GiveawayResponse.FailReason.QUERY_FAILED);
}
}
else
{
response = new GiveawayResponse(GiveawayResponse.FailReason.CANNOT_GIVEAWAY);
}
runSync(new Runnable()
{
@Override
public void run()
{
if (callback != null) callback.run(response);
}
});
}
});
}
public boolean hasGiveaway(String name)
{
return _giveawayMap.containsKey(name);
}
public boolean hasCooldown(String name)
{
return _cooldownMap.containsKey(name);
}
}

View File

@ -0,0 +1,116 @@
package mineplex.core.giveaway;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnInt;
import mineplex.core.database.column.ColumnVarChar;
import mineplex.serverdata.Region;
public class GiveawayRepository extends RepositoryBase
{
private static final String INSERT_GIVEAWAY = "INSERT INTO Account.accountGiveaway (giveawayId, accountId, cooldownId, region, serverName, time, uuid) VALUES (?, ?, ?, ?, ?, now(), ?)";
private static final String LOAD_GIVEAWAY = "SELECT id, name, header, message, max, notifyNetwork, notifyCooldown, canWinTwice FROM Account.giveaway WHERE enabled = TRUE";
private static final String LOAD_COOLDOWN = "SELECT id, name, cooldown FROM Account.giveawayCooldown";
public GiveawayRepository(JavaPlugin plugin)
{
super(plugin, DBPool.ACCOUNT);
}
public boolean canGiveaway(int accountId, String giveawayName)
{
try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_giveaway(?, ?, ?)}"))
{
callableStatement.setInt(1, accountId);
callableStatement.setString(2, giveawayName);
callableStatement.registerOutParameter(3, Types.BOOLEAN);
callableStatement.executeUpdate();
boolean pass = callableStatement.getBoolean(3);
return pass;
}
catch (Exception e)
{
}
return false;
}
public boolean addGiveaway(int accountId, int giveawayId, int cooldownId, Region region, String serverName, UUID uuid)
{
return 1 == executeUpdate(INSERT_GIVEAWAY, new ColumnInt("giveawayId", giveawayId), new ColumnInt("accountId", accountId),
new ColumnInt("cooldownId", cooldownId), new ColumnVarChar("region", 10, region.name()), new ColumnVarChar("serverName", 64, serverName),
new ColumnVarChar("uuid", 32, uuid.toString().replaceAll("-", "")));
}
public HashMap<String, Giveaway> loadGiveaways()
{
final HashMap<String, Giveaway> map = new HashMap<String, Giveaway>();
executeQuery(LOAD_GIVEAWAY, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
int id = resultSet.getInt(1);
String name = resultSet.getString(2);
String header = resultSet.getString(3);
String message = resultSet.getString(4);
int max = resultSet.getInt(5);
boolean notifyNetwork = resultSet.getBoolean(6);
int notifyCooldown = resultSet.getInt(7);
boolean canWinTwice = resultSet.getBoolean(8);
Giveaway giveaway = new Giveaway(id, name, header, message, notifyNetwork, notifyCooldown);
map.put(name, giveaway);
}
}
});
return map;
}
public HashMap<String, GiveawayCooldown> loadCooldowns()
{
final HashMap<String, GiveawayCooldown> map = new HashMap<String, GiveawayCooldown>();
executeQuery(LOAD_COOLDOWN, new ResultSetCallable()
{
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
while (resultSet.next())
{
int id = resultSet.getInt(1);
String name = resultSet.getString(2);
int cooldown = resultSet.getInt(3);
GiveawayCooldown cd = new GiveawayCooldown(id, name, cooldown);
map.put(name, cd);
}
}
});
return map;
}
@Override
protected void initialize()
{
}
@Override
protected void update()
{
}
}

View File

@ -0,0 +1,52 @@
package mineplex.core.giveaway;
import java.util.UUID;
public class GiveawayResponse
{
private boolean _success;
private FailReason _failReason;
private UUID _giveawayId;
/**
* Success Constructor
* @param giveawayId
*/
protected GiveawayResponse(UUID giveawayId)
{
_success = true;
_failReason = null;
_giveawayId = giveawayId;
}
/**
* Faulure constructor
* @param failReason
*/
protected GiveawayResponse(FailReason failReason)
{
_success = false;
_failReason = failReason;
_giveawayId = null;
}
public boolean isSuccess()
{
return _success;
}
public UUID getGiveawayId()
{
return _giveawayId;
}
public FailReason getFailReason()
{
return _failReason;
}
public static enum FailReason
{
INVALID_GIVEAWAY, INVALID_COOLDOWN, CANNOT_GIVEAWAY, INVALID_ACCOUNT_ID, QUERY_FAILED;
}
}

View File

@ -0,0 +1,39 @@
package mineplex.core.giveaway.redis;
import mineplex.serverdata.commands.ServerCommand;
public class GiveawayMessage extends ServerCommand
{
private String _giveawayName;
private String _playerName;
private String _giveawayHeader;
private String _giveawayMessage;
public GiveawayMessage(String giveawayName, String playerName, String giveawayMessage, String giveawayHeader)
{
_giveawayName = giveawayName;
_playerName = playerName;
_giveawayMessage = giveawayMessage;
_giveawayHeader = giveawayHeader;
}
public String getPlayerName()
{
return _playerName;
}
public String getGiveawayMessage()
{
return _giveawayMessage;
}
public String getGiveawayHeader()
{
return _giveawayHeader;
}
public String getGiveawayName()
{
return _giveawayName;
}
}

View File

@ -0,0 +1,45 @@
package mineplex.core.giveaway.redis;
import java.util.HashMap;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class GiveawayMessageHandler implements CommandCallback
{
private HashMap<String, Long> _cooldownMap;
public GiveawayMessageHandler()
{
_cooldownMap = new HashMap<String, Long>();
}
@Override
public void run(ServerCommand command)
{
if (command instanceof GiveawayMessage)
{
GiveawayMessage message = ((GiveawayMessage) command);
// %p - player name
String headerText = message.getGiveawayHeader();
String chatMessage = message.getGiveawayMessage().replaceAll("%p", message.getPlayerName());
// Chat Colors
headerText = ChatColor.translateAlternateColorCodes('&', headerText);
chatMessage = ChatColor.translateAlternateColorCodes('&', chatMessage);
UtilTextMiddle.display(headerText, chatMessage, 20, 80, 20);
for (Player player : UtilServer.getPlayers())
{
player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1);
}
}
}
}

View File

@ -4,6 +4,8 @@ import java.util.Random;
import org.bukkit.entity.Player;
import mineplex.core.common.util.Callback;
/**
* Created by Shaun on 9/2/2014.
*/
@ -13,16 +15,31 @@ public abstract class Reward
private RewardRarity _rarity;
private int _weight;
private boolean _requiresCallback;
public Reward(RewardRarity rarity, int weight)
{
_rarity = rarity;
_weight = weight;
this(rarity, weight, false);
}
public final RewardData giveReward(RewardType rewardType, Player player)
public Reward(RewardRarity rarity, int weight, boolean requiresCallback)
{
return giveRewardCustom(player, rewardType);
_rarity = rarity;
_weight = weight;
_requiresCallback = requiresCallback;
}
public final void giveReward(RewardType rewardType, Player player, Callback<RewardData> rewardDataCallback)
{
if (_requiresCallback)
giveRewardCallback(rewardType, player, rewardDataCallback);
else
rewardDataCallback.run(giveRewardCustom(player, rewardType));
}
protected void giveRewardCallback(RewardType rewardType, Player player, Callback<RewardData> rewardDataCallback)
{
// do nothing
}
protected abstract RewardData giveRewardCustom(Player player, RewardType rewardType);
@ -40,4 +57,9 @@ public abstract class Reward
{
return _weight;
}
public boolean isRequiresCallback()
{
return _requiresCallback;
}
}

View File

@ -14,12 +14,15 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.rewards.CoinReward;
import mineplex.core.reward.rewards.ExperienceReward;
import mineplex.core.reward.rewards.GemReward;
import mineplex.core.reward.rewards.GiveawayReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.reward.rewards.RankReward;
@ -36,11 +39,13 @@ public class RewardManager
private boolean _carlSpinner;
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private ServerStatusManager _statusManager;
private GiveawayManager _giveawayManager;
private boolean _doubleGadgetValue;
public RewardManager(CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager,
public RewardManager(CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, GiveawayManager giveawayManager,
int commonValueMin, int commonValueMax,
int uncommonValueMin, int uncommonValueMax,
int rareValueMin, int rareValueMax,
@ -58,6 +63,8 @@ public class RewardManager
_clientManager = clientManager;
_statusManager = statusManager;
_donationManager = donationManager;
_giveawayManager = giveawayManager;
_doubleGadgetValue = doubleGadgetValue;
_carlSpinner = carlSpinner;
@ -393,6 +400,10 @@ public class RewardManager
//Dont give Rank Upgrade if already has Titan
if (rarity == RewardRarity.MYTHICAL)
{
if (canGiveMythical && type == RewardType.MythicalChest/* && Math.random() <= 0.1*/)
{
return getLogitechPrize();
}
if (canGiveMythical && type == RewardType.MythicalChest && !_clientManager.Get(player).GetRank().has(Rank.TITAN))
{
return new RankReward(_clientManager, _statusManager, 0, rarity);
@ -462,4 +473,37 @@ public class RewardManager
return null;
}
private Reward getLogitechPrize()
{
double rand = Math.random();
String name;
String cooldown = "logitech";
Material mat = Material.DIAMOND;
String displayName;
if (rand < 0.2)
{
name = "logitechKeyboard";
displayName = C.cRed + "Logitech G910 RGB Keyboard";
}
else if (rand < 0.4)
{
name = "logitechMouse";
displayName = C.cRed + "Logitech G303 Gaming Mouse";
}
else if (rand < 0.6)
{
name = "logitechHeadset";
displayName = C.cRed + "Logitech G430 Gaming Headset";
}
else
{
name = "logitechMousePad";
displayName = C.cRed + "Logitech G240 Gaming Mousepad";
}
return new GiveawayReward(_giveawayManager, _clientManager, _donationManager, _statusManager, name, cooldown, displayName , mat, (byte) 0, RewardRarity.MYTHICAL, 0);
}
}

View File

@ -0,0 +1,95 @@
package mineplex.core.reward.rewards;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.donation.DonationManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.giveaway.GiveawayResponse;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.status.ServerStatusManager;
public class GiveawayReward extends Reward
{
private GiveawayManager _giveawayManager;
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private ServerStatusManager _serverStatusManager;
private String _giveawayName;
private String _cooldownName;
private String _displayName;
private Material _icon;
private byte _data;
public GiveawayReward(GiveawayManager giveawayManager, CoreClientManager clientManager, DonationManager donationManager, ServerStatusManager serverStatusManager, String giveawayName, String cooldownName, String displayName, Material icon, byte data, RewardRarity rarity, int weight)
{
super(rarity, weight, true);
_giveawayManager = giveawayManager;
_clientManager = clientManager;
_donationManager = donationManager;
_serverStatusManager = serverStatusManager;
_giveawayName = giveawayName;
_cooldownName = cooldownName;
_displayName = displayName;
_icon = icon;
_data = data;
}
@Override
protected void giveRewardCallback(final RewardType rewardType, final Player player, final Callback<RewardData> rewardDataCallback)
{
_giveawayManager.attemptToGiveaway(_giveawayName, _cooldownName, player, new Callback<GiveawayResponse>()
{
@Override
public void run(GiveawayResponse data)
{
if (data.isSuccess())
{
RewardData rewardData = new RewardData(_displayName, new ItemStack(_icon, 1, (short) 0, _data), getRarity());
if (rewardDataCallback != null) rewardDataCallback.run(rewardData);
}
else
{
// Dang, I guess we failed!
if (!_clientManager.hasRank(player, Rank.TITAN))
{
Reward reward = new RankReward(_clientManager, _serverStatusManager, 0, getRarity());
reward.giveReward(rewardType, player, rewardDataCallback);
}
else
{
Reward reward = new CoinReward(_donationManager, 20000, 30000, 0, getRarity());
reward.giveReward(rewardType, player, rewardDataCallback);
}
}
}
});
}
@Override
protected RewardData giveRewardCustom(Player player, RewardType rewardType)
{
// This is a little hacky, this should never be called!
return null;
}
@Override
public RewardData getFakeRewardData(Player player)
{
// Let's pretend we are coins!
return new RewardData(getRarity().getColor() + "Coins", new ItemStack(175), getRarity());
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
}

View File

@ -17,6 +17,7 @@ import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
@ -193,13 +194,19 @@ public class Treasure
openChest(block, true);
}
public void openChest(Block block, boolean swapList)
public void openChest(final Block block, final boolean swapList)
{
ChestData data = getChestData(block);
// This is very experimental! Pray to god that this works
final ChestData data = getChestData(block);
if (data != null && !data.isOpened() && _currentReward < _rewards.length)
{
Reward reward = _rewards[_currentReward];
RewardData rewardData = reward.giveReward(_rewardType, _player);
final Reward reward = _rewards[_currentReward];
data.setOpened(true);
reward.giveReward(_rewardType, _player, new Callback<RewardData>()
{
@Override
public void run(RewardData rewardData)
{
_currentReward++;
if (swapList)
@ -209,38 +216,39 @@ public class Treasure
_openedChestBlockInfo.add(info);
}
data.setOpened(true);
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData, _hologramManager);
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(Treasure.this, data, rewardData, _hologramManager);
_animations.add(chestOpenTask);
// Extra effects based off the rarity of the treasure
if (reward.getRarity() == RewardRarity.UNCOMMON)
{
_animations.add(new LootUncommonAnimation(this, data.getBlock()));
_animations.add(new LootUncommonAnimation(Treasure.this, data.getBlock()));
}
else if (reward.getRarity() == RewardRarity.RARE)
{
_animations.add(new LootRareAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
_animations.add(new LootRareAnimation(Treasure.this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cPurple + "Rare " + rewardData.getFriendlyName()));
}
else if (reward.getRarity() == RewardRarity.LEGENDARY)
{
_animations.add(new LootLegendaryAnimation(this, data.getBlock()));
_animations.add(new LootLegendaryAnimation(Treasure.this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGreen + "Legendary " + rewardData.getFriendlyName()));
}
else if (reward.getRarity() == RewardRarity.MYTHICAL)
{
_animations.add(new LootMythicalAnimation(this, data.getBlock()));
_animations.add(new LootMythicalAnimation(Treasure.this, data.getBlock()));
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Mythical " + rewardData.getFriendlyName()));
}
if (isFinished())
{
TreasureRemoveAnimation animation = new TreasureRemoveAnimation(this, _openedChestBlockInfo, _chestBlockInfo);
TreasureRemoveAnimation animation = new TreasureRemoveAnimation(Treasure.this, _openedChestBlockInfo, _chestBlockInfo);
_animations.add(animation);
_finished = true;
}
}
});
}
}
public BlockInfo getBlockInfo(Block block)
@ -299,7 +307,14 @@ public class Treasure
for (int i = _currentReward; i < _rewards.length; i++)
{
_rewards[_currentReward].giveReward(_rewardType, _player);
_rewards[_currentReward].giveReward(_rewardType, _player, new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
// Do nothing
}
});
}
_currentReward = _rewards.length;

View File

@ -14,6 +14,7 @@ import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.donation.DonationManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
@ -35,7 +36,7 @@ public class TreasureManager extends MiniPlugin
private StatsManager _statsManager;
private List<TreasureLocation> _treasureLocations;
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager)
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager, GiveawayManager giveawayManager)
{
super("Treasure", plugin);
@ -43,7 +44,7 @@ public class TreasureManager extends MiniPlugin
_blockRestore = blockRestore;
_hologramManager = hologramManager;
_statsManager = statsManager;
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, _inventoryManager, petManager, statsManager,
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, _inventoryManager, petManager, statsManager, giveawayManager,
100, 250,
500, 1000,
4000, 6000,

View File

@ -19,6 +19,7 @@ import mineplex.core.elo.EloManager;
import mineplex.core.energy.Energy;
import mineplex.core.friend.FriendManager;
import mineplex.core.give.Give;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.globalpacket.GlobalPacketManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager;
@ -111,6 +112,7 @@ public class Hub extends JavaPlugin implements IRelation
//Main Modules
ServerStatusManager serverStatusManager = new ServerStatusManager(this, clientManager, new LagMeter(this, clientManager));
GiveawayManager giveawayManager = new GiveawayManager(this, clientManager);
new TitanGiveawayManager(this, clientManager, serverStatusManager);
Portal portal = new Portal(this, clientManager, serverStatusManager.getCurrentServerName());
@ -127,7 +129,7 @@ public class Hub extends JavaPlugin implements IRelation
PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager);
PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler, punish, serverStatusManager);
HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, giveawayManager);
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);

View File

@ -30,6 +30,7 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.message.PrivateMessageEvent;
@ -163,7 +164,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
//Admin
private boolean _gadgetsEnabled = true;
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager)
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, GiveawayManager giveawayManager)
{
super("Hub Manager", plugin);
@ -196,7 +197,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
new BenefitManager(plugin, clientManager, _inventoryManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager);
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager);
_treasureManager = new TreasureManager(_plugin, clientManager, serverStatusManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager, giveawayManager);
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager);
new SoccerManager(this, _gadgetManager);
@ -224,7 +225,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager);
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager);
// _halloweenManager = new HalloweenSpookinessManager(this);

View File

@ -6,6 +6,8 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.FoodDupeFix;
import mineplex.core.account.CoreClient;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.globalpacket.GlobalPacketManager;
import net.minecraft.server.v1_7_R4.BiomeBase;
@ -146,9 +148,11 @@ public class Arcade extends JavaPlugin
new GlobalPacketManager(this, _clientManager, serverStatusManager);
GiveawayManager giveawayManager = new GiveawayManager(this, _clientManager);
//Arcade Manager
PollManager pollManager = new PollManager(this, _clientManager, _donationManager);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, giveawayManager);
new MemoryFix(this);
new CustomTagFix(this, packetHandler);

View File

@ -17,6 +17,7 @@ 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.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
@ -33,6 +34,7 @@ import mineplex.core.elo.EloManager;
import mineplex.core.energy.Energy;
import mineplex.core.explosion.Explosion;
import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
@ -53,6 +55,7 @@ import mineplex.core.projectile.ProjectileManager;
import mineplex.core.resourcepack.ResPackManager;
import mineplex.core.resourcepack.ResUnloadCheck;
import mineplex.core.resourcepack.redis.RedisUnloadResPack;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.stats.StatsManager;
@ -189,6 +192,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
private StatsManager _statsManager;
private PartyManager _partyManager;
private PreferencesManager _preferencesManager;
private GiveawayManager _giveawayManager;
private TaskManager _taskManager;
private PacketHandler _packetHandler;
@ -219,7 +223,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager,
StatsManager statsManager, AchievementManager achievementManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, Chat chat,
Portal portal, PreferencesManager preferences, InventoryManager inventoryManager, PacketHandler packetHandler,
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, NpcManager npcManager)
CosmeticManager cosmeticManager, ProjectileManager projectileManager, PetManager petManager, HologramManager hologramManager, String webAddress, PollManager pollManager, NpcManager npcManager, GiveawayManager giveawayManager)
{
super("Game Manager", plugin);
@ -272,6 +276,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_portal = portal;
_petManager = petManager;
_eventManager = new EventModule(this, getPlugin());
_giveawayManager = giveawayManager;
// Shop
_arcadeShop = new ArcadeShop(this, clientManager, donationManager);
@ -304,7 +309,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new NotificationManager(getPlugin(), clientManager);
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager);
new BonusManager(plugin, clientManager, serverStatusManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager, giveawayManager);
//Champions Modules
_energy = new Energy(plugin);
@ -518,6 +523,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
return _explosionManager;
}
public GiveawayManager getGiveawayManager()
{
return _giveawayManager;
}
public Fire GetFire()
{
return _fire;
@ -1328,7 +1338,14 @@ public class ArcadeManager extends MiniPlugin implements IRelation
PetReward reward = new PetReward(_petManager, _inventoryManager, _donationManager, pet, pet, type, RewardRarity.OTHER, 0);
if (reward.canGiveReward(player))
reward.giveReward(null, player);
reward.giveReward(null, player, new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
}
});
}
public void toggleChampionsModules(GameType gameType)

View File

@ -18,11 +18,13 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
@ -50,7 +52,7 @@ public class GameLootManager implements Listener
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
_rewardManager = new RewardManager(Manager.GetClients(), Manager.GetServerStatusManager(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, Manager.GetStatsManager(),
_rewardManager = new RewardManager(Manager.GetClients(), Manager.GetServerStatusManager(), Manager.GetDonation(), Manager.getInventoryManager(), petManager, Manager.GetStatsManager(), Manager.getGiveawayManager(),
100, 250,
500, 1000,
1500, 2500,
@ -133,7 +135,7 @@ public class GameLootManager implements Listener
//Delay after Achievements
}
public boolean giveReward(Player player, boolean force)
public boolean giveReward(final Player player, boolean force)
{
if (!force)
{
@ -162,10 +164,12 @@ public class GameLootManager implements Listener
return false;
}
Reward reward = _rewardManager.nextReward(player, null, false, RewardType.GameLoot, true);
RewardData rewardData = reward.giveReward(RewardType.GameLoot, player);
final Reward reward = _rewardManager.nextReward(player, null, false, RewardType.GameLoot, true);
reward.giveReward(RewardType.GameLoot, player, new Callback<RewardData>()
{
@Override
public void run(RewardData rewardData)
{
String outputName = reward.getRarity().getColor() + rewardData.getFriendlyName();
String rarityName = "";
@ -212,6 +216,8 @@ public class GameLootManager implements Listener
player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
}
}
});
return true;
}