The mess that is now this

This commit is contained in:
Sam 2017-09-16 23:33:42 +01:00
parent b8210f5eac
commit 2b4e9e62e1
126 changed files with 3361 additions and 8892 deletions

View File

@ -169,14 +169,13 @@ public class SkinData
return "_" + _nameCount;
}
/*
/**
* Creates a {@link SkinData} from a given {@link GameProfile}.
* Will return null if the GameProfile does not have any texture data
*
* @param input The GameProfile to get textures from
* @param requireSecure Whether the SkinData should be signed
* @param useDefaultSkins Whether to subsitute an Alex or Steve skin if no textures are present
* @param useDefaultSkins Whether to substitute an Alex or Steve skin if no textures are present
*
* @return The SkinData, or null if no textures are present
*/

View File

@ -26,7 +26,7 @@ import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.treasure.TreasureType;
import mineplex.core.treasure.types.TreasureType;
public class LevelingManager extends MiniDbClientPlugin<List<Integer>>
{
@ -91,12 +91,6 @@ public class LevelingManager extends MiniDbClientPlugin<List<Integer>>
addCurrencyReward(8, GlobalCurrency.GEM, 250);
addCurrencyReward(9, GlobalCurrency.GEM, 500);
addChestReward(10, TreasureType.OLD, 2);
addChestReward(10, TreasureType.ANCIENT, 1);
// TODO implement full rewards
addChestReward(100, TreasureType.OMEGA, 5);
addChestReward(101, TreasureType.OMEGA, 6);
addChestReward(102, TreasureType.OMEGA, 7);
}
private void addCurrencyReward(int level, GlobalCurrency type, int amount)

View File

