Hackyish way to log rewards given out in a database
This commit is contained in:
parent
ed59e03795
commit
88a8e3a896
@ -17,6 +17,8 @@
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-pool2-2.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jedis-2.4.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.4.2.jar" path-in-jar="/" />
|
||||
<element id="module-output" name="Mineplex.Database" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
@ -17,6 +17,8 @@
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-pool2-2.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jedis-2.4.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.4.2.jar" path-in-jar="/" />
|
||||
<element id="module-output" name="Mineplex.Database" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
@ -1,29 +0,0 @@
|
||||
package mineplex.core.reward;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 9/2/2014.
|
||||
*/
|
||||
public interface IReward
|
||||
{
|
||||
public ItemStack getItem();
|
||||
|
||||
public RewardRarity getRarity();
|
||||
|
||||
/**
|
||||
* Give the reward to the player.
|
||||
*
|
||||
* @return String detailing the reward. This will be shown to the player
|
||||
*/
|
||||
public String giveReward(Player player);
|
||||
|
||||
public boolean canGiveReward(Player player);
|
||||
|
||||
/**
|
||||
* This is used to weight rewards across different rarities. Rewards with a larger weight
|
||||
* will have a higher chance of being selected
|
||||
*/
|
||||
public int getWeight();
|
||||
}
|
47
Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java
Normal file
47
Plugins/Mineplex.Core/src/mineplex/core/reward/Reward.java
Normal file
@ -0,0 +1,47 @@
|
||||
package mineplex.core.reward;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 9/2/2014.
|
||||
*/
|
||||
public abstract class Reward
|
||||
{
|
||||
protected static final Random RANDOM = new Random();
|
||||
|
||||
// Reward Manager used to log rewards given to players. Shitty way to do this, but it works for now
|
||||
private RewardManager _rewardManager;
|
||||
|
||||
private RewardRarity _rarity;
|
||||
private int _weight;
|
||||
|
||||
public Reward(RewardManager rewardManager, RewardRarity rarity, int weight)
|
||||
{
|
||||
_rewardManager = rewardManager;
|
||||
_rarity = rarity;
|
||||
_weight = weight;
|
||||
}
|
||||
|
||||
public final RewardData giveReward(String type, Player player)
|
||||
{
|
||||
RewardData rewardData = giveRewardCustom(player);
|
||||
_rewardManager.logReward(player, type, getRarity().name(), rewardData.getFriendlyName());
|
||||
return rewardData;
|
||||
}
|
||||
|
||||
protected abstract RewardData giveRewardCustom(Player player);
|
||||
|
||||
public abstract boolean canGiveReward(Player player);
|
||||
|
||||
public RewardRarity getRarity()
|
||||
{
|
||||
return _rarity;
|
||||
}
|
||||
|
||||
public int getWeight()
|
||||
{
|
||||
return _weight;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package mineplex.core.reward;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-18.
|
||||
*/
|
||||
public class RewardData
|
||||
{
|
||||
private final String _friendlyName;
|
||||
private final ItemStack _displayItem;
|
||||
|
||||
public RewardData(String friendlyName, ItemStack displayItem)
|
||||
{
|
||||
_friendlyName = friendlyName;
|
||||
_displayItem = displayItem;
|
||||
}
|
||||
|
||||
public String getFriendlyName()
|
||||
{
|
||||
return _friendlyName;
|
||||
}
|
||||
|
||||
public ItemStack getDisplayItem()
|
||||
{
|
||||
return _displayItem;
|
||||
}
|
||||
|
||||
}
|
@ -5,10 +5,12 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
@ -21,7 +23,9 @@ import mineplex.core.reward.rewards.UnknownPackageReward;
|
||||
*/
|
||||
public class RewardManager
|
||||
{
|
||||
private HashMap<RewardRarity, List<IReward>> _treasureMap;
|
||||
private JavaPlugin _plugin;
|
||||
private RewardRepository _repository;
|
||||
private HashMap<RewardRarity, List<Reward>> _treasureMap;
|
||||
private Random _random;
|
||||
|
||||
private boolean _doubleGadgetValue;
|
||||
@ -33,12 +37,14 @@ public class RewardManager
|
||||
int legendValueMin, int legendValueMax,
|
||||
boolean doubleGadgetValue)
|
||||
{
|
||||
_treasureMap = new HashMap<RewardRarity, List<IReward>>();
|
||||
_plugin = donationManager.GetPlugin();
|
||||
_repository = new RewardRepository(_plugin);
|
||||
_treasureMap = new HashMap<RewardRarity, List<Reward>>();
|
||||
_random = new Random();
|
||||
|
||||
for (RewardRarity rarity : RewardRarity.values())
|
||||
{
|
||||
_treasureMap.put(rarity, new ArrayList<IReward>());
|
||||
_treasureMap.put(rarity, new ArrayList<Reward>());
|
||||
}
|
||||
|
||||
_doubleGadgetValue = doubleGadgetValue;
|
||||
@ -52,7 +58,7 @@ public class RewardManager
|
||||
public void addCommon(DonationManager donationManager, InventoryManager inventoryManager, double minValue, double maxValue)
|
||||
{
|
||||
// Coins
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 1, RewardRarity.COMMON));
|
||||
addReward(new CoinReward(this, donationManager, (int)minValue, (int)maxValue, 1, RewardRarity.COMMON));
|
||||
|
||||
//Increase Value
|
||||
if (_doubleGadgetValue)
|
||||
@ -62,31 +68,31 @@ public class RewardManager
|
||||
}
|
||||
|
||||
// Gadgets
|
||||
addReward(new InventoryReward(inventoryManager, "Paintball Gun Ammo", "Paintball Gun",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Paintball Gun Ammo", "Paintball Gun",
|
||||
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
|
||||
new ItemStack(Material.GOLD_BARDING), RewardRarity.COMMON, 1));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Fireworks", "Fireworks",
|
||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||
new ItemStack(Material.FIREWORK), RewardRarity.COMMON, 1));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Melon Launcher Ammo", "Melon Launcher",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Melon Launcher Ammo", "Melon Launcher",
|
||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||
new ItemStack(Material.MELON_BLOCK), RewardRarity.COMMON, 1));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Flesh Hooks", "Flesh Hook",
|
||||
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
|
||||
new ItemStack(Material.getMaterial(131)), RewardRarity.COMMON, 1));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Ethereal Pearls", "Ethereal Pearl",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Ethereal Pearls", "Ethereal Pearl",
|
||||
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
|
||||
new ItemStack(Material.ENDER_PEARL), RewardRarity.COMMON, 1));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Bat Blaster Ammo", "Bat Blaster",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Bat Blaster Ammo", "Bat Blaster",
|
||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||
new ItemStack(Material.IRON_BARDING), RewardRarity.COMMON, 1));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
|
||||
addReward(new InventoryReward(this, inventoryManager, "TNT", "TNT",
|
||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||
new ItemStack(Material.TNT), RewardRarity.COMMON, 1));
|
||||
}
|
||||
@ -94,7 +100,7 @@ public class RewardManager
|
||||
public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, double minValue, double maxValue)
|
||||
{
|
||||
// Coins
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON));
|
||||
addReward(new CoinReward(this, donationManager, (int)minValue, (int)maxValue, 250, RewardRarity.UNCOMMON));
|
||||
|
||||
//Increase Value
|
||||
if (_doubleGadgetValue)
|
||||
@ -104,130 +110,130 @@ public class RewardManager
|
||||
}
|
||||
|
||||
// Gadgets
|
||||
addReward(new InventoryReward(inventoryManager, "Paintball Gun Ammo", "Paintball Gun",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Paintball Gun Ammo", "Paintball Gun",
|
||||
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
|
||||
new ItemStack(Material.GOLD_BARDING), RewardRarity.UNCOMMON, 250));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Fireworks", "Fireworks",
|
||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||
new ItemStack(Material.FIREWORK), RewardRarity.UNCOMMON, 250));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Melon Launcher Ammo", "Melon Launcher",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Melon Launcher Ammo", "Melon Launcher",
|
||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||
new ItemStack(Material.MELON_BLOCK), RewardRarity.UNCOMMON, 250));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Flesh Hook Ammo", "Flesh Hook",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Flesh Hook Ammo", "Flesh Hook",
|
||||
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
|
||||
new ItemStack(Material.getMaterial(131)), RewardRarity.UNCOMMON, 250));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Ethereal Pearls", "Ethereal Pearl",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Ethereal Pearls", "Ethereal Pearl",
|
||||
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
|
||||
new ItemStack(Material.ENDER_PEARL), RewardRarity.UNCOMMON, 250));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Bat Blaster Ammo", "Bat Blaster",
|
||||
addReward(new InventoryReward(this, inventoryManager, "Bat Blaster Ammo", "Bat Blaster",
|
||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||
new ItemStack(Material.IRON_BARDING), RewardRarity.UNCOMMON, 250));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
|
||||
addReward(new InventoryReward(this, inventoryManager, "TNT", "TNT",
|
||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||
new ItemStack(Material.TNT), RewardRarity.UNCOMMON, 250));
|
||||
|
||||
// Pets
|
||||
addReward(new UnknownPackageReward(donationManager, "Cow Pet", "Cow",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Cow Pet", "Cow",
|
||||
new ItemStack(Material.MONSTER_EGG, 1, EntityType.COW.getTypeId()), RewardRarity.UNCOMMON, 500));
|
||||
addReward(new UnknownPackageReward(donationManager, "Sheep Pet", "Sheep",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Sheep Pet", "Sheep",
|
||||
new ItemStack(Material.MONSTER_EGG, 1, EntityType.SHEEP.getTypeId()), RewardRarity.UNCOMMON, 333));
|
||||
addReward(new UnknownPackageReward(donationManager, "Mooshroom Pet", "Mooshroom",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Mooshroom Pet", "Mooshroom",
|
||||
new ItemStack(Material.MONSTER_EGG, 1, EntityType.MUSHROOM_COW.getTypeId()), RewardRarity.UNCOMMON, 200));
|
||||
addReward(new UnknownPackageReward(donationManager, "Pig Pet", "Pig",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Pig Pet", "Pig",
|
||||
new ItemStack(Material.MONSTER_EGG, 1, EntityType.PIG.getTypeId()), RewardRarity.UNCOMMON, 200));
|
||||
addReward(new UnknownPackageReward(donationManager, "Ocelot Pet", "Ocelot",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Ocelot Pet", "Ocelot",
|
||||
new ItemStack(Material.MONSTER_EGG, 1, EntityType.OCELOT.getTypeId()), RewardRarity.UNCOMMON, 167));
|
||||
addReward(new UnknownPackageReward(donationManager, "Chicken Pet", "Chicken",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Chicken Pet", "Chicken",
|
||||
new ItemStack(Material.MONSTER_EGG, 1, EntityType.CHICKEN.getTypeId()), RewardRarity.RARE, 143));
|
||||
addReward(new UnknownPackageReward(donationManager, "Wolf Pet", "Wolf",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Wolf Pet", "Wolf",
|
||||
new ItemStack(Material.MONSTER_EGG, 1, EntityType.WOLF.getTypeId()), RewardRarity.RARE, 125));
|
||||
}
|
||||
|
||||
public void addRare(DonationManager donationManager, InventoryManager inventoryManager, double minValue, double maxValue)
|
||||
{
|
||||
// Coins
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE));
|
||||
addReward(new CoinReward(this, donationManager, (int)minValue, (int)maxValue, 100, RewardRarity.RARE));
|
||||
|
||||
// Mounts
|
||||
addReward(new UnknownPackageReward(donationManager, "Mount Mule", "Mount Mule",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Mount Mule", "Mount Mule",
|
||||
new ItemStack(Material.HAY_BLOCK), RewardRarity.RARE, 200));
|
||||
addReward(new UnknownPackageReward(donationManager, "Minecart Mount", "Minecart",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Minecart Mount", "Minecart",
|
||||
new ItemStack(Material.MINECART), RewardRarity.RARE, 100));
|
||||
addReward(new UnknownPackageReward(donationManager, "Slime Mount", "Slime Mount",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Slime Mount", "Slime Mount",
|
||||
new ItemStack(Material.SLIME_BALL), RewardRarity.RARE, 67));
|
||||
addReward(new UnknownPackageReward(donationManager, "Glacial Steed", "Glacial Steed",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Glacial Steed", "Glacial Steed",
|
||||
new ItemStack(Material.SNOW_BALL), RewardRarity.RARE, 50));
|
||||
|
||||
// Morphs
|
||||
addReward(new UnknownPackageReward(donationManager, "Cow Morph", "Cow Morph",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Cow Morph", "Cow Morph",
|
||||
new ItemStack(Material.LEATHER), RewardRarity.RARE, 167));
|
||||
addReward(new UnknownPackageReward(donationManager, "Villager Morph", "Villager Morph",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Villager Morph", "Villager Morph",
|
||||
new ItemStack(Material.EMERALD), RewardRarity.RARE, 83));
|
||||
addReward(new UnknownPackageReward(donationManager, "Chicken Morph", "Chicken Morph",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Chicken Morph", "Chicken Morph",
|
||||
new ItemStack(Material.FEATHER), RewardRarity.RARE, 50));
|
||||
addReward(new UnknownPackageReward(donationManager, "Enderman Morph", "Enderman Morph",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Enderman Morph", "Enderman Morph",
|
||||
new ItemStack(Material.ENDER_PEARL), RewardRarity.RARE, 33));
|
||||
|
||||
|
||||
// Gadgets
|
||||
addReward(new InventoryReward(inventoryManager, "Coin Party Bomb", "Coin Party Bomb", 1, 1,
|
||||
addReward(new InventoryReward(this, inventoryManager, "Coin Party Bomb", "Coin Party Bomb", 1, 1,
|
||||
new ItemStack(Material.getMaterial(175)), RewardRarity.RARE, 100));
|
||||
}
|
||||
|
||||
public void addLegendary(DonationManager donationManager, InventoryManager inventoryManager, double minValue, double maxValue)
|
||||
{
|
||||
// Coins
|
||||
addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, RewardRarity.LEGENDARY));
|
||||
addReward(new CoinReward(this, donationManager, (int)minValue, (int)maxValue, 25, RewardRarity.LEGENDARY));
|
||||
|
||||
// Mounts
|
||||
addReward(new UnknownPackageReward(donationManager, "Infernal Horror", "Infernal Horror",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Infernal Horror", "Infernal Horror",
|
||||
new ItemStack(Material.BONE), RewardRarity.LEGENDARY, 33));
|
||||
|
||||
// Morphs
|
||||
addReward(new UnknownPackageReward(donationManager, "Bat Morph", "Bat Morph",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Bat Morph", "Bat Morph",
|
||||
new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 1), RewardRarity.LEGENDARY, 25));
|
||||
addReward(new UnknownPackageReward(donationManager, "Block Morph", "Block Morph",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Block Morph", "Block Morph",
|
||||
new ItemStack(Material.EMERALD_BLOCK), RewardRarity.LEGENDARY, 20));
|
||||
|
||||
// Particles
|
||||
addReward(new UnknownPackageReward(donationManager, "Shadow Walk Particles", "Shadow Walk",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Shadow Walk Particles", "Shadow Walk",
|
||||
new ItemStack(Material.LEATHER_BOOTS), RewardRarity.LEGENDARY, 33));
|
||||
addReward(new UnknownPackageReward(donationManager, "Enchanted Particles", "Enchanted",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Enchanted Particles", "Enchanted",
|
||||
new ItemStack(Material.BOOK), RewardRarity.LEGENDARY, 25));
|
||||
addReward(new UnknownPackageReward(donationManager, "Flame Rings Particles", "Flame Rings",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Flame Rings Particles", "Flame Rings",
|
||||
new ItemStack(Material.BLAZE_POWDER), RewardRarity.LEGENDARY, 17));
|
||||
addReward(new UnknownPackageReward(donationManager, "Rain Cloud Particles", "Rain Cloud",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Rain Cloud Particles", "Rain Cloud",
|
||||
new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 4), RewardRarity.LEGENDARY, 13));
|
||||
addReward(new UnknownPackageReward(donationManager, "Blood Helix Particles", "Blood Helix",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Blood Helix Particles", "Blood Helix",
|
||||
new ItemStack(Material.REDSTONE), RewardRarity.LEGENDARY, 10));
|
||||
addReward(new UnknownPackageReward(donationManager, "Emerald Twirl Particles", "Green Ring",
|
||||
addReward(new UnknownPackageReward(this, donationManager, "Emerald Twirl Particles", "Green Ring",
|
||||
new ItemStack(Material.EMERALD), RewardRarity.LEGENDARY, 8));
|
||||
}
|
||||
|
||||
public void addReward(IReward reward)
|
||||
public void addReward(Reward reward)
|
||||
{
|
||||
RewardRarity rarity = reward.getRarity();
|
||||
|
||||
List<IReward> treasureList = _treasureMap.get(rarity);
|
||||
List<Reward> treasureList = _treasureMap.get(rarity);
|
||||
|
||||
treasureList.add(reward);
|
||||
}
|
||||
|
||||
public IReward[] getRewards(Player player, boolean isChestOpening)
|
||||
public Reward[] getRewards(Player player, boolean isChestOpening)
|
||||
{
|
||||
int currentReward = 0;
|
||||
IReward[] rewards = new IReward[4];
|
||||
Reward[] rewards = new Reward[4];
|
||||
boolean hasUncommon = false;
|
||||
|
||||
while (currentReward < 4)
|
||||
{
|
||||
IReward reward = nextReward(player, rewards, currentReward == 3 && !hasUncommon, isChestOpening);
|
||||
Reward reward = nextReward(player, rewards, currentReward == 3 && !hasUncommon, isChestOpening);
|
||||
|
||||
if (reward == null)
|
||||
{
|
||||
@ -246,8 +252,8 @@ public class RewardManager
|
||||
int slotToSwitch = _random.nextInt(4);
|
||||
if (slotToSwitch != 3)
|
||||
{
|
||||
IReward thirdReward = rewards[3];
|
||||
IReward otherReward = rewards[slotToSwitch];
|
||||
Reward thirdReward = rewards[3];
|
||||
Reward otherReward = rewards[slotToSwitch];
|
||||
|
||||
rewards[3] = otherReward;
|
||||
rewards[slotToSwitch] = thirdReward;
|
||||
@ -256,12 +262,12 @@ public class RewardManager
|
||||
return rewards;
|
||||
}
|
||||
|
||||
// private IReward nextReward(Player player, IReward[] excludedRewards)
|
||||
// private Reward nextReward(Player player, Reward[] excludedRewards)
|
||||
// {
|
||||
// return nextReward(player, excludedRewards, false, isChestOpening);
|
||||
// }
|
||||
|
||||
public IReward nextReward(Player player, IReward[] excludedRewards, boolean requiresUncommon, boolean isChestOpening)
|
||||
public Reward nextReward(Player player, Reward[] excludedRewards, boolean requiresUncommon, boolean isChestOpening)
|
||||
{
|
||||
double rand = _random.nextDouble();
|
||||
RewardRarity rarity;
|
||||
@ -287,11 +293,11 @@ public class RewardManager
|
||||
rarity = RewardRarity.COMMON;
|
||||
}
|
||||
|
||||
List<IReward> treasureList = _treasureMap.get(rarity);
|
||||
List<Reward> treasureList = _treasureMap.get(rarity);
|
||||
|
||||
int totalWeight = 0;
|
||||
ArrayList<IReward> possibleRewards = new ArrayList<IReward>();
|
||||
for (IReward treasure : treasureList)
|
||||
ArrayList<Reward> possibleRewards = new ArrayList<Reward>();
|
||||
for (Reward treasure : treasureList)
|
||||
{
|
||||
boolean isExcluded = false;
|
||||
|
||||
@ -318,7 +324,7 @@ public class RewardManager
|
||||
int weight = _random.nextInt(totalWeight);
|
||||
int currentWeight = 0;
|
||||
|
||||
for (IReward reward : possibleRewards)
|
||||
for (Reward reward : possibleRewards)
|
||||
{
|
||||
currentWeight += reward.getWeight();
|
||||
|
||||
@ -329,4 +335,19 @@ public class RewardManager
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void logReward(final Player player, final String type, final String rarity, final String reward)
|
||||
{
|
||||
final String parsedReward = ChatColor.stripColor(reward);
|
||||
|
||||
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_repository.logReward(player, type, rarity, parsedReward);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
package mineplex.core.reward;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.database.Tables;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-18.
|
||||
*/
|
||||
public class RewardRepository extends RepositoryBase
|
||||
{
|
||||
public RewardRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void logReward(Player player, String type, String rarity, String reward)
|
||||
{
|
||||
DSLContext context;
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
context = DSL.using(getConnection());
|
||||
}
|
||||
|
||||
context.insertInto(Tables.rewardLog)
|
||||
.set(Tables.rewardLog.accountId, DSL.select(Tables.accounts.id)
|
||||
.from(Tables.accounts)
|
||||
.where(Tables.accounts.uuid.eq(player.getUniqueId().toString())))
|
||||
.set(Tables.rewardLog.date, DSL.currentTimestamp())
|
||||
.set(Tables.rewardLog.type, type)
|
||||
.set(Tables.rewardLog.rarity, rarity)
|
||||
.set(Tables.rewardLog.reward, reward)
|
||||
.execute();
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package mineplex.core.reward.rewards;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.reward.IReward;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
|
||||
/**
|
||||
* Created by shaun on 2014-09-08.
|
||||
*/
|
||||
public abstract class AbstractReward implements IReward
|
||||
{
|
||||
protected static final Random RANDOM = new Random();
|
||||
|
||||
private ItemStack _itemStack;
|
||||
private RewardRarity _rarity;
|
||||
private int _weight;
|
||||
|
||||
public AbstractReward(ItemStack itemStack, RewardRarity rarity, int weight)
|
||||
{
|
||||
_itemStack = itemStack;
|
||||
_rarity = rarity;
|
||||
_weight = weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem()
|
||||
{
|
||||
return _itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWeight()
|
||||
{
|
||||
return _weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardRarity getRarity()
|
||||
{
|
||||
return _rarity;
|
||||
}
|
||||
}
|
@ -11,26 +11,29 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
|
||||
/**
|
||||
* Created by shaun on 2014-09-08.
|
||||
*/
|
||||
public class CoinReward extends AbstractReward
|
||||
public class CoinReward extends Reward
|
||||
{
|
||||
private DonationManager _donationManager;
|
||||
private Random _random;
|
||||
private int _minCoinCount;
|
||||
private int _maxCoinCount;
|
||||
|
||||
public CoinReward(DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity)
|
||||
public CoinReward(RewardManager rewardManager, DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity)
|
||||
{
|
||||
this(donationManager, minCoinCount, maxCoinCount, weight, rarity, RANDOM);
|
||||
this(rewardManager, donationManager, minCoinCount, maxCoinCount, weight, rarity, RANDOM);
|
||||
}
|
||||
|
||||
public CoinReward(DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity, Random random)
|
||||
public CoinReward(RewardManager rewardManager, DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity, Random random)
|
||||
{
|
||||
super(new ItemStack(175), rarity, weight);
|
||||
super(rewardManager, rarity, weight);
|
||||
_donationManager = donationManager;
|
||||
_minCoinCount = minCoinCount;
|
||||
_maxCoinCount = maxCoinCount;
|
||||
@ -39,7 +42,7 @@ public class CoinReward extends AbstractReward
|
||||
}
|
||||
|
||||
@Override
|
||||
public String giveReward(Player player)
|
||||
public RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
int gemsToReward = _random.nextInt(_maxCoinCount - _minCoinCount) + _minCoinCount;
|
||||
|
||||
@ -52,7 +55,7 @@ public class CoinReward extends AbstractReward
|
||||
}
|
||||
}, "Treasure Chest", player.getName(), gemsToReward);
|
||||
|
||||
return getRarity().getColor() + gemsToReward + " Coins";
|
||||
return new RewardData(getRarity().getColor() + gemsToReward + " Coins", new ItemStack(175));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,54 +0,0 @@
|
||||
package mineplex.core.reward.rewards;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
|
||||
/**
|
||||
* Created by shaun on 2014-09-04.
|
||||
*/
|
||||
public class GadgetReward extends AbstractReward
|
||||
{
|
||||
private DonationManager _donationManager;
|
||||
private Gadget _gadget;
|
||||
|
||||
public GadgetReward(Gadget gadget, DonationManager donationManager, RewardRarity rarity, int weight)
|
||||
{
|
||||
super(new ItemStack(gadget.GetDisplayMaterial()), rarity, weight);
|
||||
_gadget = gadget;
|
||||
_donationManager = donationManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String giveReward(Player player)
|
||||
{
|
||||
_donationManager.Get(player.getName()).AddUnknownSalesPackagesOwned(_gadget.GetName());
|
||||
|
||||
return getRarity().getColor() + _gadget.GetDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGiveReward(Player player)
|
||||
{
|
||||
return !(_donationManager.Get(player.getName()).OwnsUnknownPackage(_gadget.GetName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj instanceof GadgetReward)
|
||||
{
|
||||
return ((GadgetReward) obj).getGadget().equals(_gadget);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Gadget getGadget()
|
||||
{
|
||||
return _gadget;
|
||||
}
|
||||
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
package mineplex.core.reward.rewards;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
|
||||
/**
|
||||
* Created by shaun on 2014-09-04.
|
||||
*/
|
||||
public class GemReward extends AbstractReward
|
||||
{
|
||||
private DonationManager _donationManager;
|
||||
private Random _random;
|
||||
private int _minGemCount;
|
||||
private int _maxGemCount;
|
||||
|
||||
public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity)
|
||||
{
|
||||
this(donationManager, minGemCount, maxGemCount, weight, rarity, RANDOM);
|
||||
}
|
||||
|
||||
public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, RewardRarity rarity, Random random)
|
||||
{
|
||||
super(new ItemStack(Material.EMERALD), rarity, weight);
|
||||
_donationManager = donationManager;
|
||||
_minGemCount = minGemCount;
|
||||
_maxGemCount = maxGemCount;
|
||||
|
||||
_random = random;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String giveReward(Player player)
|
||||
{
|
||||
int gemsToReward = _random.nextInt(_maxGemCount - _minGemCount) + _minGemCount;
|
||||
|
||||
_donationManager.RewardGems(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
|
||||
}
|
||||
}, "Treasure Chest", player.getName(), gemsToReward);
|
||||
|
||||
return C.cGreen + gemsToReward + " Gems";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGiveReward(Player player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj instanceof GemReward)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -3,45 +3,48 @@ package mineplex.core.reward.rewards;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-12.
|
||||
*/
|
||||
public class InventoryReward extends AbstractReward
|
||||
public class InventoryReward extends Reward
|
||||
{
|
||||
private Random _random;
|
||||
|
||||
private InventoryManager _inventoryManager;
|
||||
private ItemStack _itemStack;
|
||||
private String _name;
|
||||
private String _packageName;
|
||||
private int _minAmount;
|
||||
private int _maxAmount;
|
||||
|
||||
public InventoryReward(InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||
public InventoryReward(RewardManager rewardManager, InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||
{
|
||||
this(RANDOM, inventoryManager, name, packageName, minAmount, maxAmount, itemStack, rarity, weight);
|
||||
this(RANDOM, rewardManager, inventoryManager, name, packageName, minAmount, maxAmount, itemStack, rarity, weight);
|
||||
}
|
||||
|
||||
public InventoryReward(Random random, InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||
public InventoryReward(Random random, RewardManager rewardManager, InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||
{
|
||||
super(itemStack, rarity, weight);
|
||||
super(rewardManager, rarity, weight);
|
||||
|
||||
_random = random;
|
||||
_name = name;
|
||||
_packageName = packageName;
|
||||
_minAmount = minAmount;
|
||||
_maxAmount = maxAmount;
|
||||
_itemStack = itemStack;
|
||||
_inventoryManager = inventoryManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String giveReward(Player player)
|
||||
public RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
int amountToGive;
|
||||
|
||||
@ -56,7 +59,7 @@ public class InventoryReward extends AbstractReward
|
||||
|
||||
_inventoryManager.addItemToInventory(player, "Item", _packageName, amountToGive);
|
||||
|
||||
return getRarity().getColor() + amountToGive + " " + _name;
|
||||
return new RewardData(getRarity().getColor() + amountToGive + " " + _name, _itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,31 +4,36 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-12.
|
||||
*/
|
||||
public class UnknownPackageReward extends AbstractReward
|
||||
public class UnknownPackageReward extends Reward
|
||||
{
|
||||
private DonationManager _donationManager;
|
||||
private ItemStack _itemStack;
|
||||
private String _name;
|
||||
private String _packageName;
|
||||
|
||||
public UnknownPackageReward(DonationManager donationManager, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||
public UnknownPackageReward(RewardManager rewardManager, DonationManager donationManager, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||
{
|
||||
super(itemStack, rarity, weight);
|
||||
super(rewardManager, rarity, weight);
|
||||
_donationManager = donationManager;
|
||||
_name = name;
|
||||
_packageName = packageName;
|
||||
_itemStack = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String giveReward(Player player)
|
||||
protected RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
_donationManager.Get(player.getName()).AddUnknownSalesPackagesOwned(_packageName);
|
||||
|
||||
return getRarity().getColor() + _name;
|
||||
return new RewardData(getRarity().getColor() + _name, _itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,14 +1,8 @@
|
||||
package mineplex.core.treasure;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.reward.IReward;
|
||||
import mineplex.core.reward.Reward;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/29/2014.
|
||||
@ -16,10 +10,10 @@ import mineplex.core.reward.IReward;
|
||||
public class ChestData
|
||||
{
|
||||
private Block _block;
|
||||
private IReward _reward;
|
||||
private Reward _reward;
|
||||
private boolean _opened;
|
||||
|
||||
public ChestData(Block block, IReward reward)
|
||||
public ChestData(Block block, Reward reward)
|
||||
{
|
||||
_block = block;
|
||||
_opened = false;
|
||||
@ -41,7 +35,7 @@ public class ChestData
|
||||
return _block;
|
||||
}
|
||||
|
||||
public IReward getReward()
|
||||
public Reward getReward()
|
||||
{
|
||||
return _reward;
|
||||
}
|
||||
|
@ -19,7 +19,8 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.reward.IReward;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.treasure.animation.Animation;
|
||||
import mineplex.core.treasure.animation.ChestOpenAnimation;
|
||||
@ -54,12 +55,12 @@ public class Treasure
|
||||
|
||||
private TreasureStyle _style;
|
||||
|
||||
public Treasure(Player player, IReward[] rewards)
|
||||
public Treasure(Player player, Reward[] rewards)
|
||||
{
|
||||
this(player, new Random(), rewards);
|
||||
}
|
||||
|
||||
public Treasure(Player player, Random seed, IReward[] rewards)
|
||||
public Treasure(Player player, Random seed, Reward[] rewards)
|
||||
{
|
||||
_player = player;
|
||||
_random = seed;
|
||||
@ -251,10 +252,10 @@ public class Treasure
|
||||
ChestData data = getChestData(block);
|
||||
if (data != null && !data.isOpened())
|
||||
{
|
||||
String text = data.getReward().giveReward(_player);
|
||||
RewardData rewardData = data.getReward().giveReward("Treasure", _player);
|
||||
|
||||
data.setOpened(true);
|
||||
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, text);
|
||||
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data, rewardData);
|
||||
_animations.add(chestOpenTask);
|
||||
|
||||
// Extra effects based off the rarity of the treasure
|
||||
@ -265,12 +266,12 @@ public class Treasure
|
||||
else if (data.getReward().getRarity() == RewardRarity.RARE)
|
||||
{
|
||||
_animations.add(new RareAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGold + "Rare " + text));
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cGold + "Rare " + rewardData.getFriendlyName()));
|
||||
}
|
||||
else if (data.getReward().getRarity() == RewardRarity.LEGENDARY)
|
||||
{
|
||||
_animations.add(new LegendaryAnimation(this, data.getBlock()));
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Legendary " + text));
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " found " + C.cRed + "Legendary " + rewardData.getFriendlyName()));
|
||||
}
|
||||
|
||||
if (isFinished())
|
||||
@ -340,7 +341,7 @@ public class Treasure
|
||||
if (!chestData.isOpened())
|
||||
{
|
||||
chestData.setOpened(true);
|
||||
chestData.getReward().giveReward(_player);
|
||||
chestData.getReward().giveReward("Treasure", _player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -19,7 +18,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
@ -35,12 +33,9 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.event.StackerEvent;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.reward.IReward;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.reward.rewards.CoinReward;
|
||||
import mineplex.core.reward.rewards.InventoryReward;
|
||||
import mineplex.core.reward.rewards.UnknownPackageReward;
|
||||
import mineplex.core.treasure.event.TreasureFinishEvent;
|
||||
import mineplex.core.treasure.event.TreasureStartEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -91,7 +86,7 @@ public class TreasureManager extends MiniPlugin
|
||||
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest"));
|
||||
|
||||
IReward[] rewards = _rewardManager.getRewards(player, true);
|
||||
Reward[] rewards = _rewardManager.getRewards(player, true);
|
||||
Treasure treasure = new Treasure(player, rewards);
|
||||
_playerTreasureMap.put(player, treasure);
|
||||
|
||||
@ -345,7 +340,7 @@ public class TreasureManager extends MiniPlugin
|
||||
|
||||
for (int i=0 ; i<toTest ; i++)
|
||||
{
|
||||
IReward reward = _rewardManager.nextReward(null, null, false, event.getMessage().startsWith("/rewardchest"));
|
||||
Reward reward = _rewardManager.nextReward(null, null, false, event.getMessage().startsWith("/rewardchest"));
|
||||
|
||||
if (reward.getRarity() == RewardRarity.COMMON) common++;
|
||||
if (reward.getRarity() == RewardRarity.UNCOMMON) uncommon++;
|
||||
|
@ -12,7 +12,7 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HorseHologram;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.treasure.ChestData;
|
||||
import mineplex.core.treasure.Treasure;
|
||||
|
||||
@ -22,16 +22,16 @@ import mineplex.core.treasure.Treasure;
|
||||
public class ChestOpenAnimation extends Animation
|
||||
{
|
||||
private ChestData _chestData;
|
||||
private String _text;
|
||||
private RewardData _rewardData;
|
||||
|
||||
private Item _itemEntity;
|
||||
private Hologram _hologram;
|
||||
|
||||
public ChestOpenAnimation(Treasure treasure, ChestData chestData, String text)
|
||||
public ChestOpenAnimation(Treasure treasure, ChestData chestData, RewardData rewardData)
|
||||
{
|
||||
super(treasure);
|
||||
_chestData = chestData;
|
||||
_text = text;
|
||||
_rewardData = rewardData;
|
||||
|
||||
// Send chest open packet
|
||||
Block block = chestData.getBlock();
|
||||
@ -49,13 +49,13 @@ public class ChestOpenAnimation extends Animation
|
||||
if (getTicks() == 5)
|
||||
{
|
||||
Location location = _chestData.getBlock().getLocation().add(0.5, 0.8, 0.5);
|
||||
_itemEntity = location.getWorld().dropItem(location, _chestData.getReward().getItem());
|
||||
_itemEntity = location.getWorld().dropItem(location, _rewardData.getDisplayItem());
|
||||
_itemEntity.setVelocity(new Vector(0, 0, 0));
|
||||
_itemEntity.setPickupDelay(Integer.MAX_VALUE);
|
||||
}
|
||||
else if (getTicks() == 15)
|
||||
{
|
||||
_hologram = new Hologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _text);
|
||||
_hologram = new Hologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _rewardData.getFriendlyName());
|
||||
_hologram.sendToPlayers(_chestData.getBlock().getLocation().getWorld().getPlayers().toArray(new Player[0]));
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ package mineplex.database;
|
||||
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class Account extends org.jooq.impl.SchemaImpl implements java.io.Serializable, java.lang.Cloneable {
|
||||
|
||||
private static final long serialVersionUID = -871366556;
|
||||
private static final long serialVersionUID = -1984121749;
|
||||
|
||||
/**
|
||||
* The singleton instance of <code>Account</code>
|
||||
@ -47,6 +47,7 @@ public class Account extends org.jooq.impl.SchemaImpl implements java.io.Seriali
|
||||
mineplex.database.tables.Npcs.npcs,
|
||||
mineplex.database.tables.PlayerMap.playerMap,
|
||||
mineplex.database.tables.Polls.polls,
|
||||
mineplex.database.tables.RewardLog.rewardLog,
|
||||
mineplex.database.tables.Stats.stats,
|
||||
mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard);
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ public class Keys {
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PlayerMapRecord> KEY_playerMap_PRIMARY = UniqueKeys0.KEY_playerMap_PRIMARY;
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PlayerMapRecord> KEY_playerMap_playerIndex = UniqueKeys0.KEY_playerMap_playerIndex;
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PollsRecord> KEY_polls_PRIMARY = UniqueKeys0.KEY_polls_PRIMARY;
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.RewardLogRecord> KEY_rewardLog_PRIMARY = UniqueKeys0.KEY_rewardLog_PRIMARY;
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.StatsRecord> KEY_stats_PRIMARY = UniqueKeys0.KEY_stats_PRIMARY;
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.StatsRecord> KEY_stats_nameIndex = UniqueKeys0.KEY_stats_nameIndex;
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.TournamentLeaderboardRecord> KEY_tournamentLeaderboard_PRIMARY = UniqueKeys0.KEY_tournamentLeaderboard_PRIMARY;
|
||||
@ -77,6 +78,7 @@ public class Keys {
|
||||
public static final org.jooq.ForeignKey<mineplex.database.tables.records.GamePlayersRecord, mineplex.database.tables.records.GamesRecord> FK_gamePlayers_games = ForeignKeys0.FK_gamePlayers_games;
|
||||
public static final org.jooq.ForeignKey<mineplex.database.tables.records.GamePlayersRecord, mineplex.database.tables.records.AccountsRecord> FK_gamePlayers_accounts = ForeignKeys0.FK_gamePlayers_accounts;
|
||||
public static final org.jooq.ForeignKey<mineplex.database.tables.records.ItemsRecord, mineplex.database.tables.records.ItemCategoriesRecord> items_ibfk_1 = ForeignKeys0.items_ibfk_1;
|
||||
public static final org.jooq.ForeignKey<mineplex.database.tables.records.RewardLogRecord, mineplex.database.tables.records.AccountsRecord> rewardLog_ibfk_1 = ForeignKeys0.rewardLog_ibfk_1;
|
||||
public static final org.jooq.ForeignKey<mineplex.database.tables.records.TournamentLeaderboardRecord, mineplex.database.tables.records.AccountsRecord> FK_tournamentLeaderboard_accounts = ForeignKeys0.FK_tournamentLeaderboard_accounts;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -123,6 +125,7 @@ public class Keys {
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PlayerMapRecord> KEY_playerMap_PRIMARY = createUniqueKey(mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.PlayerMap.playerMap.id);
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PlayerMapRecord> KEY_playerMap_playerIndex = createUniqueKey(mineplex.database.tables.PlayerMap.playerMap, mineplex.database.tables.PlayerMap.playerMap.playerName);
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.PollsRecord> KEY_polls_PRIMARY = createUniqueKey(mineplex.database.tables.Polls.polls, mineplex.database.tables.Polls.polls.id);
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.RewardLogRecord> KEY_rewardLog_PRIMARY = createUniqueKey(mineplex.database.tables.RewardLog.rewardLog, mineplex.database.tables.RewardLog.rewardLog.id);
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.StatsRecord> KEY_stats_PRIMARY = createUniqueKey(mineplex.database.tables.Stats.stats, mineplex.database.tables.Stats.stats.id);
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.StatsRecord> KEY_stats_nameIndex = createUniqueKey(mineplex.database.tables.Stats.stats, mineplex.database.tables.Stats.stats.name);
|
||||
public static final org.jooq.UniqueKey<mineplex.database.tables.records.TournamentLeaderboardRecord> KEY_tournamentLeaderboard_PRIMARY = createUniqueKey(mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard, mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard.id);
|
||||
@ -139,6 +142,7 @@ public class Keys {
|
||||
public static final org.jooq.ForeignKey<mineplex.database.tables.records.GamePlayersRecord, mineplex.database.tables.records.GamesRecord> FK_gamePlayers_games = createForeignKey(mineplex.database.Keys.KEY_games_PRIMARY, mineplex.database.tables.GamePlayers.gamePlayers, mineplex.database.tables.GamePlayers.gamePlayers.gameId);
|
||||
public static final org.jooq.ForeignKey<mineplex.database.tables.records.GamePlayersRecord, mineplex.database.tables.records.AccountsRecord> FK_gamePlayers_accounts = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.GamePlayers.gamePlayers, mineplex.database.tables.GamePlayers.gamePlayers.accountId);
|
||||
public static final org.jooq.ForeignKey<mineplex.database.tables.records.ItemsRecord, mineplex.database.tables.records.ItemCategoriesRecord> items_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_itemCategories_PRIMARY, mineplex.database.tables.Items.items, mineplex.database.tables.Items.items.categoryId);
|
||||
public static final org.jooq.ForeignKey<mineplex.database.tables.records.RewardLogRecord, mineplex.database.tables.records.AccountsRecord> rewardLog_ibfk_1 = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.RewardLog.rewardLog, mineplex.database.tables.RewardLog.rewardLog.accountId);
|
||||
public static final org.jooq.ForeignKey<mineplex.database.tables.records.TournamentLeaderboardRecord, mineplex.database.tables.records.AccountsRecord> FK_tournamentLeaderboard_accounts = createForeignKey(mineplex.database.Keys.KEY_accounts_PRIMARY, mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard, mineplex.database.tables.TournamentLeaderboard.tournamentLeaderboard.accountId);
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,11 @@ public class Tables {
|
||||
*/
|
||||
public static final mineplex.database.tables.Polls polls = mineplex.database.tables.Polls.polls;
|
||||
|
||||
/**
|
||||
* The table Account.rewardLog
|
||||
*/
|
||||
public static final mineplex.database.tables.RewardLog rewardLog = mineplex.database.tables.RewardLog.rewardLog;
|
||||
|
||||
/**
|
||||
* The table Account.stats
|
||||
*/
|
||||
|
@ -0,0 +1,119 @@
|
||||
/**
|
||||
* This class is generated by jOOQ
|
||||
*/
|
||||
package mineplex.database.tables;
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.2" },
|
||||
comments = "This class is generated by jOOQ")
|
||||
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class RewardLog extends org.jooq.impl.TableImpl<mineplex.database.tables.records.RewardLogRecord> implements java.io.Serializable, java.lang.Cloneable {
|
||||
|
||||
private static final long serialVersionUID = -2067456689;
|
||||
|
||||
/**
|
||||
* The singleton instance of <code>Account.rewardLog</code>
|
||||
*/
|
||||
public static final mineplex.database.tables.RewardLog rewardLog = new mineplex.database.tables.RewardLog();
|
||||
|
||||
/**
|
||||
* The class holding records for this type
|
||||
*/
|
||||
@Override
|
||||
public java.lang.Class<mineplex.database.tables.records.RewardLogRecord> getRecordType() {
|
||||
return mineplex.database.tables.records.RewardLogRecord.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* The column <code>Account.rewardLog.id</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.RewardLogRecord, java.lang.Integer> id = createField("id", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>Account.rewardLog.accountId</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.RewardLogRecord, java.lang.Integer> accountId = createField("accountId", org.jooq.impl.SQLDataType.INTEGER, this, "");
|
||||
|
||||
/**
|
||||
* The column <code>Account.rewardLog.date</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.RewardLogRecord, java.sql.Timestamp> date = createField("date", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>Account.rewardLog.type</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.RewardLogRecord, java.lang.String> type = createField("type", org.jooq.impl.SQLDataType.VARCHAR.length(16).nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>Account.rewardLog.rarity</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.RewardLogRecord, java.lang.String> rarity = createField("rarity", org.jooq.impl.SQLDataType.VARCHAR.length(16).nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* The column <code>Account.rewardLog.reward</code>.
|
||||
*/
|
||||
public final org.jooq.TableField<mineplex.database.tables.records.RewardLogRecord, java.lang.String> reward = createField("reward", org.jooq.impl.SQLDataType.VARCHAR.length(64).nullable(false), this, "");
|
||||
|
||||
/**
|
||||
* Create a <code>Account.rewardLog</code> table reference
|
||||
*/
|
||||
public RewardLog() {
|
||||
this("rewardLog", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an aliased <code>Account.rewardLog</code> table reference
|
||||
*/
|
||||
public RewardLog(java.lang.String alias) {
|
||||
this(alias, mineplex.database.tables.RewardLog.rewardLog);
|
||||
}
|
||||
|
||||
private RewardLog(java.lang.String alias, org.jooq.Table<mineplex.database.tables.records.RewardLogRecord> aliased) {
|
||||
this(alias, aliased, null);
|
||||
}
|
||||
|
||||
private RewardLog(java.lang.String alias, org.jooq.Table<mineplex.database.tables.records.RewardLogRecord> aliased, org.jooq.Field<?>[] parameters) {
|
||||
super(alias, mineplex.database.Account.Account, aliased, parameters, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.UniqueKey<mineplex.database.tables.records.RewardLogRecord> getPrimaryKey() {
|
||||
return mineplex.database.Keys.KEY_rewardLog_PRIMARY;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public java.util.List<org.jooq.UniqueKey<mineplex.database.tables.records.RewardLogRecord>> getKeys() {
|
||||
return java.util.Arrays.<org.jooq.UniqueKey<mineplex.database.tables.records.RewardLogRecord>>asList(mineplex.database.Keys.KEY_rewardLog_PRIMARY);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public java.util.List<org.jooq.ForeignKey<mineplex.database.tables.records.RewardLogRecord, ?>> getReferences() {
|
||||
return java.util.Arrays.<org.jooq.ForeignKey<mineplex.database.tables.records.RewardLogRecord, ?>>asList(mineplex.database.Keys.rewardLog_ibfk_1);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public mineplex.database.tables.RewardLog as(java.lang.String alias) {
|
||||
return new mineplex.database.tables.RewardLog(alias, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename this table
|
||||
*/
|
||||
public mineplex.database.tables.RewardLog rename(java.lang.String name) {
|
||||
return new mineplex.database.tables.RewardLog(name, null);
|
||||
}
|
||||
}
|
@ -0,0 +1,314 @@
|
||||
/**
|
||||
* This class is generated by jOOQ
|
||||
*/
|
||||
package mineplex.database.tables.records;
|
||||
|
||||
/**
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@javax.annotation.Generated(value = { "http://www.jooq.org", "3.4.2" },
|
||||
comments = "This class is generated by jOOQ")
|
||||
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class RewardLogRecord extends org.jooq.impl.UpdatableRecordImpl<mineplex.database.tables.records.RewardLogRecord> implements java.io.Serializable, java.lang.Cloneable, org.jooq.Record6<java.lang.Integer, java.lang.Integer, java.sql.Timestamp, java.lang.String, java.lang.String, java.lang.String> {
|
||||
|
||||
private static final long serialVersionUID = 2005336153;
|
||||
|
||||
/**
|
||||
* Setter for <code>Account.rewardLog.id</code>.
|
||||
*/
|
||||
public void setId(java.lang.Integer value) {
|
||||
setValue(0, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>Account.rewardLog.id</code>.
|
||||
*/
|
||||
public java.lang.Integer getId() {
|
||||
return (java.lang.Integer) getValue(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>Account.rewardLog.accountId</code>.
|
||||
*/
|
||||
public void setAccountId(java.lang.Integer value) {
|
||||
setValue(1, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>Account.rewardLog.accountId</code>.
|
||||
*/
|
||||
public java.lang.Integer getAccountId() {
|
||||
return (java.lang.Integer) getValue(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>Account.rewardLog.date</code>.
|
||||
*/
|
||||
public void setDate(java.sql.Timestamp value) {
|
||||
setValue(2, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>Account.rewardLog.date</code>.
|
||||
*/
|
||||
public java.sql.Timestamp getDate() {
|
||||
return (java.sql.Timestamp) getValue(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>Account.rewardLog.type</code>.
|
||||
*/
|
||||
public void setType(java.lang.String value) {
|
||||
setValue(3, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>Account.rewardLog.type</code>.
|
||||
*/
|
||||
public java.lang.String getType() {
|
||||
return (java.lang.String) getValue(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>Account.rewardLog.rarity</code>.
|
||||
*/
|
||||
public void setRarity(java.lang.String value) {
|
||||
setValue(4, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>Account.rewardLog.rarity</code>.
|
||||
*/
|
||||
public java.lang.String getRarity() {
|
||||
return (java.lang.String) getValue(4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>Account.rewardLog.reward</code>.
|
||||
*/
|
||||
public void setReward(java.lang.String value) {
|
||||
setValue(5, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>Account.rewardLog.reward</code>.
|
||||
*/
|
||||
public java.lang.String getReward() {
|
||||
return (java.lang.String) getValue(5);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Primary key information
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Record1<java.lang.Integer> key() {
|
||||
return (org.jooq.Record1) super.key();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Record6 type implementation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Row6<java.lang.Integer, java.lang.Integer, java.sql.Timestamp, java.lang.String, java.lang.String, java.lang.String> fieldsRow() {
|
||||
return (org.jooq.Row6) super.fieldsRow();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Row6<java.lang.Integer, java.lang.Integer, java.sql.Timestamp, java.lang.String, java.lang.String, java.lang.String> valuesRow() {
|
||||
return (org.jooq.Row6) super.valuesRow();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Field<java.lang.Integer> field1() {
|
||||
return mineplex.database.tables.RewardLog.rewardLog.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Field<java.lang.Integer> field2() {
|
||||
return mineplex.database.tables.RewardLog.rewardLog.accountId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Field<java.sql.Timestamp> field3() {
|
||||
return mineplex.database.tables.RewardLog.rewardLog.date;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Field<java.lang.String> field4() {
|
||||
return mineplex.database.tables.RewardLog.rewardLog.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Field<java.lang.String> field5() {
|
||||
return mineplex.database.tables.RewardLog.rewardLog.rarity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Field<java.lang.String> field6() {
|
||||
return mineplex.database.tables.RewardLog.rewardLog.reward;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public java.lang.Integer value1() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public java.lang.Integer value2() {
|
||||
return getAccountId();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public java.sql.Timestamp value3() {
|
||||
return getDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public java.lang.String value4() {
|
||||
return getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public java.lang.String value5() {
|
||||
return getRarity();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public java.lang.String value6() {
|
||||
return getReward();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RewardLogRecord value1(java.lang.Integer value) {
|
||||
setId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RewardLogRecord value2(java.lang.Integer value) {
|
||||
setAccountId(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RewardLogRecord value3(java.sql.Timestamp value) {
|
||||
setDate(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RewardLogRecord value4(java.lang.String value) {
|
||||
setType(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RewardLogRecord value5(java.lang.String value) {
|
||||
setRarity(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RewardLogRecord value6(java.lang.String value) {
|
||||
setReward(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RewardLogRecord values(java.lang.Integer value1, java.lang.Integer value2, java.sql.Timestamp value3, java.lang.String value4, java.lang.String value5, java.lang.String value6) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Create a detached RewardLogRecord
|
||||
*/
|
||||
public RewardLogRecord() {
|
||||
super(mineplex.database.tables.RewardLog.rewardLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a detached, initialised RewardLogRecord
|
||||
*/
|
||||
public RewardLogRecord(java.lang.Integer id, java.lang.Integer accountId, java.sql.Timestamp date, java.lang.String type, java.lang.String rarity, java.lang.String reward) {
|
||||
super(mineplex.database.tables.RewardLog.rewardLog);
|
||||
|
||||
setValue(0, id);
|
||||
setValue(1, accountId);
|
||||
setValue(2, date);
|
||||
setValue(3, type);
|
||||
setValue(4, rarity);
|
||||
setValue(5, reward);
|
||||
}
|
||||
}
|
@ -1,25 +1,8 @@
|
||||
package nautilus.game.arcade.managers;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Random;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTitle;
|
||||
import mineplex.core.reward.IReward;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.reward.rewards.InventoryReward;
|
||||
import mineplex.core.treasure.animation.Animation;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
@ -32,6 +15,20 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTitle;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardManager;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
import mineplex.core.reward.rewards.InventoryReward;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
public class GameLootManager implements Listener
|
||||
{
|
||||
private ArcadeManager Manager;
|
||||
@ -56,11 +53,11 @@ public class GameLootManager implements Listener
|
||||
false);
|
||||
|
||||
//Chest
|
||||
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Treasure Chest", "Treasure Chest", 1, 1,
|
||||
_rewardManager.addReward(new InventoryReward(_rewardManager, Manager.getInventoryManager(), "Treasure Chest", "Treasure Chest", 1, 1,
|
||||
new ItemStack(Material.CHEST), RewardRarity.COMMON, 2));
|
||||
|
||||
//Key
|
||||
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Treasure Key", "Treasure Key", 1, 1,
|
||||
_rewardManager.addReward(new InventoryReward(_rewardManager, Manager.getInventoryManager(), "Treasure Key", "Treasure Key", 1, 1,
|
||||
new ItemStack(Material.DIAMOND), RewardRarity.UNCOMMON, 500));
|
||||
}
|
||||
|
||||
@ -116,11 +113,11 @@ public class GameLootManager implements Listener
|
||||
if (Math.random() > chance)
|
||||
return;
|
||||
|
||||
IReward reward = _rewardManager.nextReward(player, null, false, false);
|
||||
Reward reward = _rewardManager.nextReward(player, null, false, false);
|
||||
|
||||
String name = reward.giveReward(player);
|
||||
RewardData rewardData = reward.giveReward("GameLoot", player);
|
||||
|
||||
String outputName = reward.getRarity().getColor() + name;
|
||||
String outputName = reward.getRarity().getColor() + rewardData.getFriendlyName();
|
||||
|
||||
//Log
|
||||
System.out.println(F.name(player.getName()) + " found " + reward.getRarity().getName() + " treasure " + outputName);
|
||||
|
Loading…
Reference in New Issue
Block a user