Merge remote-tracking branch 'origin/Bonus' into Bonus

Conflicts:
	Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java
	Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java
This commit is contained in:
Shaun Bennett 2015-08-11 03:12:55 -05:00
commit 184c592786
15 changed files with 84 additions and 142 deletions

View File

@ -16,7 +16,7 @@
</set>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -11,6 +11,7 @@
<module fileurl="file://$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" filepath="$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" group="Game" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" filepath="$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" filepath="$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" group="Bungee" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" group="Game" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" group="Game" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" filepath="$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" />

View File

@ -2,8 +2,6 @@ package mineplex.core.bonuses;
import java.util.List;
import org.bukkit.ChatColor;
import mineplex.core.common.util.C;
public class BonusAmount
@ -140,7 +138,6 @@ public class BonusAmount
public void addLore(List<String> lore)
{
lore.add(C.cYellow + "Rewards");
addLore(lore, getTickets(), 0, "Carl Spin Ticket" + (getTickets() > 1 ? "s" : ""));
addLore(lore, getCoins(), getBonusCoins(), "Coins");
addLore(lore, getGems(), getBonusGems(), "Gems");
@ -151,7 +148,7 @@ public class BonusAmount
private void addLore(List<String> lore, int amount, int bonus, String suffix)
{
if (amount > 0)
lore.add(" " + C.cWhite + amount + " " + suffix);
lore.add(C.cYellow + "Reward: " + C.cWhite + amount + " " + suffix);
// if (bonus > 0)
// lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + bonus + " " + suffix);

View File

@ -4,6 +4,7 @@ import java.sql.Date;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.TimeZone;
import mineplex.core.MiniClientPlugin;
@ -24,10 +25,9 @@ import mineplex.core.database.DBPool;
import mineplex.core.donation.DonationManager;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.npc.Npc;
import mineplex.core.npc.NpcManager;
import mineplex.core.pet.PetManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.reward.RewardManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.updater.UpdateType;
@ -45,7 +45,6 @@ import mineplex.core.bonuses.gui.SpinGui;
import mineplex.core.poll.PollManager;
import mineplex.serverdata.commands.ServerCommandManager;
import org.jooq.DSLContext;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
import org.bukkit.Bukkit;
@ -73,6 +72,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
private ArrayList<Object> _pendingExplosions = new ArrayList<>();
private ArrayList<Player> _pendingExplosionsPlayers = new ArrayList<>();
private HashMap<String, Boolean> _showCarl = new HashMap<>();
private long _explode;
private boolean _canVote;
@ -996,4 +996,36 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
entity.remove();
}
}
@EventHandler
public void Join(final PlayerJoinEvent event)
{
runSyncLater(new Runnable()
{
@Override
public void run()
{
_showCarl.put(event.getPlayer().getName(), true);
}
}, 200);
}
@EventHandler
public void carlUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Player player : UtilServer.getPlayers())
{
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
{
if(_pollManager.Get(player).shouldPoll() || canVote(player) || canRank(player) || canDaily(player))
{
if(_showCarl.containsKey(player.getName()))
UtilPlayer.message(player, C.cDGreen + C.Bold + "Carl the Creeper)" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!");
}
}
}
}
}

View File