@ -3,7 +3,7 @@ package mineplex.core.achievement.leveling.rewards;
import org.bukkit.entity.Player;
import mineplex.core.common.util.C;
import mineplex.core.treasure.TreasureType;
import mineplex.core.treasure.types.TreasureType;
public class LevelChestReward implements LevelReward
{

View File

@ -41,14 +41,12 @@ import mineplex.core.account.ILoginProcessor;
import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.account.permissions.Permission;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.bonuses.animations.AnimationCarl;
import mineplex.core.bonuses.commands.AnimationCommand;
import mineplex.core.bonuses.commands.GuiCommand;
import mineplex.core.bonuses.commands.PowerPlayCommand;
import mineplex.core.bonuses.commands.TicketCommand;
import mineplex.core.bonuses.event.CarlSpinnerEvent;
import mineplex.core.bonuses.gui.BonusGui;
import mineplex.core.bonuses.gui.SpinGui;
import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton;
import mineplex.core.bonuses.redis.VoteHandler;
import mineplex.core.bonuses.redis.VotifierCommand;
@ -57,9 +55,6 @@ import mineplex.core.common.currency.GlobalCurrency;
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.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
@ -67,8 +62,8 @@ import mineplex.core.facebook.FacebookManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.ClientItem;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.treasure.reward.TreasureRewardManager;
import mineplex.core.npc.Npc;
import mineplex.core.npc.NpcManager;
import mineplex.core.pet.PetManager;
@ -76,10 +71,8 @@ import mineplex.core.playwire.PlayWireManager;
import mineplex.core.poll.PollManager;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.core.recharge.Recharge;
import mineplex.core.reward.RewardManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.thank.ThankManager;
import mineplex.core.treasure.TreasureType;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.youtube.YoutubeManager;
@ -151,7 +144,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
private PollManager _pollManager;
private NpcManager _npcManager;
private HologramManager _hologramManager;
private RewardManager _rewardManager;
private TreasureRewardManager _rewardManager;
private StatsManager _statsManager;
private FacebookManager _facebookManager;
private YoutubeManager _youtubeManager;
@ -161,7 +154,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
public boolean _enabled;
private Npc _carlNpc;
private Location _carlLocation;
private AnimationCarl _animation;
//private AnimationCarl _animation;
private int _visualTick;
private ArrayList<String> _voteList;
@ -223,7 +216,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
System.out.print("GM NULL");
}
_rewardManager = new RewardManager(_clientManager, _donationManager, _inventoryManager, petManager, gadgetManager, statsManager);
_rewardManager = require(TreasureRewardManager.class);
_pollManager = pollManager;
_statsManager = statsManager;
@ -264,8 +257,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_carlNpc.setLocation(carlLocation);
}
_enabled = true;
_animation = new AnimationCarl(_carlNpc.getEntity());
_animation.setRunning(false);
// _animation = new AnimationCarl(_carlNpc.getEntity());
// _animation.setRunning(false);
}
}
else
@ -391,7 +384,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
})));
}
@EventHandler
//@EventHandler
public void fireCreeper(UpdateEvent event)
{
if(event.getType() != UpdateType.SLOW)
@ -411,7 +404,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_animationRunning = true;
_explode = System.currentTimeMillis();
_animation.setTicks(0);
//_animation.setTicks(0);
_canVote = false;
}
@ -421,7 +414,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (event.getType() != UpdateType.TICK)
return;
_animation.itemClean();
//_animation.itemClean();
if (_canVote)
return;
@ -446,18 +439,18 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return;
}
if(!_animation.isRunning())
{
//Effect
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, creeper.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers());
creeper.getWorld().playSound(creeper.getLocation(), Sound.EXPLODE, 2f, 1f);
_animation.setType(_pendingExplosions.get(0));
_animation.setPlayer(_pendingExplosionsPlayers.get(0));
_animation.setRunning(true);
}
if(!_animation.isDone())
return;
// if(!_animation.isRunning())
// {
// //Effect
// UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, creeper.getLocation(), 0, 0, 0, 0, 1, ViewDist.MAX, UtilServer.getPlayers());
// creeper.getWorld().playSound(creeper.getLocation(), Sound.EXPLODE, 2f, 1f);
// _animation.setType(_pendingExplosions.get(0));
// _animation.setPlayer(_pendingExplosionsPlayers.get(0));
// _animation.setRunning(true);
// }
//
// if(!_animation.isDone())
// return;
_animationRunning = false;
DecreaseSize(creeper);
@ -466,7 +459,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_canVote = true;
}
@EventHandler
//@EventHandler
public void updateAnimation(UpdateEvent event)
{
if(event.getType() != UpdateType.TICK)
@ -475,10 +468,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (!_enabled)
return;
if(!_animation.isRunning())
return;
_animation.run();
// if(!_animation.isRunning())
// return;
//
// _animation.run();
}
public void DecreaseSize(Entity player)
@ -584,7 +577,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
{
if (data)
{
new SpinGui(_plugin, player, _rewardManager, BonusManager.this).openInventory();
//new SpinGui(_plugin, player, _rewardManager, BonusManager.this).openInventory();
}
else
{
@ -844,31 +837,31 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (oldChests > 0)
{
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(oldChests + " Old Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OLD.getItemName()), oldChests));
//_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OLD.getItemName()), oldChests));
}
if (ancientChests > 0)
{
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(ancientChests + " Ancient Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ANCIENT.getItemName()), ancientChests));
//_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ANCIENT.getItemName()), ancientChests));
}
if (mythicalChests > 0)
{
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(mythicalChests + " Mythical Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.MYTHICAL.getItemName()), mythicalChests));
//_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.MYTHICAL.getItemName()), mythicalChests));
}
if (illuminatedChests > 0)
{
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(illuminatedChests + " Illuminated Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ILLUMINATED.getItemName()), illuminatedChests));
//_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.ILLUMINATED.getItemName()), illuminatedChests));
}
if (omegaChests > 0)
{
UtilPlayer.message(player, F.main(_creeperName, "Rewarded " + F.elem(omegaChests + " Omega Chests")));
_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OMEGA.getItemName()), omegaChests));
//_inventoryManager.Get(player).addItem(new ClientItem(_inventoryManager.getItem(TreasureType.OMEGA.getItemName()), omegaChests));
}
if (gems > 0)
@ -1106,7 +1099,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return _clientManager;
}
public RewardManager getRewardManager()
public TreasureRewardManager getRewardManager()
{
return _rewardManager;
}

View File

@ -10,8 +10,6 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.treasure.animation.Animation;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
@ -24,291 +22,291 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class AnimationCarl extends Animation
public class AnimationCarl
{
private boolean _isDone;
private Block _creeper;
private Object _type;
private Player _player;
private HashSet<Item> _items = new HashSet<Item>();
public AnimationCarl(Entity creeper)
{
_creeper = creeper.getLocation().getBlock();
}
@Override
protected void tick()
{
if(_type instanceof String)
{
if(((String) _type).contentEquals("DAILY") || ((String) _type).contentEquals("POLL"))
{
for (int i = 50; i < 60; i++)
{
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i));
_items.add(gem);
_items.add(shard);
Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d));
UtilAction.velocity(gem, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false);
UtilAction.velocity(shard, vel, Math.abs(Math.sin(UtilMath.r(i) * 30/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 30/3000d))*0.6, 1, false);
}
}
if(((String) _type).contentEquals("RANK"))
{
for (int i = 50; i < 60; i++)
{
Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i));
_items.add(shard);
Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
UtilAction.velocity(shard, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
}
}
if(!((String) _type).contentEquals("DAILY") && !((String) _type).contentEquals("RANK") && !((String) _type).contentEquals("POLL"))
{
Item paper = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, " " + 64));
_items.add(paper);
Vector vel = new Vector(Math.sin(64 * 8/5d), 0, Math.cos(64 * 8/5d));
UtilAction.velocity(paper, vel, Math.abs(Math.sin(64 * 9/3000d)), false, 0, 0.2 + Math.abs(Math.cos(64 + 9/3000d))*0.6, 1, false);
for (int i = 50; i < 60; i++)
{
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
_items.add(gem);
Vector velo = new Vector(Math.sin(i * 8/5d), 0, Math.cos(i * 8/5d));
UtilAction.velocity(gem, velo, Math.abs(Math.sin(i * 8/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i + 8/3000d))*0.6, 1, false);
}
}
finish();
}
if(_type instanceof Reward)
{
if(getTicks() == 0)
{
RewardData rewardData = ((Reward)_type).getFakeRewardData(_player);
ItemStack itemStack = rewardData.getDisplayItem();
Item item = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.7, 0.5), itemStack);
_items.add(item);
Vector vel = new Vector(_player.getLocation().getX() - _creeper.getLocation().getX(), 0, _player.getLocation().getZ() - _creeper.getLocation().getZ());
UtilAction.velocity(item, vel, 0.1, false, 0, 0.2 + 1*0.4, 1, false);
}
if(((Reward)_type).getRarity() == RewardRarity.RARE)
{
RareAnimation();
}
else if(((Reward)_type).getRarity() == RewardRarity.LEGENDARY)
{
LegendAnimation();
}
else if(((Reward)_type).getRarity() == RewardRarity.MYTHICAL)
{
MythicalAnimation();
}
else
{
finish();
}
}
if (_type instanceof PowerPlayAnimation)
{
for (int i = 50; i < 65; i++)
{
// Gem amplifier
Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
_items.add(gem);
Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
UtilAction.velocity(gem, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
// Omega chest
Item omega = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), SkinData.OMEGA_CHEST.getSkull());
_items.add(omega);
vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
UtilAction.velocity(omega, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
// Monthly items
PowerPlayAnimation powerPlayAnimation = (PowerPlayAnimation) _type;
for (ItemStack itemStack : powerPlayAnimation.getAnimationItems())
{
Item monthly = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), itemStack);
_items.add(monthly);
vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
UtilAction.velocity(monthly, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
}
}
finish();
}
}
@Override
protected void onFinish() {
_isDone = true;
_player = null;
setTicks(0);
}
public boolean isDone()
{
return _isDone;
}
public void setDone(boolean b)
{
_isDone = b;
}
public void setType(Object type)
{
_type = type;
}
public void setPlayer(Player player)
{
_player = player;
}
public void LegendAnimation()
{
if (getTicks() < 1)
{
UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true);
}
if (getTicks() == 1)
{
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
}
else if (getTicks() < 35)
{
double radius = 2 - (getTicks() / 10D * 2);
int particleAmount = 20 - (getTicks() * 2);
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
for (int i = 0; i < particleAmount; i++)
{
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
for(double e = 0.1 ; e < 3 ; e += 0.6)
{
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}
else
{
finish();
}
}
public void MythicalAnimation()
{
if (getTicks() < 30)
{
UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true);
}
if (getTicks() == 1)
{
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F);
_creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F);
}
else if (getTicks() < 40)
{
UtilFirework.launchFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true,
new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1);
//Particle Spiral Up
double radius = getTicks() / 20D;
int particleAmount = getTicks() / 2;
for (int i = 0; i < particleAmount; i++)
{
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location location = _creeper.getLocation().add(0.5, 0, 0.5).clone().add(xDiff, -1.3, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
for (int i = 0; i < particleAmount; i++)
{
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
for(double e = 0.1 ; e < 3 ; e += 0.5)
{
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}
else
{
finish();
}
}
public void RareAnimation()
{
if (getTicks() == 1)
{
for(int i = 0; i < 3; i++)
{
UtilFirework.playFirework(_creeper.getLocation().add(0.5, i, 0.5), Type.BALL, Color.FUCHSIA, false, false);
}
_creeper.getWorld().playSound(_creeper.getLocation(), Sound.WITHER_SPAWN, 10F, 1.2F);
}
else if (getTicks() >= 60)
{
finish();
}
else if (getTicks() < 35)
{
double radius = 2 - (getTicks() / 10D * 2);
int particleAmount = 20 - (getTicks() * 2);
Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
for (int i = 0; i < particleAmount; i++)
{
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
for(double e = 0.1 ; e < 3 ; e += 0.6)
{
Location location = _centerLocation.clone().add(xDiff, e, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}
}
public void itemClean()
{
Iterator<Item> itemIterator = _items.iterator();
while (itemIterator.hasNext())
{
Item item = itemIterator.next();
if (item.isOnGround() || !item.isValid() || item.getTicksLived() > 60)
{
item.remove();
itemIterator.remove();
}
}
}
// private boolean _isDone;
// private Block _creeper;
// private Object _type;
// private Player _player;
//
// private HashSet<Item> _items = new HashSet<Item>();
//
// public AnimationCarl(Entity creeper)
// {
// _creeper = creeper.getLocation().getBlock();
// }
//
// @Override
// protected void tick()
// {
// if(_type instanceof String)
// {
// if(((String) _type).contentEquals("DAILY") || ((String) _type).contentEquals("POLL"))
// {
// for (int i = 50; i < 60; i++)
// {
// Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
// Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i));
// _items.add(gem);
// _items.add(shard);
//
// Vector vel = new Vector(Math.sin(i * 9/5d), 0, Math.cos(i * 9/5d));
// UtilAction.velocity(gem, vel, Math.abs(Math.sin(i * 12/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i * 12/3000d))*0.6, 1, false);
// UtilAction.velocity(shard, vel, Math.abs(Math.sin(UtilMath.r(i) * 30/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 30/3000d))*0.6, 1, false);
//
// }
// }
// if(((String) _type).contentEquals("RANK"))
// {
// for (int i = 50; i < 60; i++)
// {
// Item shard = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PRISMARINE_SHARD, (byte) 0, 1, " " + i));
// _items.add(shard);
//
// Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
// UtilAction.velocity(shard, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
//
// }
// }
// if(!((String) _type).contentEquals("DAILY") && !((String) _type).contentEquals("RANK") && !((String) _type).contentEquals("POLL"))
// {
//
// Item paper = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte) 0, 1, " " + 64));
// _items.add(paper);
//
// Vector vel = new Vector(Math.sin(64 * 8/5d), 0, Math.cos(64 * 8/5d));
// UtilAction.velocity(paper, vel, Math.abs(Math.sin(64 * 9/3000d)), false, 0, 0.2 + Math.abs(Math.cos(64 + 9/3000d))*0.6, 1, false);
//
// for (int i = 50; i < 60; i++)
// {
// Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
// _items.add(gem);
//
// Vector velo = new Vector(Math.sin(i * 8/5d), 0, Math.cos(i * 8/5d));
// UtilAction.velocity(gem, velo, Math.abs(Math.sin(i * 8/3000d)), false, 0, 0.2 + Math.abs(Math.cos(i + 8/3000d))*0.6, 1, false);
//
// }
// }
// finish();
// }
// if(_type instanceof Reward)
// {
// if(getTicks() == 0)
// {
// RewardData rewardData = ((Reward)_type).getFakeRewardData(_player);
// ItemStack itemStack = rewardData.getDisplayItem();
// Item item = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.7, 0.5), itemStack);
// _items.add(item);
//
// Vector vel = new Vector(_player.getLocation().getX() - _creeper.getLocation().getX(), 0, _player.getLocation().getZ() - _creeper.getLocation().getZ());
//
// UtilAction.velocity(item, vel, 0.1, false, 0, 0.2 + 1*0.4, 1, false);
// }
//
// if(((Reward)_type).getRarity() == RewardRarity.RARE)
// {
// RareAnimation();
// }
// else if(((Reward)_type).getRarity() == RewardRarity.LEGENDARY)
// {
// LegendAnimation();
// }
// else if(((Reward)_type).getRarity() == RewardRarity.MYTHICAL)
// {
// MythicalAnimation();
// }
// else
// {
// finish();
// }
// }
// if (_type instanceof PowerPlayAnimation)
// {
// for (int i = 50; i < 65; i++)
// {
// // Gem amplifier
// Item gem = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 1, " " + i));
// _items.add(gem);
//
// Vector vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
// UtilAction.velocity(gem, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
//
// // Omega chest
// Item omega = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), SkinData.OMEGA_CHEST.getSkull());
// _items.add(omega);
//
// vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
// UtilAction.velocity(omega, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
//
// // Monthly items
// PowerPlayAnimation powerPlayAnimation = (PowerPlayAnimation) _type;
// for (ItemStack itemStack : powerPlayAnimation.getAnimationItems())
// {
// Item monthly = _creeper.getWorld().dropItem(_creeper.getLocation().add(0.5, 1.5, 0.5), itemStack);
// _items.add(monthly);
//
// vel = new Vector(Math.sin(UtilMath.r(i) * 7/5d), 0, Math.cos(UtilMath.r(i) * 7/5d));
// UtilAction.velocity(monthly, vel, Math.abs(Math.sin(UtilMath.r(i) * 7/3000d)), false, 0, 0.2 + Math.abs(Math.cos(UtilMath.r(i) * 7/3000d))*0.6, 1, false);
// }
// }
// finish();
// }
// }
//
// @Override
// protected void onFinish() {
// _isDone = true;
// _player = null;
// setTicks(0);
// }
//
// public boolean isDone()
// {
// return _isDone;
// }
//
// public void setDone(boolean b)
// {
// _isDone = b;
// }
//
// public void setType(Object type)
// {
// _type = type;
// }
//
// public void setPlayer(Player player)
// {
// _player = player;
// }
//
// public void LegendAnimation()
// {
// if (getTicks() < 1)
// {
// UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true);
// }
//
// if (getTicks() == 1)
// {
// _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
// }
// else if (getTicks() < 35)
// {
// double radius = 2 - (getTicks() / 10D * 2);
// int particleAmount = 20 - (getTicks() * 2);
// Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
// for (int i = 0; i < particleAmount; i++)
// {
// double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
// double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
// for(double e = 0.1 ; e < 3 ; e += 0.6)
// {
// Location location = _centerLocation.clone().add(xDiff, e, zDiff);
// UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
// }
// }
// }
// else
// {
// finish();
// }
// }
//
// public void MythicalAnimation()
// {
// if (getTicks() < 30)
// {
// UtilFirework.playFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true);
// }
//
// if (getTicks() == 1)
// {
// _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F);
// _creeper.getLocation().getWorld().playSound(_creeper.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F);
// }
// else if (getTicks() < 40)
// {
// UtilFirework.launchFirework(_creeper.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true,
// new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1);
//
// //Particle Spiral Up
// double radius = getTicks() / 20D;
// int particleAmount = getTicks() / 2;
// for (int i = 0; i < particleAmount; i++)
// {
// double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
// double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
//
// Location location = _creeper.getLocation().add(0.5, 0, 0.5).clone().add(xDiff, -1.3, zDiff);
// UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
// ViewDist.NORMAL, UtilServer.getPlayers());
// }
//
// Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
// for (int i = 0; i < particleAmount; i++)
// {
// double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
// double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
// for(double e = 0.1 ; e < 3 ; e += 0.5)
// {
// Location location = _centerLocation.clone().add(xDiff, e, zDiff);
// UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
// }
// }
// }
// else
// {
// finish();
// }
// }
//
// public void RareAnimation()
// {
// if (getTicks() == 1)
// {
// for(int i = 0; i < 3; i++)
// {
// UtilFirework.playFirework(_creeper.getLocation().add(0.5, i, 0.5), Type.BALL, Color.FUCHSIA, false, false);
// }
// _creeper.getWorld().playSound(_creeper.getLocation(), Sound.WITHER_SPAWN, 10F, 1.2F);
// }
// else if (getTicks() >= 60)
// {
// finish();
// }
//
// else if (getTicks() < 35)
// {
// double radius = 2 - (getTicks() / 10D * 2);
// int particleAmount = 20 - (getTicks() * 2);
// Location _centerLocation = _creeper.getLocation().add(0.5, 0.1, 0.5);
// for (int i = 0; i < particleAmount; i++)
// {
// double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
// double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
// for(double e = 0.1 ; e < 3 ; e += 0.6)
// {
// Location location = _centerLocation.clone().add(xDiff, e, zDiff);
// UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers());
// }
// }
// }
// }
//
// public void itemClean()
// {
// Iterator<Item> itemIterator = _items.iterator();
//
// while (itemIterator.hasNext())
// {
// Item item = itemIterator.next();
//
// if (item.isOnGround() || !item.isValid() || item.getTicksLived() > 60)
// {
// item.remove();
// itemIterator.remove();
// }
// }
// }
}

View File

@ -21,7 +21,7 @@ public class AnimationCommand extends CommandBase<BonusManager>{
public void Execute(Player caller, String[] args)
{
caller = Bukkit.getPlayer(args[0]);
_plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SPINNER_FILLER, true));
//plugin.addPendingExplosion(caller, _plugin.getRewardManager().nextReward(caller, null, false, RewardType.SPINNER_FILLER, true));
if (args.length >= 2)
{

View File

@ -17,8 +17,8 @@ import mineplex.core.bonuses.gui.buttons.VoteButton;
import mineplex.core.bonuses.gui.buttons.YoutubeButton;
import mineplex.core.facebook.FacebookManager;
import mineplex.core.gui.SimpleGui;
import mineplex.core.treasure.reward.TreasureRewardManager;
import mineplex.core.playwire.PlayWireManager;
import mineplex.core.reward.RewardManager;
import mineplex.core.thank.ThankManager;
import mineplex.core.youtube.YoutubeManager;
@ -38,7 +38,7 @@ public class BonusGui extends SimpleGui
private static final int INV_SIZE = 54;
public BonusGui(Plugin plugin, Player player, BonusManager manager, RewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, ThankManager thankManager, PlayWireManager playWireManager)
public BonusGui(Plugin plugin, Player player, BonusManager manager, TreasureRewardManager rewardManager, FacebookManager facebookManager, YoutubeManager youtubeManager, ThankManager thankManager, PlayWireManager playWireManager)
{
super(plugin, player, player.getName() + "'s Bonuses", INV_SIZE);

View File

@ -1,289 +1,264 @@
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;
import mineplex.core.gui.SimpleGui;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardPool.Type;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.bonuses.gui.buttons.RewardButton;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import mineplex.core.gui.SimpleGui;
public class SpinGui extends SimpleGui
{
private static final int HOPPER_SLOT = 4;
private static final int CARL_SLOT = 22;
private static final int[] LINE_NUMS = { /*-27, -18,*/ -9, 9/*, 18*/ };
private int _tickCount;
private RewardData _rewardData;
private Reward _reward;
private BonusManager _manager;
private int _currentRewardIndex;
private int _ticksThisSwap;
private int _ticksPerSwap;
private int _swapCount;
private Reward[] _rewards;
private boolean _stopped;
private boolean _rewarded;
private ArrayList<Integer> _ticks;
private int _frame;
private float _pitch;
private int _stopSpinnerAt;
public SpinGui(Plugin plugin, Player player, RewardManager rewardManager, BonusManager manager)
public SpinGui(Plugin plugin, Player player)
{
super(plugin, player, "Carl's Spinner", 27);
_manager = manager;
ShopItem carlItem = new ShopItem(Material.SKULL_ITEM, (byte) 4, "Carl's Spinner", new String[] {ChatColor.RESET + "Good Luck!" }, 1, false, false);
setItem(HOPPER_SLOT, new DisplayItem(new ItemStack(Material.HOPPER)));
//setItem(CARL_SLOT, new DisplayItem(carlItem));
_ticks = new ArrayList<>();
_frame = 0;
_pitch = 1;
_ticksPerSwap = 1;
for (int i=0 ; i<40 ; i++)
_ticks.add(1);
for (int i=0 ; i<20 ; i++)
_ticks.add(2);
for (int i=0 ; i<10 ; i++)
_ticks.add(4);
for (int i=0 ; i<4 ; i++)
_ticks.add(6);
for (int i=0 ; i<3 ; i++)
_ticks.add(8);
if (Math.random() > 0.5)
{
_ticks.add(12);
}
_stopSpinnerAt = _ticks.size();
//Create Rewards
_rewards = new Reward[_stopSpinnerAt+10]; //Adding 10, so theres items to the right still.
for (int i = 0; i < _stopSpinnerAt+10 ; i++)
{
if (i != _stopSpinnerAt + 4)
{
_rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SPINNER_FILLER, true);
}
else
{
_rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SPINNER_REAL, true);
_reward = _rewards[i];
}
}
_reward.giveReward(RewardType.SPINNER_REAL, getPlayer(), new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
_rewardData = data;
}
});
super(plugin, player);
}
private void tick()
{
if(_stopped)
return;
_ticksThisSwap++;
// Swap
if (_ticksThisSwap >= _ticksPerSwap)
{
_ticksThisSwap = 0;
_swapCount++;
if(_pitch == 1)
_pitch = (float) 1.5;
else if(_pitch == 1.5)
_pitch = 2;
else if(_pitch == 2)
_pitch = 1;
getPlayer().playSound(getPlayer().getEyeLocation(), Sound.NOTE_PLING, 1, _pitch);
_currentRewardIndex++;
updateGui();
// Slow
_ticksPerSwap = _ticks.get(_currentRewardIndex - 1);
if(_currentRewardIndex == _stopSpinnerAt)
_stopped = true;
}
_tickCount++;
}
public void updateGui()
{
for (int i = 0; i < 9; i++)
{
int index = _currentRewardIndex + i;
int slot = 9 + i;
RewardData data = _rewards[index].getFakeRewardData(getPlayer());
setItem(slot, new RewardButton(data));
// Glass Panes
for (int j = 0; j < LINE_NUMS.length; j++)
{
int paneSlot = slot + LINE_NUMS[j];
if (paneSlot == HOPPER_SLOT)
continue;
setItem(paneSlot, new DisplayItem(data.getRarity().getItemStack()));
}
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
tick();
checkIfDone();
}
@EventHandler(priority = EventPriority.HIGHEST)
public void close(InventoryCloseEvent event)
{
if(_rewarded)
return;
if(event.getPlayer() != getPlayer())
return;
_manager.addPendingExplosion(getPlayer(), _reward);
if (_reward.getRarity() == RewardRarity.RARE)
{
Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
}
else if (_reward.getRarity() == RewardRarity.LEGENDARY)
{
Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
}
else if (_reward.getRarity() == RewardRarity.MYTHICAL)
{
Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
}
else
{
UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
}
}
@EventHandler
public void Glass(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if(!_stopped)
return;
if(!_rewarded)
return;
if(_frame == 0)
{
setItem(CARL_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
setItem(HOPPER_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
_frame++;
}
else if(_frame < 5)
{
setItem(HOPPER_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
setItem(HOPPER_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
setItem(CARL_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
setItem(CARL_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
setItem(13 + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
setItem(13 - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
_frame++;
}
if(_frame == 6)
{
}
}
public void checkIfDone()
{
if(!_stopped)
return;
if(_rewarded)
return;
_manager.addPendingExplosion(getPlayer(), _reward);
if (_reward.getRarity() == RewardRarity.RARE)
{
Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
}
else if (_reward.getRarity() == RewardRarity.LEGENDARY)
{
Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
}
else if (_reward.getRarity() == RewardRarity.MYTHICAL)
{
Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
}
else
{
UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
}
ItemStack item = getInventory().getItem(13);
getInventory().setItem(13, ItemStackFactory.Instance.CreateStack(item.getType(), (byte) 0, 1, _rewardData.getFriendlyName()));
_rewarded = true;
}
// private static final int HOPPER_SLOT = 4;
// private static final int CARL_SLOT = 22;
// private static final int[] LINE_NUMS = { /*-27, -18,*/ -9, 9/*, 18*/ };
//
// private RewardData _rewardData;
// private Reward _reward;
// private BonusManager _manager;
// private int _currentRewardIndex;
// private int _ticksThisSwap;
// private int _ticksPerSwap;
// private Reward[] _rewards;
// private boolean _stopped;
// private boolean _rewarded;
// private ArrayList<Integer> _ticks;
// private int _frame;
// private float _pitch;
// private int _stopSpinnerAt;
//
// public SpinGui(Plugin plugin, Player player, TreasureRewardManager rewardManager, BonusManager manager)
// {
// super(plugin, player, "Carl's Spinner", 27);
//
// _manager = manager;
//
// ShopItem carlItem = new ShopItem(Material.SKULL_ITEM, (byte) 4, "Carl's Spinner", new String[] {ChatColor.RESET + "Good Luck!" }, 1, false, false);
//
// setItem(HOPPER_SLOT, new DisplayItem(new ItemStack(Material.HOPPER)));
// //setItem(CARL_SLOT, new DisplayItem(carlItem));
//
//
// _ticks = new ArrayList<>();
// _frame = 0;
// _pitch = 1;
//
//
//
// _ticksPerSwap = 1;
//
// for (int i=0 ; i<40 ; i++)
// _ticks.add(1);
//
// for (int i=0 ; i<20 ; i++)
// _ticks.add(2);
//
// for (int i=0 ; i<10 ; i++)
// _ticks.add(4);
//
// for (int i=0 ; i<4 ; i++)
// _ticks.add(6);
//
// for (int i=0 ; i<3 ; i++)
// _ticks.add(8);
//
// if (Math.random() > 0.5)
// {
// _ticks.add(12);
// }
//
// _stopSpinnerAt = _ticks.size();
//
// //Create Rewards
// _rewards = new Reward[_stopSpinnerAt+10]; //Adding 10, so theres items to the right still.
// for (int i = 0; i < _stopSpinnerAt+10 ; i++)
// {
// if (i != _stopSpinnerAt + 4)
// {
// _rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SPINNER_FILLER, true);
// }
// else
// {
// _rewards[i] = rewardManager.nextReward(player, Type.CARL_SPINNER, null, false, RewardType.SPINNER_REAL, true);
// _reward = _rewards[i];
// }
// }
//
// _reward.giveReward(RewardType.SPINNER_REAL, getPlayer(), new Callback<RewardData>()
// {
// @Override
// public void run(RewardData data)
// {
// _rewardData = data;
// }
// });
// }
//
// private void tick()
// {
//
// if(_stopped)
// return;
//
// _ticksThisSwap++;
//
// // Swap
// if (_ticksThisSwap >= _ticksPerSwap)
// {
// _ticksThisSwap = 0;
//
// if(_pitch == 1)
// _pitch = (float) 1.5;
// else if(_pitch == 1.5)
// _pitch = 2;
// else if(_pitch == 2)
// _pitch = 1;
//
// getPlayer().playSound(getPlayer().getEyeLocation(), Sound.NOTE_PLING, 1, _pitch);
//
// _currentRewardIndex++;
//
// updateGui();
//
// // Slow
// _ticksPerSwap = _ticks.get(_currentRewardIndex - 1);
//
// if(_currentRewardIndex == _stopSpinnerAt)
// _stopped = true;
// }
//
// _tickCount++;
// }
//
// public void updateGui()
// {
// for (int i = 0; i < 9; i++)
// {
// int index = _currentRewardIndex + i;
//
// int slot = 9 + i;
// RewardData data = _rewards[index].getFakeRewardData(getPlayer());
// setItem(slot, new RewardButton(data));
//
// // Glass Panes
// for (int j = 0; j < LINE_NUMS.length; j++)
// {
// int paneSlot = slot + LINE_NUMS[j];
// if (paneSlot == HOPPER_SLOT)
// continue;
//
// setItem(paneSlot, new DisplayItem(data.getRarity().getItemStack()));
// }
// }
// }
//
// @EventHandler
// public void update(UpdateEvent event)
// {
// if (event.getType() != UpdateType.TICK)
// return;
//
// tick();
// checkIfDone();
// }
//
// @EventHandler(priority = EventPriority.HIGHEST)
// public void close(InventoryCloseEvent event)
// {
// if(_rewarded)
// return;
//
// if(event.getPlayer() != getPlayer())
// return;
//
// _manager.addPendingExplosion(getPlayer(), _reward);
//
// if (_reward.getRarity() == RewardRarity.RARE)
// {
// Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
// }
// else if (_reward.getRarity() == RewardRarity.LEGENDARY)
// {
// Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
// }
// else if (_reward.getRarity() == RewardRarity.MYTHICAL)
// {
// Bukkit.broadcastMessage(F.main("Treasure", F.name(event.getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
// }
// else
// {
// UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
// }
// }
//
// @EventHandler
// public void Glass(UpdateEvent event)
// {
// if (event.getType() != UpdateType.FAST)
// return;
//
// if(!_stopped)
// return;
//
// if(!_rewarded)
// return;
//
// if(_frame == 0)
// {
// setItem(CARL_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
// setItem(HOPPER_SLOT, new DisplayItem(_rewardData.getRarity().getItemStack()));
// _frame++;
// }
// else if(_frame < 5)
// {
// setItem(HOPPER_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
// setItem(HOPPER_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
//
// setItem(CARL_SLOT + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
// setItem(CARL_SLOT - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
//
// setItem(13 + _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
// setItem(13 - _frame, new DisplayItem(_rewardData.getRarity().getItemStack()));
// _frame++;
// }
// if(_frame == 6)
// {
//
// }
// }
//
// public void checkIfDone()
// {
// if(!_stopped)
// return;
//
// if(_rewarded)
// return;
//
// _manager.addPendingExplosion(getPlayer(), _reward);
// if (_reward.getRarity() == RewardRarity.RARE)
// {
// Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cPurple + "Rare " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
// }
// else if (_reward.getRarity() == RewardRarity.LEGENDARY)
// {
// Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cGreen + "Legendary " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
// }
// else if (_reward.getRarity() == RewardRarity.MYTHICAL)
// {
// Bukkit.broadcastMessage(F.main("Treasure", F.name(getPlayer().getName()) + " won " + C.cRed + "Mythical " + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
// }
// else
// {
// UtilPlayer.message(getPlayer(), F.main("Carl's Spinner", "You won " + _rewardData.getRarity().getColor() + _rewardData.getFriendlyName() + C.cGray + " from Carl's Spinner."));
// }
// ItemStack item = getInventory().getItem(13);
// getInventory().setItem(13, ItemStackFactory.Instance.CreateStack(item.getType(), (byte) 0, 1, _rewardData.getFriendlyName()));
// _rewarded = true;
//
// }
}

View File

@ -11,7 +11,7 @@ import org.bukkit.plugin.Plugin;
import mineplex.core.common.util.C;
import mineplex.core.gui.GuiItem;
import mineplex.core.reward.RewardManager;
import mineplex.core.treasure.reward.TreasureRewardManager;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.bonuses.BonusClientData;
import mineplex.core.bonuses.BonusManager;
@ -21,9 +21,9 @@ public class CarlSpinButton implements GuiItem
private Plugin _plugin;
private Player _player;
private BonusManager _bonusManager;
private RewardManager _rewardManager;
private TreasureRewardManager _rewardManager;
public CarlSpinButton(Plugin plugin, Player player, BonusManager bonusManager, RewardManager rewardManager)
public CarlSpinButton(Plugin plugin, Player player, BonusManager bonusManager, TreasureRewardManager rewardManager)
{
_plugin = plugin;
_player = player;

View File

@ -33,9 +33,9 @@ import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.treasure.TreasureManager;
import mineplex.core.pet.PetManager;
import mineplex.core.punish.Punish;
import mineplex.core.treasure.TreasureManager;
import mineplex.core.twofactor.TwoFactorAuth;
public class CosmeticManager extends MiniPlugin

View File

@ -18,7 +18,6 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.facebook.command.FacebookCommand;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.treasure.TreasureType;
public class FacebookManager extends MiniDbClientPlugin<FacebookClient>
{
@ -85,7 +84,7 @@ public class FacebookManager extends MiniDbClientPlugin<FacebookClient>
boolean completed = _repository.activateCode(code, accountId);
if (completed)
{
_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 10);
//_inventoryManager.addItemToInventory(player, TreasureType.ANCIENT.getItemName(), 10);
message(player, "Thanks! You earned " + F.elem("10 Ancient Chests"));
player.playSound(player.getLocation(), Sound.NOTE_PIANO, 1f, 1f);
//_donationManager.RewardCoinsLater(getName(), player, 20000);

View File

@ -25,6 +25,8 @@ import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.permissions.Permission;
import mineplex.core.account.permissions.PermissionGroup;
@ -309,8 +311,8 @@ import mineplex.core.pet.PetManager;
import mineplex.core.pet.custom.CustomPet;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.treasure.TreasureManager;
@ReflectivelyCreateMiniPlugin
public class GadgetManager extends MiniPlugin
{
@ -349,7 +351,6 @@ public class GadgetManager extends MiniPlugin
private final OutfitWindUpSuitBoosterManager _boosterManager;
private final IncognitoManager _incognitoManager;
private final GameCosmeticManager _gameCosmeticManager;
private TreasureManager _treasureManager;
private SoulManager _soulManager;
private CastleManager _castleManager;
@ -370,30 +371,27 @@ public class GadgetManager extends MiniPlugin
private Set<Entity> _gadgetCollideWhitelist = new HashSet<>();
public GadgetManager(CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
PetManager petManager, PreferencesManager preferencesManager, DisguiseManager disguiseManager,
BlockRestore blockRestore, ProjectileManager projectileManager, AchievementManager achievementManager,
PacketHandler packetHandler, HologramManager hologramManager, IncognitoManager incognitoManager, CastleManager castleManager)
private GadgetManager()
{
super("Gadget");
_clientManager = clientManager;
_donationManager = donationManager;
_inventoryManager = inventoryManager;
_petManager = petManager;
_preferencesManager = preferencesManager;
_disguiseManager = disguiseManager;
_blockRestore = blockRestore;
_projectileManager = projectileManager;
_achievementManager = achievementManager;
_packetManager = packetHandler;
_hologramManager = hologramManager;
_clientManager = require(CoreClientManager.class);
_donationManager = require(DonationManager.class);
_inventoryManager = require(InventoryManager.class);
_petManager = require(PetManager.class);
_preferencesManager = require(PreferencesManager.class);
_disguiseManager = require(DisguiseManager.class);
_blockRestore = require(BlockRestore.class);
_projectileManager = require(ProjectileManager.class);
_achievementManager = require(AchievementManager.class);
_packetManager = require(PacketHandler.class);
_hologramManager = require(HologramManager.class);
_userGadgetPersistence = new UserGadgetPersistence(this);
_boosterManager = new OutfitWindUpSuitBoosterManager(this);
_incognitoManager = incognitoManager;
_incognitoManager = require(IncognitoManager.class);
_gameCosmeticManager = require(GameCosmeticManager.class);
_soulManager = new SoulManager();
_castleManager = castleManager;
_castleManager = require(CastleManager.class);
createGadgets();
createSets();
@ -1537,16 +1535,6 @@ public class GadgetManager extends MiniPlugin
}
}
public void setTreasureManager(TreasureManager treasureManager)
{
_treasureManager = treasureManager;
}
public TreasureManager getTreasureManager()
{
return _treasureManager;
}
public SoulManager getSoulManager()
{
return _soulManager;

View File

@ -2,7 +2,7 @@ package mineplex.core.gadget.gadgets.gamemodifiers.moba.emblems;
import org.bukkit.Material;
import mineplex.core.reward.RewardRarity;
import mineplex.core.treasure.reward.RewardRarity;
public enum EmblemType
{

View File

@ -25,7 +25,7 @@ import mineplex.core.disguise.disguises.DisguiseSnowman;
import mineplex.core.disguise.disguises.DisguiseSpider;
import mineplex.core.disguise.disguises.DisguiseWitch;
import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.reward.RewardRarity;
import mineplex.core.treasure.reward.RewardRarity;
public enum ShopMorphType
{

View File

@ -19,7 +19,7 @@ import mineplex.core.gadget.types.GameModifierGadget;
import mineplex.core.gadget.util.CostConstants;
import mineplex.core.game.GameDisplay;
import mineplex.core.google.GoogleSheetsManager;
import mineplex.core.reward.RewardRarity;
import mineplex.core.treasure.reward.RewardRarity;
public class HeroSkinGadget extends GameModifierGadget
{

View File

@ -1,8 +1,7 @@
package mineplex.core.gadget.gadgets.gamemodifiers.moba.skins;
import mineplex.core.common.skin.SkinData;
import mineplex.core.gadget.gadgets.gamemodifiers.moba.skins.HeroSkinGadget;
import mineplex.core.reward.RewardRarity;
import mineplex.core.treasure.reward.RewardRarity;
public class HeroSkinGadgetData
{

View File

@ -3,7 +3,6 @@ package mineplex.core.gadget.gadgets.item;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
@ -34,8 +33,8 @@ import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.pet.PetType;
import mineplex.core.recharge.Recharge;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.treasure.reward.RewardRarity;
public class ItemCoal extends ItemGadget
{
@ -132,10 +131,7 @@ public class ItemCoal extends ItemGadget
Recharge.Instance.use(player, getName(), 30000, true, true);
PetReward reward = new PetReward(
Manager.getPetManager(),
Manager.getInventoryManager(),
Manager.getDonationManager(),
"Coal Apparition", "Coal Apparition", PetType.PIG_ZOMBIE, RewardRarity.OTHER, 0, 0);
"Coal Apparition", PetType.PIG_ZOMBIE, RewardRarity.LEGENDARY, 0);
if (reward.canGiveReward(player))
reward.giveReward(null, player, new Callback<RewardData>()

View File

@ -102,23 +102,23 @@ public class MorphWitch extends MorphGadget
return;
}
// Checks if player is opening a treasure chest/close to a treasure area
if (Manager.getTreasureManager() != null)
{
if (Manager.getTreasureManager().isOpening(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
return;
}
for (Location blockLocation : Manager.getTreasureManager().getBlockLocations())
{
if (blockLocation.distanceSquared(cauldronLocation) <= 25)
{
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
return;
}
}
}
// // Checks if player is opening a treasure chest/close to a treasure area
// if (Manager.getTreasureManager() != null)
// {
// if (Manager.getTreasureManager().isOpening(event.getPlayer()))
// {
// UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
// return;
// }
// for (Location blockLocation : Manager.getTreasureManager().getBlockLocations())
// {
// if (blockLocation.distanceSquared(cauldronLocation) <= 25)
// {
// UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
// return;
// }
// }
// }
// Checks if the player is close to a cactus
for (int x = -3; x < 3; x++)

View File

@ -9,7 +9,6 @@ import java.util.UUID;
import org.bukkit.Color;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -126,29 +125,29 @@ public class OutfitFreezeSuit extends OutfitGadget
Map<Block, Double> blocks = UtilBlock.getInRadius(player.getLocation(), RANGE);
boolean setBlocks = true, forceBreak = false;
//boolean setBlocks = true, forceBreak = false;
for (Block block : blocks.keySet())
{
if (Manager.getTreasureManager() != null)
{
if (Manager.getTreasureManager().isOpening(player))
{
forceBreak= true;
}
for (Location blockLocation : Manager.getTreasureManager().getBlockLocations())
{
if (blockLocation.distanceSquared(block.getLocation()) <= 25)
{
setBlocks = false;
}
}
}
if (forceBreak)
break;
if (!setBlocks)
continue;
// if (Manager.getTreasureManager() != null)
// {
// if (Manager.getTreasureManager().isOpening(player))
// {
// forceBreak= true;
// }
// for (Location blockLocation : Manager.getTreasureManager().getBlockLocations())
// {
// if (blockLocation.distanceSquared(block.getLocation()) <= 25)
// {
// setBlocks = false;
// }
// }
// }
// if (forceBreak)
// break;
//
// if (!setBlocks)
// continue;
Manager.getBlockRestore().snow(block, (byte) 1, (byte) 1, (int) (DURATION * (1 + blocks.get(block))), 250, 0);
}

View File

@ -1,96 +0,0 @@
package mineplex.core.globalpacket;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.permissions.Permission;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.globalpacket.command.GlobalPacketCommand;
import mineplex.core.globalpacket.listeners.GlobalGiveCoins;
import mineplex.core.globalpacket.listeners.GlobalGiveGems;
import mineplex.core.globalpacket.listeners.GlobalGiveItem;
import mineplex.core.globalpacket.redis.GlobalPacketHandler;
import mineplex.core.globalpacket.redis.GlobalPacketMessage;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.RewardManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import mineplex.serverdata.commands.ServerCommandManager;
public class GlobalPacketManager extends MiniPlugin
{
public enum Perm implements Permission
{
GLOBAL_PACKET_COMMAND,
}
private CoreClientManager _clientManager;
private ServerStatusManager _statusManager;
private InventoryManager _inventoryManager;
private DonationManager _donationManager;
private RewardManager _rewardManager;
public GlobalPacketManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, InventoryManager inventoryManager, DonationManager donationManager, PetManager petManager, StatsManager statsManager, RewardManager rewardmanager)
{
super("Global Packet Manager", plugin);
_clientManager = clientManager;
_statusManager = statusManager;
_inventoryManager = inventoryManager;
_donationManager = donationManager;
_rewardManager = rewardmanager;
ServerCommandManager.getInstance().registerCommandType("GlobalPacketMessage", GlobalPacketMessage.class, new GlobalPacketHandler(statusManager));
getPluginManager().registerEvents(new GlobalGiveItem(inventoryManager, _rewardManager), getPlugin());
getPluginManager().registerEvents(new GlobalGiveGems(donationManager), getPlugin());
getPluginManager().registerEvents(new GlobalGiveCoins(donationManager, clientManager), getPlugin());
generatePermissions();
}
private void generatePermissions()
{
PermissionGroup.ADMIN.setPermission(Perm.GLOBAL_PACKET_COMMAND, true, true);
}
public void callGlobalCommand(Player caller, String[] args)
{
String callerName = null;
UUID callerUUID = null;
List<String> callerRanks = null;
if (caller != null)
{
callerName = caller.getName();
callerUUID = caller.getUniqueId();
callerRanks = _clientManager.Get(caller).getAdditionalGroups().stream().map(PermissionGroup::name).collect(Collectors.toList());
callerRanks.add(_clientManager.Get(caller).getPrimaryGroup().name());
UtilPlayer.message(caller, F.main("Global", "Sending Global Command with Arguments;"));
UtilPlayer.message(caller, F.main("Global", F.elem(Arrays.toString(args))));
UtilPlayer.message(caller, F.main("Global", "Please be patient for a response."));
}
GlobalPacketMessage message = new GlobalPacketMessage(callerName, callerUUID, callerRanks, _statusManager.getCurrentServerName(), args);
message.publish();
}
@Override
public void addCommands()
{
addCommand(new GlobalPacketCommand(this));
}
}

View File

@ -1,29 +0,0 @@
package mineplex.core.globalpacket.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.globalpacket.GlobalPacketManager;
public class GlobalPacketCommand extends CommandBase<GlobalPacketManager>
{
public GlobalPacketCommand(GlobalPacketManager plugin)
{
super(plugin, GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND, "global", "globalpacket");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null || args.length < 1)
{
UtilPlayer.message(caller, F.main("Global", "Please call the global command with at least 1 argument"));
UtilPlayer.message(caller, F.main("Global", "For help please see /global google doc"));
return;
}
Plugin.callGlobalCommand(caller, args);
}
}

View File

@ -1,82 +0,0 @@
package mineplex.core.globalpacket.event;
import java.util.List;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class GlobalPacketEvent extends Event
{
private Player _caller;
private String _callerName;
private UUID _callerUUID;
private List<String> _callerGroups;
private String _sourceServer;
private String[] _parts;
public GlobalPacketEvent(Player caller, String callerName, UUID callerUUID, List<String> callerGroups, String sourceServer, String[] parts)
{
_caller = caller;
_callerName = callerName;
_callerUUID = callerUUID;
_callerGroups = callerGroups;
_sourceServer = sourceServer;
_parts = parts;
}
/**
* The player that executed this global command.
* This player will be NULL when called on the servers that aren't _sourceServer
*/
public Player getCaller()
{
return _caller;
}
/**
* The player name of the player that called the command
*/
public String getCallerName()
{
return _callerName;
}
/**
* The UUID of the player that called the command
*/
public UUID getCallerUUID()
{
return _callerUUID;
}
/**
* Get the rank of the player that called this global command
*/
public List<String> getCallerGroups()
{
return _callerGroups;
}
/**
* The server name that this global command came from
*/
public String getSourceServer()
{
return _sourceServer;
}
/**
* Get the unprocessed parts of this command
*/
public String[] getParts()
{
return _parts;
}
// Bukkit event stuff
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { return handlers; }
public HandlerList getHandlers() { return handlers; }
}

View File

@ -1,93 +0,0 @@
package mineplex.core.globalpacket.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.globalpacket.GlobalPacketManager;
import mineplex.core.globalpacket.event.GlobalPacketEvent;
public class GlobalGiveCoins implements Listener
{
private DonationManager _donationManager;
private CoreClientManager _clientManager;
public GlobalGiveCoins(DonationManager donationManager, CoreClientManager coreClientManager)
{
_donationManager = donationManager;
_clientManager = coreClientManager;
}
@EventHandler
public void giveCoins(final GlobalPacketEvent e)
{
boolean allowed = false;
for (String id : e.getCallerGroups())
{
if (PermissionGroup.valueOf(id).hasPermission(GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND))
{
allowed = true;
break;
}
}
if (!allowed)
{
return;
}
if (e.getParts() == null || e.getParts().length < 1)
return;
if (!e.getParts()[0].equalsIgnoreCase("givecoins"))
return;
if (e.getParts().length != 2)
{
if (e.getCaller() != null)
{
UtilPlayer.message(e.getCaller(), F.main("Global", "/global givecoins <amount>"));
}
return;
}
int amount = 1;
try
{
amount = Integer.parseInt(e.getParts()[1]);
}
catch (Exception ex)
{
// No number
if (e.getCaller() != null)
{
UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(amount + "") + "] is not a valid amount."));
}
return;
}
final int fAmount = amount;
for (final Player p : UtilServer.getPlayers())
{
_donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, p, "Global Coins", amount, response ->
{
if (response)
{
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " Coins") + "."));
UtilTextMiddle.display(C.cYellow + fAmount + " Coins", C.cGold + "received from " + e.getCallerName() + "!", p);
}
});
}
}
}

View File

@ -1,87 +0,0 @@
package mineplex.core.globalpacket.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.globalpacket.GlobalPacketManager;
import mineplex.core.globalpacket.event.GlobalPacketEvent;
public class GlobalGiveGems implements Listener
{
private DonationManager _donationManager;
public GlobalGiveGems(DonationManager donationManager)
{
_donationManager = donationManager;
}
@EventHandler
public void giveGems(final GlobalPacketEvent e)
{
boolean allowed = false;
for (String id : e.getCallerGroups())
{
if (PermissionGroup.valueOf(id).hasPermission(GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND))
{
allowed = true;
break;
}
}
if (!allowed)
{
return;
}
if (e.getParts() == null || e.getParts().length < 1)
return;
if (!e.getParts()[0].equalsIgnoreCase("givegems"))
return;
if (e.getParts().length != 2)
{
if (e.getCaller() != null)
{
UtilPlayer.message(e.getCaller(), F.main("Global", "/global givegems <amount>"));
}
return;
}
int amount = 1;
try
{
amount = Integer.parseInt(e.getParts()[1]);
}
catch (Exception ex)
{
// No number
if (e.getCaller() != null)
{
UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(amount + "") + "] is not a valid amount."));
}
return;
}
final int fAmount = amount;
for (final Player p : UtilServer.getPlayers())
{
_donationManager.rewardCurrency(GlobalCurrency.GEM, p, "Global Gems", amount, success ->
{
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " Gems") + "."));
UtilTextMiddle.display(C.cYellow + fAmount + " Gems", C.cGold + "received from " + e.getCallerName() + "!", p);
});
}
}
}

View File

@ -1,159 +0,0 @@
package mineplex.core.globalpacket.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.globalpacket.GlobalPacketManager;
import mineplex.core.globalpacket.event.GlobalPacketEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardType;
public class GlobalGiveItem implements Listener
{
private InventoryManager _inventoryManager;
private RewardManager _rewardManager;
public GlobalGiveItem(InventoryManager inventoryManager, RewardManager rewardManager)
{
_inventoryManager = inventoryManager;
_rewardManager = rewardManager;
}
public enum GlobalItem
{
OLD_CHEST("Old Chest"),
ANCIENT_CHEST("Ancient Chest"),
MYTHICAL_CHEST("Mythical Chest"),
GAME_LOOT("Game Loot");
private String _invName;
GlobalItem(String invName)
{
_invName = invName;
}
public String getInvName()
{
return _invName;
}
}
@EventHandler
public void giveItem(final GlobalPacketEvent e)
{
boolean allowed = false;
for (String id : e.getCallerGroups())
{
if (PermissionGroup.valueOf(id).hasPermission(GlobalPacketManager.Perm.GLOBAL_PACKET_COMMAND))
{
allowed = true;
break;
}
}
if (!allowed)
{
return;
}
if (e.getParts() == null || e.getParts().length < 1)
return;
if (!e.getParts()[0].equalsIgnoreCase("giveitem"))
return;
if (e.getParts().length != 3)
{
if (e.getCaller() != null)
{
UtilPlayer.message(e.getCaller(), F.main("Global", "/global giveitem <item> <amount>"));
}
return;
}
GlobalItem item = null;
try
{
item = GlobalItem.valueOf(e.getParts()[1]);
}
catch (Exception ex)
{
// Wrong item
if (e.getCaller() != null)
{
UtilPlayer.message(e.getCaller(), F.main("Global", "That GlobalItem type can't be found. Types:"));
String list = "";
for (GlobalItem i : GlobalItem.values())
{
list += i.toString() + " ";
}
UtilPlayer.message(e.getCaller(), C.cYellow + list);
}
return;
}
int amount = 1; // Default, shouldn't happen anyway.
try
{
amount = Integer.parseInt(e.getParts()[2]);
}
catch (Exception ex)
{
// Not a number
if (e.getCaller() != null)
{
UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(e.getParts()[2]) + "] is not a valid number."));
}
return;
}
if (item.toString().contains("CHEST"))
{
for (final Player p : UtilServer.getPlayers())
{
final int fAmount = amount;
final GlobalItem fItem = item;
_inventoryManager.addItemToInventory(data ->
{
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " " + fItem.getInvName() + "(s)") + " from " + F.name(e.getCallerName()) + "."));
UtilTextMiddle.display(C.cYellow + fAmount + " " + fItem.getInvName() + "(s)", C.cGold + "received from " + e.getCallerName() + "!", p);
}, p, item.getInvName(), amount);
}
return;
}
else if (item.toString().equalsIgnoreCase("GAME_LOOT"))
{
for (final Player p : UtilServer.getPlayers())
{
Reward reward = _rewardManager.nextReward(p, null, false, RewardType.GAME_LOOT, true);
reward.giveReward(RewardType.GAME_LOOT, p, data ->
{
UtilPlayer.message(p, F.main("Global", "You received " + F.elem("Game Loot") + " from " + F.name(e.getCallerName()) + "."));
UtilPlayer.message(p, F.main("Global", "You won " + F.elem(data.getFriendlyName()) + "!"));
UtilTextMiddle.display(C.cYellow + data.getFriendlyName(), C.cGold + "received from " + e.getCallerName() + "!", p);
});
}
}
}
}

View File

@ -1,39 +0,0 @@
package mineplex.core.globalpacket.redis;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.globalpacket.event.GlobalPacketEvent;
import mineplex.core.status.ServerStatusManager;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class GlobalPacketHandler implements CommandCallback
{
private ServerStatusManager _serverStatus;
public GlobalPacketHandler(ServerStatusManager serverStatus)
{
_serverStatus = serverStatus;
}
@Override
public void run(ServerCommand command)
{
if (command instanceof GlobalPacketMessage)
{
GlobalPacketMessage packetMessage = ((GlobalPacketMessage) command);
Player caller = null;
if (packetMessage.getSourceServer() != null && packetMessage.getSourceServer().equals(_serverStatus.getCurrentServerName()))
{
caller = UtilPlayer.searchExact(packetMessage.getCallerUUID());
}
GlobalPacketEvent event = new GlobalPacketEvent(caller, packetMessage.getCallerName(), packetMessage.getCallerUUID(),
packetMessage.getCallerGroups(), packetMessage.getSourceServer(), packetMessage.getParts());
UtilServer.getServer().getPluginManager().callEvent(event);
}
}
}

View File

@ -1,49 +0,0 @@
package mineplex.core.globalpacket.redis;
import java.util.List;
import java.util.UUID;
import mineplex.serverdata.commands.ServerCommand;
public class GlobalPacketMessage extends ServerCommand
{
private String _callerName;
private UUID _callerUUID;
private List<String> _callerGroups;
private String _sourceServer;
private String[] _parts;
public GlobalPacketMessage(String callerName, UUID callerUUID, List<String> callerGroups, String sourceServer, String[] parts)
{
_callerName = callerName;
_callerUUID = callerUUID;
_callerGroups = callerGroups;
_sourceServer = sourceServer;
_parts = parts;
}
public String getCallerName()
{
return _callerName;
}
public UUID getCallerUUID()
{
return _callerUUID;
}
public List<String> getCallerGroups()
{
return _callerGroups;
}
public String getSourceServer()
{
return _sourceServer;
}
public String[] getParts()
{
return _parts;
}
}

View File

@ -10,7 +10,10 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EntityEquipment;
import mineplex.core.Managers;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.serverdata.database.column.Column;
import mineplex.serverdata.database.column.ColumnDouble;
@ -20,6 +23,8 @@ import mineplex.serverdata.database.column.ColumnVarChar;
public class NPC
{
private final HologramManager HOLOGRAM_MANAGER = Managers.require(HologramManager.class);
private int _id;
protected EntityType _entityType;
protected String _name;
@ -32,6 +37,7 @@ public class NPC
private String _metadata;
private LivingEntity _entity;
private Hologram _nameTag;
public NPC(int id, EntityType entityType, String name, Location spawn, Material inHand, Material helmet, Material chestplate, Material leggings, Material boots, String metadata)
{
@ -51,11 +57,12 @@ public class NPC
{
_spawn.getChunk().load(true);
LivingEntity entity = (LivingEntity) _spawn.getWorld().spawnEntity(_spawn, _entityType);
boolean nullName = _name.equals("NULL");
entity.setCanPickupItems(false);
entity.setRemoveWhenFarAway(false);
entity.setCustomName(ChatColor.translateAlternateColorCodes('&', _name));
entity.setCustomNameVisible(!_name.equals("NULL"));
entity.setCustomName(nullName ? null : ChatColor.translateAlternateColorCodes('&', _name));
entity.setCustomNameVisible(!nullName);
EntityEquipment equipment = entity.getEquipment();
@ -90,6 +97,20 @@ public class NPC
return entity;
}
public Hologram getNameTag()
{
if (_nameTag == null)
{
_nameTag = new Hologram(HOLOGRAM_MANAGER, _entity.getLocation().add(0, UtilEnt.getHeight(_entity), 0), true, _entity.getCustomName())
.start();
_entity.setCustomNameVisible(false);
_entity.setCustomName(null);
}
return _nameTag;
}
void setId(int id)
{
_id = id;

View File

@ -3,14 +3,17 @@ package mineplex.core.reward;
import org.bukkit.inventory.ItemStack;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.treasure.reward.RewardRarity;
public class RankRewardData extends RewardData
{
private PermissionGroup _rank;
private final PermissionGroup _rank;
public RankRewardData(String friendlyName, ItemStack displayItem, RewardRarity rarity, PermissionGroup rank)
{
super(null, friendlyName, displayItem, rarity);
_rank = rank;
}

View File

@ -4,26 +4,33 @@ import java.util.Random;
import org.bukkit.entity.Player;
import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.Callback;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.treasure.reward.RewardRarity;
public abstract class Reward
{
protected static final CoreClientManager CLIENT_MANAGER = Managers.require(CoreClientManager.class);
protected static final DonationManager DONATION_MANAGER = Managers.require(DonationManager.class);
protected static final InventoryManager INVENTORY_MANAGER = Managers.require(InventoryManager.class);
protected static final Random RANDOM = new Random();
private RewardRarity _rarity;
private int _weight;
private int _shardValue;
private boolean _requiresCallback;
public Reward(RewardRarity rarity, int weight, int shardValue)
public Reward(RewardRarity rarity, int shardValue)
{
this(rarity, weight, shardValue, false);
this(rarity, shardValue, false);
}
public Reward(RewardRarity rarity, int weight, int shardValue, boolean requiresCallback)
public Reward(RewardRarity rarity, int shardValue, boolean requiresCallback)
{
_rarity = rarity;
_weight = weight;
_shardValue = shardValue;
_requiresCallback = requiresCallback;
}
@ -31,9 +38,13 @@ public abstract class Reward
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)
@ -52,18 +63,8 @@ public abstract class Reward
return _rarity;
}
public int getWeight()
{
return _weight;
}
public int getShardValue()
{
return _shardValue;
}
public boolean isRequiresCallback()
{
return _requiresCallback;
}
}

View File

@ -2,6 +2,8 @@ package mineplex.core.reward;
import org.bukkit.inventory.ItemStack;
import mineplex.core.treasure.reward.RewardRarity;
public class RewardData
{
private final String _header;

View File

@ -1,124 +0,0 @@
package mineplex.core.reward;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import org.bukkit.entity.Player;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.TreasureShardReward;
import mineplex.core.reward.rewards.UnknownPackageReward;
/**
* Used to separate different "Reward Pools". This allows us to have treasure chests with different loot.
*
*/
public class RewardPool
{
private EnumMap<RewardRarity, List<Reward>> _rewardMap;
public RewardPool()
{
_rewardMap = new EnumMap<RewardRarity, List<Reward>>(RewardRarity.class);
for (RewardRarity rarity : RewardRarity.values())
{
_rewardMap.put(rarity, new ArrayList<Reward>());
}
}
public void add(Reward reward)
{
_rewardMap.get(reward.getRarity()).add(reward);
}
public List<Reward> getRewards(RewardRarity rarity)
{
return _rewardMap.get(rarity);
}
public boolean hasItemsToGive(RewardRarity rarity, Player player)
{
for(Reward r : getRewards(rarity))
{
if(r.canGiveReward(player)) return true;
}
return false;
}
public static enum Type
{
NORMAL(true),
WINTER_HOLIDAY(true),
VALENTINES_GIFT(false),
ILLUMINATED(false, 1),
FREEDOM(false, 1),
OMEGA(false, 1),
HAUNTED(false, 1),
TRICK_OR_TREAT(false),
INFUSED_CHESTS(false),
INFUSED_GADGETS(true),
MYTHICAL(true),
THANKFUL(false),
GINGERBREAD(false, 1),
MINESTRIKE(true, 2),
LOVECHEST(false, 1),
STPATRICKS(false, 1),
SPRING(false, 1),
MOBA(true),
CARL_SPINNER(true);
private boolean _useDuplicates;
private int _chestAmount;
Type(boolean useDuplicates, int amount)
{
_useDuplicates = useDuplicates;
_chestAmount = amount;
}
Type(boolean useDuplicates)
{
this(useDuplicates, 4);
}
public boolean getUseDuplicates()
{
return _useDuplicates;
}
public int getChestAmount()
{
return _chestAmount;
}
public boolean canGive(Player player, Reward reward)
{
if(this == Type.ILLUMINATED)
{
if(reward instanceof InventoryReward)
{
return false;
}
}
if (this == OMEGA)
{
if (reward instanceof InventoryReward || reward instanceof TreasureShardReward)
{
return false;
}
else if (reward instanceof UnknownPackageReward)
{
UnknownPackageReward unknownPackageReward = (UnknownPackageReward) reward;
if (unknownPackageReward.getHeader().equalsIgnoreCase("Game Modifiers"))
{
return false;
}
}
}
return true;
}
}
}

View File

@ -1,77 +0,0 @@
package mineplex.core.reward;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.common.util.C;
import static mineplex.core.common.util.C.*;
public enum RewardRarity
{
/**
* This will probably be used to figure out what effects are shown when the chest is opened
*
* (Fireworks, sounds, etc)
*/
OTHER("Other", cWhite, C.cGray, Material.STAINED_GLASS_PANE, (byte) 0),
COMMON("Common", cWhite, C.cGray, Material.STAINED_GLASS_PANE, (byte) 0),
GAME("Game", cYellow, C.cYellow, Material.STAINED_GLASS_PANE, (byte) 4),
UNCOMMON("Uncommon", cAqua, C.cDAqua, Material.STAINED_GLASS_PANE, (byte) 3),
RARE("Rare", cPurple, C.cDPurple, Material.STAINED_GLASS_PANE, (byte) 10),
LEGENDARY("Legendary", cGreen, C.cDGreen, Material.STAINED_GLASS_PANE, (byte) 5),
MYTHICAL("Mythical", cRed, C.cDRed, Material.STAINED_GLASS_PANE, (byte) 14);
private String _name;
private String _color;
private String _darkColor;
private Material _material;
private byte _data;
private ItemStack _stack;
RewardRarity(String name, String color, String darkColor, Material material, byte data)
{
_name = name;
_color = color;
_darkColor = darkColor;
_material = material;
_data = data;
_stack = new ItemStack(getMaterial(), 1, (short) 0, getData());
ItemMeta meta = _stack.getItemMeta();
meta.setDisplayName(_color + _name);
_stack.setItemMeta(meta);
}
public String getColor()
{
return _color;
}
public String getDarkColor()
{
return _darkColor;
}
public String getName()
{
return _name;
}
public Material getMaterial()
{
return _material;
}
public byte getData()
{
return _data;
}
public ItemStack getItemStack()
{
return _stack;
}
}

View File

@ -1,96 +1,79 @@
package mineplex.core.reward;
import java.util.ArrayList;
import mineplex.core.treasure.reward.RewardRarity;
public enum RewardType
{
//% Chances Mythic Legend Rare Uncommon
GAME_LOOT( 0.000001, 0.00001, 0.0001, 3),
//% Chances Mythic Legend Rare Uncommon Common
GAME_LOOT( 0.000001, 0.00001, 0.0001, 3, 0),
OLD_CHEST( 0, 0.06, 0.8, 16),
ANCIENT_CHEST( 0, 2, 8, 32),
MYTHICAL_CHEST( 0.1, 4, 16, 72),
WINTER_CHEST( 0, 5, 18, 32),
ILLUMINATED_CHEST( 0, 2, 16, 72),
FREEDOM_CHEST( 0, 5, 18, 0),
HAUNTED_CHEST( 0, 5, 18, 0),
OMEGA_CHEST( 0, 32, 16, 2),
TRICK_OR_TREAT_CHEST(0.1, 2, 16, 0),
THANKFUL_CHEST( 0.1, 2, 16, 0),
GINGERBREAD_CHEST( 0, 2, 16, 0),
MINESTRIKE_CHEST( 0, 2, 16, 0),
LOVE_CHEST( 0, 6, 18, 0),
VALENTINES_GIFT( 0, 7, 20, 20),
ST_PATRICKS( 0, 6, 18, 0),
SPRING( 0, 6, 18, 0),
MOBA( 0, 5, 20, 30),
OLD_CHEST( 0, 0.06, 0.8, 16, 40),
ANCIENT_CHEST( 0, 2, 8, 32, 0),
MYTHICAL_CHEST( 0.1, 4, 16, 72, 0),
WINTER_CHEST( 0, 5, 18, 32, 0),
ILLUMINATED_CHEST( 0, 2, 16, 72, 0),
FREEDOM_CHEST( 0, 5, 18, 0, 0),
HAUNTED_CHEST( 0, 5, 18, 0, 0),
OMEGA_CHEST( 0, 32, 16, 2, 0),
TRICK_OR_TREAT_CHEST(0.1, 2, 16, 0, 0),
THANKFUL_CHEST( 0.1, 2, 16, 0, 0),
GINGERBREAD_CHEST( 0, 2, 16, 0, 0),
MINESTRIKE_CHEST( 0, 2, 16, 0, 0),
LOVE_CHEST( 0, 6, 18, 0, 0),
VALENTINES_GIFT( 0, 7, 20, 20, 0),
ST_PATRICKS( 0, 6, 18, 0, 0),
SPRING( 0, 6, 18, 0, 0),
MOBA( 0, 5, 20, 30, 0),
SPINNER_FILLER( 0.1, 1, 4, 20),
SPINNER_REAL( 0.000001, 0.05, 0.4, 5);
SPINNER_FILLER( 0.1, 1, 4, 20, 30),
SPINNER_REAL( 0.000001, 0.05, 0.4, 5, 20);
private double _mythicalChance;
private double _legendaryChance;
private double _rareChance;
private double _uncommonChance;
private final Rarity[] _rarities;
RewardType(double mythical, double legend, double rare, double uncommon)
RewardType(double mythical, double legend, double rare, double uncommon, double common)
{
_mythicalChance = (mythical / 100d);
_legendaryChance = _mythicalChance + (legend / 100d); //Add previous chance to prep for generateRarity random values.
_rareChance = _legendaryChance + (rare / 100d);
_uncommonChance = _rareChance + (uncommon / 100d);
_rarities = new Rarity[]
{
new Rarity(RewardRarity.MYTHICAL, mythical),
new Rarity(RewardRarity.LEGENDARY, legend),
new Rarity(RewardRarity.RARE, rare),
new Rarity(RewardRarity.UNCOMMON, uncommon),
new Rarity(RewardRarity.COMMON, common)
};
}
public RewardRarity generateRarity(boolean requiresUncommon)
public RewardRarity generateRarity()
{
double rand = Math.random();
double totalRoll = 0;
RewardRarity rarity = RewardRarity.COMMON;
for (Rarity rarity : _rarities)
{
totalRoll += rarity.Chance;
}
if (rand <= _mythicalChance) rarity = RewardRarity.MYTHICAL;
else if (rand <= _legendaryChance) rarity = RewardRarity.LEGENDARY;
else if (rand <= _rareChance) rarity = RewardRarity.RARE;
else if (rand <= _uncommonChance || requiresUncommon) rarity = RewardRarity.UNCOMMON;
double roll = Math.random() * totalRoll;
return rarity;
for (Rarity rarity : _rarities)
{
if ((roll -= rarity.Chance) < 0)
{
return rarity.RewardRarity;
}
}
return null;
}
public static void main(String[] args)
private class Rarity
{
int maxCount = Integer.MAX_VALUE;
int openCount = 0;
RewardType type = RewardType.MYTHICAL_CHEST;
ArrayList<RewardTest> data = new ArrayList<RewardTest>();
for (RewardRarity rarity : RewardRarity.values())
RewardRarity RewardRarity;
double Chance;
public Rarity(RewardRarity rewardRarity, double chance)
{
data.add(rarity.ordinal(), new RewardTest(rarity));
}
for (int i = 0; i < maxCount; i++)
{
RewardRarity rarity = type.generateRarity(false);
data.get(rarity.ordinal()).Count++;
openCount++;
if (rarity == RewardRarity.MYTHICAL) break;
}
System.out.printf("Opened %10d rewards using type " + type.name() + "\n", openCount);
for (RewardTest test : data)
{
System.out.printf("Opened %10d of reward type %10s", test.Count, test.Rarity.name());
System.out.println();
}
}
private static class RewardTest
{
public final RewardRarity Rarity;
public int Count;
public RewardTest(RewardRarity rare)
{
Rarity = rare;
RewardRarity = rewardRarity;
Chance = chance;
}
}
}

View File

@ -1,80 +1,26 @@
package mineplex.core.reward.rewards;
import java.util.Random;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.treasure.types.Treasure;
import mineplex.core.treasure.types.TreasureType;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.treasure.TreasureType;
public class ChestReward extends Reward
public class ChestReward extends InventoryReward
{
private Random _random;
private InventoryManager _inventoryManager;
private int _max, _min;
private TreasureType _type;
public ChestReward(InventoryManager inventoryManager, TreasureType type, int min, int max, RewardRarity rarity, int weight, int shardValue)
public ChestReward(TreasureType type, RewardRarity rarity, int shardValue)
{
this(RANDOM, inventoryManager, type, min, max, rarity, weight, shardValue);
this(type, 1, rarity, shardValue);
}
public ChestReward(Random random, InventoryManager inventoryManager, TreasureType type, int min, int max, RewardRarity rarity, int weight, int shardValue)
public ChestReward(TreasureType type, int amount, RewardRarity rarity, int shardValue)
{
super(rarity, weight, shardValue);
_random = random;
_inventoryManager = inventoryManager;
_max = max;
_min = min;
_type = type;
this(type, amount, amount, rarity, shardValue);
}
@Override
public RewardData giveRewardCustom(Player player, RewardType rewardType)
public ChestReward(TreasureType type, int min, int max, RewardRarity rarity, int shardValue)
{
int amountToGive;
if (_min != _max)
{
amountToGive = _random.nextInt(_max - _min) + _min;
}
else
{
amountToGive = _min;
}
_inventoryManager.addItemToInventory(player, _type.getItemName(), amountToGive);
return new RewardData(getRarity().getDarkColor() + "Treasure Chest", getRarity().getColor() + amountToGive + " " + ChatColor.stripColor(_type.getName()), new ItemStack(_type.getMaterial()), getRarity());
super(type.getName(), type.getItemName(), "Treasure Chest", min, max, type.getItemStack(), rarity, shardValue);
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + "Treasure Chest", getRarity().getColor() + ChatColor.stripColor(_type.getName()), new ItemStack(_type.getMaterial()), getRarity());
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof ChestReward)
{
return ((ChestReward) obj)._type.getName().equals(_type.getName());
}
return false;
}
}

View File

@ -6,24 +6,27 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.stats.StatsManager;
public class ExperienceReward extends Reward
{
private StatsManager _statsManager;
private static final StatsManager STATS_MANAGER = Managers.require(StatsManager.class);
private static final ItemStack ITEM_STACK = new ItemStack(Material.EXP_BOTTLE);
private Random _random;
private int _minExperience;
private int _maxExperience;
public ExperienceReward(StatsManager statsManager, int minExperience, int maxExperience, int weight, int shardValue, RewardRarity rarity)
public ExperienceReward(int minExperience, int maxExperience, int shardValue, RewardRarity rarity)
{
super(rarity, weight, shardValue);
super(rarity, shardValue);
_statsManager = statsManager;
_random = new Random();
_minExperience = minExperience;
_maxExperience = maxExperience;
@ -34,15 +37,15 @@ public class ExperienceReward extends Reward
{
int experience = _random.nextInt(_maxExperience - _minExperience) + _minExperience;
_statsManager.incrementStat(player, "Global.ExpEarned", experience);
STATS_MANAGER.incrementStat(player, "Global.ExpEarned", experience);
return new RewardData(null, getRarity().getColor() + experience + " Experience", new ItemStack(Material.EXP_BOTTLE), getRarity());
return new RewardData(null, getRarity().getColor() + experience + " Experience", ITEM_STACK, getRarity());
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(null, getRarity().getColor() + "Experience", new ItemStack(Material.EXP_BOTTLE), getRarity());
return new RewardData(null, getRarity().getColor() + "Experience", ITEM_STACK, getRarity());
}
@Override

View File

@ -0,0 +1,43 @@
package mineplex.core.reward.rewards;
import org.bukkit.entity.Player;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardType;
public class GadgetReward extends Reward
{
private final Gadget _gadget;
public GadgetReward(Gadget gadget, RewardRarity rarity, int shardValue)
{
super(rarity, shardValue);
_gadget = gadget;
}
@Override
protected RewardData giveRewardCustom(Player player, RewardType rewardType)
{
DONATION_MANAGER.purchaseUnknownSalesPackage(player, _gadget.getName(), GlobalCurrency.TREASURE_SHARD, 0, true, null);
return getFakeRewardData(player);
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + "Gadget", getRarity().getColor() + _gadget.getName(), _gadget.getDisplayItem(), getRarity());
}
@Override
public boolean canGiveReward(Player player)
{
return !_gadget.ownsGadget(player);
}
}

View File

@ -1,78 +1,29 @@
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.boosters.BoosterManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.treasure.reward.RewardRarity;
public class GameAmplifierReward extends Reward
public class GameAmplifierReward extends InventoryReward
{
private Random _random;
private InventoryManager _inventoryManager;
private int _max, _min;
private static final ItemStack ITEM_STACK = new ItemStack(Material.EMERALD);
public GameAmplifierReward(InventoryManager inventoryManager, int min, int max, RewardRarity rarity, int weight, int shardValue)
public GameAmplifierReward(RewardRarity rarity, int shardValue)
{
this(RANDOM, inventoryManager, min, max, rarity, weight, shardValue);
this(1, rarity, shardValue);
}
public GameAmplifierReward(Random random, InventoryManager inventoryManager, int min, int max, RewardRarity rarity, int weight, int shardValue)
public GameAmplifierReward(int amount, RewardRarity rarity, int shardValue)
{
super(rarity, weight, shardValue);
_random = random;
_inventoryManager = inventoryManager;
_max = max;
_min = min;
this(amount, amount, rarity, shardValue);
}
@Override
public RewardData giveRewardCustom(Player player, RewardType rewardType)
public GameAmplifierReward(int min, int max, RewardRarity rarity, int shardValue)
{
int amountToGive;
if (_min != _max)
{
amountToGive = _random.nextInt(_max - _min) + _min;
}
else
{
amountToGive = _min;
}
_inventoryManager.addItemToInventory(player, BoosterManager.BOOSTER_ITEM, amountToGive);
return new RewardData(getRarity().getDarkColor() + "Game Amplifier", getRarity().getColor() + amountToGive + " Game Amplifier", new ItemStack(Material.EMERALD), getRarity());
super("Game Amplifier", BoosterManager.BOOSTER_ITEM, "Game Amplifier", min, max, ITEM_STACK, rarity, shardValue);
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + "Game Amplifier", getRarity().getColor() + "Game Amplifier", new ItemStack(Material.EMERALD), getRarity());
}
@Override
public boolean canGiveReward(Player player)
{
return true;
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof GameAmplifierReward)
{
return true;
}
return false;
}
}

View File

@ -1,49 +1,37 @@
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.currency.GlobalCurrency;
import mineplex.core.common.util.Callback;
import mineplex.core.donation.DonationManager;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
public class GemReward extends Reward
{
private DonationManager _donationManager;
private Random _random;
private int _minGemCount;
private int _maxGemCount;
public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, int shardValue, RewardRarity rarity)
public GemReward(int minGemCount, int maxGemCount, int shardValue, RewardRarity rarity)
{
this(donationManager, minGemCount, maxGemCount, weight, shardValue, rarity, RANDOM);
}
super(rarity, shardValue);
public GemReward(DonationManager donationManager, int minGemCount, int maxGemCount, int weight, int shardValue, RewardRarity rarity, Random random)
{
super(rarity, weight, shardValue);
_donationManager = donationManager;
_minGemCount = minGemCount;
_maxGemCount = maxGemCount;
_random = random;
}
@Override
public RewardData giveRewardCustom(Player player, RewardType rewardType)
{
int GemsToReward = _random.nextInt(_maxGemCount - _minGemCount) + _minGemCount;
int gemsToReward = RANDOM.nextInt(_maxGemCount - _minGemCount) + _minGemCount;
_donationManager.rewardCurrency(GlobalCurrency.GEM, player, "Treasure Chest", GemsToReward);
DONATION_MANAGER.rewardCurrency(GlobalCurrency.GEM, player, "Treasure Chest", gemsToReward);
return new RewardData(null, getRarity().getColor() + GemsToReward + " Gems", new ItemStack(Material.EMERALD), getRarity());
return new RewardData(null, getRarity().getColor() + gemsToReward + " Gems", new ItemStack(Material.EMERALD), getRarity());
}
@Override
@ -61,9 +49,6 @@ public class GemReward extends Reward
@Override
public boolean equals(Object obj)
{
if (obj instanceof GemReward)
return true;
return false;
return obj instanceof GemReward;
}
}

View File

@ -1,46 +1,43 @@
package mineplex.core.reward.rewards;
import java.util.Random;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
/**
* Created by shaun on 14-09-12.
*/
public class InventoryReward extends Reward
{
private Random _random;
private InventoryManager _inventoryManager;
private ItemStack _itemStack;
private String _name;
private String _packageName;
private String _header;
private int _minAmount;
private int _maxAmount;
public InventoryReward(InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue)
public InventoryReward(String name, String packageName, String header, ItemStack itemStack, RewardRarity rarity, int shardValue)
{
this(RANDOM, inventoryManager, name, packageName, minAmount, maxAmount, itemStack, rarity, weight, shardValue);
this(name, packageName, header, 1, itemStack, rarity, shardValue);
}
public InventoryReward(Random random, InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue)
public InventoryReward(String name, String packageName, String header, int amount, ItemStack itemStack, RewardRarity rarity, int shardValue)
{
super(rarity, weight, shardValue);
this(name, packageName, header, amount, amount, itemStack, rarity, shardValue);
}
public InventoryReward(String name, String packageName, String header, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int shardValue)
{
super(rarity, shardValue);
_random = random;
_name = name;
_packageName = packageName;
_header = header;
_minAmount = minAmount;
_maxAmount = maxAmount;
_itemStack = itemStack;
_inventoryManager = inventoryManager;
}
@Override
@ -50,22 +47,27 @@ public class InventoryReward extends Reward
if (_minAmount != _maxAmount)
{
amountToGive = _random.nextInt(_maxAmount - _minAmount) + _minAmount;
amountToGive = RANDOM.nextInt(_maxAmount - _minAmount) + _minAmount;
}
else
{
amountToGive = _minAmount;
}
_inventoryManager.addItemToInventory(player, _packageName, amountToGive);
INVENTORY_MANAGER.addItemToInventory(player, _packageName, amountToGive);
return new RewardData(getRarity().getDarkColor() + "Gadget", getRarity().getColor() + amountToGive + " " + _name, _itemStack, getRarity());
if (amountToGive == 1)
{
return getFakeRewardData(player);
}
return new RewardData(getRarity().getDarkColor() + _header, getRarity().getColor() + amountToGive + " " + _name, _itemStack, getRarity());
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + "Gadget", getRarity().getColor() + _name, _itemStack, getRarity());
return new RewardData(getRarity().getDarkColor() + _header, getRarity().getColor() + _name, _itemStack, getRarity());
}
@Override
@ -82,10 +84,6 @@ public class InventoryReward extends Reward
@Override
public boolean equals(Object obj)
{
if (obj instanceof InventoryReward)
{
return ((InventoryReward) obj).getPackageName().equals(_packageName);
}
return false;
return obj instanceof InventoryReward && ((InventoryReward) obj).getPackageName().equals(_packageName);
}
}

View File

@ -5,31 +5,31 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.cache.player.PlayerCache;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.Managers;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.pet.PetManager;
import mineplex.core.pet.PetType;
import mineplex.core.pet.repository.token.PetChangeToken;
import mineplex.core.pet.repository.token.PetToken;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
/**
* Created by shaun on 14-09-18.
*/
public class PetReward extends UnknownPackageReward
public class PetReward extends Reward
{
private InventoryManager _inventoryManager;
private PetManager _petManager;
private static final PetManager PET_MANAGER = Managers.require(PetManager.class);
private String _packageName;
private ItemStack _itemStack;
private PetType _petType;
public PetReward(PetManager petManager, InventoryManager inventoryManager, DonationManager donationManager, String name, String packageName, PetType petType, RewardRarity rarity, int weight, int shardValue)
public PetReward(String packageName, PetType petType, RewardRarity rarity, int shardValue)
{
super(donationManager, inventoryManager, "Pet", name, packageName, new ItemStack(Material.MONSTER_EGG, 1, petType.getEntityType().getTypeId()), rarity, weight, shardValue);
super(rarity, shardValue);
_petManager = petManager;
_inventoryManager = inventoryManager;
_packageName = packageName;
_itemStack = new ItemStack(Material.MONSTER_EGG, 1, petType.getEntityType().getTypeId());
_petType = petType;
}
@ -38,35 +38,45 @@ public class PetReward extends UnknownPackageReward
{
PetChangeToken token = new PetChangeToken();
if (_inventoryManager.getClientManager().Get(player) != null)
token.AccountId = _inventoryManager.getClientManager().Get(player).getAccountId();
if (INVENTORY_MANAGER.getClientManager().Get(player) != null)
{
token.AccountId = INVENTORY_MANAGER.getClientManager().Get(player).getAccountId();
}
else
{
token.AccountId = PlayerCache.getInstance().getAccountId(player.getUniqueId());
}
token.Name = player.getName();
token.PetType = _petType.toString();
token.PetName = getPackageName();
token.PetName = _packageName;
PetToken petToken = new PetToken();
petToken.PetType = token.PetType;
_petManager.getRepository().AddPet(token);
_petManager.Get(player).getPets().put(_petType, token.PetName);
PET_MANAGER.getRepository().AddPet(token);
PET_MANAGER.Get(player).getPets().put(_petType, token.PetName);
_inventoryManager.addItemToInventory(player, _petType.toString(), 1);
INVENTORY_MANAGER.addItemToInventory(player, _petType.toString(), 1);
return getFakeRewardData(player);
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + "Pet", getRarity().getColor() + _petType.getName(), _itemStack, getRarity());
}
@Override
public boolean canGiveReward(Player player)
{
if (_donationManager.Get(player) == null)
if (DONATION_MANAGER.Get(player) == null)
{
System.out.println("Could not give reward " + getPackageName() + " to Offline Player: " + player.getName());
System.out.println("Could not give reward " + _packageName + " to Offline Player: " + player.getName());
return false;
}
return !_petManager.Get(player).getPets().containsKey(_petType);
return !PET_MANAGER.Get(player).getPets().containsKey(_petType);
}
}

View File

@ -11,10 +11,10 @@ import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.UtilServer;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.powerplayclub.PowerPlayData.SubscriptionDuration;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
public class PowerPlayReward extends Reward
@ -22,9 +22,9 @@ public class PowerPlayReward extends Reward
private CoreClientManager _clientManager;
private SubscriptionDuration _duration;
public PowerPlayReward(CoreClientManager clientManager, SubscriptionDuration duration, RewardRarity rarity, int weight, int shardValue)
public PowerPlayReward(CoreClientManager clientManager, SubscriptionDuration duration, RewardRarity rarity, int shardValue)
{
super(rarity, weight, shardValue);
super(rarity, shardValue);
_clientManager = clientManager;
_duration = duration;
@ -59,10 +59,6 @@ public class PowerPlayReward extends Reward
@Override
public boolean equals(Object obj)
{
if (obj instanceof PowerPlayReward)
{
return true;
}
return false;
return obj instanceof PowerPlayReward;
}
}

View File

@ -1,30 +1,25 @@
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.account.CoreClientManager;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.RankRewardData;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
public class RankReward extends Reward
{
private Random _random;
private CoreClientManager _clientManager;
public RankReward(CoreClientManager clientManager, int weight, int shardValue, RewardRarity rarity)
private static final ItemStack ITEM_STACK = new ItemStack(Material.NETHER_STAR);
private static final ItemStack ITEM_STACK_FAILED = new ItemStack(Material.PAPER);
public RankReward(int shardValue, RewardRarity rarity)
{
super(rarity, weight, shardValue);
_clientManager = clientManager;
_random = new Random();
super(rarity, shardValue);
}
private PermissionGroup getNext(PermissionGroup current, boolean canPassLegend)
@ -64,50 +59,45 @@ public class RankReward extends Reward
@Override
public RewardData giveRewardCustom(Player player, RewardType rewardType)
{
PermissionGroup group = getNext(_clientManager.Get(player).getPrimaryGroup(), rewardType == RewardType.MYTHICAL_CHEST || rewardType == RewardType.TRICK_OR_TREAT_CHEST || rewardType == RewardType.THANKFUL_CHEST);
PermissionGroup group = getNext(CLIENT_MANAGER.Get(player).getPrimaryGroup(), rewardType == RewardType.MYTHICAL_CHEST || rewardType == RewardType.TRICK_OR_TREAT_CHEST || rewardType == RewardType.THANKFUL_CHEST);
if (rewardType == RewardType.MYTHICAL_CHEST && _random.nextDouble() < 0.01) // 1 Percent
if (rewardType == RewardType.MYTHICAL_CHEST && RANDOM.nextDouble() < 0.01) // 1 Percent
{
group = PermissionGroup.ETERNAL;
}
if (group == null)
{
return new RewardData(null, getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER), getRarity());
return new RewardData(null, getRarity().getColor() + "Rank Upgrade Error", ITEM_STACK_FAILED, getRarity());
}
_clientManager.setPrimaryGroup(player, group, () -> {});
CLIENT_MANAGER.setPrimaryGroup(player, group, () -> {});
return new RankRewardData(getRarity().getColor() + group.getDisplay(false, false, false, true) + " Rank", new ItemStack(Material.NETHER_STAR), getRarity(), group);
return new RankRewardData(getRarity().getColor() + group.getDisplay(false, false, false, true) + " Rank", ITEM_STACK, getRarity(), group);
}
@Override
public RewardData getFakeRewardData(Player player)
{
PermissionGroup group = getNext(_clientManager.Get(player).getPrimaryGroup(), true);
PermissionGroup group = getNext(CLIENT_MANAGER.Get(player).getPrimaryGroup(), true);
if (group == null)
{
return new RewardData(null, getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER), getRarity());
return new RewardData(null, getRarity().getColor() + "Rank Upgrade Error", ITEM_STACK_FAILED, getRarity());
}
return new RankRewardData(getRarity().getColor() + group.getDisplay(false, false, false, true) + " Rank", new ItemStack(Material.NETHER_STAR), getRarity(), group);
return new RankRewardData(getRarity().getColor() + group.getDisplay(false, false, false, true) + " Rank", ITEM_STACK, getRarity(), group);
}
@Override
public boolean canGiveReward(Player player)
{
return !_clientManager.Get(player).getPrimaryGroup().inheritsFrom(PermissionGroup.ETERNAL);
return !CLIENT_MANAGER.Get(player).getPrimaryGroup().inheritsFrom(PermissionGroup.ETERNAL);
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof RankReward)
{
return true;
}
return false;
return obj instanceof RankReward;
}
}

View File

@ -1,63 +1,40 @@
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.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
public class RuneAmplifierReward extends Reward
public class RuneAmplifierReward extends InventoryReward
{
private Random _random;
private InventoryManager _inventoryManager;
private int _max, _min, _minutes;
private static final ItemStack ITEM_STACK = new ItemStack(Material.NETHER_STAR);
public RuneAmplifierReward(InventoryManager inventoryManager, int minutes, int min, int max, RewardRarity rarity, int weight, int shardValue)
private final int _minutes;
public RuneAmplifierReward(int minutes, RewardRarity rarity, int shardValue)
{
this(RANDOM, inventoryManager, minutes, min, max, rarity, weight, shardValue);
this(minutes, 1, rarity, shardValue);
}
public RuneAmplifierReward(Random random, InventoryManager inventoryManager, int minutes, int min, int max, RewardRarity rarity, int weight, int shardValue)
public RuneAmplifierReward(int minutes, int amount, RewardRarity rarity, int shardValue)
{
super(rarity, weight, shardValue);
this(minutes, amount, amount, rarity, shardValue);
}
public RuneAmplifierReward(int minutes, int min, int max, RewardRarity rarity, int shardValue)
{
super("Clans Amplifier", "Rune Amplifier " + minutes, "Clans Amplifier", min, max, ITEM_STACK, rarity, shardValue);
_random = random;
_inventoryManager = inventoryManager;
_max = max;
_min = min;
_minutes = minutes;
}
@Override
public RewardData giveRewardCustom(Player player, RewardType rewardType)
{
int amountToGive;
if (_min != _max)
{
amountToGive = _random.nextInt(_max - _min) + _min;
}
else
{
amountToGive = _min;
}
_inventoryManager.addItemToInventory(player, "Rune Amplifier " + _minutes, amountToGive);
return new RewardData(getRarity().getDarkColor() + "Clans Amplifier", getRarity().getColor() + amountToGive + " " + _minutes + " minute Clans Amplifier", new ItemStack(Material.NETHER_STAR), getRarity());
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + "Clans Amplifier", getRarity().getColor() + _minutes + " minute Clans Amplifier", new ItemStack(Material.NETHER_STAR), getRarity());
return new RewardData(getRarity().getDarkColor() + "Clans Amplifier", getRarity().getColor() + _minutes + " minute Clans Amplifier", ITEM_STACK, getRarity());
}
@Override
@ -69,10 +46,6 @@ public class RuneAmplifierReward extends Reward
@Override
public boolean equals(Object obj)
{
if (obj instanceof RuneAmplifierReward)
{
return ((RuneAmplifierReward) obj)._minutes == _minutes;
}
return false;
return obj instanceof RuneAmplifierReward && ((RuneAmplifierReward) obj)._minutes == _minutes;
}
}

View File

@ -3,40 +3,31 @@ package mineplex.core.reward.rewards;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.account.CoreClientManager;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.Callback;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.serverdata.database.DBPool;
public class SpinTicketReward extends Reward
{
private Random _random;
private CoreClientManager _clientManager;
private static final ItemStack ITEM_STACK = new ItemStack(Material.PAPER);
private int _max, _min;
public SpinTicketReward(CoreClientManager clientManager, int min, int max, RewardRarity rarity, int weight, int shardValue)
public SpinTicketReward(int min, int max, RewardRarity rarity, int shardValue)
{
this(RANDOM, clientManager, min, max, rarity, weight, shardValue);
}
super(rarity, shardValue);
public SpinTicketReward(Random random, CoreClientManager clientManager, int min, int max, RewardRarity rarity, int weight, int shardValue)
{
super(rarity, weight, shardValue);
_random = random;
_clientManager = clientManager;
_max = max;
_min = min;
}
@ -44,7 +35,7 @@ public class SpinTicketReward extends Reward
@Override
public RewardData giveRewardCustom(Player player, RewardType rewardType)
{
if (_clientManager.getAccountId(player) == -1)
if (CLIENT_MANAGER.getAccountId(player) == -1)
{
return getFakeRewardData(player);
}
@ -53,22 +44,16 @@ public class SpinTicketReward extends Reward
if (_min != _max)
{
amountToGive = _random.nextInt(_max - _min) + _min;
amountToGive = RANDOM.nextInt(_max - _min) + _min;
}
else
{
amountToGive = _min;
}
final int accountId = _clientManager.getAccountId(player);
final Callback<Integer> ticketCallback = new Callback<Integer>()
{
public void run(Integer newTickets)
{
Managers.get(BonusManager.class).Get(player).setTickets(newTickets);
}
};
_clientManager.runAsync(() ->
final int accountId = CLIENT_MANAGER.getAccountId(player);
final Callback<Integer> ticketCallback = newTickets -> Managers.get(BonusManager.class).Get(player).setTickets(newTickets);
CLIENT_MANAGER.runAsync(() ->
{
try (Connection c = DBPool.getAccount().getConnection(); Statement statement = c.createStatement())
{
@ -82,10 +67,7 @@ public class SpinTicketReward extends Reward
if (rs.next())
{
final int newTickets = rs.getInt(1);
_clientManager.runSync(() ->
{
ticketCallback.run(newTickets);
});
CLIENT_MANAGER.runSync(() -> ticketCallback.run(newTickets));
}
}
catch (Exception e)
@ -95,13 +77,13 @@ public class SpinTicketReward extends Reward
}
});
return new RewardData(getRarity().getDarkColor() + "Carl Spin Ticket", getRarity().getColor() + amountToGive + " Carl Spin Ticket", new ItemStack(Material.PAPER), getRarity());
return new RewardData(getRarity().getDarkColor() + "Carl Spin Ticket", getRarity().getColor() + amountToGive + " Carl Spin Ticket", ITEM_STACK, getRarity());
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + "Carl Spin Ticket", getRarity().getColor() + "Carl Spin ticket", new ItemStack(Material.PAPER), getRarity());
return new RewardData(getRarity().getDarkColor() + "Carl Spin Ticket", getRarity().getColor() + "Carl Spin ticket", ITEM_STACK, getRarity());
}
@Override
@ -113,10 +95,6 @@ public class SpinTicketReward extends Reward
@Override
public boolean equals(Object obj)
{
if (obj instanceof SpinTicketReward)
{
return true;
}
return false;
return obj instanceof SpinTicketReward;
}
}

View File

@ -5,26 +5,29 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.Managers;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.titles.tracks.Track;
import mineplex.core.titles.tracks.TrackManager;
public class TitleReward extends Reward
{
private final ItemStack ITEM_STACK = new ItemStack(Material.BOOK);
private final TrackManager _trackManager = Managers.require(TrackManager.class);
private final Track _track;
public TitleReward(Track track, RewardRarity rarity, int weight, int shardValue)
public TitleReward(Track track, RewardRarity rarity, int shardValue)
{
super(rarity, weight, shardValue);
super(rarity, shardValue);
if (track == null)
{
throw new IllegalStateException();
}
_track = track;
}

View File

@ -1,48 +1,40 @@
package mineplex.core.reward.rewards;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.UtilMath;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.Callback;
import mineplex.core.donation.DonationManager;
import mineplex.core.account.CoreClient;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
public class TreasureShardReward extends Reward
{
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private static final ItemStack ITEM_STACK = new ItemStack(Material.PRISMARINE_SHARD);
private Reward _otherReward;
private int _shardsMin = 0;
private int _shardsMax = 0;
public TreasureShardReward(CoreClientManager clientManager, DonationManager donationManager, Reward otherReward, int weight, RewardRarity rarity)
public TreasureShardReward(Reward otherReward, RewardRarity rarity)
{
super(rarity, weight, 0);
super(rarity, 0);
_clientManager = clientManager;
_donationManager = donationManager;
_otherReward = otherReward;
_shardsMin = (int) (otherReward.getShardValue() + (Math.random() * otherReward.getShardValue() / 2.0));
_shardsMax = _shardsMin;
}
public TreasureShardReward(CoreClientManager clientManager, DonationManager donationManager, int min, int max, int weight, RewardRarity rarity)
public TreasureShardReward(int min, int max, RewardRarity rarity)
{
super(rarity, weight, 0);
_clientManager = clientManager;
_donationManager = donationManager;
super(rarity, 0);
_shardsMin = min;
_shardsMax = max;
@ -61,20 +53,13 @@ public class TreasureShardReward extends Reward
}
else
{
rewardData = new RewardData(null, getRarity().getColor() + shards + " Treasure Shards", new ItemStack(Material.PRISMARINE_SHARD), getRarity());
rewardData = new RewardData(null, getRarity().getColor() + shards + " Treasure Shards", ITEM_STACK, getRarity());
}
CoreClient client = _clientManager.Get(player);
CoreClient client = CLIENT_MANAGER.Get(player);
// Give shards 5 seconds later for better effect
Bukkit.getScheduler().runTaskLater(_donationManager.getPlugin(), new Runnable()
{
@Override
public void run()
{
_donationManager.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, client, "Treasure", shards);
}
}, 100);
UtilServer.runSyncLater(() -> DONATION_MANAGER.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, client, "Treasure", shards), 100);
return rewardData;
}
@ -94,10 +79,7 @@ public class TreasureShardReward extends Reward
@Override
public boolean equals(Object obj)
{
if (obj instanceof TreasureShardReward)
return true;
return false;
return obj instanceof TreasureShardReward;
}
}

View File

@ -1,123 +0,0 @@
package mineplex.core.reward.rewards;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
/**
* Created by shaun on 14-09-12.
*/
public class UnknownPackageReward extends Reward
{
protected DonationManager _donationManager;
protected InventoryManager _inventoryManager;
private ItemStack _itemStack;
private String _header;
private String _name;
private String _packageName;
private String[] _alternativeNames;
public UnknownPackageReward(DonationManager donationManager, InventoryManager inventoryManager, String header, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue)
{
super(rarity, weight, shardValue);
_donationManager = donationManager;
_inventoryManager = inventoryManager;
_header = header;
_name = name;
_packageName = packageName;
_itemStack = itemStack;
_alternativeNames = new String[]{};
}
public UnknownPackageReward(DonationManager donationManager, InventoryManager inventoryManager, String header, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue, String... alternativeNames)
{
super(rarity, weight, shardValue);
_donationManager = donationManager;
_inventoryManager = inventoryManager;
_header = header;
_name = name;
_packageName = packageName;
_itemStack = itemStack;
_alternativeNames = alternativeNames;
}
@Override
protected RewardData giveRewardCustom(Player player, RewardType type)
{
_donationManager.purchaseUnknownSalesPackage(player, _packageName, GlobalCurrency.TREASURE_SHARD, 0, true, null);
return new RewardData(getRarity().getDarkColor() + _header, getRarity().getColor() + _name, _itemStack, getRarity());
}
@Override
public boolean canGiveReward(Player player)
{
if (_donationManager.Get(player) == null)
{
System.out.println("Could not give reward " + _packageName + " to Offline Player: " + player.getName());
return false;
}
boolean hasItem = false;
if (_donationManager.Get(player).ownsUnknownSalesPackage(_packageName))
{
hasItem = true;
}
else if (_inventoryManager.Get(player).getItemCount(_packageName) > 0)
{
hasItem = true;
}
else
{
for (String altName : _alternativeNames)
{
if (_donationManager.Get(player).ownsUnknownSalesPackage(altName))
{
hasItem = true;
}
if (_inventoryManager.Get(player).getItemCount(altName) > 0)
{
hasItem = true;
}
}
}
return !hasItem;
}
@Override
public RewardData getFakeRewardData(Player player)
{
return new RewardData(getRarity().getDarkColor() + _header, getRarity().getColor() + _name, _itemStack, getRarity());
}
protected String getPackageName()
{
return _packageName;
}
protected String getFriendlyName()
{
return _name;
}
@Override
public boolean equals(Object obj)
{
if (obj instanceof UnknownPackageReward)
{
return ((UnknownPackageReward) obj).getPackageName().equals(_packageName);
}
return false;
}
public String getHeader()
{
return _header;
}
}

View File