@ -7,11 +7,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import com.sun.org.apache.xpath.internal.operations.Bool;
import mineplex.core.bonuses.gui.SpinGui;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable;
@ -21,9 +17,7 @@ import mineplex.database.Tables;
import mineplex.database.tables.records.BonusRecord;
import org.jooq.DSLContext;
import org.jooq.Record2;
import org.jooq.SQLDialect;
import org.jooq.TableField;
import org.jooq.impl.DSL;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -101,42 +95,6 @@ public class BonusRepository extends RepositoryBase
});
}
public void attemptAddTickets(final int accountId, final BonusClientData client, final int tickets, final Callback<Boolean> callback)
{
if (client.getTickets() + tickets < 0)
callback.run(false);
Bukkit.getScheduler().runTaskAsynchronously(_manager.getPlugin(), new Runnable()
{
@Override
public void run()
{
try
{
DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL);
create.update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(tickets)).
where(Tables.bonus.accountId.eq(accountId)).execute();
final int newTickets = create.select(Tables.bonus.tickets).from(Tables.bonus).where(Tables.bonus.accountId.eq(accountId)).fetchOne().value1();
Bukkit.getScheduler().runTask(_manager.getPlugin(), new Runnable()
{
@Override
public void run()
{
client.setTickets(newTickets);
callback.run(true);
}
});
}
catch (Exception e)
{
e.printStackTrace();
callback.run(false);
}
}
});
}
public void attemptDailyBonus(final Player player, final Callback<Boolean> result)
{
final int accountId = _manager.getClientManager().Get(player).getAccountId();

View File

@ -2,7 +2,6 @@ package mineplex.core.bonuses.commands;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.bonuses.BonusManager;
@ -37,28 +36,15 @@ public class TicketCommand extends CommandBase<BonusManager>
{
try
{
final int tickets = Integer.parseInt(ticketString);
int accountId = Plugin.getClientManager().getAccountId(target);
Plugin.getRepository().attemptAddTickets(accountId, Plugin.Get(target), tickets, new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
if (data)
{
UtilPlayer.message(caller, F.main("Carl", "You gave " + F.elem(tickets + " Carl Tickets") + " to " + F.name(targetName) + "."));
int tickets = Integer.parseInt(ticketString);
Plugin.Get(target).setTickets(Plugin.Get(targetName).getTickets() + tickets);
if (target != null && !target.equals(caller))
{
UtilPlayer.message(target, F.main("Carl", F.name(caller.getName()) + " gave you " + F.elem(tickets + " Carl Tickets") + "."));
}
}
else
{
UtilPlayer.message(caller, F.main("Carl", "Failed to give tickets. Try again later!"));
}
}
});
UtilPlayer.message(caller, F.main("Carl", "You gave " + F.elem(tickets + " Carl Tickets") + " to " + F.name(targetName) + "."));
if (target != null)
{
UtilPlayer.message(target, F.main("Carl", F.name(caller.getName()) + " gave you " + F.elem(tickets + " Carl Tickets") + "."));
}
}
catch (Exception e)
{

View File

@ -144,7 +144,9 @@ public class DailyBonusButton implements GuiItem, Listener
lore.add(" ");
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getDailyStreak());
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getDailyMultiplier(_player) + "%");
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + _bonusManager.getDailyMultiplier(_player) + "%");
lore.add(" ");
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxDailyStreak());
if (client.getDailyTime() != null)
{
@ -157,8 +159,6 @@ public class DailyBonusButton implements GuiItem, Listener
}
}
lore.add(" ");
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxDailyStreak());
StreakRecord streakRecord = _bonusManager.getDailyStreak();
if (streakRecord != null)
{

View File

@ -32,7 +32,6 @@ public class RewardManager
private JavaPlugin _plugin;
private HashMap<RewardRarity, List<Reward>> _treasureMap;
private Random _random;
private boolean _carlSpinner;
private CoreClientManager _clientManager;
@ -43,7 +42,7 @@ public class RewardManager
int uncommonValueMin, int uncommonValueMax,
int rareValueMin, int rareValueMax,
int legendValueMin, int legendValueMax,
boolean doubleGadgetValue, boolean carlSpinner)
boolean doubleGadgetValue)
{
_plugin = donationManager.getPlugin();
_treasureMap = new HashMap<RewardRarity, List<Reward>>();
@ -57,15 +56,21 @@ public class RewardManager
_clientManager = clientManager;
_doubleGadgetValue = doubleGadgetValue;
_carlSpinner = carlSpinner;
addCommon(donationManager, inventoryManager, petManager, statsManager, commonValueMin, commonValueMax);
addUncommon(donationManager, inventoryManager, petManager, statsManager, uncommonValueMin, uncommonValueMax);
addRare(donationManager, inventoryManager, petManager, statsManager, rareValueMin, rareValueMax);
addLegendary(donationManager, inventoryManager, petManager, statsManager, legendValueMin, legendValueMax);
addGame(donationManager, inventoryManager, petManager, statsManager);
addCommon(donationManager, inventoryManager, petManager, commonValueMin, commonValueMax);
addUncommon(donationManager, inventoryManager, petManager, uncommonValueMin, uncommonValueMax);
addRare(donationManager, inventoryManager, petManager, rareValueMin, rareValueMax);
addLegendary(donationManager, inventoryManager, petManager, legendValueMin, legendValueMax);
}
public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
public void addGame(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager)
{
addReward(new GemReward(donationManager, 100, 500, 100, RewardRarity.GAME));
addReward(new ExperienceReward(statsManager, 100, 5000, 100, RewardRarity.GAME));
}
public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
{
RewardRarity rarity = RewardRarity.COMMON;
@ -107,16 +112,9 @@ public class RewardManager
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
new ItemStack(Material.TNT), rarity, 10));
if (_carlSpinner)
{
addReward(new GemReward(donationManager, 0, 0, 25, rarity));
addReward(new CoinReward(donationManager, 0, 0, 25, rarity));
addReward(new ExperienceReward(statsManager, 0, 0, 25, rarity));
}
}
public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
{
RewardRarity rarity = RewardRarity.UNCOMMON;
@ -200,16 +198,9 @@ public class RewardManager
// new ItemStack(2266), rarity, 25));
addReward(new UnknownPackageReward(donationManager, "Wait Disc", "Wait Disc",
new ItemStack(2267), rarity, 25));
if (_carlSpinner)
{
addReward(new GemReward(donationManager, 0, 0, 1300, rarity));
addReward(new CoinReward(donationManager, 0, 0, 1300, rarity));
addReward(new ExperienceReward(statsManager, 0, 0, 1300, rarity));
}
}
public void addRare(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
public void addRare(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
{
RewardRarity rarity = RewardRarity.RARE;
@ -259,20 +250,14 @@ public class RewardManager
addReward(new UnknownPackageReward(donationManager, "Space Boots", "Space Boots",
new ItemStack(Material.GOLD_BOOTS), rarity, 50));
if (_carlSpinner)
{
addReward(new GemReward(donationManager, 0, 0, 390, rarity));
addReward(new CoinReward(donationManager, 0, 0, 390, rarity));
addReward(new ExperienceReward(statsManager, 0, 0, 390, rarity));
}
}
public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, double minValue, double maxValue)
public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
{
RewardRarity rarity = RewardRarity.LEGENDARY;
// Coins
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity));
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, RewardRarity.LEGENDARY));
// Mounts
addReward(new UnknownPackageReward(donationManager, "Infernal Horror", "Infernal Horror",
@ -301,13 +286,6 @@ public class RewardManager
new ItemStack(Material.APPLE), rarity, 4));
addReward(new UnknownPackageReward(donationManager, "Heart Particles", "I Heart You",
new ItemStack(Material.BLAZE_POWDER), rarity, 2));
if (_carlSpinner)
{
addReward(new GemReward(donationManager, 0, 0, 70, rarity));
addReward(new CoinReward(donationManager, 0, 0, 70, rarity));
addReward(new ExperienceReward(statsManager, 0, 0, 70, rarity));
}
}
public void addReward(Reward reward)