@ -28,8 +28,8 @@ import mineplex.core.gadget.types.GadgetSet;
import mineplex.core.titles.tracks.Track;
import mineplex.core.titles.tracks.TrackFormat;
import mineplex.core.titles.tracks.TrackTier;
import mineplex.core.treasure.TreasureType;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.types.TreasureType;
public class HolidayCheerTrack extends Track
{
@ -45,15 +45,15 @@ public class HolidayCheerTrack extends Track
POINTS.put(ItemFreezeCannon.class, 1);
POINTS.put(ItemLovePotion.class, 10);
HOLIDAY_CHESTS.add(TreasureType.CHRISTMAS);
HOLIDAY_CHESTS.add(TreasureType.FREEDOM);
HOLIDAY_CHESTS.add(TreasureType.HAUNTED);
HOLIDAY_CHESTS.add(TreasureType.THANKFUL);
HOLIDAY_CHESTS.add(TreasureType.TRICK_OR_TREAT);
HOLIDAY_CHESTS.add(TreasureType.GINGERBREAD);
HOLIDAY_CHESTS.add(TreasureType.LOVE_CHEST);
HOLIDAY_CHESTS.add(TreasureType.ST_PATRICKS);
HOLIDAY_CHESTS.add(TreasureType.SPRING);
// HOLIDAY_CHESTS.add(TreasureType.CHRISTMAS);
// HOLIDAY_CHESTS.add(TreasureType.FREEDOM);
// HOLIDAY_CHESTS.add(TreasureType.HAUNTED);
// HOLIDAY_CHESTS.add(TreasureType.THANKFUL);
// HOLIDAY_CHESTS.add(TreasureType.TRICK_OR_TREAT);
// HOLIDAY_CHESTS.add(TreasureType.GINGERBREAD);
// HOLIDAY_CHESTS.add(TreasureType.LOVE_CHEST);
// HOLIDAY_CHESTS.add(TreasureType.ST_PATRICKS);
// HOLIDAY_CHESTS.add(TreasureType.SPRING);
HOLIDAY_SETS.add(SetFreedom.class);
HOLIDAY_SETS.add(SetCupidsLove.class);
@ -118,7 +118,7 @@ public class HolidayCheerTrack extends Track
@EventHandler
public void onUseCosmetic(TreasureStartEvent event)
{
if (!HOLIDAY_CHESTS.contains(event.getTreasure().getTreasureType()))
if (!HOLIDAY_CHESTS.contains(event.getTreasureType()))
return;
int points = 100;

View File

@ -13,12 +13,12 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardRarity;
import mineplex.core.titles.tracks.Track;
import mineplex.core.titles.tracks.TrackFormat;
import mineplex.core.titles.tracks.TrackTier;
import mineplex.core.treasure.TreasureType;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.treasure.types.TreasureType;
public class LuckyTrack extends Track
{
@ -33,14 +33,14 @@ public class LuckyTrack extends Track
POINTS.put(RewardRarity.LEGENDARY, 5);
POINTS.put(RewardRarity.MYTHICAL, 50);
MULTIPLIER.put(TreasureType.FREEDOM, 2);
MULTIPLIER.put(TreasureType.HAUNTED, 2);
MULTIPLIER.put(TreasureType.CHRISTMAS, 2);
MULTIPLIER.put(TreasureType.TRICK_OR_TREAT, 2);
MULTIPLIER.put(TreasureType.LOVE_CHEST, 2);
MULTIPLIER.put(TreasureType.ST_PATRICKS, 2);
MULTIPLIER.put(TreasureType.SPRING, 2);
MULTIPLIER.put(TreasureType.OMEGA, 3);
// MULTIPLIER.put(TreasureType.FREEDOM, 2);
// MULTIPLIER.put(TreasureType.HAUNTED, 2);
// MULTIPLIER.put(TreasureType.CHRISTMAS, 2);
// MULTIPLIER.put(TreasureType.TRICK_OR_TREAT, 2);
// MULTIPLIER.put(TreasureType.LOVE_CHEST, 2);
// MULTIPLIER.put(TreasureType.ST_PATRICKS, 2);
// MULTIPLIER.put(TreasureType.SPRING, 2);
// MULTIPLIER.put(TreasureType.OMEGA, 3);
IRON.add(Material.IRON_SPADE);
IRON.add(Material.IRON_PICKAXE);
@ -125,8 +125,8 @@ public class LuckyTrack extends Track
int basePoints = POINTS.get(reward.getRarity());
if (MULTIPLIER.get(event.getTreasure().getTreasureType()) != null)
basePoints *= MULTIPLIER.get(event.getTreasure().getTreasureType());
if (MULTIPLIER.get(event.getTreasureType()) != null)
basePoints *= MULTIPLIER.get(event.getTreasureType());
incrementFor(event.getPlayer(), basePoints);
}

View File

@ -10,8 +10,8 @@ import mineplex.core.gadget.set.SetWisdom;
import mineplex.core.titles.tracks.Track;
import mineplex.core.titles.tracks.TrackFormat;
import mineplex.core.titles.tracks.TrackTier;
import mineplex.core.treasure.TreasureType;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.types.TreasureType;
public class TreasureHunterTrack extends Track
{
@ -20,20 +20,20 @@ public class TreasureHunterTrack extends Track
static
{
POINTS.put(TreasureType.OLD, 1);
POINTS.put(TreasureType.ANCIENT, 3);
POINTS.put(TreasureType.MYTHICAL, 5);
POINTS.put(TreasureType.ILLUMINATED, 10);
POINTS.put(TreasureType.FREEDOM, 25);
POINTS.put(TreasureType.HAUNTED, 25);
POINTS.put(TreasureType.CHRISTMAS, 25);
POINTS.put(TreasureType.TRICK_OR_TREAT, 25);
POINTS.put(TreasureType.THANKFUL, 25);
POINTS.put(TreasureType.GINGERBREAD, 25);
POINTS.put(TreasureType.LOVE_CHEST, 25);
POINTS.put(TreasureType.ST_PATRICKS, 25);
POINTS.put(TreasureType.SPRING, 25);
POINTS.put(TreasureType.OMEGA, 50);
POINTS.put(TreasureType.MINESTRIKE, 3);
// POINTS.put(TreasureType.ANCIENT, 3);
// POINTS.put(TreasureType.MYTHICAL, 5);
// POINTS.put(TreasureType.ILLUMINATED, 10);
// POINTS.put(TreasureType.FREEDOM, 25);
// POINTS.put(TreasureType.HAUNTED, 25);
// POINTS.put(TreasureType.CHRISTMAS, 25);
// POINTS.put(TreasureType.TRICK_OR_TREAT, 25);
// POINTS.put(TreasureType.THANKFUL, 25);
// POINTS.put(TreasureType.GINGERBREAD, 25);
// POINTS.put(TreasureType.LOVE_CHEST, 25);
// POINTS.put(TreasureType.ST_PATRICKS, 25);
// POINTS.put(TreasureType.SPRING, 25);
// POINTS.put(TreasureType.OMEGA, 50);
// POINTS.put(TreasureType.MINESTRIKE, 3);
}
public TreasureHunterTrack()
@ -84,9 +84,9 @@ public class TreasureHunterTrack extends Track
@EventHandler
public void onUseCosmetic(TreasureStartEvent event)
{
if (POINTS.containsKey(event.getTreasure().getTreasureType()))
if (POINTS.containsKey(event.getTreasureType()))
{
int basePoints = POINTS.get(event.getTreasure().getTreasureType());
int basePoints = POINTS.get(event.getTreasureType());
if (isSetActive(event.getPlayer(), SetWisdom.class))
{

View File

@ -13,11 +13,11 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardRarity;
import mineplex.core.titles.tracks.Track;
import mineplex.core.titles.tracks.TrackFormat;
import mineplex.core.titles.tracks.TrackTier;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.reward.RewardRarity;
public class UnluckyTrack extends Track
{

View File

@ -1,36 +0,0 @@
package mineplex.core.treasure;
import org.bukkit.block.Block;
/**
* Created by Shaun on 8/28/2014.
*/
public class BlockInfo
{
private Block _block;
private int _id;
private byte _data;
public BlockInfo(Block block)
{
_block = block;
_id = block.getTypeId();
_data = block.getData();
}
public Block getBlock()
{
return _block;
}
public int getId()
{
return _id;
}
public byte getData()
{
return _data;
}
}

View File

@ -1,31 +0,0 @@
package mineplex.core.treasure;
import org.bukkit.block.Block;
public class ChestData
{
private Block _block;
private boolean _opened;
public ChestData(Block block)
{
_block = block;
_opened = false;
}
public boolean isOpened()
{
return _opened;
}
public void setOpened(boolean opened)
{
_opened = opened;
}
public Block getBlock()
{
return _block;
}
}

View File

@ -1,483 +0,0 @@
package mineplex.core.treasure;
import java.awt.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.entity.Player;
import mineplex.core.account.permissions.PermissionGroup;
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.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.hologram.HologramManager;
import mineplex.core.rankGiveaway.redis.TitanChestGiveawayMessage;
import mineplex.core.reward.RankRewardData;
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;
import mineplex.core.treasure.animation.Animation;
import mineplex.core.treasure.animation.BlockChangeAnimation;
import mineplex.core.treasure.animation.ChestOpenAnimation;
import mineplex.core.treasure.animation.ChestSpawnAnimation;
import mineplex.core.treasure.animation.FreedomChestAnimation;
import mineplex.core.treasure.animation.LootLegendaryAnimation;
import mineplex.core.treasure.animation.LootMythicalAnimation;
import mineplex.core.treasure.animation.LootRareAnimation;
import mineplex.core.treasure.animation.LootUncommonAnimation;
import mineplex.core.treasure.animation.TreasureRemoveAnimation;
public class Treasure
{
private BlockRestore _blockRestore;
private List<BlockInfo> _chestBlockInfo = new ArrayList<>();
private List<BlockInfo> _openedChestBlockInfo = new ArrayList<>();
private List<BlockInfo> _otherBlockInfo = new ArrayList<>();
private Player _player;
private Random _random;
private Block _centerBlock;
private int _tickCount;
private TreasureType _treasureType;
private ChestData[] _chestData;
private int _currentChest;
private Reward[] _rewards;
private RewardType _rewardType;
private ConcurrentHashMap<Integer, RewardData> _rewardData = new ConcurrentHashMap<Integer, RewardData>();
private int _currentReward;
private boolean _finished;
private int _finishedTickCount;
private LinkedList<Animation> _animations;
private HologramManager _hologramManager;
private ServerStatusManager _statusManager;
private TreasureManager _treasureManager;
public Treasure(TreasureManager treasureManager, Player player, Reward[] rewards, RewardType rewardType, Block centerBlock, Block[] chestBlocks, TreasureType treasureType, BlockRestore blockRestore, HologramManager hologramManager, ServerStatusManager statusManager)
{
this(treasureManager, player, new Random(), rewards, rewardType, centerBlock, chestBlocks, treasureType, hologramManager, statusManager);
_blockRestore = blockRestore;
}
public Treasure(TreasureManager treasureManager, Player player, Random seed, Reward[] rewards, RewardType rewardType, Block centerBlock, Block[] chestBlocks, TreasureType treasureType, HologramManager hologramManager, ServerStatusManager statusManager)
{
_treasureManager = treasureManager;
_player = player;
_random = seed;
_treasureType = treasureType;
_centerBlock = centerBlock;
_animations = new LinkedList<Animation>();
_hologramManager = hologramManager;
_statusManager = statusManager;
_currentChest = 0;
_currentReward = 0;
_rewardType = rewardType;
_rewards = rewards;
int max = chestBlocks.length;
_chestData = new ChestData[max];
for (int i = 0; i < max; i++)
{
_chestData[i] = new ChestData(chestBlocks[i]);
}
_animations.add(new BlockChangeAnimation(this, _otherBlockInfo, chestBlocks));
for (int i = 0; i < _rewards.length; i++)
{
Reward reward = _rewards[i];
final int count = i;
reward.giveReward(_rewardType, player, new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
_rewardData.put(count, data);
}
});
}
}
public int getFinishedTickCount()
{
return _finishedTickCount;
}
public void update()
{
if (_finished)
{
_finishedTickCount++;
}
if (_tickCount % 10 == 0 && _currentChest < _chestData.length)
{
ChestSpawnAnimation chestSpawn = new ChestSpawnAnimation(this,_chestData[_currentChest].getBlock(), _chestBlockInfo, _centerBlock, _currentChest, _statusManager.getPlugin());
_animations.add(chestSpawn);
_currentChest++;
}
//Auto-open after 1 minute
if (_tickCount == 60 * 20)
{
for (BlockInfo blockInfo : _chestBlockInfo)
{
Block block = blockInfo.getBlock();
openChest(block, false);
}
}
Block block = _player.getTargetBlock((Set<Material>) null, 3);
if (block.getType() == _treasureType.getMaterial())
{
ChestData data = getChestData(block);
if (!isFinished() && data != null && !data.isOpened())
{
UtilParticle.ParticleType type = getTreasureType().getStyle().getHoverParticle();
if (_treasureType == TreasureType.OLD)
{
UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0F, 0F, 0F, 1, 4,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (_treasureType == TreasureType.ANCIENT)
{
double yDif = 0.2 + 0.6 * Math.sin(Math.PI * (_tickCount / 10.0));
double xDif = 0.7 * Math.sin(Math.PI * (_tickCount / 5.0));
double zDif = 0.7 * Math.cos(Math.PI * (_tickCount / 5.0));
float red = 0.1F + (float)( 0.4 * (1 + Math.cos(Math.PI * (_tickCount / 20.0))));
UtilParticle.PlayParticle(type, block.getLocation().add(0.5 + xDif, 0.5 + yDif, 0.5 + zDif), red, 0.2F, 0.2F, 1F, 0,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (_treasureType == TreasureType.CHRISTMAS)
{
UtilParticle.PlayParticle(type, block.getLocation().add(0.5f, 0.5f, 0.5f), 0.1f, 0.1F, 0.1F, 0.2F, 5,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (_treasureType == TreasureType.ILLUMINATED)
{
UtilParticle.PlayParticleToAll(type, block.getLocation().add(0.5, 0.0, 0.5), 0.1f, 0.1f, 0.1f, 0.05f, 4,
ViewDist.NORMAL);
}
else if (_treasureType == TreasureType.FREEDOM)
{
int r = (int) (Math.random() * 3);
double rX = Math.random() * 2 - 1, rZ = Math.random() * 2 - 1;
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST,
new DustSpellColor((r == 0) ? Color.RED : (r == 1) ? Color.WHITE : Color.BLUE),
block.getLocation().add(.5 + rX, .7, .5 + rX));
coloredParticle.display();
}
else if (_treasureType == TreasureType.HAUNTED)
{
int r = (int) (Math.random() * 2);
double rX = Math.random() * 2 - 1, rZ = Math.random() * 2 - 1;
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST,
new DustSpellColor((r == 0) ? Color.ORANGE : Color.BLACK),
block.getLocation().add(.5 + rX, .7, .5 + rZ));
coloredParticle.display();
}
else if (_treasureType == TreasureType.LOVE_CHEST)
{
int r = (int) (Math.random() * 2);
double rX = Math.random() * 2 - 1, rZ = Math.random() * 2 - 1;
UtilParticle.PlayParticle(type, block.getLocation().add(.5 + rX, .7, .5 + rZ), .5f, .5f, .5f, .25f, 1, ViewDist.NORMAL);
}
else if (_treasureType == TreasureType.ST_PATRICKS)
{
int r = (int) (Math.random() * 2);
double rX = Math.random() * 2 - 1, rZ = Math.random() * 2 - 1;
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST,
new DustSpellColor((r == 0) ? Color.GREEN : new Color(0, 100, 0)),
block.getLocation().add(.5 + rX, .7, .5 + rZ));
coloredParticle.display();
}
else if (_treasureType == TreasureType.SPRING)
{
int r = (int) (Math.random() * 2);
double rX = Math.random() * 2 - 1, rZ = Math.random() * 2 - 1;
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST,
new DustSpellColor((r == 0) ? Color.RED : Color.YELLOW),
block.getLocation().add(.5 + rX, .7, .5 + rZ));
coloredParticle.display();
}
else
{
UtilParticle.PlayParticle(type, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.2F, 0,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
}
Iterator<Animation> taskIterator = _animations.iterator();
while (taskIterator.hasNext())
{
Animation animation = taskIterator.next();
if (animation.isRunning())
{
animation.run();
}
else
{
taskIterator.remove();
}
}
_tickCount++;
}
public Block getCenterBlock()
{
return _centerBlock;
}
public void setBlock(Block block, Material material, byte data)
{
block.setType(material);
block.setData(data);
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
}
public void openChest(Block block)
{
openChest(block, true);
}
public void openChest(final Block block, final boolean swapList)
{
if(block.getType() != _treasureType.getMaterial()) return;
// This is very experimental! Pray to god that this works
final ChestData data = getChestData(block);
if (data != null && !data.isOpened() && _currentReward < _rewards.length)
{
//final Reward reward = _rewards[_currentReward];
final RewardData rewardData = _rewardData.get(_currentReward);
data.setOpened(true);
_currentReward++;
//reward.giveReward(_rewardType, _player, new Callback<RewardData>()
//{
//@Override
//public void run(RewardData rewardData)
//{
if (swapList)
{
BlockInfo info = getBlockInfo(block);
_chestBlockInfo.remove(info);
_openedChestBlockInfo.add(info);
}
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(Treasure.this, data, rewardData, _hologramManager);
_animations.add(chestOpenTask);
// Extra effects based off the rarity of the treasure
if (_treasureType == TreasureType.FREEDOM)
{
_animations.add(new FreedomChestAnimation(Treasure.this, data.getBlock().getLocation().add(.5, .5, .5)));
}
if (rewardData.getRarity() == RewardRarity.UNCOMMON)
{
_animations.add(new LootUncommonAnimation(Treasure.this, data.getBlock()));
}
else if (rewardData.getRarity() == RewardRarity.RARE)
{
_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 (rewardData.getRarity() == RewardRarity.LEGENDARY)
{
_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 (rewardData.getRarity() == RewardRarity.MYTHICAL)
{
if (rewardData instanceof RankRewardData)
{
if (((RankRewardData)rewardData).getWonRank() == PermissionGroup.TITAN)
{
TitanChestGiveawayMessage message = new TitanChestGiveawayMessage(_player.getName(), _statusManager.getCurrentServerName());
message.publish();
}
}
_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(Treasure.this, _chestBlockInfo);
_animations.add(animation);
_finished = true;
}
//}
//});
}
}
public BlockInfo getBlockInfo(Block block)
{
for (BlockInfo blockInfo : _chestBlockInfo)
{
if (blockInfo.getBlock().equals(block))
return blockInfo;
}
return null;
}
public void sendChestOpenPackets(Player... players)
{
for (ChestData data : _chestData)
{
if (data.isOpened())
{
Block block = data.getBlock();
PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(new BlockPosition(block.getX(), block.getY(), block.getZ()), CraftMagicNumbers.getBlock(block), 1, 1);
for (Player player : players)
{
UtilPlayer.sendPacket(player, packet);
}
}
}
}
public ChestData getChestData(Block block)
{
for (ChestData data : _chestData)
{
if (data.getBlock().equals(block))
{
return data;
}
}
return null;
}
public Player getPlayer()
{
return _player;
}
public boolean isFinished()
{
return _currentReward == _rewards.length;
}
public void cleanup()
{
for (int i = _currentReward; i < _rewards.length; i++)
{
_rewards[_currentReward].giveReward(_rewardType, _player, new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
// Do nothing
System.out.println("Shards: " + data.getShards());
}
});
}
_currentReward = _rewards.length;
// Remove any extra blocks
resetBlockInfo(_chestBlockInfo);
resetBlockInfo(_openedChestBlockInfo);
resetBlockInfo(_otherBlockInfo);
for (Animation animation : _animations)
{
animation.finish();
}
_animations.clear();
}
public void resetBlockInfo(List<BlockInfo> blockInfoSet)
{
for (BlockInfo blockInfo : blockInfoSet)
{
resetBlockInfo(blockInfo);
}
blockInfoSet.clear();
}
public void resetBlockInfo(BlockInfo blockInfo)
{
if (blockInfo == null)
return;
Block block = blockInfo.getBlock();
if (block.getType().equals(Material.CHEST))
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.LARGE_SMOKE, block.getLocation().add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.1F, 10,
ViewDist.NORMAL, UtilServer.getPlayers());
// block.getLocation().getWorld().createExplosion(block.getLocation().add(0.5, 0.5, 0.5), 0F);
}
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setTypeId(blockInfo.getId());
block.setData(blockInfo.getData());
}
public boolean containsBlock(Block block)
{
for (BlockInfo info : _chestBlockInfo)
if (info.getBlock().equals(block))
return true;
return false;
}
public TreasureType getTreasureType()
{
return _treasureType;
}
public void addAnimation(Animation animation)
{
_animations.add(animation);
}
public TreasureManager getTreasureManager()
{
return _treasureManager;
}
}

View File

@ -1,19 +0,0 @@
package mineplex.core.treasure;
import mineplex.core.shop.item.SalesPackageBase;
import org.bukkit.ChatColor;
import org.bukkit.Material;
/**
* Created by shaun on 14-09-18.
*/
public class TreasureKey extends SalesPackageBase
{
public TreasureKey()
{
super("Treasure Key", Material.TRIPWIRE_HOOK, (byte) 0, new String[] { ChatColor.RESET + "Used to open Treasure Chests" }, 1000);
KnownPackage = false;
OneTimePurchaseOnly = false;
}
}

View File

@ -1,456 +1,231 @@
package mineplex.core.treasure;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import mineplex.core.account.CoreClientManager;
import mineplex.core.Managers;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramInteraction;
import mineplex.core.hologram.Hologram.HologramTarget;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.event.TreasurePreStartEvent;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.gui.TreasureShop;
import mineplex.core.treasure.animation.TreasureAnimation;
import mineplex.core.treasure.types.Treasure;
import mineplex.core.treasure.ui.TreasureShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class TreasureLocation implements Listener
{
private TreasureManager _treasureManager;
private InventoryManager _inventoryManager;
private Hologram _hologram;
private HologramManager _hologramManager;
private ServerStatusManager _statusManager;
private Treasure _currentTreasure;
private Block _chestBlock;
private byte _chestBlockData;
private Block[] _chestSpawns;
private TreasureShop _shop;
private Location _resetLocation;
public TreasureLocation(TreasureManager treasureManager, InventoryManager inventoryManager, CoreClientManager clientManager, DonationManager donationManager, Block chestBlock, Block[] chestSpawns, Location resetLocation, HologramManager hologramManager, GadgetManager gadgetManager, ServerStatusManager statusManager)
private static final HologramManager HOLOGRAM_MANAGER = Managers.require(HologramManager.class);
private static final String HOLOGRAM_TEXT = C.cGreenB + "Open Treasure";
private final TreasureManager _manager;
private final Location _chest;
private final TreasureShop _shop;
private final Map<Player, Hologram> _hologramMap;
private TreasureSession _session;
private boolean _colourTick;
public TreasureLocation(TreasureManager manager, Location chest)
{
_treasureManager = treasureManager;
_resetLocation = resetLocation;
_inventoryManager = inventoryManager;
_chestBlock = chestBlock;
_chestBlockData = _chestBlock.getData();
_chestSpawns = chestSpawns;
_hologramManager = hologramManager;
_statusManager = statusManager;
_currentTreasure = null;
_hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 1.5, 0.5), C.cGreen + C.Bold + "Open Treasure");
_hologram.setInteraction(new HologramInteraction()
{
_manager = manager;
_chest = chest;
_shop = new TreasureShop(manager, manager.getClientManager(), manager.getDonationManager(), this);
_hologramMap = new HashMap<>();
@Override
public void onClick(Player player, ClickType clickType)
{
if (clickType == ClickType.LEFT)
return;
openShop(player);
}
});
setHoloChestVisible(true);
_shop = new TreasureShop(treasureManager, _inventoryManager, clientManager, donationManager, gadgetManager, this);
setHologramVisible(true);
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
public void playerInteract(PlayerInteractEvent event)
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().equals(_chestBlock))
{
openShop(event.getPlayer());
event.setCancelled(true);
}
}
public void attemptOpenTreasure(Player player, TreasureType treasureType)
{
if (isTreasureInProgress())
{
player.sendMessage(F.main("Treasure", "Please wait for the current chest to be opened"));
return;
}
TreasurePreStartEvent event = new TreasurePreStartEvent(player, treasureType);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
if (!UtilEvent.isAction(event, ActionType.R_BLOCK) || inUse())
{
return;
}
Location location = event.getClickedBlock().getLocation();
chargeAccount(player, treasureType, new Callback<Boolean>()
if (UtilMath.offsetSquared(location, _chest) > 4)
{
@Override
public void run(Boolean success)
{
if (!success)
{
player.sendMessage(F.main("Treasure", "You don't have any chests to open!"));
return;
}
if (isTreasureInProgress())
{
// Need to check again because of callback. Add item back
player.sendMessage(F.main("Treasure", "Please wait for the current chest to be opened"));
_inventoryManager.addItemToInventory(player, treasureType.getItemName(), 1);
return;
}
if(treasureType == TreasureType.ILLUMINATED || treasureType == TreasureType.FREEDOM || treasureType == TreasureType.OMEGA
|| treasureType == TreasureType.HAUNTED || treasureType == TreasureType.GINGERBREAD || treasureType == TreasureType.LOVE_CHEST)
{
if(!_treasureManager.hasItemsToGivePlayer(treasureType.getRewardPool(), player))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
_inventoryManager.addItemToInventory(player, treasureType.getItemName(), 1);
return;
}
}
Reward[] rewards = _treasureManager.getRewards(player, treasureType.getRewardPool(), treasureType.getRewardType());
for(Reward r : rewards)
{
if(r == null)
{
reset();
player.sendMessage(F.main("Treasure", "There are no available items in this chest for you to open"));
_inventoryManager.addItemToInventory(player, treasureType.getItemName(), 1);
return;
}
}
// Treasure is now being opened
setHoloChestVisible(false);
if (treasureType != TreasureType.OLD)
{
String pron = "a ";
if (treasureType == TreasureType.ANCIENT || treasureType == TreasureType.ILLUMINATED || treasureType == TreasureType.OMEGA)
pron = "an ";
String name = treasureType.getName().replace("Chest", "Treasure");
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening " + pron + name));
}
Treasure treasure = new Treasure(_treasureManager, player, rewards, treasureType.getRewardType(), _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager, _statusManager);
_currentTreasure = treasure;
for (Entity entity : player.getNearbyEntities(3, 3, 3))
{
UtilAction.velocity(entity, UtilAlg.getTrajectory(entity.getLocation(), treasure.getCenterBlock().getLocation()).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
}
Location teleportLocation = treasure.getCenterBlock().getLocation().add(0.5, 0, 0.5);
teleportLocation.setPitch(player.getLocation().getPitch());
teleportLocation.setYaw(player.getLocation().getYaw());
player.teleport(teleportLocation);
TreasureStartEvent startEvent = new TreasureStartEvent(player, treasure, Arrays.asList(rewards));
UtilServer.CallEvent(startEvent);
UtilTextMiddle.display(treasureType.getName(), "Choose " + rewards.length + " " + UtilText.plural("Chest", rewards.length) + " To Open", 20, 180, 20, player);
UtilPlayer.message(player, F.main("Treasure", "Choose " + rewards.length + " " + UtilText.plural("Chest", rewards.length) + " To Open"));
_treasureManager.addOpenStat(player, treasureType);
}
});
}
private void chargeAccount(Player player, TreasureType treasureType, Callback<Boolean> callback)
{
int itemCount = _inventoryManager.Get(player).getItemCount(treasureType.getItemName());
if (itemCount > 0)
{
// Should always handle the callback for us
_inventoryManager.addItemToInventory(callback, player, treasureType.getItemName(), -1);
return;
}
else
{
callback.run(false);
}
}
private void setHoloChestVisible(boolean visible)
{
if (visible)
{
_hologram.start();
_chestBlock.setType(Material.CHEST);
_chestBlock.setData(_chestBlockData);
}
else
{
_hologram.stop();
_chestBlock.setType(Material.AIR);
}
}
public void cleanup()
{
if (_currentTreasure != null)
{
_currentTreasure.cleanup();
_currentTreasure = null;
}
event.setCancelled(true);
_shop.attemptShopOpen(event.getPlayer());
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
if (event.getType() != UpdateType.SEC || inUse())
{
return;
if (isTreasureInProgress())
{
Treasure treasure = _currentTreasure;
treasure.update();
if (!treasure.getPlayer().isOnline() || (treasure.isFinished() && treasure.getFinishedTickCount() >= 80))
{
treasure.cleanup();
TreasureFinishEvent finishEvent = new TreasureFinishEvent(treasure.getPlayer(), treasure);
Bukkit.getPluginManager().callEvent(finishEvent);
}
}
}
@EventHandler
public void onTreasureFinish(TreasureFinishEvent event)
{
if (event.getTreasure().equals(_currentTreasure))
for (Player player : UtilServer.getPlayersCollection())
{
Player player = _currentTreasure.getPlayer();
player.teleport(_resetLocation);
_currentTreasure = null;
setHoloChestVisible(true);
}
}
Hologram hologram = _hologramMap.get(player);
@EventHandler(priority = EventPriority.HIGH)
public void interact(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (isTreasureInProgress())
{
if (_currentTreasure.getPlayer().equals(player))
if (hologram == null)
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
_currentTreasure.openChest(event.getClickedBlock());
}
event.setCancelled(true);
}
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
ChestData chestData = _currentTreasure.getChestData(event.getClickedBlock());
if (chestData != null)
{
event.setCancelled(true);
}
}
}
}
@EventHandler
public void inventoryOpen(InventoryOpenEvent event)
{
// Ignore punish gui
if (event.getInventory().getTitle() != null && event.getInventory().getTitle().contains("Punish"))
return;
if (isTreasureInProgress() && event.getPlayer().equals(_currentTreasure.getPlayer()))
{
event.setCancelled(true);
}
}
@EventHandler
public void cancelMove(PlayerMoveEvent event)
{
Player player = event.getPlayer();
if (isTreasureInProgress())
{
if (_currentTreasure.getPlayer().equals(player))
{
Treasure treasure = _currentTreasure;
Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 0.5, 0.5);
if (event.getTo().distanceSquared(centerLocation) > 9)
{
Location newTo = centerLocation.clone();
newTo.setPitch(event.getTo().getPitch());
newTo.setYaw(event.getTo().getYaw());
event.setTo(newTo);
}
}
else if (event.getFrom().getWorld().equals(_currentTreasure.getCenterBlock().getWorld()) &&
event.getTo().getWorld().equals(_currentTreasure.getCenterBlock().getWorld()))
{
Location fromLocation = event.getFrom();
Location toLocation = event.getTo();
if (!fromLocation.getWorld().equals(toLocation.getWorld())) return;
Location centerLocation = _currentTreasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5);
double toDistanceFromCenter = centerLocation.distanceSquared(toLocation);
if (toDistanceFromCenter <= 16)
{
// Only cancel movement if they are moving towards the center
double fromDistanceFromCenter = centerLocation.distanceSquared(fromLocation);
if (toDistanceFromCenter < fromDistanceFromCenter)
{
Entity target = player;
while (target.getVehicle() != null)
hologram = new Hologram(HOLOGRAM_MANAGER, _chest.clone().add(0, 1, 0), true, "")
.setHologramTarget(HologramTarget.WHITELIST)
.addPlayer(player)
.setInteraction((interactor, clicktype) ->
{
target = target.getVehicle();
}
Location spawnLocation = new Location(target.getWorld(), 0, 64, 0);
UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), spawnLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
}
}
if (clicktype == ClickType.LEFT)
{
return;
}
_shop.attemptShopOpen(player);
})
.start();
_hologramMap.put(player, hologram);
}
hologram.setText((_colourTick ? C.cAqua : C.cDAqua) + _manager.getChestsToOpen(player) + " Chests to Open", HOLOGRAM_TEXT);
}
_colourTick = !_colourTick;
}
@EventHandler
public void cancelTeleport(PlayerTeleportEvent event)
public void playerQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
if (isTreasureInProgress())
Hologram hologram = _hologramMap.remove(event.getPlayer());
if (hologram != null)
{
if (_currentTreasure.getPlayer().equals(player))
{
return;
}
if (_currentTreasure.getCenterBlock().getWorld() != event.getTo().getWorld())
{
return;
}
double toDistanceFromCenter = _currentTreasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5).distanceSquared(event.getTo());
if (toDistanceFromCenter <= 16)
{
Location spawnLocation = new Location(player.getWorld(), 0, 64, 0);
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), spawnLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
}
hologram.stop();
}
}
public boolean openChest(Player player, Treasure treasure)
{
if (inUse())
{
player.sendMessage(F.main(getManager().getName(), "This station is already in use."));
return false;
}
else if (getManager().getChestsToOpen(player, treasure) <= 0)
{
player.sendMessage(F.main(getManager().getName(), "You do not have any " + F.name(treasure.getTreasureType().getName()) + " to open."));
return false;
}
if (!treasure.hasAnimations())
{
player.sendMessage(F.main(getManager().getName(), "Ruh ro rhaggy, looks like there's no ranimation set for the rhest type."));
return false;
}
_session = new TreasureSession(player, this, treasure);
if (_session.hasFailed())
{
_session = null;
player.sendMessage(F.main(getManager().getName(), "Sorry, it looks like the rewards for the chest could not be generated."));
return false;
}
player.eject();
player.leaveVehicle();
player.teleport(_chest);
prepareChestArea();
return true;
}
private void prepareChestArea()
{
_session.pushEntitiesAway();
setHologramVisible(false);
}
@EventHandler
public void cancelVelocity(PlayerVelocityEvent event)
public void updateEntities(UpdateEvent event)
{
Player player = event.getPlayer();
if (isTreasureInProgress() && _currentTreasure.getPlayer().equals(player))
if (event.getType() != UpdateType.FAST || !inUse())
{
event.setCancelled(true);
return;
}
_session.pushEntitiesAway();
}
@EventHandler
public void preventGadgetBlockEvent(GadgetBlockEvent event)
public void updateAnimation(UpdateEvent event)
{
List<Block> blocks = event.getBlocks();
int x = _chestBlock.getX();
int y = _chestBlock.getY();
int z = _chestBlock.getZ();
for (Block block : blocks)
if (event.getType() != UpdateType.TICK || !inUse())
{
int dx = Math.abs(x - block.getX());
int dy = Math.abs(y - block.getY());
int dz = Math.abs(z - block.getZ());
return;
}
if (dx <= 4 && dz <= 4 && dy <= 4)
{
event.setCancelled(true);
return;
}
_session.getAnimations()
.stream()
.filter(TreasureAnimation::isRunning)
.forEach(TreasureAnimation::run);
}
private void setHologramVisible(boolean visible)
{
if (visible)
{
_chest.getBlock().setType(Material.CHEST);
_hologramMap.values().forEach(Hologram::start);
}
else
{
_chest.getBlock().setType(Material.AIR);
_hologramMap.values().forEach(Hologram::stop);
}
}
@EventHandler
public void quit(PlayerQuitEvent event)
private boolean inUse()
{
if (isTreasureInProgress() && _currentTreasure.getPlayer().equals(event.getPlayer()))
{
reset();
}
return _session != null;
}
public boolean isTreasureInProgress()
public Location getChest()
{
return _currentTreasure != null;
return _chest;
}
public void reset()
public List<Location> getChestLocations()
{
cleanup();
_chestBlock.setType(Material.CHEST);
_chestBlock.setData(_chestBlockData);
_hologram.start();
return Arrays.asList(
_chest.clone().add(3, 0, 1),
_chest.clone().add(3, 0, -1),
_chest.clone().add(-3, 0, 1),
_chest.clone().add(-3, 0, -1),
_chest.clone().add(1, 0, 3),
_chest.clone().add(-1, 0, 3),
_chest.clone().add(1, 0, -3),
_chest.clone().add(-1, 0, -3)
);
}
public Treasure getCurrentTreasure()
public TreasureManager getManager()
{
return _currentTreasure;
}
public void openShop(Player player)
{
_shop.attemptShopOpen(player);
}
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("TesureLoc: ").append(_chestBlock.getX()).append(" : ").append(_chestBlock.getY()).append(" : ").append(_chestBlock.getZ());
builder.append("BlockLocs: [");
for(Block block : _chestSpawns)
{
builder.append("BlockLoc: ").append(block.getX()).append(" : ").append(block.getY()).append(" : ").append(block.getZ()).append(",\n");
}
builder.append("]");
return builder.toString();
return _manager;
}
}

View File

@ -1,162 +1,122 @@
package mineplex.core.treasure;
import java.util.HashMap;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.collect.Lists;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.locations.LocationConstants;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardPool;
import mineplex.core.reward.RewardType;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.treasure.animation.Animation;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.treasure.reward.TreasureRewardManager;
import mineplex.core.treasure.types.OldTreasure;
import mineplex.core.treasure.types.Treasure;
import mineplex.core.recharge.Recharge;
@ReflectivelyCreateMiniPlugin
public class TreasureManager extends MiniPlugin
{
private CoreClientManager _clientManager;
private RewardManager _rewardManager;
private InventoryManager _inventoryManager;
private BlockRestore _blockRestore;
private HologramManager _hologramManager;
private StatsManager _statsManager;
private List<TreasureLocation> _treasureLocations;
private List<Location> _blockLocations;
private List<Item> _items;
private Map<Treasure, Animation> _treasureAnimations = new HashMap<>();
private final BonusManager _bonusManager;
private final CoreClientManager _clientManager;
private final DonationManager _donationManager;
private final InventoryManager _inventoryManager;
private final TreasureRewardManager _rewardManager;
public TreasureManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, GadgetManager gadgetManager, BlockRestore blockRestore, HologramManager hologramManager, StatsManager statsManager, RewardManager rewardManager)
private final List<Treasure> _treasures;
private final List<TreasureLocation> _treasureLocations;
private TreasureManager()
{
super("Treasure", plugin);
super("Treasure");
_clientManager = clientManager;
_inventoryManager = inventoryManager;
_blockRestore = blockRestore;
_hologramManager = hologramManager;
_statsManager = statsManager;
_rewardManager = rewardManager;
_bonusManager = require(BonusManager.class);
_clientManager = require(CoreClientManager.class);
_donationManager = require(DonationManager.class);
_inventoryManager = require(InventoryManager.class);
_rewardManager = require(TreasureRewardManager.class);
_treasureLocations = Lists.newArrayList();
_blockLocations = Lists.newArrayList();
_items = Lists.newArrayList();
_treasures = new ArrayList<>();
_treasureLocations = new ArrayList<>(5);
for(Location location : LocationConstants.CHEST_LOCATIONS)
populateTreasureTypes();
}
private void populateTreasureTypes()
{
_treasures.add(new OldTreasure());
}
public void addTreasureLocation(Location location)
{
TreasureLocation treasureLocation = new TreasureLocation(this, location);
UtilServer.RegisterEvents(treasureLocation);
_treasureLocations.add(treasureLocation);
}
public int getChestsToOpen(Player player)
{
int chests = 0;
for (Treasure treasure : _treasures)
{
Location resetLocation = LocationConstants.getResetLocation(location);
Block[] blocks = setup(location.getBlock());
_blockLocations.add(location);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, location.getBlock(), blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
chests += getChestsToOpen(player, treasure);
}
for (TreasureLocation treasureLocation : _treasureLocations)
return chests;
}
public int getChestsToOpen(Player player, Treasure treasure)
{
return _inventoryManager.Get(player).getItemCount(treasure.getTreasureType().getItemName());
}
public void purchase(Consumer<Integer> callback, Player player, Treasure treasure, int amount)
{
if (!Recharge.Instance.use(player, "Buy Treasure Chest", 1000, false, false))
{
_plugin.getServer().getPluginManager().registerEvents(treasureLocation, _plugin);
return;
}
gadgetManager.setTreasureManager(this);
}
int ownedItems = _rewardManager.getOwnedItems(player, treasure);
int totalItems = _rewardManager.getTotalItems(treasure);
private Block[] setup(Block chestBlock)
{
List<Location> locations = Lists.newArrayList(new Location(chestBlock.getWorld(), chestBlock.getX() + 3, chestBlock.getY(), chestBlock.getZ() - 1),
new Location(chestBlock.getWorld(), chestBlock.getX() + 3, chestBlock.getY(), chestBlock.getZ() + 1),
new Location(chestBlock.getWorld(), chestBlock.getX() - 3, chestBlock.getY(), chestBlock.getZ() - 1),
new Location(chestBlock.getWorld(), chestBlock.getX() - 3, chestBlock.getY(), chestBlock.getZ() + 1),
new Location(chestBlock.getWorld(), chestBlock.getX() - 1, chestBlock.getY(), chestBlock.getZ() + 3),
new Location(chestBlock.getWorld(), chestBlock.getX() + 1, chestBlock.getY(), chestBlock.getZ() - 3),
new Location(chestBlock.getWorld(), chestBlock.getX() + 1, chestBlock.getY(), chestBlock.getZ() + 3),
new Location(chestBlock.getWorld(), chestBlock.getX() - 1, chestBlock.getY(), chestBlock.getZ() - 3));
Block[] blocks = new Block[locations.size()];
for (int i = 0; i < blocks.length; i++)
if (ownedItems == totalItems)
{
blocks[i] = locations.get(i).getBlock();
player.sendMessage(F.main(_moduleName, "Sorry, it seems that you already have all the items for this chest!"));
return;
}
return blocks;
}
@Override
public void disable()
{
for (TreasureLocation treasureLocation : _treasureLocations)
if (!treasure.isDuplicates())
{
treasureLocation.cleanup();
HandlerList.unregisterAll(treasureLocation);
}
_treasureLocations.clear();
}
int chests = getChestsToOpen(player, treasure);
int remainingRewards = totalItems - ownedItems - chests * treasure.getRewardsPerChest();
public void addOpenStat(Player player, TreasureType treasureType)
{
_statsManager.incrementStat(player, "Global.Treasure." + treasureType.getStatName(), 1);
}
public void addTreasureLocation(TreasureLocation loc)
{
_treasureLocations.add(loc);
_plugin.getServer().getPluginManager().registerEvents(loc, _plugin);
}
public Reward[] getRewards(Player player, RewardPool.Type pool, RewardType rewardType)
{
return _rewardManager.getRewards(player, pool, rewardType);
}
public boolean hasItemsToGivePlayer(RewardPool.Type pool, Player player)
{
return _rewardManager.hasItemsToGivePlayer(pool, player);
}
public boolean isOpening(Player player)
{
for (TreasureLocation treasureLocation : _treasureLocations)
{
Treasure treasure = treasureLocation.getCurrentTreasure();
if (treasure == null)
if (amount > remainingRewards)
{
continue;
}
if (treasure.getPlayer().equals(player))
{
return true;
player.sendMessage(F.main(_moduleName, "Hello again, it seems that would you have over-purchased chests. I'll reduce your purchase to the number of items remaining."));
amount = remainingRewards;
}
}
return false;
callback.accept(amount);
}
public BlockRestore getBlockRestore()
public void giveTreasure(Player player, Treasure treasure, int amount)
{
return _blockRestore;
_inventoryManager.addItemToInventory(player, treasure.getTreasureType().getItemName(), amount);
}
public BonusManager getBonusManager()
{
return _bonusManager;
}
public CoreClientManager getClientManager()
@ -164,67 +124,13 @@ public class TreasureManager extends MiniPlugin
return _clientManager;
}
public List<TreasureLocation> getTreasureLocations()
public DonationManager getDonationManager()
{
return _treasureLocations;
return _donationManager;
}
public List<Location> getBlockLocations()
public List<Treasure> getTreasures()
{
return _blockLocations;
}
@EventHandler
public void playCustomAnimation(TreasureStartEvent event)
{
TreasureType treasureType = event.getTreasure().getTreasureType();
/*if (treasureType == TreasureType.ST_PATRICKS)
{
StPatricksChestAnimation stPatricksChestAnimation = new StPatricksChestAnimation(event.getTreasure(), event.getTreasure().getCenterBlock());
event.getTreasure().addAnimation(stPatricksChestAnimation);
_treasureAnimations.put(event.getTreasure(), stPatricksChestAnimation);
}*/
}
@EventHandler
public void stopCustomAnimation(TreasureFinishEvent event)
{
if (_treasureAnimations.containsKey(event.getTreasure()))
{
Animation animation = _treasureAnimations.get(event.getTreasure());
animation.setRunning(false);
}
}
public void addItem(Item item)
{
_items.add(item);
}
@EventHandler
public void pickupItem(PlayerPickupItemEvent event)
{
if (_items.contains(event.getItem()))
{
event.setCancelled(true);
}
}
@EventHandler
public void removeItems(UpdateEvent event)
{
if (event.getType() == UpdateType.TICK)
{
Iterator<Item> it = _items.iterator();
while (it.hasNext())
{
Item item = it.next();
if (item.getTicksLived() >= 20)
{
item.remove();
it.remove();
}
}
}
return _treasures;
}
}

View File

@ -0,0 +1,81 @@
package mineplex.core.treasure;
import java.util.List;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.treasure.animation.TreasureAnimation;
import mineplex.core.treasure.animation.TreasureOpenAnimation;
import mineplex.core.treasure.types.Treasure;
import mineplex.core.reward.Reward;
public class TreasureSession
{
private static final int CHEST_RADIUS = 4;
private final Player _player;
private final TreasureLocation _treasureLocation;
private final Treasure _treasure;
private final List<TreasureAnimation> _animations;
private final List<Reward> _rewards;
public TreasureSession(Player player, TreasureLocation treasureLocation, Treasure treasure)
{
_player = player;
_treasureLocation = treasureLocation;
_treasure = treasure;
_animations = treasure.getAnimations(treasureLocation);
_rewards = Treasure.getRewardManager().getRewards(player, treasure);
if (!hasFailed())
{
for (TreasureAnimation animation : _animations)
{
if (animation instanceof TreasureOpenAnimation)
{
animation.setRunning(true);
break;
}
}
}
}
public List<Reward> getRewards()
{
return _rewards;
}
boolean hasFailed()
{
return _rewards == null;
}
void pushEntitiesAway()
{
for (LivingEntity entity : UtilEnt.getInRadius(_treasureLocation.getChest(), CHEST_RADIUS).keySet())
{
if (entity.equals(_player))
{
continue;
}
UtilAction.velocity(entity, UtilAlg.getTrajectory(_treasureLocation.getChest(), entity.getLocation()).setY(1));
}
}
public Treasure getTreasure()
{
return _treasure;
}
public List<TreasureAnimation> getAnimations()
{
return _animations;
}
}

View File

@ -1,157 +0,0 @@
package mineplex.core.treasure;
import org.bukkit.Sound;
import mineplex.core.common.util.UtilParticle.ParticleType;
public enum TreasureStyle
{
OLD(
ParticleType.EXPLODE,
ParticleType.EXPLODE,
ParticleType.ENCHANTMENT_TABLE,
Sound.FIZZ,
Sound.HORSE_ARMOR),
ANCIENT(
ParticleType.FLAME,
ParticleType.LAVA,
ParticleType.MOB_SPELL,
Sound.LAVA_POP,
Sound.EXPLODE),
MYTHICAL(
ParticleType.HAPPY_VILLAGER,
ParticleType.LARGE_EXPLODE,
ParticleType.INSTANT_SPELL,
Sound.PORTAL_TRAVEL,
Sound.ANVIL_LAND),
CHRISTMAS(
ParticleType.SNOW_SHOVEL,
ParticleType.SNOWBALL_POOF,
ParticleType.SNOW_SHOVEL,
Sound.FIZZ,
Sound.CHICKEN_EGG_POP),
ILLUMINATED(
ParticleType.WITCH_MAGIC,
null,
ParticleType.WITCH_MAGIC,
Sound.ENDERDRAGON_DEATH,
Sound.BLAZE_HIT
),
FREEDOM(
ParticleType.RED_DUST,
ParticleType.RED_DUST,
ParticleType.RED_DUST,
Sound.FIZZ,
Sound.FIREWORK_TWINKLE2
),
OMEGA(
ParticleType.CRIT,
null,
ParticleType.CRIT,
Sound.FIRE,
Sound.FIREWORK_TWINKLE
),
HALLOWEEN(
ParticleType.RED_DUST,
ParticleType.RED_DUST,
ParticleType.RED_DUST,
Sound.IRONGOLEM_HIT,
Sound.IRONGOLEM_THROW
),
THANKFUL(
ParticleType.HAPPY_VILLAGER,
ParticleType.HAPPY_VILLAGER,
ParticleType.HAPPY_VILLAGER,
Sound.CHICKEN_IDLE,
Sound.CHICKEN_EGG_POP
),
GINGERBREAD(
ParticleType.SNOW_SHOVEL,
ParticleType.SNOW_SHOVEL,
ParticleType.SNOW_SHOVEL,
Sound.DIG_SNOW,
Sound.DIG_SNOW
),
MINESTRIKE(
ParticleType.FIREWORKS_SPARK,
ParticleType.FIREWORKS_SPARK,
ParticleType.INSTANT_SPELL,
Sound.EXPLODE,
Sound.EXPLODE
),
LOVECHEST(
ParticleType.HEART,
ParticleType.HEART,
ParticleType.HEART,
Sound.VILLAGER_YES,
Sound.VILLAGER_YES
),
STPATRICKS(
ParticleType.HAPPY_VILLAGER,
ParticleType.HAPPY_VILLAGER,
ParticleType.HAPPY_VILLAGER,
Sound.VILLAGER_YES,
Sound.VILLAGER_YES
),
SPRING(
ParticleType.RED_DUST,
ParticleType.RED_DUST,
ParticleType.RED_DUST,
Sound.STEP_GRASS,
Sound.STEP_GRASS
),
MOBA(
ParticleType.FIREWORKS_SPARK,
ParticleType.FIREWORKS_SPARK,
ParticleType.FIREWORKS_SPARK,
Sound.ANVIL_LAND,
Sound.ANVIL_LAND
),
;
private ParticleType _secondaryParticle;
private ParticleType _chestSpawnParticle;
private ParticleType _hoverParticle;
private Sound _sound;
private Sound _chestSpawnSound;
TreasureStyle(ParticleType secondaryParticle, ParticleType chestSpawnParticle, ParticleType hoverParticle, Sound sound, Sound chestSpawnSound)
{
_secondaryParticle = secondaryParticle;
_chestSpawnParticle = chestSpawnParticle;
_hoverParticle = hoverParticle;
_sound = sound;
_chestSpawnSound = chestSpawnSound;
}
public ParticleType getSecondaryParticle()
{
return _secondaryParticle;
}
public ParticleType getChestSpawnParticle()
{
return _chestSpawnParticle;
}
public ParticleType getHoverParticle()
{
return _hoverParticle;
}
public Sound getSound()
{
return _sound;
}
public Sound getChestSpawnSound()
{
return _chestSpawnSound;
}
}

View File

@ -1,112 +0,0 @@
package mineplex.core.treasure;
import org.bukkit.Material;
import mineplex.core.common.util.C;
import mineplex.core.reward.RewardPool;
import mineplex.core.reward.RewardPool.Type;
import mineplex.core.reward.RewardType;
public enum TreasureType
{
OLD(C.cYellow + "Old Treasure", "Old Chest", "Old", RewardType.OLD_CHEST, Material.CHEST, TreasureStyle.OLD, RewardPool.Type.NORMAL, true, 1000),
ANCIENT(C.cGold + "Ancient Treasure", "Ancient Chest", "Ancient", RewardType.ANCIENT_CHEST, Material.TRAPPED_CHEST, TreasureStyle.ANCIENT, RewardPool.Type.NORMAL, true, 5000),
MYTHICAL(C.cRed + "Mythical Treasure", "Mythical Chest", "Mythical", RewardType.MYTHICAL_CHEST, Material.ENDER_CHEST, TreasureStyle.MYTHICAL, RewardPool.Type.MYTHICAL, true, 10000),
CHRISTMAS(C.cDGreen + "Winter Holiday Treasure", "Winter Chest", "Christmas", RewardType.WINTER_CHEST, Material.CHEST, TreasureStyle.CHRISTMAS, RewardPool.Type.WINTER_HOLIDAY, false, 15000),
ILLUMINATED(C.cAqua + "Illuminated Treasure", "Illuminated Chest", "Illuminated", RewardType.ILLUMINATED_CHEST, Material.CHEST, TreasureStyle.ILLUMINATED, RewardPool.Type.ILLUMINATED, true, 20000),
FREEDOM(C.cRed + "Freedom " + C.cBlue + "Treasure", "Freedom Treasure", "Freedom", RewardType.FREEDOM_CHEST, Material.CHEST, TreasureStyle.FREEDOM, RewardPool.Type.FREEDOM, true, 20000),
OMEGA(C.cAqua + "Omega Chest", "Omega Chest", "Omega", RewardType.OMEGA_CHEST, Material.ENDER_CHEST, TreasureStyle.OMEGA, RewardPool.Type.OMEGA, false, 50000),
HAUNTED(C.cGold + "Haunted Chest", "Haunted Chest", "Haunted", RewardType.HAUNTED_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.HAUNTED, true, 35000),
TRICK_OR_TREAT(C.cGold + "Trick or Treat Treasure", "Trick or Treat Chest", "TrickOrTreat", RewardType.TRICK_OR_TREAT_CHEST, Material.CHEST, TreasureStyle.HALLOWEEN, RewardPool.Type.TRICK_OR_TREAT, true, 20000),
THANKFUL(C.cGold + "Thankful Treasure", "Thankful Chest", "ThankFul", RewardType.THANKFUL_CHEST, Material.CHEST, TreasureStyle.THANKFUL, RewardPool.Type.THANKFUL, true, 20000),
GINGERBREAD(C.cRed + "Gingerbread " + C.cGreen + "Treasure", "Gingerbread Chest", "Gingerbread", RewardType.GINGERBREAD_CHEST, Material.CHEST, TreasureStyle.GINGERBREAD, RewardPool.Type.GINGERBREAD, true, 20000),
MINESTRIKE(C.cGold + "Minestrike Treasure", "Minestrike Chest", "MinestrikeChest", RewardType.MINESTRIKE_CHEST, Material.CHEST, TreasureStyle.MINESTRIKE, RewardPool.Type.MINESTRIKE, true, 10000),
LOVE_CHEST(C.cRed + "Love Treasure", "Love Chest", "LoveChest", RewardType.LOVE_CHEST, Material.CHEST, TreasureStyle.LOVECHEST, RewardPool.Type.LOVECHEST, true, 20000),
ST_PATRICKS(C.cGreen + "St Patrick's Treasure", "St Patricks Chest", "StPatricksChest", RewardType.ST_PATRICKS, Material.CHEST, TreasureStyle.STPATRICKS,RewardPool.Type.STPATRICKS, true, 20000),
SPRING(C.cGreen + "Spring Treasure", "Spring Chest", "SpringChest", RewardType.SPRING, Material.CHEST, TreasureStyle.SPRING, RewardPool.Type.SPRING, true, 20000),
MOBA(C.cAqua + "Heroes of GWEN Treasure", "HOG Chest", "HOGChest", RewardType.MOBA, Material.ENDER_CHEST, TreasureStyle.MOBA, RewardPool.Type.MOBA, true, 12000),
;
private final String _name;
private final RewardType _rewardType;
private final Material _material;
private final TreasureStyle _treasureStyle;
private final String _itemName;
private final String _statName;
private final RewardPool.Type _rewardPool;
private final int _purchasePrice;
private final boolean _purchasable;
TreasureType(String name, String itemName, String statName, RewardType rewardType, Material material, TreasureStyle treasureStyle, RewardPool.Type rewardPool, boolean purchasable, int purchasePrice)
{
_name = name;
_itemName = itemName;
_statName = statName;
_rewardType = rewardType;
_material = material;
_treasureStyle = treasureStyle;
_rewardPool = rewardPool;
_purchasePrice = purchasePrice;
_purchasable = purchasable;
}
public RewardType getRewardType()
{
return _rewardType;
}
public String getName()
{
return _name;
}
public Material getMaterial()
{
return _material;
}
public TreasureStyle getStyle()
{
return _treasureStyle;
}
public String getItemName()
{
return _itemName;
}
public String getStatName()
{
return _statName;
}
public RewardPool.Type getRewardPool()
{
return _rewardPool;
}
public int getPurchasePrice()
{
return _purchasePrice;
}
public boolean isPurchasable()
{
return _purchasable;
}
}

View File

@ -1,66 +0,0 @@
package mineplex.core.treasure.animation;
import mineplex.core.treasure.Treasure;
/**
* Created by Shaun on 8/29/2014.
*/
public abstract class Animation
{
private Treasure _treasure;
private boolean _running;
private int _ticks;
public Animation(Treasure treasure)
{
_treasure = treasure;
_running = true;
}
public Animation() {}
public void run()
{
tick();
_ticks++;
}
protected abstract void tick();
protected abstract void onFinish();
public void finish()
{
if (_running)
{
_running = false;
onFinish();
}
}
public boolean isRunning()
{
return _running;
}
public int getTicks()
{
return _ticks;
}
public Treasure getTreasure()
{
return _treasure;
}
public void setRunning(boolean b)
{
_running = b;
}
public void setTicks(int ticks)
{
_ticks = ticks;
}
}

View File

@ -1,354 +0,0 @@
package mineplex.core.treasure.animation;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import mineplex.core.common.MaterialData;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
public class BlockChangeAnimation extends Animation
{
private static final int MAX_RADIUS = 4;
private int _currentRadius;
private List<BlockInfo> _blockInfoList;
private Block[] _chests;
public BlockChangeAnimation(Treasure treasure, List<BlockInfo> blockInfoList, Block[] chests)
{
super(treasure);
_currentRadius = 0;
_blockInfoList = blockInfoList;
_chests = chests;
}
@Override
protected void tick()
{
if (_currentRadius == MAX_RADIUS)
{
finish();
return;
}
else if (getTicks() % 10 == 0)
{
Block centerBlock = getTreasure().getCenterBlock().getRelative(BlockFace.DOWN);
for (int x = -_currentRadius; x <= _currentRadius; x++)
{
for (int y = 0; y <= _currentRadius; y++)
{
for (int z = -_currentRadius; z <= _currentRadius; z++)
{
Block b = centerBlock.getRelative(x, y, z);
if (y > 0 && (b.getType() == Material.SMOOTH_BRICK || b.getType() == Material.STEP || b.getType() == Material.SMOOTH_STAIRS))
{
_blockInfoList.add(new BlockInfo(b));
b.setType(Material.AIR);
}
else if (b.getType() == Material.SMOOTH_BRICK)
{
if (getTreasure().getTreasureType() == TreasureType.OLD)
continue;
Material mat;
byte data = -1;
if (getTreasure().getTreasureType() == TreasureType.ANCIENT) mat = Material.NETHER_BRICK;
else if (getTreasure().getTreasureType() == TreasureType.MYTHICAL) mat = Material.QUARTZ_BLOCK;
else if (getTreasure().getTreasureType() == TreasureType.CHRISTMAS) mat = Material.ICE;
else if (getTreasure().getTreasureType() == TreasureType.ILLUMINATED)
{
mat = Material.PRISMARINE;
data = 1;
}
else if (getTreasure().getTreasureType() == TreasureType.FREEDOM)
{
mat = Material.WOOL;
data = 11;
}
else if (getTreasure().getTreasureType() == TreasureType.OMEGA)
{
mat = Material.ENDER_STONE;
data = 0;
}
else if (getTreasure().getTreasureType() == TreasureType.HAUNTED || getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT)
{
mat = Material.WOOL;
data = 1;
}
else if (getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
mat = Material.STAINED_CLAY;
data = 13;
}
else if (getTreasure().getTreasureType() == TreasureType.LOVE_CHEST)
{
mat = Material.WOOL;
data = 6;
}
else if (getTreasure().getTreasureType() == TreasureType.ST_PATRICKS)
{
mat = Material.WOOL;
data = 13;
}
else if (getTreasure().getTreasureType() == TreasureType.SPRING)
{
mat = Material.GRASS;
}
else if (getTreasure().getTreasureType() == TreasureType.MOBA)
{
mat = Material.PRISMARINE;
data = 1;
}
else
continue;
_blockInfoList.add(new BlockInfo(b));
b.setType(mat);
if(data != -1) b.setData(data);
}
else if (b.getType() == Material.SMOOTH_STAIRS || b.getType() == Material.COBBLESTONE_STAIRS)
{
if (getTreasure().getTreasureType() == TreasureType.OLD)
continue;
Material mat;
byte data = -1;
if (getTreasure().getTreasureType() == TreasureType.ANCIENT) mat = Material.NETHER_BRICK_STAIRS;
else if (getTreasure().getTreasureType() == TreasureType.MYTHICAL) mat = Material.QUARTZ_STAIRS;
else if (getTreasure().getTreasureType() == TreasureType.CHRISTMAS) mat = Material.PACKED_ICE;
else if (getTreasure().getTreasureType() == TreasureType.ILLUMINATED)
{
mat = Material.PRISMARINE;
data = 2;
}
else if (getTreasure().getTreasureType() == TreasureType.FREEDOM)
{
mat = Material.WOOL;
data = 14;
}
else if (getTreasure().getTreasureType() == TreasureType.OMEGA)
{
mat = Material.ENDER_STONE;
data = 0;
}
else if (getTreasure().getTreasureType() == TreasureType.HAUNTED || getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT)
{
mat = Material.WOOL;
data = 15;
}
else if (getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
mat = Material.STAINED_CLAY;
data = 14;
}
else if (getTreasure().getTreasureType() == TreasureType.LOVE_CHEST)
{
mat = Material.WOOL;
data = 14;
}
else if (getTreasure().getTreasureType() == TreasureType.ST_PATRICKS)
{
mat = Material.GOLD_BLOCK;
data = 0;
}
else if (getTreasure().getTreasureType() == TreasureType.SPRING)
{
mat = Material.DIRT;
data = 2;
}
else if (getTreasure().getTreasureType() == TreasureType.MOBA)
{
mat = Material.STAINED_CLAY;
data = 11;
}
else
continue;
_blockInfoList.add(new BlockInfo(b));
if(data == -1) data = b.getData();
b.setType(mat);
b.setData(data);
}
if(getTreasure().getTreasureType() == TreasureType.ILLUMINATED)
{
for(Block c : _chests)
{
if(c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
b.setType(Material.SEA_LANTERN);
}
}
}
else if (getTreasure().getTreasureType() == TreasureType.FREEDOM)
{
for(Block c : _chests)
{
if(c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
b.setType(Material.WOOL);
b.setData((byte) 0);
}
}
}
else if (getTreasure().getTreasureType() == TreasureType.HAUNTED)
{
for(Block c : _chests)
{
if(c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
b.setType(Material.JACK_O_LANTERN);
b.setData(getDirection(c));
}
}
}
else if (getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT)
{
for (Block c : _chests)
{
if (c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
b.setType(Material.CAULDRON);
b.setData((byte)3);
}
}
}
else if (getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
for (Block c : _chests)
{
if (c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
try
{
Skull skull = UtilBlock.blockToSkull(c, SkinData.GINGERBREAD);
if (skull != null)
{
skull.setRotation(getSkullDirection(skull.getBlock()));
skull.update();
}
else
{
c.setType(Material.AIR);
}
} catch (Exception e)
{
e.printStackTrace();
}
}
}
}
else if (getTreasure().getTreasureType() == TreasureType.LOVE_CHEST)
{
for (Block c : _chests)
{
if (c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
b.setType(Material.WOOL);
b.setData((byte) 6);
}
}
}
else if (getTreasure().getTreasureType() == TreasureType.SPRING)
{
List<MaterialData> materials = new ArrayList<>();
materials.add(MaterialData.of(Material.LEAVES, (byte) 0));
materials.add(MaterialData.of(Material.LEAVES, (byte) 1));
materials.add(MaterialData.of(Material.LEAVES, (byte) 2));
materials.add(MaterialData.of(Material.LEAVES, (byte) 3));
materials.add(MaterialData.of(Material.LEAVES_2, (byte) 0));
materials.add(MaterialData.of(Material.LEAVES_2, (byte) 1));
for (Block c : _chests)
{
if (c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
int r = UtilMath.random.nextInt(materials.size());
MaterialData materialData = materials.get(r);
b.setType(materialData.getMaterial());
b.setData(materialData.getData());
}
}
}
else if(getTreasure().getTreasureType() == TreasureType.MOBA)
{
for(Block c : _chests)
{
if(c.equals(b))
{
_blockInfoList.add(new BlockInfo(b));
b.setType(Material.PRISMARINE);
}
}
}
}
}
}
_currentRadius++;
}
}
@Override
protected void onFinish()
{
}
private byte getDirection(Block block)
{
byte direction;
int relX = getTreasure().getCenterBlock().getX() - block.getX();
int relZ = getTreasure().getCenterBlock().getZ() - block.getZ();
if (Math.abs(relX) > Math.abs(relZ))
{
if (relX > 0)
direction = (byte) 3;
else
direction = (byte) 1;
}
else
{
if (relZ > 0)
direction = (byte) 0;
else
direction = (byte) 2;
}
return direction;
}
private BlockFace getSkullDirection(Block block)
{
byte direction = getDirection(block);
switch (direction)
{
case (byte) 0:
return BlockFace.SOUTH;
case (byte) 1:
return BlockFace.WEST;
case (byte) 2:
return BlockFace.NORTH;
case (byte) 3:
return BlockFace.EAST;
default:
return BlockFace.SOUTH;
}
}
}

View File

@ -1,125 +0,0 @@
package mineplex.core.treasure.animation;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.reward.RankRewardData;
import mineplex.core.reward.RewardData;
import mineplex.core.treasure.ChestData;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction;
import net.minecraft.server.v1_8_R3.TileEntity;
import net.minecraft.server.v1_8_R3.TileEntityEnderChest;
/**
* Created by Shaun on 8/29/2014.
*/
public class ChestOpenAnimation extends Animation
{
private ChestData _chestData;
private RewardData _rewardData;
private HologramManager _hologramManager;
private Item _itemEntity;
private Hologram _hologram;
public ChestOpenAnimation(Treasure treasure, ChestData chestData, RewardData rewardData, HologramManager hologramManager)
{
super(treasure);
_hologramManager = hologramManager;
_chestData = chestData;
_rewardData = rewardData;
if (treasure.getTreasureType() == TreasureType.TRICK_OR_TREAT && rewardData instanceof RankRewardData)
{
Block block = chestData.getBlock();
for (Player other : UtilServer.getPlayers())
{
other.sendBlockChange(block.getLocation(), Material.DRAGON_EGG, (byte)0);
}
return;
}
// Send chest open packet
Block block = chestData.getBlock();
PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(new BlockPosition(block.getX(), block.getY(), block.getZ()),
CraftMagicNumbers.getBlock(block), 1, 1);
for (Player other : UtilServer.getPlayers())
{
UtilPlayer.sendPacket(other, packet);
if (block.getType() == Material.ENDER_CHEST)
{
// Fix for Ender Chests closing as soon as they are opened
TileEntity tileEntity = ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());
if (tileEntity instanceof TileEntityEnderChest)
((TileEntityEnderChest)tileEntity).g = 1;
}
other.playSound(block.getLocation(), Sound.CHEST_OPEN, 1, 1);
}
}
@Override
protected void tick()
{
if (getTicks() == 5)
{
double y = UtilBlock.getSize(_chestData.getBlock(), BlockFace.UP);
Location location = _chestData.getBlock().getLocation().add(0.5, y, 0.5);
_itemEntity = location.getWorld().dropItem(location, _rewardData.getDisplayItem());
_itemEntity.setVelocity(new Vector(0, 0, 0));
_itemEntity.setPickupDelay(Integer.MAX_VALUE);
}
else if (getTicks() == 15)
{
if (_rewardData.getHeader() != null)
{
_hologram = new Hologram(_hologramManager, _chestData.getBlock().getLocation().add(0.5, 1.4, 0.5),
_rewardData.getHeader(), _rewardData.getFriendlyName());
}
else
{
_hologram = new Hologram(_hologramManager, _chestData.getBlock().getLocation().add(0.5, 1.4, 0.5),
_rewardData.getFriendlyName());
}
_hologram.start();
}
else if (getTicks() == 25)
{
if (_rewardData.isRewardedShards())
{
if (_rewardData.getHeader() != null)
_hologram.setText(C.cWhite + "Duplicate", C.cAqua + "+" + _rewardData.getShards() + " Treasure Shards", " ", _rewardData.getHeader(), _rewardData.getFriendlyName());
else
_hologram.setText(C.cWhite + "Duplicate", C.cAqua + "+" + _rewardData.getShards() + " Treasure Shards", " ", _rewardData.getFriendlyName());
}
}
}
public void onFinish()
{
if (_hologram != null)
{
_hologram.stop();
_itemEntity.remove();
}
}
}

View File