View File

@ -20,7 +20,7 @@ public enum RewardRarity
OTHER("Other", cWhite, Material.STAINED_GLASS_PANE, (byte) 0),
COMMON("Common", cWhite, Material.STAINED_GLASS_PANE, (byte) 0),
// CARL_EXTRA("Game", cYellow, Material.STAINED_GLASS_PANE, (byte) 4),
GAME("Game", cYellow, Material.STAINED_GLASS_PANE, (byte) 4),
UNCOMMON("Uncommon", cAqua, Material.STAINED_GLASS_PANE, (byte) 3),
RARE("Rare", cPurple, Material.STAINED_GLASS_PANE, (byte) 10),
LEGENDARY("Legendary", cGreen, Material.STAINED_GLASS_PANE, (byte) 5),

View File

@ -3,7 +3,7 @@ package mineplex.core.reward;
public enum RewardType
{
//% Chances Mythic Legend Rare Uncommon
GameLoot( 0.000001, 0.00001, 0.0001, 3, 0),
GameLoot( 0.000001, 0.00001, 0.0001, 3, 10),
OldChest( 0, 0.05, 0.4, 5, 0),
AncientChest( 0, 1, 4, 25, 0),
@ -37,7 +37,7 @@ public enum RewardType
else if (rand <= _legendaryChance) rarity = RewardRarity.LEGENDARY;
else if (rand <= _rareChance) rarity = RewardRarity.RARE;
else if (rand <= _uncommonChance || requiresUncommon) rarity = RewardRarity.UNCOMMON;
// else if (rand <= _gameChance) rarity = RewardRarity.CARL_EXTRA;
else if (rand <= _gameChance) rarity = RewardRarity.GAME;
return rarity;
}