@ -1,450 +0,0 @@
package mineplex.core.treasure.animation;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.MathHelper;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import com.google.common.collect.Lists;
import mineplex.core.Managers;
import mineplex.core.common.MaterialData;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseBat;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.particleeffects.BabyFireworkEffect;
import mineplex.core.particleeffects.CircleEffect;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
public class ChestSpawnAnimation extends Animation implements Listener
{
private static final int ANIMATION_DURATION = 80;
private Block _block;
private byte _direction;
private Location _centerLocation;
private Location _particleLocation;
private Vector _particleDirection;
private Location _openingCenter;
private List<BlockInfo> _chestBlockInfo;
private double _radialOffset;
private JavaPlugin _javaPlugin;
private int _babyFireworks = 0;
private int _circleAmount = 0;
private int _currentHauntedColor = 0;
private List<ArmorStand> _bats = Lists.newArrayList();
private List<MaterialData> _flowers = new ArrayList<>();
private List<Item> _droppedFlowers = new ArrayList<>();
public ChestSpawnAnimation(Treasure treasure, Block block, List<BlockInfo> chestBlockInfo, Block openingCenter, double radialOffset, JavaPlugin javaPlugin)
{
super(treasure);
_block = block;
int relX = getTreasure().getCenterBlock().getX() - block.getX();
int relZ = getTreasure().getCenterBlock().getZ() - block.getZ();
if (Math.abs(relX) > Math.abs(relZ))
{
if (relX > 0)
_direction = (byte) 5;
else
_direction = (byte) 4;
}
else
{
if (relZ > 0)
_direction = (byte) 3;
else
_direction = (byte) 2;
}
_centerLocation = block.getLocation().clone().add(0.5, 0.5, 0.5);
_chestBlockInfo = chestBlockInfo;
_particleLocation = openingCenter.getLocation().clone().add(0.5, 4, 0.5);
_openingCenter = openingCenter.getLocation();
_particleDirection = UtilAlg.getTrajectory(_particleLocation, _centerLocation);
_particleDirection.multiply(UtilMath.offset(_particleLocation, _centerLocation) / (double)ANIMATION_DURATION);
if (treasure.getTreasureType() == TreasureType.TRICK_OR_TREAT)
{
for (int i = 0; i < 5; i++)
{
ArmorStand stand = (ArmorStand)_centerLocation.getWorld().spawnEntity(_centerLocation, EntityType.ARMOR_STAND);
stand.setGravity(false);
stand.setVisible(false);
_bats.add(stand);
}
doBats(true, _centerLocation.clone().add(0, 6, 0), _bats);
}
_radialOffset = radialOffset;
_javaPlugin = javaPlugin;
Bukkit.getPluginManager().registerEvents(this, javaPlugin);
}
@Override
public void tick()
{
float scale = (float)((double)(ANIMATION_DURATION - getTicks()) / (double)ANIMATION_DURATION);
//Move Particle Forwards
_particleLocation.add(_particleDirection);
Iterator<Item> droppedFlowersIterator = _droppedFlowers.iterator();
while (droppedFlowersIterator.hasNext())
{
Item flower = droppedFlowersIterator.next();
if (flower.getTicksLived() >= 20)
{
flower.remove();
droppedFlowersIterator.remove();
}
}
//Play Particles
if (getTreasure().getTreasureType() == TreasureType.OLD || getTreasure().getTreasureType() == TreasureType.LOVE_CHEST)
{
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation, 0.1f, 0.1f, 0.1f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (getTreasure().getTreasureType() == TreasureType.ANCIENT)
{
float x = (float) (Math.sin(getTicks()/4D));
float z = (float) (Math.cos(getTicks()/4D));
Location newLoc = _particleLocation.clone();
newLoc.add(UtilAlg.getLeft(_particleDirection).multiply(x * scale));
newLoc.add(UtilAlg.getUp(_particleDirection).multiply(z * scale));
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), newLoc, 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (getTreasure().getTreasureType() == TreasureType.MYTHICAL || getTreasure().getTreasureType() == TreasureType.MINESTRIKE ||
getTreasure().getTreasureType() == TreasureType.ST_PATRICKS || getTreasure().getTreasureType() == TreasureType.MOBA)
{
float y = 5 * scale;
double width = 0.7 * ((double) getTicks() / (double) ANIMATION_DURATION);
for (int i=0 ; i < 2 ; i++)
{
double lead = i * ((2d * Math.PI)/2);
float x = (float) (Math.sin(getTicks()/4D + lead));
float z = (float) (Math.cos(getTicks()/4D + lead));
if (getTreasure().getTreasureType() == TreasureType.MYTHICAL || getTreasure().getTreasureType() == TreasureType.MOBA)
{
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else
{
DustSpellColor minestrikeColor = new DustSpellColor(Color.YELLOW);
DustSpellColor stpatricksColor = new DustSpellColor(Color.GREEN);
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST,
(getTreasure().getTreasureType() == TreasureType.MINESTRIKE) ? minestrikeColor : stpatricksColor, _centerLocation.clone().add(x * width, y, z * width));
coloredParticle.display();
}
}
}
else if (getTreasure().getTreasureType() == TreasureType.CHRISTMAS)
{
float spread = 1f - (getTicks() / (float)ANIMATION_DURATION);
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, _centerLocation.clone().add(0, 5, 0), spread, 0.1f, spread, 0, 30,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (getTreasure().getTreasureType() == TreasureType.ILLUMINATED || getTreasure().getTreasureType() == TreasureType.THANKFUL)
{
Location loc = _centerLocation.clone();
loc.add(Vector.getRandom().subtract(Vector.getRandom()).multiply(0.5));
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), loc, null, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
if(getTicks() >= ANIMATION_DURATION-70 && getTicks() <= ANIMATION_DURATION-30)
{
loc = _centerLocation.clone().subtract(0, 0.5, 0);
UtilParticle.PlayParticleToAll(ParticleType.PORTAL, loc, null, 0.55f, 20, ViewDist.NORMAL);
}
}
else if (getTreasure().getTreasureType() == TreasureType.FREEDOM)
{
if (_babyFireworks <= 2)
{
Location loc = _centerLocation.clone().add(Vector.getRandom().subtract(Vector.getRandom()).multiply(0.5));
int r = (int) (Math.random() * 3);
BabyFireworkEffect babyFireworkEffect = new BabyFireworkEffect(loc, _javaPlugin, (r == 0) ?
Color.RED : (r == 1) ? Color.WHITE : Color.BLUE);
babyFireworkEffect.start();
_babyFireworks++;
}
}
else if (getTreasure().getTreasureType() == TreasureType.OMEGA)
{
if (_circleAmount <= 15)
{
int particles = 50;
int radius = 1;
for (int i = 0; i < particles; i++)
{
double angle = (double) 2 * Math.PI * i / particles;
double x = Math.cos(angle) * radius;
double z = Math.sin(angle) * radius;
Location loc = _centerLocation.clone().add(x, .1 * _circleAmount, z);
UtilParticle.PlayParticleToAll(ParticleType.PORTAL, loc, null, 0, 2, ViewDist.NORMAL);
}
}
_circleAmount++;
}
else if (getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
CircleEffect circleEffect = new CircleEffect(_javaPlugin, _centerLocation.clone().add(0, 0.5, 0), 1.3, Color.GREEN);
circleEffect.setMaxCircles(2);
circleEffect.start();
}
else if (getTreasure().getTreasureType() == TreasureType.HAUNTED || getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT)
{
float x = (float) (Math.sin(getTicks()/4D));
float z = (float) (Math.cos(getTicks()/4D));
Location newLoc = _particleLocation.clone();
newLoc.add(UtilAlg.getLeft(_particleDirection).multiply(x * scale));
newLoc.add(UtilAlg.getUp(_particleDirection).multiply(z * scale));
Color color = (_currentHauntedColor == 0) ? Color.ORANGE : Color.BLACK;
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST, new DustSpellColor(color), newLoc);
coloredParticle.display();
if (_currentHauntedColor == 0)
{
_currentHauntedColor = 1;
}
else
{
_currentHauntedColor = 0;
}
if (getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT)
{
doBats(true, _centerLocation.clone().add(0, 6, 0), _bats);
}
}
else if (getTreasure().getTreasureType() == TreasureType.SPRING)
{
if (getTicks() % 5 == 0)
{
if (_flowers.size() == 0)
generateFlowerList();
int r = UtilMath.random.nextInt(_flowers.size());
MaterialData materialData = _flowers.get(r);
Item flower = _openingCenter.getWorld().dropItem(_openingCenter.clone().add(0.5, 0, 0.5), ItemStackFactory.Instance.CreateStack(materialData.getMaterial(), materialData.getData(), 1, "Flower" + getTicks()));
Vector vel = new Vector(_openingCenter.getX() - _centerLocation.getX(), 0, _openingCenter.getZ() - _centerLocation.getZ());
UtilAction.velocity(flower, vel, 0.1, false, 0, 0.2 + 1 * 0.4, 1, false);
_droppedFlowers.add(flower);
}
}
//Spawn Chest
if (getTicks() >= ANIMATION_DURATION)
{
if(getTreasure().getTreasureType() == TreasureType.ILLUMINATED || getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
UtilBlock.setQuick(_block.getWorld(), _block.getX(), _block.getY(), _block.getZ(), 0, (byte) 0);
}
_chestBlockInfo.add(new BlockInfo(_block));
getTreasure().setBlock(_block, getTreasure().getTreasureType().getMaterial(), _direction);
_block.getLocation().getWorld().playSound(_centerLocation, getTreasure().getTreasureType().getStyle().getChestSpawnSound(), 0.5f, 1f);
if(getTreasure().getTreasureType() == TreasureType.ILLUMINATED)
{
Location loc = _block.getLocation().add(0.5, 0.2, 0.5);
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), loc, 0.7f, 0.7f, 0.7f, 1, 50,
ViewDist.NORMAL, UtilServer.getPlayers());
}
if (getTreasure().getTreasureType() == TreasureType.TRICK_OR_TREAT)
{
_bats.forEach(bat -> bat.remove());
_bats.clear();
}
UtilParticle.ParticleType particleType = getTreasure().getTreasureType().getStyle().getChestSpawnParticle();
if (particleType != null)
{
if (getTreasure().getTreasureType() == TreasureType.MINESTRIKE)
{
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST, new DustSpellColor(Color.YELLOW), _centerLocation.clone().add(0, 1, 0));
coloredParticle.display(50);
}
else if (getTreasure().getTreasureType() != TreasureType.FREEDOM && getTreasure().getTreasureType() != TreasureType.HAUNTED
&& getTreasure().getTreasureType() != TreasureType.GINGERBREAD && getTreasure().getTreasureType() != TreasureType.LOVE_CHEST)
{
UtilParticle.PlayParticle(particleType, _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (getTreasure().getTreasureType() == TreasureType.LOVE_CHEST)
{
UtilParticle.PlayParticle(particleType, _centerLocation, 0.2f, 0.2f, 0.2f, 0, 15,
ViewDist.NORMAL, UtilServer.getPlayers());
}
else if (getTreasure().getTreasureType() == TreasureType.FREEDOM)
{
int r = (int) (Math.random() * 3);
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST,
new DustSpellColor((r == 0) ? Color.RED : (r == 1) ? Color.WHITE : Color.BLUE),
_centerLocation.clone().add(.5, .5, .5));
coloredParticle.display();
}
else if (getTreasure().getTreasureType() == TreasureType.GINGERBREAD)
{
int r = (int) (Math.random() * 3);
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST,
new DustSpellColor(Color.GREEN),
_centerLocation.clone().add(.5, .5, .5));
coloredParticle.display();
}
else
{
int r = (int) (Math.random() * 2);
ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST,
new DustSpellColor((r == 0) ? Color.ORANGE : Color.BLACK),
_centerLocation.clone().add(.5, .5, .5));
coloredParticle.display();
}
}
else
{
// TODO This doesnt work for 1.8 clients
int i = MathHelper.floor(_centerLocation.getX());
int j = MathHelper.floor(_centerLocation.getY() - 0.20000000298023224D - 0.5);
int k = MathHelper.floor(_centerLocation.getZ());
((CraftWorld) _centerLocation.getWorld()).getHandle().triggerEffect(2006, new BlockPosition(i, j, k), MathHelper.f(60 - 3.0F));
}
finish();
}
}
@Override
protected void onFinish()
{
HandlerList.unregisterAll(this);
for (Item item : _droppedFlowers)
{
item.remove();
}
_droppedFlowers.clear();
}
private void doBats(boolean initial, Location center, List<ArmorStand> bats)
{
for (int i = 0; i < bats.size(); i++)
{
ArmorStand bat = bats.get(i);
double lead = i * ((2d * Math.PI)/bats.size());
double sizeMod = 2;
//Orbit
double speed = 10d;
double oX = -Math.sin(getTicks()/speed + lead) * 2 * sizeMod;
double oY = 0;
double oZ = Math.cos(getTicks()/speed + lead) * 2 * sizeMod;
if (initial)
{
DisguiseManager disguiseMan = Managers.get(DisguiseManager.class);
DisguiseBat disguise = new DisguiseBat(bat);
disguise.setSitting(false);
disguiseMan.disguise(disguise);
bat.teleport(center.clone().add(oX, oY, oZ));
}
else
{
Location to = center.clone().add(oX, oY, oZ);
UtilEnt.LookAt(bat, to);
UtilAction.velocity(bat, UtilAlg.getTrajectory(bat.getLocation(), to), 0.4, false, 0, 0.1, 1, true);
}
}
}
private void generateFlowerList()
{
_flowers.add(MaterialData.of(Material.LONG_GRASS, (byte) 1));
_flowers.add(MaterialData.of(Material.LONG_GRASS, (byte) 2));
_flowers.add(MaterialData.of(Material.DEAD_BUSH, (byte) 0));
_flowers.add(MaterialData.of(Material.YELLOW_FLOWER, (byte) 0));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 0));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 1));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 2));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 3));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 4));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 5));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 6));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 7));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 8));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 0));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 1));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 2));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 3));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 4));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 5));
}
@EventHandler
public void onPickup(PlayerPickupItemEvent event)
{
if (_droppedFlowers.contains(event.getItem()))
event.setCancelled(true);
}
}

View File

@ -1,37 +0,0 @@
package mineplex.core.treasure.animation;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.treasure.Treasure;
import org.bukkit.Location;
public class FreedomChestAnimation extends Animation
{
private Location _centerLocation;
public FreedomChestAnimation(Treasure treasure, Location location)
{
super(treasure);
_centerLocation = location;
}
@Override
protected void tick()
{
if (getTicks() == 2)
{
UtilFirework.playFreedomFirework(_centerLocation);
}
else if (getTicks() >= 60)
{
finish();
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -1,85 +0,0 @@
package mineplex.core.treasure.animation;
import java.util.Random;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 14-09-12.
*/
public class LootLegendaryAnimation extends Animation
{
/**
* Played when a "Very Rare" chest is opened
*/
private Random _random = new Random();
private Block _chestBlock;
public LootLegendaryAnimation(Treasure treasure, Block chestBlock)
{
super(treasure);
_chestBlock = chestBlock;
}
@Override
protected void tick()
{
if (getTicks() < 12 && getTicks() % 3 == 0)
{
UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.LIME, true, true);
}
if (getTicks() == 1)
{
_chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
}
else if (getTicks() < 35)
{
double radius = 2 - (getTicks() / 10D * 2);
int particleAmount = 20 - (getTicks() * 2);
Location _centerLocation = _chestBlock.getLocation().add(0.5, 0.1, 0.5);
for (int i = 0; i < particleAmount; i++)
{
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, 0, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, location, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
else if (getTicks() < 40)
{
double xDif = _random.nextGaussian() * 0.5;
double zDif = _random.nextGaussian() * 0.5;
double yDif = _random.nextGaussian() * 0.5;
Location loc = _chestBlock.getLocation().add(0.5, 0.5, 0.5).add(xDif, zDif, yDif);
loc.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 0F);
}
else
{
finish();
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -1,65 +0,0 @@
package mineplex.core.treasure.animation;
import java.util.Random;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 14-09-12.
*/
public class LootMythicalAnimation extends Animation
{
/**
* Played when a "Very Rare" chest is opened
*/
private Random _random = new Random();
private Block _chestBlock;
public LootMythicalAnimation(Treasure treasure, Block chestBlock)
{
super(treasure);
_chestBlock = chestBlock;
}
@Override
protected void tick()
{
if (getTicks() < 30 && getTicks() % 3 == 0)
{
UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true);
}
if (getTicks() == 1)
{
_chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.PORTAL_TRAVEL, 10F, 2.0F);
_chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.ZOMBIE_UNFECT, 10F, 0.1F);
}
else if (getTicks() < 60)
{
UtilFirework.launchFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.RED, true, true,
new Vector((Math.random()-0.5)*0.05, 0.1, (Math.random()-0.5)*0.05), 1);
}
else
{
finish();
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -1,80 +0,0 @@
package mineplex.core.treasure.animation;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 2014-09-09.
*/
public class LootRareAnimation extends Animation
{
/**
* Played when a "Rare" chest is opened
*/
private Location _centerLocation;
public LootRareAnimation(Treasure treasure, Location centerLocation)
{
super(treasure);
_centerLocation = centerLocation;
}
@Override
protected void tick()
{
if (getTicks() == 2)
{
UtilFirework.playFirework(_centerLocation, Type.BALL, Color.FUCHSIA, false, false);
_centerLocation.getWorld().playSound(_centerLocation, Sound.WITHER_SPAWN, 10F, 1.2F);
}
else if (getTicks() >= 60)
{
finish();
}
//Particle Ground
{
double currentRotation = getTicks() / 20D;
double radius = currentRotation;
double yDiff = currentRotation;
double xDiff = Math.sin(currentRotation * 2 * Math.PI) * radius;
double zDiff = Math.cos(currentRotation * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, yDiff, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
//Particle Spiral Up
double radius = getTicks() / 20D;
int particleAmount = getTicks() / 2;
for (int i = 0; i < particleAmount; i++)
{
double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius;
double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius;
Location location = _centerLocation.clone().add(xDiff, -1.3, zDiff);
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -1,57 +0,0 @@
package mineplex.core.treasure.animation;
import java.util.Random;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.treasure.Treasure;
/**
* Created by shaun on 2014-09-09.
*/
public class LootUncommonAnimation extends Animation
{
/**
* Played when an "Uncommon" chest is opened
*/
private Random _random = new Random();
private Block _block;
public LootUncommonAnimation(Treasure treasure, Block block)
{
super(treasure);
_block = block;
}
@Override
protected void tick()
{
if (getTicks() >= 10)
finish();
if (getTicks() == 10)
{
UtilFirework.playFirework(_block.getLocation().add(0.5, 0.5, 0.5), Type.BURST, Color.AQUA, false, false);
}
else if (getTicks() % 2 == 0)
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.HEART, _block.getLocation().add(0.5, 1.2, 0.5), 0.5F, 0.2F, 0.5F, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -1,71 +0,0 @@
package mineplex.core.treasure.animation;
import java.util.ArrayList;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.treasure.Treasure;
/**
* Created by Shaun on 8/29/2014.
*/
public class ParticleAnimation extends Animation
{
private static double MODIFIER = 0.5;
private static ArrayList<Vector> PATH = new ArrayList<Vector>();
static
{
double y = 5;
double x = 3;
double z = -3;
for (z = -3; z <= 3; z += MODIFIER)
{
PATH.add(new Vector(x, y, z));
}
for (x = 3; x >= -3; x -= MODIFIER)
{
PATH.add(new Vector(x, y, z));
}
for (z = 3; z >= -3; z -= MODIFIER)
{
PATH.add(new Vector(x, y, z));
}
for (x = -3; x <= 3; x += MODIFIER)
{
PATH.add(new Vector(x, y, z));
}
}
private int pathPosition = 0;
public ParticleAnimation(Treasure treasure)
{
super(treasure);
}
@Override
protected void tick()
{
Vector position = PATH.get(pathPosition);
UtilParticle.PlayParticle(getTreasure().getTreasureType().getStyle().getSecondaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1,
ViewDist.NORMAL, UtilServer.getPlayers());
pathPosition = (pathPosition + 1) % PATH.size();
}
@Override
protected void onFinish()
{
}
}

View File

@ -1,46 +0,0 @@
package mineplex.core.treasure.animation;
import java.awt.Color;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
import mineplex.core.common.shape.ShapeWings;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure;
public class StPatricksChestAnimation extends Animation
{
private Block _center;
private int _tick = 0;
private ShapeWings _cloverBlack = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '#', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER);
private ShapeWings _cloverDarkGreen = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '%', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER);
private ShapeWings _cloverGreen = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(1, 1, 1), 1, 0, '*', ShapeWings.DEFAULT_ROTATION, ShapeWings.FOUR_LEAF_CLOVER);
public StPatricksChestAnimation(Treasure treasure, Block center)
{
super(treasure);
_center = center;
}
@Override
protected void tick()
{
_tick++;
if (_tick % 5 == 0)
{
_cloverBlack.displayColored(_center.getLocation().add(0, 5, 0), Color.BLACK);
_cloverDarkGreen.displayColored(_center.getLocation().add(0, 5, 0), new Color(0, 100, 0));
_cloverGreen.displayColored(_center.getLocation().add(0, 5, 0), Color.GREEN);
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -0,0 +1,118 @@
package mineplex.core.treasure.animation;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.util.EulerAngle;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.types.Treasure;
public abstract class TreasureAnimation implements Runnable
{
private final Treasure _treasure;
private final TreasureLocation _treasureLocation;
protected final List<ArmorStand> _stands;
private int _tick;
private boolean _running;
public TreasureAnimation(Treasure treasure, TreasureLocation treasureLocation)
{
_treasure = treasure;
_treasureLocation = treasureLocation;
_stands = new ArrayList<>();
}
protected abstract void onStart();
@Override
public void run()
{
onTick();
_tick++;
}
public abstract void onTick();
protected abstract void onFinish();
public void cleanup()
{
_stands.forEach(Entity::remove);
_stands.clear();
}
protected ArmorStand spawnArmourStand(Location location)
{
float yaw = Math.round(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _treasureLocation.getChest())) / 90F) * 90F;
location.setYaw(yaw);
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _treasureLocation.getChest())));
ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class);
stand.setVisible(false);
stand.setGravity(false);
_stands.add(stand);
return stand;
}
protected void shakeArmourStand(ArmorStand stand, double magnitude)
{
stand.setHeadPose(
new EulerAngle(
UtilMath.random(-magnitude, magnitude),
UtilMath.random(-magnitude, magnitude),
UtilMath.random(-magnitude, magnitude)
)
);
}
protected void resetArmourStand(ArmorStand stand)
{
stand.setHeadPose(EulerAngle.ZERO);
}
public Treasure getTreasure()
{
return _treasure;
}
public TreasureLocation getTreasureLocation()
{
return _treasureLocation;
}
public int getTicks()
{
return _tick;
}
public boolean isRunning()
{
return _running;
}
public void setRunning(boolean running)
{
_running = running;
if (_running)
{
onStart();
}
else
{
onFinish();
}
}
}

View File

@ -0,0 +1,13 @@
package mineplex.core.treasure.animation;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.types.Treasure;
public abstract class TreasureOpenAnimation extends TreasureAnimation
{
public TreasureOpenAnimation(Treasure treasure, TreasureLocation treasureLocation)
{
super(treasure, treasureLocation);
}
}

View File

@ -1,108 +0,0 @@
package mineplex.core.treasure.animation;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.common.MaterialData;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilMath;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.treasure.BlockInfo;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureType;
public class TreasureRemoveAnimation extends Animation
{
private Random _random = new Random();
private List<BlockInfo> _otherChests;
private int _count = 0;
private List<MaterialData> _flowers = new ArrayList<>();
public TreasureRemoveAnimation(Treasure treasure, List<BlockInfo> otherChests)
{
super(treasure);
_otherChests = otherChests;
}
@Override
protected void tick()
{
if (getTicks() >= 20 && getTicks() % 10 == 0)
{
if (!_otherChests.isEmpty())
{
BlockInfo info = _otherChests.remove(_random.nextInt(_otherChests.size()));
getTreasure().resetBlockInfo(info);
if (getTreasure().getTreasureType() == TreasureType.ST_PATRICKS)
{
// Drops gold nugget
dropItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_NUGGET, (byte) 0, 1, "DroppedNugget" + _count), info);
_count++;
}
else if (getTreasure().getTreasureType() == TreasureType.SPRING)
{
// Drops random flower
if (_flowers.size() == 0)
generateFlowerList();
int r = UtilMath.random.nextInt(_flowers.size());
MaterialData materialData = _flowers.get(r);
dropItem(ItemStackFactory.Instance.CreateStack(materialData.getMaterial(), materialData.getData(), 1, "Flower" + _count), info);
_count++;
info.getBlock().setType(Material.AIR);
info.getBlock().setData((byte) 0);
}
}
else
{
finish();
}
}
}
private void dropItem(ItemStack itemStack, BlockInfo blockInfo)
{
Location location = blockInfo.getBlock().getLocation();
Item item = location.getWorld().dropItem(location.add(0, .5, 0), itemStack);
Vector vel = new Vector(Math.sin(_count * 9/5d), 0, Math.cos(_count * 9/5d));
UtilAction.velocity(item, vel, Math.abs(Math.sin(_count * 12/3000d)), false, 0, 0.2 +
Math.abs(Math.cos(_count * 12/3000d))*0.6, 1, false);
getTreasure().getTreasureManager().addItem(item);
}
private void generateFlowerList()
{
_flowers.add(MaterialData.of(Material.LONG_GRASS, (byte) 1));
_flowers.add(MaterialData.of(Material.LONG_GRASS, (byte) 2));
_flowers.add(MaterialData.of(Material.DEAD_BUSH, (byte) 0));
_flowers.add(MaterialData.of(Material.YELLOW_FLOWER, (byte) 0));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 0));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 1));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 2));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 3));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 4));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 5));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 6));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 7));
_flowers.add(MaterialData.of(Material.RED_ROSE, (byte) 8));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 0));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 1));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 2));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 3));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 4));
_flowers.add(MaterialData.of(Material.DOUBLE_PLANT, (byte) 5));
}
@Override
protected void onFinish()
{
}
}

View File

@ -0,0 +1,23 @@
package mineplex.core.treasure.animation;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.types.Treasure;
import mineplex.core.reward.Reward;
public abstract class TreasureRewardAnimation extends TreasureAnimation
{
private final Reward _reward;
public TreasureRewardAnimation(Treasure treasure, TreasureLocation treasureLocation, Reward reward)
{
super(treasure, treasureLocation);
_reward = reward;
}
public Reward getReward()
{
return _reward;
}
}

View File

@ -0,0 +1,94 @@
package mineplex.core.treasure.animation.animations;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.ArmorStand;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.animation.TreasureOpenAnimation;
import mineplex.core.treasure.types.Treasure;
public class OldChestAnimation extends TreasureOpenAnimation
{
private static final ItemStack HELMET = new ItemBuilder(Material.SKULL_ITEM, (byte) 3)
.setPlayerHead("MHF_Chest")
.build();
private static final double SHAKE_MAGNITUDE = Math.PI / 30D;
private int _index;
public OldChestAnimation(Treasure treasure, TreasureLocation treasureLocation)
{
super(treasure, treasureLocation);
}
@Override
protected void onStart()
{
for (Location location : getTreasureLocation().getChestLocations())
{
ArmorStand stand = spawnArmourStand(location.subtract(0, 2.5, 0));
stand.setHelmet(HELMET);
}
}
@Override
public void onTick()
{
if (getTicks() % 10 == 0 && _index != _stands.size())
{
_index++;
}
int chestY = getTreasureLocation().getChest().getBlockY();
boolean moved = false;
for (int i = 0; i < _index; i++)
{
ArmorStand stand = _stands.get(i);
Location location = stand.getLocation();
if (location.getY() > chestY - 1)
{
continue;
}
else if (getTicks() + i % 10 == 0)
{
stand.getWorld().playSound(location, Sound.HORSE_ARMOR, 1, 0.7F);
}
moved = true;
location.add(0, 0.1, 0);
stand.teleport(location);
UtilParticle.PlayParticleToAll(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), stand.getLocation().add(0, 1.5, 0), 0.25F, 0.25F, 0.25F, 0, 3, ViewDist.NORMAL);
if (location.getY() > chestY - 1)
{
resetArmourStand(stand);
}
else
{
shakeArmourStand(stand, SHAKE_MAGNITUDE);
}
}
if (!moved)
{
setRunning(false);
}
}
@Override
protected void onFinish()
{
}
}

View File

@ -0,0 +1,30 @@
package mineplex.core.treasure.event;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerEvent;
import mineplex.core.treasure.TreasureSession;
import mineplex.core.treasure.types.TreasureType;
public abstract class TreasureEvent extends PlayerEvent
{
private final TreasureSession _session;
public TreasureEvent(Player who, TreasureSession session)
{
super(who);
_session = session;
}
public TreasureSession getSession()
{
return _session;
}
public TreasureType getTreasureType()
{
return _session.getTreasure().getTreasureType();
}
}

View File