View File

@ -35,13 +35,13 @@ public class ExperienceReward extends Reward
_statsManager.incrementStat(player, "Global.ExpEarned", experience);
return new RewardData(getRarity().getColor() + experience + " Experience", new ItemStack(Material.EXP_BOTTLE), getRarity());
return new RewardData(getRarity().getColor() + experience + " Experience", new ItemStack(Material.EXP_BOTTLE), RewardRarity.GAME);
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getColor() + "Experience", new ItemStack(Material.EXP_BOTTLE), getRarity());
return new RewardData(getRarity().getColor() + "Experience", new ItemStack(Material.EXP_BOTTLE), RewardRarity.GAME);
}
@Override

View File

@ -20,7 +20,6 @@ import mineplex.core.pet.PetManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardType;
import mineplex.core.stats.StatsManager;
/**
* Created by Shaun on 8/27/2014.
@ -33,19 +32,14 @@ public class TreasureManager extends MiniPlugin
private HologramManager _hologramManager;
private List<TreasureLocation> _treasureLocations;
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager)
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, BlockRestore blockRestore, HologramManager hologramManager, RewardManager rewardManager)
{
super("Treasure", plugin);
_inventoryManager = inventoryManager;
_blockRestore = blockRestore;
_hologramManager = hologramManager;
_rewardManager = new RewardManager(clientManager, donationManager, _inventoryManager, petManager, statsManager,
100, 250,
500, 1000,
4000, 6000,
12000, 32000,
true, false);;
_rewardManager = rewardManager;
World world = Bukkit.getWorlds().get(0);

View File

@ -190,7 +190,14 @@ 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, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, statsManager);
RewardManager rewardManager = new RewardManager(clientManager, donationManager, _inventoryManager, petManager, statsManager,
100, 250,
500, 1000,
4000, 6000,
12000, 32000,
true);
_treasureManager = new TreasureManager(_plugin, clientManager, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager, rewardManager);
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager);
new SoccerManager(this, _gadgetManager);
@ -215,7 +222,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
((CraftWorld)Bukkit.getWorlds().get(0)).getHandle().pvpMode = true;
new BonusManager(plugin, clientManager, donationManager, pollManager , npcManager, hologramManager, statsManager, _inventoryManager, petManager);
new BonusManager(plugin, clientManager, donationManager, pollManager , npcManager, hologramManager, rewardManager, statsManager);
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);

View File

@ -55,7 +55,7 @@ public class GameLootManager implements Listener
500, 1000,
1500, 2500,
6000, 12000,
false, false);
false);
//Chest
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Old Chest", "Old Chest", 1, 1,

View File

@ -3,7 +3,6 @@ package nautilus.game.arcade.managers;
import java.util.ArrayList;
import java.util.Iterator;
import mineplex.core.bonuses.event.CarlSpinnerEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilFirework;
@ -132,16 +131,6 @@ public class GameManager implements Listener
UtilTime.MakeStr(Math.max(0, game.PrepareTime - (System.currentTimeMillis() - game.GetStateTime()))), player);
}
@EventHandler
public void cancelCarlSpinner(CarlSpinnerEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game.GetCountdown() <= 0)
event.setCancelled(true);
}
@EventHandler
public void StateUpdate(UpdateEvent event)
{