@ -1,37 +1,24 @@
package mineplex.core.treasure.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.treasure.Treasure;
import mineplex.core.treasure.TreasureSession;
/**
* Called once a player has finished with the treasure opening process.
* Called when a player is able to begin opening chests.
*/
public class TreasureFinishEvent extends Event
public class TreasureFinishEvent extends TreasureEvent
{
private static final HandlerList handlers = new HandlerList();
private final Player _player;
private final Treasure _treasure;
public TreasureFinishEvent(Player player, Treasure treasure)
public TreasureFinishEvent(Player player, TreasureSession session)
{
_player = player;
_treasure = treasure;
}
public Player getPlayer()
{
return _player;
}
public Treasure getTreasure()
{
return _treasure;
super(player, session);
}
@Override
public HandlerList getHandlers()
{
return handlers;

View File

@ -1,57 +0,0 @@
package mineplex.core.treasure.event;
import mineplex.core.treasure.TreasureType;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when a player selects a chest to open.
*/
public class TreasurePreStartEvent extends Event implements Cancellable
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private TreasureType _treasureType;
private boolean _cancelled = false;
public TreasurePreStartEvent(Player player, TreasureType treasureType)
{
_player = player;
_treasureType = treasureType;
}
public Player getPlayer()
{
return _player;
}
public TreasureType getTreasureType()
{
return _treasureType;
}
@Override
public boolean isCancelled()
{
return _cancelled;
}
@Override
public void setCancelled(boolean cancelled)
{
_cancelled = cancelled;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -4,45 +4,30 @@ import java.util.Collections;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.treasure.TreasureSession;
import mineplex.core.reward.Reward;
import mineplex.core.treasure.Treasure;
/**
* Called when a player is able to begin opening chests.
*/
public class TreasureStartEvent extends Event
public class TreasureStartEvent extends TreasureEvent
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
private Treasure _treasure;
private List<Reward> _rewards;
public TreasureStartEvent(Player player, Treasure treasure, List<Reward> rewards)
public TreasureStartEvent(Player player, TreasureSession session)
{
_player = player;
_treasure = treasure;
_rewards = rewards;
}
public Player getPlayer()
{
return _player;
}
public Treasure getTreasure()
{
return _treasure;
super(player, session);
}
public List<Reward> getRewards()
{
return Collections.unmodifiableList(_rewards);
return Collections.unmodifiableList(getSession().getRewards());
}
@Override
public HandlerList getHandlers()
{
return handlers;

View File

@ -1,175 +0,0 @@
package mineplex.core.treasure.gui;
import java.io.File;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.F;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.shop.confirmation.ConfirmationPage;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.SalesPackageBase;
import mineplex.core.shop.item.SalesPackageProcessor;
import mineplex.core.treasure.ChestPackage;
import mineplex.core.treasure.TreasureType;
public class BuyChestButton implements IButton
{
private InventoryManager _inventoryManager;
private TreasurePage _page;
private String _chestName;
private Material _chestMat;
private int _chestCost;
private TreasureType _chestType;
public BuyChestButton(InventoryManager inventoryManager, TreasurePage page,
String chestName, Material chestMat, int chestCost, TreasureType chestType)
{
_inventoryManager = inventoryManager;
_page = page;
_chestName = chestName;
_chestMat = chestMat;
_chestCost = chestCost;
_chestType = chestType;
}
@Override
public void onClick(final Player player, ClickType clickType)
{
if (!Recharge.Instance.use(player, "Buy Treasure Chest", 1000, false, false))
{
return;
}
if (_chestType == TreasureType.TRICK_OR_TREAT)
{
if (!new File("../../update/files/EnableTrickOrTreatChest.dat").exists())
{
player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!"));
return;
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
}
if (_chestType == TreasureType.THANKFUL)
{
if (!new File("../../update/files/EnableThankfulChest.dat").exists())
{
player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!"));
return;
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
}
if (_chestType == TreasureType.GINGERBREAD)
{
if (!new File("../../update/files/EnableGingerbreadChest.dat").exists())
{
player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!"));
return;
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
}
if (_chestType == TreasureType.LOVE_CHEST)
{
if (!new File("../../update/files/EnableLoveChest.dat").exists())
{
player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!"));
return;
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
}
if (_chestType == TreasureType.ST_PATRICKS)
{
if (!new File("../../update/files/EnableStPatricksChest.dat").exists())
{
player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!"));
return;
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
}
if (_chestType == TreasureType.SPRING)
{
if (!new File("../../update/files/EnableSpringChest.dat").exists())
{
player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!"));
return;
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
}
if (_chestType == TreasureType.HAUNTED)
{
if (!new File("../../update/files/EnableHauntedChest.dat").exists())
{
player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!"));
return;
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
}
if (_chestType == TreasureType.FREEDOM)
{
if (!new File("../../update/files/EnableFreedomChest.dat").exists())
{
player.sendMessage(F.main("Treasure", "That chest is no longer available for purchase!"));
return;
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
}
if (!_page.getPlugin().hasItemsToGivePlayer(_chestType.getRewardPool(), player)
&& (_chestType == TreasureType.ILLUMINATED || _chestType == TreasureType.OMEGA
|| _chestType == TreasureType.HAUNTED || _chestType == TreasureType.GINGERBREAD
|| _chestType == TreasureType.ST_PATRICKS))
{
player.sendMessage(F.main("Treasure", "You seem to have all treasures for this chest unlocked already!"));
return;
}
SalesPackageBase salesPackage = new ChestPackage(_chestName, _chestMat, _chestCost);
_page.getShop().openPageForPlayer(player, new ConfirmationPage<>(player, _page, new SalesPackageProcessor(player, GlobalCurrency.TREASURE_SHARD, salesPackage, _page.getDonationManager(), () ->
{
_inventoryManager.addItemToInventory(player, _chestName, 1);
player.closeInventory();
TreasurePage page = new TreasurePage(_page.getTreasureManager(), _page.getTreasureShop(), _page.getTreasureLocation(),
_page.getClientManager(), _page.getDonationManager(), _page.getInventoryManager(),
_page.getGadgetManager(), player, _page.getActualPage());
_page.getTreasureShop().openPageForPlayer(player, page);
}), salesPackage.buildIcon()));
}
}

View File

@ -1,36 +0,0 @@
package mineplex.core.treasure.gui;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.recharge.Recharge;
import mineplex.core.shop.item.IButton;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.TreasureType;
public class OpenTreasureButton implements IButton
{
private Player _player;
private TreasureLocation _treasureLocation;
private TreasureType _treasureType;
public OpenTreasureButton(Player player, TreasureLocation treasureLocation, TreasureType treasureType)
{
_player = player;
_treasureLocation = treasureLocation;
_treasureType = treasureType;
}
@Override
public void onClick(Player player, ClickType clickType)
{
if (!Recharge.Instance.use(player, "Open Treasure Chest", 1000, false, false))
{
return;
}
_treasureLocation.attemptOpenTreasure(player, _treasureType);
player.closeInventory();
}
}

View File

@ -1,785 +0,0 @@
package mineplex.core.treasure.gui;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.google.common.collect.Lists;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilText;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite;
import mineplex.core.gadget.gadgets.death.DeathFreedom;
import mineplex.core.gadget.gadgets.death.DeathMapleLeaf;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple;
import mineplex.core.gadget.gadgets.flag.FlagType;
import mineplex.core.gadget.gadgets.hat.HatType;
import mineplex.core.gadget.gadgets.morph.MorphUncleSam;
import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness;
import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian;
import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom;
import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks;
import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.TreasureManager;
import mineplex.core.treasure.TreasureType;
import mineplex.core.treasure.gui.pages.NextPageButton;
import mineplex.core.treasure.gui.pages.PreviousPageButton;
public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
{
private TreasureManager _treasureManager;
private TreasureShop _treasureShop;
private TreasureLocation _treasureLocation;
private InventoryManager _inventoryManager;
private GadgetManager _gadgetManager;
private int _actualPage = 1;
private List<TreasurePageItem> _specialTreasures = new ArrayList<>();
private List<TreasurePageItem> _normalTreasures = new ArrayList<>();
private List<TreasurePageItem> _seasonalTreasures = new ArrayList<>();
public TreasurePage(TreasureManager plugin, TreasureShop shop, TreasureLocation treasureLocation, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, Player player)
{
super(plugin, shop, clientManager, donationManager, "Open Treasure - Page 1", player, 54);
_treasureManager = plugin;
_treasureShop = shop;
_treasureLocation = treasureLocation;
_inventoryManager = inventoryManager;
_gadgetManager = gadgetManager;
buildPage();
}
public TreasurePage(TreasureManager plugin, TreasureShop shop, TreasureLocation treasureLocation, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, GadgetManager gadgetManager, Player player, int actualPage)
{
super(plugin, shop, clientManager, donationManager, "Open Treasure - Page " + actualPage, player, 54);
_treasureManager = plugin;
_treasureShop = shop;
_treasureLocation = treasureLocation;
_inventoryManager = inventoryManager;
_gadgetManager = gadgetManager;
_actualPage = actualPage;
buildPage();
}
public TreasureManager getTreasureManager()
{
return _treasureManager;
}
public TreasureShop getTreasureShop()
{
return _treasureShop;
}
public TreasureLocation getTreasureLocation()
{
return _treasureLocation;
}
public InventoryManager getInventoryManager()
{
return _inventoryManager;
}
public GadgetManager getGadgetManager()
{
return _gadgetManager;
}
public int getActualPage()
{
return _actualPage;
}
@Override
public void buildPage()
{
addAllChests();
if (_actualPage == 1)
buildFirstPage();
else
buildSecondPage();
}
private void addAllChests()
{
int treasureShards = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD);
int basicCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.OLD.getItemName());
int heroicCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.ANCIENT.getItemName());
int legendaryCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.MYTHICAL.getItemName());
int christmasCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.CHRISTMAS.getItemName());
int illuminatedCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.ILLUMINATED.getItemName());
int freedomCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.FREEDOM.getItemName());
int omegaCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.OMEGA.getItemName());
int hauntedCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.HAUNTED.getItemName());
int trickCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.TRICK_OR_TREAT.getItemName());
int thankCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.THANKFUL.getItemName());
int gingerbreadCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.GINGERBREAD.getItemName());
int minestrikeCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.MINESTRIKE.getItemName());
int loveCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.LOVE_CHEST.getItemName());
int stpatricksCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.ST_PATRICKS.getItemName());
int springCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.SPRING.getItemName());
int mobaCount = _inventoryManager.Get(getPlayer()).getItemCount(TreasureType.MOBA.getItemName());
boolean availableChristmas = new File("../../update/files/EnableChristmasChest.dat").exists();
boolean availableFreedom = new File("../../update/files/EnableFreedomChest.dat").exists();
boolean availableHaunted = new File("../../update/files/EnableHauntedChest.dat").exists();
boolean availableTrick = new File("../../update/files/EnableTrickOrTreatChest.dat").exists();
boolean availableThank = new File("../../update/files/EnableThankfulChest.dat").exists();
boolean availableGingerbread = new File("../../update/files/EnableGingerbreadChest.dat").exists();
boolean availableLove = new File("../../update/files/EnableLoveChest.dat").exists();
boolean availableStPatricks = new File("../../update/files/EnableStPatricksChest.dat").exists();
boolean availableSpring = new File("../../update/files/EnableSpringChest.dat").exists();
List<String> shardLore = new ArrayList<>();
shardLore.add(" ");
shardLore.add(C.cGray + "These seem like they might come in");
shardLore.add(C.cGray + "handy. Maybe I should collect more!");
List<String> basicLore = new ArrayList<>();
basicLore.add(" ");
basicLore.add(F.value("Old Chests Owned", "" + basicCount));
basicLore.add(" ");
basicLore.add(C.cGray + "We've scoured the lands of Minecraft");
basicLore.add(C.cGray + "and found these abandoned chests.");
basicLore.add(C.cGray + "The contents are unknown, but");
basicLore.add(C.cGray + "according to the inscriptions on the");
basicLore.add(C.cGray + "the straps they appear to contain");
basicLore.add(C.cGray + "many kinds of loot.");
basicLore.add(" ");
if (basicCount > 0)
basicLore.add(C.cGreen + "Click to Open!");
else
{
basicLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "1000 Treasure Shards");
basicLore.add(" ");
basicLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
List<String> heroicLore = new ArrayList<>();
heroicLore.add(" ");
heroicLore.add(F.value("Ancient Chests Owned", "" + heroicCount));
heroicLore.add(" ");
heroicLore.add(C.cGray + "Some of our bravest adventurers");
heroicLore.add(C.cGray + "have discovered these chests within ");
heroicLore.add(C.cGray + "temples hidden in Minecrafts worlds.");
heroicLore.add(" ");
if (heroicCount > 0)
heroicLore.add(C.cGreen + "Click to Open!");
else
{
heroicLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "5000 Treasure Shards");
heroicLore.add(" ");
heroicLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
List<String> legendaryLore = new ArrayList<>();
legendaryLore.add(" ");
legendaryLore.add(F.value("Mythical Chests Owned", "" + legendaryCount));
legendaryLore.add(" ");
legendaryLore.add(C.cGray + "All our previous adventurers have");
legendaryLore.add(C.cGray + "perished in search of these chests.");
legendaryLore.add(C.cGray + "However, legends of their existence");
legendaryLore.add(C.cGray + "convinced Sterling, Chiss and Defek7");
legendaryLore.add(C.cGray + "to venture out and discover the");
legendaryLore.add(C.cGray + "location of these chests on their own.");
legendaryLore.add(" ");
if (legendaryCount > 0)
legendaryLore.add(C.cGreen + "Click to Open!");
else
{
legendaryLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "10000 Treasure Shards");
legendaryLore.add(" ");
legendaryLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
List<String> christmasLore = new ArrayList<>();
christmasLore.add(" ");
christmasLore.add(F.value("Winter Holiday Chests Owned", "" + christmasCount));
christmasLore.add(" ");
christmasLore.add(C.cGray + "Legend tells of the Winter Lord's");
christmasLore.add(C.cGray + "vast treasure horde, locked away in");
christmasLore.add(C.cGray + "in a vault of ice, deep beneath the");
christmasLore.add(C.cGray + "Frozen Sea. It is said it can only be");
christmasLore.add(C.cGray + "accessed in the deepest parts of Winter...");
christmasLore.add(" ");
if (christmasCount > 0)
christmasLore.add(C.cGreen + "Click to Open!");
else
{
christmasLore.add(C.cRed + "This item is no longer available!");
}
List<String> illuminatedLore = new ArrayList<String>();
illuminatedLore.add(" ");
illuminatedLore.add(F.value("Illuminated Chests Owned", "" + illuminatedCount));
illuminatedLore.add(" ");
illuminatedLore.add(C.cGray + "The illuminated chest shines brightly");
illuminatedLore.add(C.cGray + "in the depths, always bringing a new");
illuminatedLore.add(C.cGray + "treasure from the darkness.");
illuminatedLore.add(" ");
if (illuminatedCount > 0)
illuminatedLore.add(C.cGreen + "Click to Open!");
else
{
illuminatedLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards");
illuminatedLore.add(" ");
illuminatedLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
List<String> freedomLore = new ArrayList<>();
freedomLore.add(" ");
freedomLore.add(F.value("Freedom Chests Owned", "" + freedomCount));
freedomLore.add(" ");
freedomLore.add(C.cGray + "It is said that George Washington");
freedomLore.add(C.cGray + "carved this chest himself from the wood");
freedomLore.add(C.cGray + "of the cherry tree he cut down...");
freedomLore.add(" ");
if (freedomCount > 0)
{
if (hasAllFreedomItems(getPlayer()))
{
freedomLore.add(C.cWhite + "You own all treasures from this chest.");
}
else
{
freedomLore.add(C.cGreen + "Click to Open!");
}
}
else
{
if (!availableFreedom)
{
freedomLore.add(C.cRed + "This item is no longer available!");
}
else if (hasAllFreedomItems(getPlayer()))
{
freedomLore.add(C.cWhite + "You own all treasures from this chest.");
}
else
{
freedomLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards");
freedomLore.add(" ");
freedomLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
}
freedomLore.add(" ");
freedomLore.add(ChatColor.RESET + C.cGreen + getFreedomUnlockedAmount(getPlayer()) + "/18 Unlocked");
List<String> omegaLore = new ArrayList<>();
omegaLore.add(" ");
omegaLore.add(F.value("Omega Chests Owned", "" + omegaCount));
omegaLore.add(" ");
omegaLore.add(C.cGray + "The most powerful of all chests,");
omegaLore.add(C.cGray + "it is able to go back in time to find");
omegaLore.add(C.cGray + "loot that has been lost...");
omegaLore.add(" ");
if (omegaCount > 0)
omegaLore.add(C.cGreen + "Click to Open!");
else
{
}
List<String> hauntedLore = new ArrayList<>();
hauntedLore.add(" ");
hauntedLore.add(F.value("Haunted Chests Owned", "" + hauntedCount));
hauntedLore.add(" ");
hauntedLore.add(C.cGray + "The Haunted Chest can only be found");
hauntedLore.add(C.cGray + "during the month of October when the");
hauntedLore.add(C.cGray + "veil between this world and the shadow is thin...");
hauntedLore.add(" ");
if (hauntedCount > 0 && !hasAllHauntedItems(getPlayer()))
{
hauntedLore.add(C.cGreen + "Click to Open!");
}
else
{
hauntedLore.add(C.cRed + "This item is no longer available!");
}
List<String> trickLore = Lists.newArrayList();
trickLore.add(" ");
trickLore.add(F.value("Trick or Treat Chests Owned", "" + trickCount));
trickLore.add(" ");
trickLore.add(C.cGray + "The Trick or Treat Chest contains all");
trickLore.add(C.cGray + "sorts of surprises, from Rank Upgrades to");
trickLore.add(C.cGray + "long lost Halloween items, and even other chests!");
trickLore.add(" ");
if (trickCount > 0)
{
trickLore.add(C.cGreen + "Click to Open!");
}
else
{
if (!availableTrick)
{
trickLore.add(C.cRed + "This item is no longer available!");
}
else
{
trickLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards");
trickLore.add(" ");
trickLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
}
List<String> thankLore = Lists.newArrayList();
thankLore.add(" ");
thankLore.add(F.value("Thankful Chests Owned", "" + thankCount));
thankLore.add(" ");
thankLore.add(C.cGray + "The Thankful Chest is our way of");
thankLore.add(C.cGray + "showing thanks to you, containing items from Rank Upgrades to");
thankLore.add(C.cGray + "Power Play Club Subscriptions, among other things!");
thankLore.add(" ");
if (thankCount > 0)
{
thankLore.add(C.cGreen + "Click to Open!");
}
else
{
if (!availableThank)
{
thankLore.add(C.cRed + "This item is no longer available!");
}
else
{
thankLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "20000 Treasure Shards");
thankLore.add(" ");
thankLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
}
List<String> gingerbreadLore = Lists.newArrayList();
gingerbreadLore.add(" ");
gingerbreadLore.add(F.value("Gingerbread Chests Owned", "" + gingerbreadCount));
gingerbreadLore.add(" ");
gingerbreadLore.addAll(UtilText.splitLine(C.cGray + "The legendary burglar, " +
"the Gingerbread Man, has finally been caught! Now, for the first time his loot is available for auction." +
" There are 8 pieces available for to collect and no duplicates can be obtained from this chest!",
LineFormat.LORE));
gingerbreadLore.add(" ");
if (gingerbreadCount > 0)
{
gingerbreadLore.add(C.cGreen + "Click to Open!");
}
else
{
gingerbreadLore.add(C.cRed + "This item is no longer available!");
}
List<String> minestrikeLore = Lists.newArrayList();
minestrikeLore.add(" ");
minestrikeLore.add(F.value("Minestrike Chests Owned", "" + minestrikeCount));
minestrikeLore.add(" ");
minestrikeLore.addAll(UtilText.splitLines(new String[]
{
C.cGray + "The Minestrike Chest is the only place to get the unique skins for Minestrike weapons!",
"",
C.cWhite + "Each use opens two chests. Can give duplicates."
}, LineFormat.LORE));
minestrikeLore.add(" ");
if (minestrikeCount > 0)
{
minestrikeLore.add(C.cGreen + "Click to Open!");
}
else
{
minestrikeLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + "10000 Treasure Shards");
minestrikeLore.add(" ");
minestrikeLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
List<String> lovechestLore = Lists.newArrayList();
lovechestLore.add(" ");
lovechestLore.add(F.value("Love Chests Owned", "" + loveCount));
lovechestLore.add(" ");
lovechestLore.addAll(UtilText.splitLines(new String[]{C.cGray + "Cupid and his hunters have searched far and wide to collect a whole bunch of lovey dovey items. 6 items, no duplicates."}, LineFormat.LORE));
lovechestLore.add(" ");
if (loveCount > 0)
{
lovechestLore.add(C.cGreen + "Click to Open!");
}
else
{
if (!availableLove)
{
lovechestLore.add(C.cRed + "This item is no longer available");
}
else
{
lovechestLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + TreasureType.LOVE_CHEST.getPurchasePrice() + " Treasure Shards");
lovechestLore.add(" ");
lovechestLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
}
List<String> stpatricksLore = Lists.newArrayList();
stpatricksLore.add(" ");
stpatricksLore.add(F.value("St Patrick's Chests Owned", "" + stpatricksCount));
stpatricksLore.add(" ");
stpatricksLore.addAll(UtilText.splitLines(new String[]{C.cGray + "Happy St. Patrick's Day! Get your Pot's of Gold and Luck of the Irish in this chest! 7 items, no duplicates."}, LineFormat.LORE));
stpatricksLore.add(" ");
if (stpatricksCount > 0)
{
stpatricksLore.add(C.cGreen + "Click to Open!");
}
else
{
if (!availableStPatricks)
{
stpatricksLore.add(C.cRed + "This item is no longer available");
}
else
{
stpatricksLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + TreasureType.ST_PATRICKS.getPurchasePrice() + " Treasure Shards");
stpatricksLore.add(" ");
stpatricksLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
}
List<String> springLore = Lists.newArrayList();
springLore.add(" ");
springLore.add(F.value("Spring Chests Owned", "" + springCount));
springLore.add(" ");
springLore.addAll(UtilText.splitLines(new String[]{C.cGray + "Spring is here! Find 6 limited edition Spring Cosmetics in the Spring Chest! Only available for a limited time. Guaranteed no Duplicate items!"}, LineFormat.LORE));
springLore.add(" ");
if (springCount > 0)
{
springLore.add(C.cGreen + "Click to Open!");
}
else
{
if (!availableSpring)
{
springLore.add(C.cRed + "This item is no longer available");
}
else
{
springLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + TreasureType.SPRING.getPurchasePrice() + " Treasure Shards");
springLore.add(" ");
springLore.add(ChatColor.RESET + "or Purchase at: " + C.cYellow + "www.mineplex.com/shop");
}
}
List<String> mobaLore = Lists.newArrayList();
mobaLore.add(" ");
mobaLore.add(F.value("HOG Chests Owned", "" + mobaCount));
mobaLore.add(" ");
mobaLore.addAll(UtilText.splitLines(new String[]{C.cGray + "Heroes of GWEN exclusive cosmetics! Each chest contains 4 exclusive items to the game!"}, LineFormat.LORE));
mobaLore.add(" ");
if (mobaCount > 0)
{
mobaLore.add(C.cGreen + "Click to Open!");
}
else
{
mobaLore.add(ChatColor.RESET + "Click to craft for " + C.cAqua + TreasureType.MOBA.getPurchasePrice() + " Treasure Shards");
mobaLore.add(" ");
mobaLore.add(C.cAqua + "or Earn HOG Chests by leveling up Roles with in Heroes of GWEN.");
}
ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false);
// Normal chests
ShopItem basic = new ShopItem(Material.CHEST, C.cGreen + C.Bold + "Old Treasure", basicLore.toArray(new String[0]), 0, false, false);
ShopItem heroic = new ShopItem(Material.TRAPPED_CHEST, C.cGold + C.Bold + "Ancient Treasure", heroicLore.toArray(new String[0]), 0, false, false);
ShopItem legendary = new ShopItem(Material.ENDER_CHEST, C.cRed + C.Bold + "Mythical Treasure", legendaryLore.toArray(new String[0]), 0, false, false);
ItemStack illuminated = new ShopItem(Material.SEA_LANTERN, C.cDAqua + C.Bold + "Illuminated Treasure", illuminatedLore.toArray(new String[0]), 0, false, false);
ItemStack omega = SkinData.OMEGA_CHEST.getSkull(C.cAquaB + "Omega Treasure", omegaLore);
ItemStack minestrike = new ShopItem(Material.TNT, C.cGoldB + "Minestrike Treasure", minestrikeLore.toArray(new String[0]), 0, false, false);
ItemStack moba = new ShopItem(Material.PRISMARINE, (byte) 2, C.cAquaB + "Heroes of GWEN Treasure", mobaLore.toArray(new String[0]), 0, false, false);
// Seasonal chests
ItemStack christmas = SkinData.PRESENT.getSkull(C.cDGreen + C.Bold + "Winter Holiday Treasure", christmasLore);
ItemStack freedom = SkinData.FREEDOM_CHEST.getSkull(C.cRedB + "Freedom " + C.cBlueB + "Treasure", freedomLore);
ItemStack haunted = SkinData.HAUNTED_CHEST.getSkull(C.cGoldB + "Haunted Treasure", hauntedLore);
ItemStack trick = new ShopItem(Material.SKULL_ITEM, C.cGoldB + "Trick or Treat Treasure", trickLore.toArray(new String[0]), 0, false, false);
ItemStack thank = new ShopItem(Material.COOKED_CHICKEN, C.cGoldB + "Thankful Treasure", thankLore.toArray(new String[0]), 0, false, false);
ItemStack gingerbread = SkinData.GINGERBREAD.getSkull(C.cRedB + "Gingerbread" + C.cGreenB + " Treasure", gingerbreadLore);
ItemStack lovechest = new ShopItem(Material.WOOL, (byte) 6, C.cRedB + "Love Chest", lovechestLore.toArray(new String[0]), 0, false, false);
ItemStack stpatricks = SkinData.LEPRECHAUN.getSkull(C.cGreenB + "St Patrick's Treasure", stpatricksLore);
ItemStack spring = new ShopItem(Material.DOUBLE_PLANT, (byte) 4, C.cGreenB + "Spring Treasure", springLore.toArray(new String[0]), 1, false, false);
// Adds shard item
addItem(49, shards);
// Adds chests to lists, to handle them later
// Normal chests
TreasurePageItem oldTreasureItem = new TreasurePageItem(basic, basicCount, TreasureType.OLD);
TreasurePageItem ancientTreasureItem = new TreasurePageItem(heroic, heroicCount, TreasureType.ANCIENT);
TreasurePageItem mythicalTreasureItem = new TreasurePageItem(legendary, legendaryCount, TreasureType.MYTHICAL);
TreasurePageItem illuminatedTreasureItem = new TreasurePageItem(illuminated, illuminatedCount, TreasureType.ILLUMINATED);
TreasurePageItem omegaTreasureItem = new TreasurePageItem(omega, omegaCount, TreasureType.OMEGA);
TreasurePageItem minestrikeTreasureItem = new TreasurePageItem(minestrike, minestrikeCount, TreasureType.MINESTRIKE);
TreasurePageItem mobaTreasureItem = new TreasurePageItem(moba, mobaCount, TreasureType.MOBA);
// Seasonal chests
TreasurePageItem winterTreasureItem = new TreasurePageItem(christmas, christmasCount, TreasureType.CHRISTMAS);
TreasurePageItem freedomTreasureItem = new TreasurePageItem(freedom, freedomCount, TreasureType.FREEDOM);
TreasurePageItem hauntedTreasureItem = new TreasurePageItem(haunted, hauntedCount, TreasureType.HAUNTED);
TreasurePageItem trickTreasureItem = new TreasurePageItem(trick, trickCount, TreasureType.TRICK_OR_TREAT);
TreasurePageItem thankTreasureItem = new TreasurePageItem(thank, thankCount, TreasureType.THANKFUL);
TreasurePageItem gingerbreadTreasureItem = new TreasurePageItem(gingerbread, gingerbreadCount, TreasureType.GINGERBREAD);
TreasurePageItem loveChestItem = new TreasurePageItem(lovechest, loveCount, TreasureType.LOVE_CHEST);
TreasurePageItem stPatricksItem = new TreasurePageItem(stpatricks, stpatricksCount, TreasureType.ST_PATRICKS);
TreasurePageItem springItem = new TreasurePageItem(spring, springCount, TreasureType.SPRING);
_normalTreasures.add(oldTreasureItem);
_normalTreasures.add(ancientTreasureItem);
_normalTreasures.add(mythicalTreasureItem);
_normalTreasures.add(illuminatedTreasureItem);
_normalTreasures.add(omegaTreasureItem);
_normalTreasures.add(minestrikeTreasureItem);
_normalTreasures.add(mobaTreasureItem);
if (availableSpring)
_specialTreasures.add(springItem);
else
_seasonalTreasures.add(springItem);
if (availableStPatricks)
_specialTreasures.add(stPatricksItem);
else
_seasonalTreasures.add(stPatricksItem);
if (availableLove)
_specialTreasures.add(loveChestItem);
else
_seasonalTreasures.add(loveChestItem);
if (availableChristmas)
_specialTreasures.add(winterTreasureItem);
else
_seasonalTreasures.add(winterTreasureItem);
if (availableFreedom)
_specialTreasures.add(freedomTreasureItem);
else
_seasonalTreasures.add(freedomTreasureItem);
if (availableHaunted)
_specialTreasures.add(hauntedTreasureItem);
else
_seasonalTreasures.add(hauntedTreasureItem);
if (availableTrick)
_specialTreasures.add(trickTreasureItem);
else
_seasonalTreasures.add(trickTreasureItem);
if (availableThank)
_specialTreasures.add(thankTreasureItem);
else
_seasonalTreasures.add(thankTreasureItem);
if (availableGingerbread)
_specialTreasures.add(gingerbreadTreasureItem);
else
_seasonalTreasures.add(gingerbreadTreasureItem);
}
private void buildFirstPage()
{
int i = 0;
if (_specialTreasures.size() >= 0)
{
int[] specialDisplayPositions = getSpecialDisplayOrder();
for (TreasurePageItem treasurePageItem : _specialTreasures)
{
addChest(treasurePageItem, specialDisplayPositions[i]);
i++;
}
}
i = 0;
int[] normalDisplayPositions = getNormalDisplayOrder();
for (TreasurePageItem treasurePageItem : _normalTreasures)
{
addChest(treasurePageItem, normalDisplayPositions[i]);
i++;
}
ItemStack nextPage = ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte) 0, 1, C.cGreen + "Next Page");
NextPageButton nextPageButton = new NextPageButton(this, _player);
addButton(53, nextPage, nextPageButton);
}
private void buildSecondPage()
{
int i = 0;
int[] seasonalDisplayPositions = getSeasonalDisplayOrder();
for (TreasurePageItem treasurePageItem : _seasonalTreasures)
{
addChest(treasurePageItem, seasonalDisplayPositions[i]);
i++;
}
ItemStack previousPage = ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte) 0, 1, C.cGreen + "Previous Page");
PreviousPageButton previousPageButton = new PreviousPageButton(this, _player);
addButton(45, previousPage, previousPageButton);
}
private void addChest(TreasurePageItem treasurePageItem, int position)
{
ItemStack item = treasurePageItem.getItem();
int owned = treasurePageItem.getCount();
TreasureType treasureType = treasurePageItem.getTreasureType();
if (owned > 0)
{
addButton(position, item, new OpenTreasureButton(getPlayer(), _treasureLocation, treasureType));
}
else if (treasureType.isPurchasable()) {
addButton(position, item, new BuyChestButton(_inventoryManager, this, treasureType.getItemName(), Material.CHEST, treasureType.getPurchasePrice(), treasureType));
}
else
{
setItem(position, item);
}
}
private int[] getSpecialDisplayOrder()
{
int specialTreasuresSize = _specialTreasures.size();
switch (specialTreasuresSize)
{
case 1:
return new int[]{4};
case 2:
return new int[]{3, 5};
case 3:
return new int[]{2, 4, 6};
case 4:
return new int[]{1, 3, 5, 7};
}
return new int[]{4};
}
private int[] getNormalDisplayOrder()
{
int normalTreasuresSize = _normalTreasures.size();
switch (normalTreasuresSize)
{
case 5:
return new int[]{20, 22, 24, 39, 41};
case 6:
return new int[]{19, 21, 23, 25, 38, 42};
case 7:
return new int[]{19, 21, 23, 25, 38, 40, 42};
case 8:
return new int[]{19, 21, 23, 25, 37, 39, 41, 43};
case 9:
return new int[]{19, 21, 23, 25, 31, 37, 39, 41, 43};
case 10:
return new int[]{19, 21, 23, 25, 29, 33, 37, 39, 41, 43};
case 11:
return new int[]{19, 21, 23, 25, 29, 31, 33, 37, 39, 32, 43};
}
return new int[]{20, 22, 24, 39, 41};
}
private int[] getSeasonalDisplayOrder()
{
int seasonalTreasuresSize = _seasonalTreasures.size();
switch (seasonalTreasuresSize)
{
case 5:
return new int[]{11, 13, 15, 30, 32};
case 6:
return new int[]{10, 12, 14, 16, 29, 33};
case 7:
return new int[]{10, 12, 14, 16, 29, 31, 33};
case 8:
return new int[]{10, 12, 14, 16, 28, 30, 32, 34};
case 9:
return new int[]{10, 12, 14, 16, 22, 28, 30, 32, 34};
case 10:
return new int[]{10, 12, 14, 16, 20, 24, 28, 30, 32, 34};
case 11:
return new int[]{10, 12, 14, 16, 20, 22, 24, 28, 30, 32, 34};
}
return new int[]{11, 13, 15, 30, 32};
}
public boolean hasAllFreedomItems(Player player)
{
return !getPlugin().hasItemsToGivePlayer(TreasureType.FREEDOM.getRewardPool(), player);
}
/**
* Checks if the player has all the items for the halloween chest
* @param player
* @return
*/
public boolean hasAllHauntedItems(Player player)
{
return !getPlugin().hasItemsToGivePlayer(TreasureType.HAUNTED.getRewardPool(), player);
}
public int getFreedomUnlockedAmount(Player player)
{
if (hasAllFreedomItems(player))
return 18;
int amount = 0;
Gadget[] gadgets = new Gadget[]
{
_gadgetManager.getGadget("Uncle Sam Hat", GadgetType.HAT),
_gadgetManager.getGadget(ParticleFreedom.class),
_gadgetManager.getGadget(ArrowTrailFreedom.class),
_gadgetManager.getGadget(DoubleJumpFreedom.class),
_gadgetManager.getGadget(DeathFreedom.class),
_gadgetManager.getGadget(MorphUncleSam.class),
_gadgetManager.getGadget(ArrowTrailRedWhite.class),
_gadgetManager.getGadget(DeathMapleLeaf.class),
_gadgetManager.getGadget(DoubleJumpMaple.class),
_gadgetManager.getGadget(ParticleAuraNiceness.class),
_gadgetManager.getGadget(ParticleCanadian.class),
_gadgetManager.getGadget(ParticleFreedomFireworks.class),
_gadgetManager.getGadget(ParticleStarSpangled.class),
_gadgetManager.getHatGadget(HatType.AMERICA),
_gadgetManager.getHatGadget(HatType.CANADA),
_gadgetManager.getFlagGadget(FlagType.CANADA),
_gadgetManager.getFlagGadget(FlagType.USA),
};
for (Gadget gadget : gadgets)
{
if (gadget.ownsGadget(player))
amount++;
}
return amount;
}
}

View File

@ -1,35 +0,0 @@
package mineplex.core.treasure.gui;
import org.bukkit.inventory.ItemStack;
import mineplex.core.treasure.TreasureType;
public class TreasurePageItem
{
private final ItemStack _item;
private final int _count;
private final TreasureType _treasureType;
public TreasurePageItem(ItemStack item, int count, TreasureType treasureType)
{
_item = item;
_count = count;
_treasureType = treasureType;
}
public ItemStack getItem()
{
return _item;
}
public int getCount()
{
return _count;
}
public TreasureType getTreasureType()
{
return _treasureType;
}
}

View File

@ -1,33 +0,0 @@
package mineplex.core.treasure.gui;
import mineplex.core.gadget.GadgetManager;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.TreasureManager;
public class TreasureShop extends ShopBase<TreasureManager>
{
private TreasureLocation _treasureLocation;
private InventoryManager _inventoryManager;
private GadgetManager _gadgetManager;
public TreasureShop(TreasureManager plugin, InventoryManager inventoryManager, CoreClientManager clientManager, DonationManager donationManager, GadgetManager gadgetManager, TreasureLocation treasureLocation)
{
super(plugin, clientManager, donationManager, "Treasure Shop");
_treasureLocation = treasureLocation;
_inventoryManager = inventoryManager;
_gadgetManager = gadgetManager;
}
@Override
protected ShopPageBase<TreasureManager, ? extends ShopBase<TreasureManager>> buildPagesFor(Player player)
{
return new TreasurePage(getPlugin(), this, _treasureLocation, getClientManager(), getDonationManager(), _inventoryManager, _gadgetManager, player);
}
}

View File

@ -1,32 +0,0 @@
package mineplex.core.treasure.gui.pages;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
import mineplex.core.treasure.gui.TreasurePage;
public class NextPageButton implements IButton
{
private TreasurePage _treasurePage;
private Player _player;
public NextPageButton(TreasurePage treasurePage, Player player)
{
_treasurePage = treasurePage;
_player = player;
}
@Override
public void onClick(Player player, ClickType clickType)
{
if (_player != player)
return;
player.closeInventory();
TreasurePage nextPage = new TreasurePage(_treasurePage.getTreasureManager(), _treasurePage.getTreasureShop(), _treasurePage.getTreasureLocation(),
_treasurePage.getClientManager(), _treasurePage.getDonationManager(), _treasurePage.getInventoryManager(),
_treasurePage.getGadgetManager(), _player, _treasurePage.getActualPage() + 1);
_treasurePage.getTreasureShop().openPageForPlayer(player, nextPage);
}
}

View File

@ -1,33 +0,0 @@
package mineplex.core.treasure.gui.pages;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.shop.item.IButton;
import mineplex.core.treasure.gui.TreasurePage;
public class PreviousPageButton implements IButton
{
private TreasurePage _treasurePage;
private Player _player;
public PreviousPageButton(TreasurePage treasurePage, Player player)
{
_treasurePage = treasurePage;
_player = player;
}
@Override
public void onClick(Player player, ClickType clickType)
{
if (_player != player)
return;
player.closeInventory();
TreasurePage previousPage = new TreasurePage(_treasurePage.getTreasureManager(), _treasurePage.getTreasureShop(), _treasurePage.getTreasureLocation(),
_treasurePage.getClientManager(), _treasurePage.getDonationManager(), _treasurePage.getInventoryManager(),
_treasurePage.getGadgetManager(), _player, _treasurePage.getActualPage() - 1);
_treasurePage.getTreasureShop().openPageForPlayer(player, previousPage);
}
}

View File

@ -0,0 +1,39 @@
package mineplex.core.treasure.reward;
import java.util.HashMap;
import java.util.Map;
import mineplex.core.common.weight.WeightSet;
import mineplex.core.reward.Reward;
public class RewardPool
{
private final Map<RewardRarity, WeightSet<Reward>> _rewards;
private final boolean _duplicates;
private final int _amount;
public RewardPool(boolean duplicates, int amount)
{
_rewards = new HashMap<>();
_duplicates = duplicates;
_amount = amount;
}
public void addReward(Reward reward, int weight)
{
RewardRarity rarity = reward.getRarity();
_rewards.putIfAbsent(rarity, new WeightSet<>());
_rewards.get(rarity).add(weight, reward);
}
public boolean hasDuplicates()
{
return _duplicates;
}
public int getAmount()
{
return _amount;
}
}

View File

@ -0,0 +1,39 @@
package mineplex.core.treasure.reward;
import mineplex.core.common.util.C;
public enum RewardRarity
{
COMMON("Common", C.cWhite, C.cGray),
UNCOMMON("Uncommon", C.cAqua, C.cDAqua),
RARE("Rare", C.cPurple, C.cDPurple),
LEGENDARY("Legendary", C.cGreen, C.cDGreen),
MYTHICAL("Mythical", C.cRed, C.cDRed);
private final String _name;
private final String _color;
private final String _darkColor;
RewardRarity(String name, String color, String darkColor)
{
_name = name;
_color = color;
_darkColor = darkColor;
}
public String getName()
{
return _name;
}
public String getColor()
{
return _color;
}
public String getDarkColor()
{
return _darkColor;
}
}

View File

@ -0,0 +1,278 @@
package mineplex.core.treasure.reward;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.entity.Player;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.weight.WeightSet;
import mineplex.core.reward.Reward;
import mineplex.core.reward.rewards.TreasureShardReward;
import mineplex.core.treasure.types.Treasure;
/**
* This manager serves as a random reward generator.
* A lot of this was adapted from the previous reward manager, so if you've come here to
* fix something then prepare yourself for a shock.
*/
@ReflectivelyCreateMiniPlugin
public class TreasureRewardManager extends MiniPlugin
{
/**
* For all the reward algorithms, if a condition cannot be met within {@value} iterations then it gives up.
* {@value} is a very generous threshold and most likely, unless due to error, each one should complete in one
* or two iterations.
*/
private static final int MAX_ATTEMPTS = 20;
private final Map<Treasure, Map<RewardRarity, WeightSet<Reward>>> _rewardPoolMap;
private TreasureRewardManager()
{
super("Treasure Rewards");
_rewardPoolMap = new HashMap<>();
}
/**
* Adds a reward into the pool for a particular chest type.
*
* @param treasure The {@link Treasure}'s pool you want to add the reward to.
* @param reward The {@link Reward} you want to add to the pool.
* @param weight The weight of the reward, bigger weight, more probable to be picked.
*/
public void addReward(Treasure treasure, Reward reward, int weight)
{
// Populate the map if absent
_rewardPoolMap.computeIfAbsent(treasure, k -> new HashMap<>());
// Populate the inner map if absent
Map<RewardRarity, WeightSet<Reward>> map = _rewardPoolMap.get(treasure);
map.computeIfAbsent(reward.getRarity(), k -> new WeightSet<>());
// Add the reward to the WeightSet
map.get(reward.getRarity()).add(weight, reward);
}
/**
* Returns whether or not a player has all the items within a chest's pool
*
* @param player The player you want to checl.
* @param treasure The {@link Treasure} you want to search through the pool of.
* @return a boolean value of if the player has all the items within a chest's pool.
*/
public boolean hasAllItems(Player player, Treasure treasure)
{
Map<RewardRarity, WeightSet<Reward>> rewardMap = _rewardPoolMap.get(treasure);
// Null entry, programmer error
return rewardMap == null || getOwnedItems(player, treasure) == getTotalItems(treasure);
}
/**
* Returns the number of items a player owns within a chest's pool
*
* @param player The player you want to check.
* @param treasure The {@link Treasure} you want to search through the pool of.
* @return an integer value of the amount of items the player has within a chest's pool.
*/
public int getOwnedItems(Player player, Treasure treasure)
{
Map<RewardRarity, WeightSet<Reward>> rewardMap = _rewardPoolMap.get(treasure);
// Null entry, programmer error
if (rewardMap == null)
{
return 0;
}
int owned = 0;
// Check every reward
for (WeightSet<Reward> weightSet : rewardMap.values())
{
for (Reward reward : weightSet.elements())
{
// If the player cannot be given that reward
if (!reward.canGiveReward(player))
{
owned++;
}
}
}
return owned;
}
public int getTotalItems(Treasure treasure)
{
Map<RewardRarity, WeightSet<Reward>> rewardMap = _rewardPoolMap.get(treasure);
// Null entry, programmer error
if (rewardMap == null)
{
return 0;
}
int amount = 0;
// Check every reward
for (WeightSet<Reward> weightSet : rewardMap.values())
{
amount += weightSet.elements().size();
}
return amount;
}
/**
* Returns a list of random rewards that can be awarded to a player.
*
* @param player The player you want to give the rewards to.
* @param treasure The {@link Treasure} you want to search through the pool of.
* @return A {@link List} the size of {@link Treasure#getRewardsPerChest()} and with the contents of random rewards
* that can be given to the player or null if an error has occurred.
*/
public List<Reward> getRewards(Player player, Treasure treasure)
{
Map<RewardRarity, WeightSet<Reward>> rewardMap = _rewardPoolMap.get(treasure);
// Null entry, programmer error
if (rewardMap == null)
{
return null;
}
// The list of rewards that will be returned
List<Reward> rewards = new ArrayList<>(treasure.getRewardsPerChest());
// These variables here are used to ensure that each chest opening will always contain at least one uncommon
// but never more than one mythical.
boolean hasUncommon = false;
boolean hasMythical = false;
int attempts = 0;
for (int i = 0; i < treasure.getRewardsPerChest(); i++)
{
attempts++;
Reward reward = nextReward(player, treasure, rewardMap, i, hasUncommon, hasMythical);
// If the reward was null then the reward could not have been given to the player
if (reward == null)
{
// At this point if it has taken 20+ attempts to find a reward and it's still null, then there seems to
// be a problem with the chest's pool or a programmer error.
if (attempts > MAX_ATTEMPTS)
{
return null;
}
// We run the loop again
i--;
continue;
}
RewardRarity rarity = reward.getRarity();
// If the reward is as or more uncommon than an uncommon
if (rarity.ordinal() >= RewardRarity.UNCOMMON.ordinal())
{
hasUncommon = true;
}
// If the reward is as more uncommon than an mythical
if (rarity.ordinal() >= RewardRarity.MYTHICAL.ordinal())
{
hasMythical = true;
}
// Add the reward to our list of rewards
rewards.add(reward);
}
// Due to the last reward always being an uncommon or better, we swap it randomly with another element as to
// appear more random.
Collections.swap(rewards, rewards.size() - 1, UtilMath.r(rewardMap.size()));
return rewards;
}
/**
* This determines the rarity of the reward.
*
* @param player The player you want to give the reward to.
* @param treasure The {@link Treasure} you want to search through the pool of.
* @param rewardMap The map of rarities and weights.
* @param index The current index of this reward, for example the first chest to open will have an index of 0, second 1 etc...
* @param hasUncommon Does the current list of rewards contain an uncommon or better?
* @param hasMythical Does the current list of rewards contain a mythical or better?
* @return A random reward that can be given to the player or null if not or an error has occurred.
*/
private Reward nextReward(Player player, Treasure treasure, Map<RewardRarity, WeightSet<Reward>> rewardMap, int index, boolean hasUncommon, boolean hasMythical)
{
RewardRarity rarity = treasure.getRewardType().generateRarity();
int attempts = 0;
// If the reward list already contains a mythical, keep trying until it isn't one
while (attempts++ < MAX_ATTEMPTS && hasMythical && rarity == RewardRarity.MYTHICAL)
{
rarity = treasure.getRewardType().generateRarity();
}
// If we are on the last reward and there hasn't been an uncommon then make sure this reward is uncommon
if (!hasUncommon && index == treasure.getRewardsPerChest() - 1)
{
rarity = RewardRarity.UNCOMMON;
}
WeightSet<Reward> rewardSet = rewardMap.get(rarity);
// Null entry, programmer error
if (rewardSet == null || rewardSet.elements().isEmpty())
{
return null;
}
return nextReward(player, treasure, rewardSet);
}
/**
* This determines the actual reward.
*
* @param player The player you want to give the reward to.
* @param treasure The {@link Treasure} you want to search through the pool of.
* @param rewardSet The set of reward weights.
* @return A random reward that can be given to the player or null if not or an error has occurred.
*/
private Reward nextReward(Player player, Treasure treasure, WeightSet<Reward> rewardSet)
{
Reward reward;
int attempts = 0;
// Keep iterating until it breaks or gives up
while (attempts++ < MAX_ATTEMPTS)
{
// Get a random reward
reward = rewardSet.generateRandom();
// If the reward can be given to the player. Great!
if (reward.canGiveReward(player))
{
return reward;
}
// Otherwise does the chest give duplicates
else if (treasure.isDuplicates())
{
return new TreasureShardReward(reward, reward.getRarity());
}
}
// This should never be reached but could be if the chest's pool wasn't setup correctly.
return null;
}
}

View File

@ -0,0 +1,291 @@
package mineplex.core.treasure.types;
import java.util.Collections;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm;
import mineplex.core.gadget.gadgets.balloons.BalloonType;
import mineplex.core.gadget.gadgets.death.DeathBlood;
import mineplex.core.gadget.gadgets.death.DeathEmerald;
import mineplex.core.gadget.gadgets.death.DeathEnchant;
import mineplex.core.gadget.gadgets.death.DeathMusic;
import mineplex.core.gadget.gadgets.death.DeathPinataBurst;
import mineplex.core.gadget.gadgets.death.DeathShadow;
import mineplex.core.gadget.gadgets.death.DeathStorm;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm;
import mineplex.core.gadget.gadgets.item.ItemBatGun;
import mineplex.core.gadget.gadgets.item.ItemEtherealPearl;
import mineplex.core.gadget.gadgets.item.ItemFirework;
import mineplex.core.gadget.gadgets.item.ItemFleshHook;
import mineplex.core.gadget.gadgets.item.ItemMelonLauncher;
import mineplex.core.gadget.gadgets.item.ItemPaintballGun;
import mineplex.core.gadget.gadgets.item.ItemTNT;
import mineplex.core.gadget.gadgets.morph.MorphBat;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
import mineplex.core.gadget.gadgets.morph.MorphChicken;
import mineplex.core.gadget.gadgets.morph.MorphCow;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
import mineplex.core.gadget.gadgets.morph.MorphSlime;
import mineplex.core.gadget.gadgets.morph.MorphVillager;
import mineplex.core.gadget.gadgets.mount.types.MountCart;
import mineplex.core.gadget.gadgets.mount.types.MountFrost;
import mineplex.core.gadget.gadgets.mount.types.MountMule;
import mineplex.core.gadget.gadgets.mount.types.MountSlime;
import mineplex.core.gadget.gadgets.mount.types.MountUndead;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitBoots;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitLeggings;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitBoots;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitLeggings;
import mineplex.core.gadget.gadgets.particle.ParticleBlood;
import mineplex.core.gadget.gadgets.particle.ParticleEmerald;
import mineplex.core.gadget.gadgets.particle.ParticleEnchant;
import mineplex.core.gadget.gadgets.particle.ParticleFairy;
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
import mineplex.core.gadget.gadgets.particle.ParticleFoot;
import mineplex.core.gadget.gadgets.particle.ParticleHeart;
import mineplex.core.gadget.gadgets.particle.ParticleMusic;
import mineplex.core.gadget.gadgets.particle.ParticlePartyTime;
import mineplex.core.gadget.gadgets.particle.ParticleRain;
import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel;
import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons;
import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal;
import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie;
import mineplex.core.gadget.gadgets.particle.ParticleYinYang;
import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike;
import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan;
import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian;
import mineplex.core.pet.PetType;
import mineplex.core.reward.RewardType;
import mineplex.core.treasure.animation.animations.OldChestAnimation;
import mineplex.core.treasure.reward.RewardRarity;
public class OldTreasure extends Treasure
{
public OldTreasure()
{
super(TreasureType.OLD);
setAnimations(treasureLocation ->
Collections.singletonList(
new OldChestAnimation(this, treasureLocation)
)
);
setRewards(RewardType.OLD_CHEST);
setRewardsPerChest(4);
allowDuplicates();
setPurchasable(1000);
purchaseAbleFromStore();
enabledByDefault();
}
@Override
protected void addCommon(RewardRarity rarity)
{
// Gadgets
addGadgetReward(getGadget(ItemBatGun.class), rarity, 10, 4, 10);
addGadgetReward(getGadget(ItemEtherealPearl.class), rarity, 10, 6, 15);
addGadgetReward(getGadget(ItemFirework.class), rarity, 10, 10, 25);
addGadgetReward(getGadget(ItemFleshHook.class), rarity, 10, 8, 20);
addGadgetReward(getGadget(ItemMelonLauncher.class), rarity, 10, 10, 25);
addGadgetReward(getGadget(ItemPaintballGun.class), rarity, 10, 20, 50);
addGadgetReward(getGadget(ItemTNT.class), rarity, 10, 4, 10);
}
@Override
protected void addUncommon(RewardRarity rarity)
{
//Gadgets
addGadgetReward(getGadget(ItemBatGun.class), rarity, 250, 0, 20, 40);
addGadgetReward(getGadget(ItemEtherealPearl.class), rarity, 250, 0, 30, 60);
addGadgetReward(getGadget(ItemFirework.class), rarity, 250, 0, 25, 50);
addGadgetReward(getGadget(ItemFleshHook.class), rarity, 250, 0, 40, 80);
addGadgetReward(getGadget(ItemMelonLauncher.class), rarity, 250, 0, 25, 50);
addGadgetReward(getGadget(ItemPaintballGun.class), rarity, 250, 0, 100, 200);
addGadgetReward(getGadget(ItemTNT.class), rarity, 250, 0, 20, 40);
//Pets
addPetReward(PetType.CHICKEN, rarity, 143);
addPetReward(PetType.COW, rarity, 500);
addPetReward(PetType.MUSHROOM_COW, rarity, 200);
addPetReward(PetType.OCELOT, rarity, 167);
addPetReward(PetType.PIG, rarity, 200);
addPetReward(PetType.SHEEP, rarity, 333);
addPetReward(PetType.WOLF, rarity, 125);
//Music Discs
addMusicReward("Blocks", rarity, 25);
addMusicReward("Cat", rarity, 25);
addMusicReward("Chirp", rarity, 25);
addMusicReward("Far", rarity, 25);
addMusicReward("Mall", rarity, 25);
addMusicReward("Mellohi", rarity, 25);
addMusicReward("Stal", rarity, 25);
addMusicReward("Strad", rarity, 25);
addMusicReward("Wait", rarity, 25);
addMusicReward("Ward", rarity, 25);
// Balloons
addBalloonReward(BalloonType.BABY_COW, rarity, 10, 100);
addBalloonReward(BalloonType.BABY_PIG, rarity, 10, 100);
addBalloonReward(BalloonType.BABY_SHEEP, rarity, 15, 100);
}
@Override
protected void addRare(RewardRarity rarity)
{
//Morphs
addGadgetReward(getGadget(MorphVillager.class), rarity, 83);
addGadgetReward(getGadget(MorphCow.class), rarity, 167);
addGadgetReward(getGadget(MorphChicken.class), rarity, 50);
addGadgetReward(getGadget(MorphEnderman.class), rarity, 33);
//Mounts
addGadgetReward(getGadget(MountFrost.class), rarity, 50);
addGadgetReward(getGadget(MountSlime.class), rarity, 67);
addGadgetReward(getGadget(MountCart.class), rarity, 100);
addGadgetReward(getGadget(MountMule.class), rarity, 200);
//Outfit Rave
addGadgetReward(getGadget(OutfitRaveSuitHelmet.class), rarity, 30);
addGadgetReward(getGadget(OutfitRaveSuitChestplate.class), rarity, 30);
addGadgetReward(getGadget(OutfitRaveSuitLeggings.class), rarity, 30);
addGadgetReward(getGadget(OutfitRaveSuitBoots.class), rarity, 30);
//Outfit Space
addGadgetReward(getGadget(OutfitSpaceSuitHelmet.class), rarity, 50);
addGadgetReward(getGadget(OutfitSpaceSuitChestplate.class), rarity, 50);
addGadgetReward(getGadget(OutfitSpaceSuitLeggings.class), rarity, 50);
addGadgetReward(getGadget(OutfitSpaceSuitBoots.class), rarity, 50);
//Arrow Trails
addGadgetReward(getGadget(ArrowTrailConfetti.class), rarity, 27);
addGadgetReward(getGadget(ArrowTrailBlood.class), rarity, 50);
addGadgetReward(getGadget(ArrowTrailEmerald.class), rarity, 25);
addGadgetReward(getGadget(ArrowTrailMusic.class), rarity, 27);
addGadgetReward(getGadget(ArrowTrailStorm.class), rarity, 30);
addGadgetReward(getGadget(ArrowTrailShadow.class), rarity, 15);
//Double Jumps
addGadgetReward(getGadget(DoubleJumpFirecracker.class), rarity, 33);
addGadgetReward(getGadget(DoubleJumpEmerald.class), rarity, 25);
addGadgetReward(getGadget(DoubleJumpShadow.class), rarity, 15);
addGadgetReward(getGadget(DoubleJumpStorm.class), rarity, 30);
addGadgetReward(getGadget(DoubleJumpBlood.class), rarity, 50);
addGadgetReward(getGadget(DoubleJumpMusic.class), rarity, 20);
//Death Effects
addGadgetReward(getGadget(DeathPinataBurst.class), rarity, 27);
addGadgetReward(getGadget(DeathEmerald.class), rarity, 25);
addGadgetReward(getGadget(DeathShadow.class), rarity, 15);
addGadgetReward(getGadget(DeathStorm.class), rarity, 30);
addGadgetReward(getGadget(DeathBlood.class), rarity, 50);
addGadgetReward(getGadget(DeathMusic.class), rarity, 20);
//Particles
addGadgetReward(getGadget(ParticlePartyTime.class), rarity, 12);
//Titles
addTitleReward("shrug", rarity, 10, 500);
addTitleReward("tableflip", rarity, 10, 500);
addTitleReward("tablerespecter", rarity, 15, 500);
addTitleReward("tableflip-disgusted", rarity, 15, 500);
addTitleReward("tableflip-enraged", rarity, 15, 500);
addTitleReward("tableflip-riot", rarity, 10, 500);
addTitleReward("teddy-bear", rarity, 10, 500);
addTitleReward("disgust", rarity, 10, 500);
addTitleReward("old-man", rarity, 5, 500);
addTitleReward("jake", rarity, 5, 500);
addTitleReward("finn", rarity, 5, 500);
addTitleReward("finn-and-jake", rarity, 5, 500);
addTitleReward("boxer", rarity, 5, 500);
addTitleReward("zoidberg", rarity, 5, 500);
// Balloons
addBalloonReward(BalloonType.BABY_ZOMBIE, rarity, 25, 500);
addBalloonReward(BalloonType.BABY_MUSHROOM, rarity, 50, 500);
addBalloonReward(BalloonType.BABY_OCELOT, rarity, 50, 500);
addBalloonReward(BalloonType.BABY_WOLF, rarity, 75, 500);
addBalloonReward(BalloonType.BABY_VILLAGER, rarity, 25, 500);
addBalloonReward(BalloonType.BABY_SLIME, rarity, 25, 500);
addBalloonReward(BalloonType.BAT, rarity, 50, 500);
}
@Override
protected void addLegendary(RewardRarity rarity)
{
//Enchant set
addGadgetReward(getGadget(ArrowTrailEnchant.class), rarity, 10);
addGadgetReward(getGadget(DeathEnchant.class), rarity, 10);
addGadgetReward(getGadget(DoubleJumpEnchant.class), rarity, 10);
//Morphs
addGadgetReward(getGadget(MorphSlime.class), rarity, 10);
addGadgetReward(getGadget(MorphBat.class), rarity, 25);
addGadgetReward(getGadget(MorphBlock.class), rarity, 20);
//Mounts
addGadgetReward(getGadget(MountUndead.class), rarity, 33);
//Particle Trails
addGadgetReward(getGadget(ParticleWingsAngel.class), rarity, 15);
addGadgetReward(getGadget(ParticleBlood.class), rarity, 10);
addGadgetReward(getGadget(ParticleWingsDemons.class), rarity, 15);
addGadgetReward(getGadget(ParticleEnchant.class), rarity, 25);
addGadgetReward(getGadget(ParticleFairy.class), rarity, 4);
addGadgetReward(getGadget(ParticleFireRings.class), rarity, 17);
addGadgetReward(getGadget(ParticleEmerald.class), rarity, 8);
addGadgetReward(getGadget(ParticleHeart.class), rarity, 2);
addGadgetReward(getGadget(ParticleWingsInfernal.class), rarity, 4);
addGadgetReward(getGadget(ParticleMusic.class), rarity, 15);
addGadgetReward(getGadget(ParticleWingsPixie.class), rarity, 4);
addGadgetReward(getGadget(ParticleRain.class), rarity, 13);
addGadgetReward(getGadget(ParticleFoot.class), rarity, 33);
addGadgetReward(getGadget(ParticleYinYang.class), rarity, 20);
//Win Effects
addGadgetReward(getGadget(WinEffectBabyChicken.class), rarity, 10);
addGadgetReward(getGadget(WinEffectLavaTrap.class), rarity, 20);
addGadgetReward(getGadget(WinEffectLightningStrike.class), rarity, 20);
addGadgetReward(getGadget(WinEffectMrPunchMan.class), rarity, 33);
addGadgetReward(getGadget(WinEffectRiseOfTheElderGuardian.class), rarity, 4);
// Titles
addTitleReward("ayyye", rarity, 25);
addTitleReward("ameno", rarity, 15);
addTitleReward("magician", rarity, 25);
addTitleReward("fireball", rarity, 75);
addTitleReward("magic-missile", rarity, 75);
addTitleReward("pewpewpew", rarity, 75);
addTitleReward("stardust", rarity, 60);
addTitleReward("blow-a-kiss", rarity, 60);
addTitleReward("cool-guy", rarity, 60);
addTitleReward("deal-with-it", rarity, 60);
addTitleReward("party-time", rarity, 55);
addTitleReward("lalala", rarity, 30);
addTitleReward("gotta-go", rarity, 30);
addTitleReward("whaaat", rarity, 30);
// Balloons
addBalloonReward(BalloonType.SQUID, rarity, 10);
addBalloonReward(BalloonType.SILVERFISH, rarity, 30);
addBalloonReward(BalloonType.GUARDIAN, rarity, 30);
addBalloonReward(BalloonType.EMERALD_BLOCK, rarity, 15);
}
}

View File

@ -0,0 +1,289 @@
package mineplex.core.treasure.types;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import org.bukkit.inventory.ItemStack;
import com.google.common.collect.ImmutableMap;
import mineplex.core.Managers;
import mineplex.core.common.util.C;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.balloons.BalloonType;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.pet.PetType;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardType;
import mineplex.core.reward.rewards.GadgetReward;
import mineplex.core.reward.rewards.InventoryReward;
import mineplex.core.reward.rewards.PetReward;
import mineplex.core.reward.rewards.TitleReward;
import mineplex.core.titles.tracks.TrackManager;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.animation.TreasureAnimation;
import mineplex.core.treasure.reward.RewardRarity;
import mineplex.core.treasure.reward.TreasureRewardManager;
/**
*
*/
public class Treasure
{
private static final String PURCHASABLE_FROM_STORE = "Purchase at mineplex.com/shop";
private static final Map<RewardRarity, Integer> SHARD_WORTH = ImmutableMap.<RewardRarity, Integer>builder()
.put(RewardRarity.UNCOMMON, 100)
.put(RewardRarity.RARE, 500)
.put(RewardRarity.LEGENDARY, 5000)
.build();
private static final TreasureRewardManager TREASURE_REWARD_MANAGER = Managers.require(TreasureRewardManager.class);
public static TreasureRewardManager getRewardManager()
{
return TREASURE_REWARD_MANAGER;
}
private static final GadgetManager GADGET_MANAGER = Managers.require(GadgetManager.class);
private static final TrackManager TRACK_MANAGER = Managers.require(TrackManager.class);
private final TreasureType _treasureType;
private final List<String> _purchaseMethods;
private RewardType _rewardType;
private Function<TreasureLocation, List<TreasureAnimation>> _animationFunction;
private boolean _duplicates;
private int _rewardsPerChest;
private boolean _purchasable;
private int _purchasePrice;
private boolean _enabledDefault;
Treasure(TreasureType treasureType)
{
_treasureType = treasureType;
_purchaseMethods = new ArrayList<>(2);
addCommon(RewardRarity.COMMON);
addUncommon(RewardRarity.UNCOMMON);
addRare(RewardRarity.RARE);
addLegendary(RewardRarity.LEGENDARY);
addMythical(RewardRarity.MYTHICAL);
}
protected void addCommon(RewardRarity rarity)
{
}
protected void addUncommon(RewardRarity rarity)
{
}
protected void addRare(RewardRarity rarity)
{
}
protected void addLegendary(RewardRarity rarity)
{
}
protected void addMythical(RewardRarity rarity)
{
}
public TreasureType getTreasureType()
{
return _treasureType;
}
public RewardType getRewardType()
{
return _rewardType;
}
public void allowDuplicates()
{
_duplicates = true;
}
public boolean isDuplicates()
{
return _duplicates;
}
public void setRewardsPerChest(int rewardsPerChest)
{
_rewardsPerChest = rewardsPerChest;
}
public int getRewardsPerChest()
{
return _rewardsPerChest;
}
protected void purchaseAbleFromStore()
{
addPurchaseMethod(PURCHASABLE_FROM_STORE);
}
protected void addPurchaseMethod(String method)
{
_purchaseMethods.add(C.cBlue + method);
}
protected void setRewards(RewardType rewardType)
{
_rewardType = rewardType;
}
protected void setAnimations(Function<TreasureLocation, List<TreasureAnimation>> animations)
{
_animationFunction = animations;
}
public List<TreasureAnimation> getAnimations(TreasureLocation location)
{
return _animationFunction.apply(location);
}
public boolean hasAnimations()
{
return _animationFunction != null;
}
public boolean isPurchasable()
{
return _purchasable;
}
public int getPurchasePrice()
{
return _purchasePrice;
}
public void setPurchasable(boolean purchasable)
{
_purchasable = purchasable;
}
protected void setPurchasable(int purchasePrice)
{
_purchasable = true;
_purchasePrice = purchasePrice;
addPurchaseMethod("Craftable for " + C.cAqua + _purchasePrice + " Treasure Shards");
}
public List<String> getPurchaseMethods()
{
return _purchaseMethods;
}
protected void enabledByDefault()
{
_enabledDefault = true;
}
protected final <T extends Gadget> T getGadget(Class<T> clazz)
{
return GADGET_MANAGER.getGadget(clazz);
}
protected final InventoryReward addGadgetReward(ItemGadget gadget, RewardRarity rarity, int weight, int minAmmo, int maxAmmo)
{
return addGadgetReward(gadget, rarity, weight, getShards(rarity), minAmmo, maxAmmo);
}
protected final InventoryReward addGadgetReward(ItemGadget gadget, RewardRarity rarity, int weight, int shards, int minAmmo, int maxAmmo)
{
InventoryReward reward = new InventoryReward(
gadget.getDisplayName(),
gadget.getName(),
"Gadget",
minAmmo,
maxAmmo,
new ItemStack(gadget.getDisplayMaterial(), 1, (short) 0, gadget.getDisplayData()),
rarity,
shards
);
addReward(reward, weight);
return reward;
}
protected final GadgetReward addGadgetReward(Gadget gadget, RewardRarity rarity, int weight)
{
return addGadgetReward(gadget, rarity, weight, getShards(rarity));
}
protected final GadgetReward addGadgetReward(Gadget gadget, RewardRarity rarity, int weight, int shards)
{
GadgetReward reward = new GadgetReward(gadget, rarity, shards);
addReward(reward, weight);
return reward;
}
protected PetReward addPetReward(PetType petType, RewardRarity rarity, int weight)
{
return addPetReward(petType, rarity, weight, getShards(rarity));
}
protected PetReward addPetReward(PetType petType, RewardRarity rarity, int weight, int shards)
{
PetReward reward = new PetReward(petType.getName(), petType, rarity, shards);
addReward(reward, weight);
return reward;
}
protected GadgetReward addMusicReward(String disc, RewardRarity rarity, int weight)
{
return addMusicReward(disc, rarity, weight, getShards(rarity));
}
protected GadgetReward addMusicReward(String disc, RewardRarity rarity, int weight, int shards)
{
for (Gadget gadget : GADGET_MANAGER.getGadgets(GadgetType.MUSIC_DISC))
{
if (gadget.getName().equals(disc + " Disc"))
{
return addGadgetReward(gadget, rarity, weight, shards);
}
}
return null;
}
protected GadgetReward addBalloonReward(BalloonType type, RewardRarity rarity, int weight)
{
return addBalloonReward(type, rarity, weight, getShards(rarity));
}
protected GadgetReward addBalloonReward(BalloonType type, RewardRarity rarity, int weight, int shards)
{
return addGadgetReward(GADGET_MANAGER.getBalloonGadget(type), rarity, weight, shards);
}
protected TitleReward addTitleReward(String id, RewardRarity rarity, int weight)
{
return addTitleReward(id, rarity, weight, getShards(rarity));
}
protected TitleReward addTitleReward(String id, RewardRarity rarity, int weight, int shards)
{
TitleReward reward = new TitleReward(TRACK_MANAGER.getTrackById(id), rarity, shards);
addReward(reward, weight);
return reward;
}
private int getShards(RewardRarity rarity)
{
return SHARD_WORTH.getOrDefault(rarity, 0);
}
private void addReward(Reward reward, int weight)
{
TREASURE_REWARD_MANAGER.addReward(this, reward, weight);
}
}

View File

@ -0,0 +1,65 @@
package mineplex.core.treasure.types;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
public enum TreasureType
{
OLD(
C.cYellow + "Old Treasure",
"Old Chest",
"Old",
new ItemStack(Material.CHEST),
"We've scoured the lands of Minecraft",
"and found these abandoned chests.",
"The contents are unknown, but",
"according to the inscriptions on the",
"the straps they appear to contain",
"many kinds of loot."
),
;
private final String _name;
private final String _itemName;
private final String _statName;
private final ItemStack _itemStack;
private final String[] _description;
TreasureType(String name, String itemName, String statName, ItemStack itemStack, String... description)
{
_name = name;
_itemName = itemName;
_statName = statName;
_itemStack = itemStack;
_description = description;
}
public String getName()
{
return _name;
}
public String getItemName()
{
return _itemName;
}
public String getStatName()
{
return _statName;
}
public ItemStack getItemStack()
{
return _itemStack;
}
public String[] getDescription()
{
return _description;
}
}

View File

@ -0,0 +1,112 @@
package mineplex.core.treasure.ui;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.treasure.TreasureManager;
import mineplex.core.treasure.types.Treasure;
import mineplex.core.shop.confirmation.ConfirmationPage;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.SalesPackageBase;
import mineplex.core.shop.item.SalesPackageProcessor;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.treasure.ChestPackage;
public class PurchaseTreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
{
private final Treasure _treasure;
private final TreasurePage _previous;
public PurchaseTreasurePage(TreasureManager plugin, TreasureShop shop, Player player, Treasure treasure, TreasurePage previous)
{
super(plugin, shop, plugin.getClientManager(), plugin.getDonationManager(), "Purchase " + treasure.getTreasureType().getName(), player);
_treasure = treasure;
_previous = previous;
buildPage();
}
@Override
protected void buildPage()
{
int purchaseAmount = 1;
addButton(20, getPurchaseItem(purchaseAmount), new PurchaseChestButton(purchaseAmount));
purchaseAmount = 5;
addButton(22, getPurchaseItem(purchaseAmount), new PurchaseChestButton(purchaseAmount));
purchaseAmount = 10;
addButton(24, getPurchaseItem(purchaseAmount), new PurchaseChestButton(purchaseAmount));
}
private ItemStack getPurchaseItem(int amount)
{
ItemStack itemStack = _treasure.getTreasureType().getItemStack().clone();
ItemMeta meta = itemStack.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("");
lore.add(C.cGray + "Bulk buy " + F.elem(amount) + " chests.");
lore.add(C.cGray + "This will cost " + F.currency(GlobalCurrency.TREASURE_SHARD, _treasure.getPurchasePrice() * amount) + "!");
lore.add("");
lore.add(C.cGreen + "Click to purchase the chests!");
meta.setDisplayName(_treasure.getTreasureType().getName());
meta.setLore(lore);
itemStack.setItemMeta(meta);
itemStack.setAmount(amount);
return itemStack;
}
private class PurchaseChestButton implements IButton
{
private final int _amount;
PurchaseChestButton(int amount)
{
_amount = amount;
}
@Override
public void onClick(Player player, ClickType clickType)
{
getPlugin().purchase(newAmount ->
{
SalesPackageBase salesPackage = new ChestPackage(_treasure.getTreasureType().getItemName(), Material.CHEST, _treasure.getPurchasePrice() * newAmount);
getShop().openPageForPlayer(
player,
new ConfirmationPage<>(
player,
_previous,
new SalesPackageProcessor(
player,
GlobalCurrency.TREASURE_SHARD,
salesPackage,
getDonationManager(),
() ->
{
_previous.buildPage();
getPlugin().giveTreasure(player, _treasure, newAmount);
player.sendMessage(F.main(getPlugin().getName(), "Purchased " + F.elem(newAmount) + " " + F.name(_treasure.getTreasureType().getName()) + "."));
}),
salesPackage.buildIcon()));
}, player, _treasure, _amount);
}
}
}

View File

@ -0,0 +1,122 @@
package mineplex.core.treasure.ui;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilUI;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.TreasureManager;
import mineplex.core.treasure.types.Treasure;
public class TreasurePage extends ShopPageBase<TreasureManager, TreasureShop>
{
private final TreasureLocation _treasureLocation;
public TreasurePage(TreasureManager plugin, TreasureShop shop, Player player, TreasureLocation treasureLocation)
{
super(plugin, shop, plugin.getClientManager(), plugin.getDonationManager(), "Treasure Chest", player);
_treasureLocation = treasureLocation;
buildPage();
}
@Override
protected void buildPage()
{
List<Treasure> treasures = _treasureLocation.getManager().getTreasures();
int[] slots = UtilUI.getIndicesFor(treasures.size(), 2);
int index = 0;
for (Treasure treasure : _treasureLocation.getManager().getTreasures())
{
addButton(slots[index++], prettifyItem(getPlayer(), treasure), new TreasureButton(treasure));
}
}
private ItemStack prettifyItem(Player player, Treasure treasure)
{
int toOpen = _treasureLocation.getManager().getChestsToOpen(player, treasure);
boolean canOpen = toOpen > 0;
ItemStack itemStack = treasure.getTreasureType().getItemStack().clone();
ItemMeta meta = itemStack.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("");
lore.add(C.cGray + ChatColor.stripColor(treasure.getTreasureType().getName()) + "s Owned: " + F.elem(toOpen));
lore.add("");
for (String description : treasure.getTreasureType().getDescription())
{
lore.add(C.cGray + description);
}
lore.add("");
if (treasure.isPurchasable())
{
lore.addAll(treasure.getPurchaseMethods());
}
if (canOpen)
{
lore.add("");
lore.add(C.cGreen + "Left-Click to open!");
}
if (treasure.isPurchasable())
{
lore.add(C.cGreen + "Right-Click to purchase!");
}
meta.setDisplayName(treasure.getTreasureType().getName());
meta.setLore(lore);
itemStack.setItemMeta(meta);
return itemStack;
}
private class TreasureButton implements IButton
{
private final Treasure _treasure;
TreasureButton(Treasure treasure)
{
_treasure = treasure;
}
@Override
public void onClick(Player player, ClickType clickType)
{
// Open
if (clickType.isLeftClick())
{
if (_treasureLocation.openChest(player, _treasure))
{
playAcceptSound(player);
}
else
{
playDenySound(player);
}
}
// Purchase
else
{
getShop().openPageForPlayer(player, new PurchaseTreasurePage(getPlugin(), getShop(), getPlayer(), _treasure, TreasurePage.this));
}
}
}
}

View File

@ -0,0 +1,29 @@
package mineplex.core.treasure.ui;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.treasure.TreasureLocation;
import mineplex.core.treasure.TreasureManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
public class TreasureShop extends ShopBase<TreasureManager>
{
private final TreasureLocation _treasureLocation;
public TreasureShop(TreasureManager plugin, CoreClientManager clientManager, DonationManager donationManager, TreasureLocation treasureLocation)
{
super(plugin, clientManager, donationManager, "Treasure Chest");
_treasureLocation = treasureLocation;
}
@Override
protected ShopPageBase<TreasureManager, ? extends ShopBase<TreasureManager>> buildPagesFor(Player player)
{
return new TreasurePage(getPlugin(), this, player, _treasureLocation);
}
}

View File

@ -18,10 +18,10 @@ import mineplex.core.gadget.GadgetManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardPool;
import mineplex.core.reward.RewardType;
import mineplex.core.stats.StatsManager;
import mineplex.core.treasure.reward.RewardPool;
import mineplex.core.treasure.reward.TreasureRewardManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.valentines.event.AttemptGiftEvent;
@ -33,7 +33,7 @@ public class ValentinesGiftManager extends MiniPlugin
private final Material ITEM_MATERIAL = Material.RED_ROSE;
private CoreClientManager _clientManager;
private RewardManager _rewardManager;
private TreasureRewardManager _rewardManager;
private InventoryManager _inventoryManager;
private GadgetManager _gadgetManager;
private StatsManager _statsManager;
@ -41,7 +41,7 @@ public class ValentinesGiftManager extends MiniPlugin
private ValentinesGiftRepository _repository;
private LinkedList<GiftEffect> _effects;
public ValentinesGiftManager(JavaPlugin plugin, CoreClientManager clientManager, RewardManager rewardManager, InventoryManager inventoryManager, GadgetManager gadgetManager, StatsManager statsManager)
public ValentinesGiftManager(JavaPlugin plugin, CoreClientManager clientManager, TreasureRewardManager rewardManager, InventoryManager inventoryManager, GadgetManager gadgetManager, StatsManager statsManager)
{
super("Valentines", plugin);
@ -76,49 +76,49 @@ public class ValentinesGiftManager extends MiniPlugin
*/
private void giveGift(Player from, Player to, boolean success)
{
if (success)
{
_inventoryManager.addItemToInventory(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
if (data)
{
_rewardManager.nextReward(to, RewardPool.Type.VALENTINES_GIFT, null, false, RewardType.VALENTINES_GIFT, false).giveReward(RewardType.VALENTINES_GIFT, to, new Callback<RewardData>()
{
@Override
public void run(RewardData toData)
{
String toGift = ChatColor.stripColor(toData.getFriendlyName());
_rewardManager.nextReward(from, RewardPool.Type.VALENTINES_GIFT, null, false, RewardType.VALENTINES_GIFT, false).giveReward(RewardType.VALENTINES_GIFT, from, new Callback<RewardData>()
{
@Override
public void run(RewardData fromData)
{
String fromGift = ChatColor.stripColor(fromData.getFriendlyName());
_effects.add(new GiftEffect(from, to, fromGift, toGift, UtilAlg.getMidpoint(to.getLocation(), from.getLocation())));
incrementStat(from, to);
}
});
}
});
from.getInventory().setItem(_gadgetManager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(ITEM_MATERIAL, (byte) 0, 1, F.item(_inventoryManager.Get(from).getItemCount(ITEM_NAME) + " " + ITEM_NAME)));
}
else
{
UtilPlayer.message(from, F.main("Gift", "Error giving gift! Please try again"));
}
}
}, from, ITEM_NAME, -1);
}
else
{
UtilPlayer.message(from, F.main("Gift", "Spread the love! You have already gifted " + F.name(to.getName())));
}
// if (success)
// {
// _inventoryManager.addItemToInventory(new Callback<Boolean>()
// {
// @Override
// public void run(Boolean data)
// {
// if (data)
// {
// _rewardManager.nextReward(to, RewardPool.Type.VALENTINES_GIFT, null, false, RewardType.VALENTINES_GIFT, false).giveReward(RewardType.VALENTINES_GIFT, to, new Callback<RewardData>()
// {
// @Override
// public void run(RewardData toData)
// {
// String toGift = ChatColor.stripColor(toData.getFriendlyName());
//
// _rewardManager.nextReward(from, RewardPool.Type.VALENTINES_GIFT, null, false, RewardType.VALENTINES_GIFT, false).giveReward(RewardType.VALENTINES_GIFT, from, new Callback<RewardData>()
// {
// @Override
// public void run(RewardData fromData)
// {
// String fromGift = ChatColor.stripColor(fromData.getFriendlyName());
// _effects.add(new GiftEffect(from, to, fromGift, toGift, UtilAlg.getMidpoint(to.getLocation(), from.getLocation())));
//
// incrementStat(from, to);
// }
// });
// }
// });
//
// from.getInventory().setItem(_gadgetManager.getActiveItemSlot(), ItemStackFactory.Instance.CreateStack(ITEM_MATERIAL, (byte) 0, 1, F.item(_inventoryManager.Get(from).getItemCount(ITEM_NAME) + " " + ITEM_NAME)));
// }
// else
// {
// UtilPlayer.message(from, F.main("Gift", "Error giving gift! Please try again"));
// }
// }
// }, from, ITEM_NAME, -1);
// }
// else
// {
// UtilPlayer.message(from, F.main("Gift", "Spread the love! You have already gifted " + F.name(to.getName())));
// }
}
@EventHandler

View File

@ -25,7 +25,6 @@ import mineplex.core.elo.EloManager;
import mineplex.core.friend.FriendManager;
import mineplex.core.gadget.gadgets.particle.king.CastleManager;
import mineplex.core.give.Give;
import mineplex.core.globalpacket.GlobalPacketManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager;
import mineplex.core.incognito.IncognitoManager;
@ -165,7 +164,6 @@ public class ClansHub extends JavaPlugin
new CustomTagFix(this, packetHandler);
new PacketsInteractionFix(this, packetHandler);
new ResourcePackManager(this, portal);
new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager, hubManager.getBonusManager().getRewardManager());
AprilFoolsManager.getInstance();

Some files were not shown because too many files have changed in this diff Show More