Fix fireworks for 1.8 client, a bunch more treasure stuff
This commit is contained in:
parent
b910c5098c
commit
4ea786a1a5
@ -10,7 +10,7 @@ import org.bukkit.inventory.meta.FireworkMeta;
|
||||
|
||||
public class FireworkUtil
|
||||
{
|
||||
public static void LaunchRandomFirework(Location location)
|
||||
public static Firework LaunchRandomFirework(Location location)
|
||||
{
|
||||
Builder builder = FireworkEffect.builder();
|
||||
|
||||
@ -40,5 +40,7 @@ public class FireworkUtil
|
||||
data.addEffects(builder.build());
|
||||
data.setPower(RandomUtils.nextInt(3));
|
||||
firework.setFireworkMeta(data);
|
||||
|
||||
return firework;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFirework;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -19,10 +20,10 @@ public class UtilFirework
|
||||
data.setPower(1);
|
||||
data.addEffect(fe);
|
||||
firework.setFireworkMeta(data);
|
||||
|
||||
((CraftWorld)loc.getWorld()).getHandle().broadcastEntityEffect(((CraftEntity)firework).getHandle(), (byte)17);
|
||||
|
||||
firework.remove();
|
||||
((CraftFirework) firework).getHandle().expectedLifespan = 1;
|
||||
// ((CraftWorld)loc.getWorld()).getHandle().broadcastEntityEffect(((CraftEntity)firework).getHandle(), (byte)17);
|
||||
// firework.remove();
|
||||
}
|
||||
|
||||
public static Firework launchFirework(Location loc, FireworkEffect fe, Vector dir, int power)
|
||||
|
@ -12,13 +12,16 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.treasure.animation.Animation;
|
||||
import mineplex.core.treasure.animation.ChestExplodeAnimation;
|
||||
import mineplex.core.treasure.animation.ChestOpenAnimation;
|
||||
import mineplex.core.treasure.animation.ChestSpawnAnimation;
|
||||
import mineplex.core.treasure.animation.CircleAnimation;
|
||||
import mineplex.core.treasure.animation.FireworksAnimation;
|
||||
import mineplex.core.treasure.event.TreasureFinishEvent;
|
||||
import mineplex.core.treasure.reward.ITreasureReward;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
|
||||
@ -34,6 +37,9 @@ public class Treasure
|
||||
private int _tickCount;
|
||||
private ChestData[] _chestData;
|
||||
|
||||
private boolean _finished;
|
||||
private int _finishedTickCount;
|
||||
|
||||
private LinkedList<Animation> _animations;
|
||||
|
||||
private TreasureStyle _style;
|
||||
@ -60,6 +66,8 @@ public class Treasure
|
||||
_chestData[1] = new ChestData(_centerBlock.getRelative(-2, 1, 0), rewards[1]);
|
||||
_chestData[2] = new ChestData(_centerBlock.getRelative(0, 1, 2), rewards[2]);
|
||||
_chestData[3] = new ChestData(_centerBlock.getRelative(0, 1, -2), rewards[3]);
|
||||
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " is opening treasure at " + F.elem(_centerBlock.getX() + ", " + _centerBlock.getZ()) + "!"));
|
||||
}
|
||||
|
||||
private void createCenterClay()
|
||||
@ -124,6 +132,16 @@ public class Treasure
|
||||
|
||||
public void update()
|
||||
{
|
||||
if (_finished)
|
||||
{
|
||||
if (_finishedTickCount >= 100)
|
||||
{
|
||||
finish();
|
||||
}
|
||||
|
||||
_finishedTickCount++;
|
||||
}
|
||||
|
||||
|
||||
if (_tickCount == 5)
|
||||
{
|
||||
@ -226,19 +244,22 @@ public class Treasure
|
||||
|
||||
// Extra effects based off the rarity of the treasure
|
||||
if (data.getReward().getRarity() == RewardRarity.UNCOMMON)
|
||||
{
|
||||
_animations.add(new FireworksAnimation(this, data.getBlock()));
|
||||
}
|
||||
else if (data.getReward().getRarity() == RewardRarity.RARE)
|
||||
{
|
||||
_animations.add(new CircleAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
|
||||
}
|
||||
else
|
||||
// if (data.getReward().getRarity() == RewardRarity.RARE)
|
||||
else if (data.getReward().getRarity() == RewardRarity.VERY_RARE)
|
||||
{
|
||||
_animations.add(new FireworksAnimation(this, data.getBlock()));
|
||||
_animations.add(new ChestExplodeAnimation(this, data.getBlock()));
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " just opened an extremely rare treasure chest!"));
|
||||
}
|
||||
|
||||
if (isFinished())
|
||||
{
|
||||
// TODO figure out finish event
|
||||
System.out.println("finished");
|
||||
_finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,6 +290,19 @@ public class Treasure
|
||||
|
||||
public void finish()
|
||||
{
|
||||
for (ChestData chestData : _chestData)
|
||||
{
|
||||
// Give any unopened rewards to the player
|
||||
// This only applies if they leave the server
|
||||
// while opening a treasure
|
||||
if (!chestData.isOpened())
|
||||
{
|
||||
chestData.setOpened(true);
|
||||
chestData.setFinishedOpen(true);
|
||||
chestData.getReward().giveReward(_player);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<Block, BlockInfo> entry : _blockRestoreMap.entrySet())
|
||||
{
|
||||
Block block = entry.getKey();
|
||||
@ -276,6 +310,7 @@ public class Treasure
|
||||
|
||||
block.setTypeId(data.getId());
|
||||
block.setData(data.getData());
|
||||
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
|
||||
}
|
||||
|
||||
for (Animation animation : _animations)
|
||||
@ -283,6 +318,9 @@ public class Treasure
|
||||
animation.finish();
|
||||
}
|
||||
_animations.clear();
|
||||
|
||||
TreasureFinishEvent event = new TreasureFinishEvent(_player, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
public TreasureStyle getStyle()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.core.treasure;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -10,6 +11,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
@ -20,11 +22,16 @@ import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.treasure.event.TreasureFinishEvent;
|
||||
import mineplex.core.treasure.event.TreasureStartEvent;
|
||||
import mineplex.core.treasure.reward.ITreasureReward;
|
||||
import mineplex.core.treasure.reward.RewardManager;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
import mineplex.core.treasure.reward.rewards.CoinReward;
|
||||
import mineplex.core.treasure.reward.rewards.GemReward;
|
||||
import mineplex.core.treasure.reward.rewards.InventoryReward;
|
||||
import mineplex.core.treasure.reward.rewards.UnknownPackageReward;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
@ -36,26 +43,60 @@ public class TreasureManager extends MiniPlugin
|
||||
private NautHashMap<Player, Treasure> _playerTreasureMap;
|
||||
private RewardManager _rewardManager;
|
||||
private DonationManager _donationManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
|
||||
public TreasureManager(JavaPlugin plugin, DonationManager donationManager)
|
||||
public TreasureManager(JavaPlugin plugin, DonationManager donationManager, InventoryManager inventoryManager)
|
||||
{
|
||||
super("Treasure", plugin);
|
||||
|
||||
_donationManager = donationManager;
|
||||
_playerTreasureMap = new NautHashMap<Player, Treasure>();
|
||||
_rewardManager = new RewardManager();
|
||||
_inventoryManager = inventoryManager;
|
||||
|
||||
// Very Rare
|
||||
_rewardManager.addReward(new CoinReward(donationManager, 1000, 2000, 1000, RewardRarity.VERY_RARE));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Helix Particles", "Blood Helix",
|
||||
new ItemStack(Material.REDSTONE), RewardRarity.VERY_RARE, 100));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Enchant Particles", "Enchanted",
|
||||
new ItemStack(Material.BOOK), RewardRarity.VERY_RARE, 1000));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Fire Rings Particles", "Flame Rings",
|
||||
new ItemStack(Material.BLAZE_POWDER), RewardRarity.VERY_RARE, 600));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Foot Particles", "Shadow Walk",
|
||||
new ItemStack(Material.LEATHER_BOOTS), RewardRarity.VERY_RARE, 1200));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Green Particles", "Green Ring",
|
||||
new ItemStack(Material.EMERALD), RewardRarity.VERY_RARE, 200));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Rain Particles", "Rain Cloud",
|
||||
new ItemStack(Material.INK_SACK), RewardRarity.VERY_RARE, 300));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Notch Morph", "Notch",
|
||||
new ItemStack(Material.INK_SACK), RewardRarity.VERY_RARE, 10));
|
||||
|
||||
// Rare
|
||||
_rewardManager.addReward(new CoinReward(donationManager, 500, 1000, 1000, RewardRarity.RARE));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Bat Morph", "Bat Morph",
|
||||
new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 1), RewardRarity.RARE, 100));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Block Morph", "Block Morph",
|
||||
new ItemStack(Material.EMERALD_BLOCK), RewardRarity.RARE, 200));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Chicken Morph", "Chicken Morph",
|
||||
new ItemStack(Material.FEATHER), RewardRarity.RARE, 300));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Cow Morph", "Cow Morph",
|
||||
new ItemStack(Material.LEATHER), RewardRarity.RARE, 500));
|
||||
_rewardManager.addReward(new UnknownPackageReward(donationManager, "Enderman Morph", "Enderman Morph",
|
||||
new ItemStack(Material.ENDER_PEARL), RewardRarity.RARE, 200));
|
||||
|
||||
// Uncommon
|
||||
_rewardManager.addReward(new CoinReward(donationManager, 100, 500, 1000, RewardRarity.UNCOMMON));
|
||||
|
||||
// Common
|
||||
_rewardManager.addReward(new CoinReward(donationManager, 0, 100, 1000, RewardRarity.COMMON));
|
||||
_rewardManager.addReward(new InventoryReward(inventoryManager, "Ender Pearls", "Ethereal Pearl", 25, 75,
|
||||
new ItemStack(Material.ENDER_PEARL), RewardRarity.COMMON, 1000));
|
||||
_rewardManager.addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks", 25, 75,
|
||||
new ItemStack(Material.FIREWORK), RewardRarity.COMMON, 1000));
|
||||
_rewardManager.addReward(new InventoryReward(inventoryManager, "TNT", "TNT", 10, 30,
|
||||
new ItemStack(Material.TNT), RewardRarity.COMMON, 1000));
|
||||
_rewardManager.addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher", 50, 150,
|
||||
new ItemStack(Material.MELON_BLOCK), RewardRarity.COMMON, 1000));
|
||||
|
||||
}
|
||||
|
||||
@ -73,6 +114,15 @@ public class TreasureManager extends MiniPlugin
|
||||
if (!checkNearbyBlocks(player))
|
||||
return;
|
||||
|
||||
TreasureStartEvent event = new TreasureStartEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
player.sendMessage(F.main("Treasure", "Failed to create a treasure. Unknown reason"));
|
||||
return;
|
||||
}
|
||||
|
||||
ITreasureReward[] rewards = new ITreasureReward[4];
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
@ -195,6 +245,12 @@ public class TreasureManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void treasureFinish(TreasureFinishEvent event)
|
||||
{
|
||||
_playerTreasureMap.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// public void command(PlayerCommandPreprocessEvent event)
|
||||
// {
|
||||
|
@ -30,7 +30,7 @@ public enum TreasureStyle
|
||||
Material.STAINED_CLAY, (byte) 6,
|
||||
Material.STAINED_GLASS_PANE, (byte) 0,
|
||||
ParticleType.HEART,
|
||||
ParticleType.FLAME,
|
||||
ParticleType.CLOUD,
|
||||
null),
|
||||
|
||||
|
||||
@ -39,21 +39,21 @@ public enum TreasureStyle
|
||||
Material.STAINED_GLASS_PANE, (byte) 8,
|
||||
ParticleType.FLAME,
|
||||
ParticleType.HAPPY_VILLAGER,
|
||||
ParticleType.LAVA),
|
||||
ParticleType.LAVA);
|
||||
|
||||
FANCY(Material.DIAMOND_BLOCK,(byte) 0,
|
||||
Material.GOLD_BLOCK, (byte) 0,
|
||||
Material.AIR, (byte) 0,
|
||||
ParticleType.FLAME,
|
||||
ParticleType.CLOUD,
|
||||
ParticleType.LAVA),
|
||||
|
||||
FANCY_2(Material.IRON_BLOCK,(byte) 0,
|
||||
Material.EMERALD_BLOCK, (byte) 0,
|
||||
Material.AIR, (byte) 0,
|
||||
ParticleType.FLAME,
|
||||
ParticleType.HAPPY_VILLAGER,
|
||||
null);
|
||||
// FANCY(Material.DIAMOND_BLOCK,(byte) 0,
|
||||
// Material.GOLD_BLOCK, (byte) 0,
|
||||
// Material.AIR, (byte) 0,
|
||||
// ParticleType.FLAME,
|
||||
// ParticleType.CLOUD,
|
||||
// ParticleType.LAVA),
|
||||
//
|
||||
// FANCY_2(Material.IRON_BLOCK,(byte) 0,
|
||||
// Material.EMERALD_BLOCK, (byte) 0,
|
||||
// Material.AIR, (byte) 0,
|
||||
// ParticleType.FLAME,
|
||||
// ParticleType.HAPPY_VILLAGER,
|
||||
// null);
|
||||
|
||||
private Material _primaryMaterial;
|
||||
private byte _primaryData;
|
||||
|
@ -0,0 +1,65 @@
|
||||
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.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.treasure.Treasure;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-12.
|
||||
*/
|
||||
public class ChestExplodeAnimation extends Animation
|
||||
{
|
||||
private Random _random = new Random();
|
||||
private Block _chestBlock;
|
||||
|
||||
public ChestExplodeAnimation(Treasure treasure, Block chestBlock)
|
||||
{
|
||||
super(treasure);
|
||||
|
||||
_chestBlock = chestBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick()
|
||||
{
|
||||
if (getTicks() == 1)
|
||||
{
|
||||
// _chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.WITHER_SPAWN, 10F, 1.2F);
|
||||
_chestBlock.getLocation().getWorld().playSound(_chestBlock.getLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
|
||||
}
|
||||
if (getTicks() == 10)
|
||||
{
|
||||
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build();
|
||||
UtilFirework.playFirework(_chestBlock.getLocation().add(0.5, 0.5, 0.5), effect);
|
||||
// ((CraftWorld) _chestBlock.getWorld()).getHandle().triggerEffect(1005, _chestBlock.getX(), _chestBlock.getY(), _chestBlock.getZ(), 2257);
|
||||
}
|
||||
else if (getTicks() < 10)
|
||||
{
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package mineplex.core.treasure.animation;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
@ -30,9 +31,10 @@ public class CircleAnimation extends Animation
|
||||
@Override
|
||||
protected void tick()
|
||||
{
|
||||
if (getTicks() == 1)
|
||||
if (getTicks() == 2)
|
||||
{
|
||||
UtilFirework.playFirework(_centerLocation, FireworkEffect.builder().withColor(Color.RED).build());
|
||||
UtilFirework.playFirework(_centerLocation, FireworkEffect.builder().withColor(Color.ORANGE).with(FireworkEffect.Type.BURST).build());
|
||||
_centerLocation.getWorld().playSound(_centerLocation, Sound.WITHER_SPAWN, 10F, 1.2F);
|
||||
}
|
||||
else if (getTicks() >= 60)
|
||||
{
|
||||
|
@ -2,11 +2,21 @@ package mineplex.core.treasure.animation;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFirework;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityStatus;
|
||||
|
||||
import mineplex.core.common.util.FireworkUtil;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.treasure.Treasure;
|
||||
|
||||
/**
|
||||
@ -36,17 +46,18 @@ public class FireworksAnimation extends Animation
|
||||
|
||||
if (getTicks() % 10 == 0)
|
||||
{
|
||||
double xDif = _random.nextGaussian() * _random.nextInt(4);
|
||||
double zDif = _random.nextGaussian() * _random.nextInt(4);
|
||||
double yDif = _random.nextInt(5) + 1;
|
||||
double xDif = _random.nextGaussian() * 2;
|
||||
double zDif = _random.nextGaussian() * 2;
|
||||
double yDif = (_random.nextInt(3) * _random.nextDouble()) + 2;
|
||||
|
||||
FireworkEffect effect = FireworkEffect.builder().withColor(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
|
||||
.withFade(Color.fromRGB(_random.nextInt(255), _random.nextInt(255), _random.nextInt(255)))
|
||||
.with(FireworkEffect.Type.values()[_random.nextInt(FireworkEffect.Type.values().length)])
|
||||
.with(FireworkEffect.Type.STAR)
|
||||
.build();
|
||||
|
||||
UtilFirework.playFirework(_block.getLocation().add(xDif, yDif, zDif), effect);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,44 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-12.
|
||||
*/
|
||||
public class TreasureFinishEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final Player _player;
|
||||
private final Treasure _treasure;
|
||||
|
||||
public TreasureFinishEvent(Player player, Treasure treasure)
|
||||
{
|
||||
_player = player;
|
||||
_treasure = treasure;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public Treasure getTreasure()
|
||||
{
|
||||
return _treasure;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package mineplex.core.treasure.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-12.
|
||||
*/
|
||||
public class TreasureStartEvent extends Event implements Cancellable
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private boolean _cancelled = false;
|
||||
|
||||
public TreasureStartEvent(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
@ -40,17 +40,17 @@ public class RewardManager
|
||||
double rand = _random.nextDouble();
|
||||
RewardRarity rarity;
|
||||
|
||||
if (rand >= 0.98)
|
||||
if (rand <= 0.04)
|
||||
{
|
||||
// 2%
|
||||
// 4%
|
||||
rarity = RewardRarity.VERY_RARE;
|
||||
}
|
||||
else if (rand >= 0.90)
|
||||
else if (rand <= 0.10)
|
||||
{
|
||||
// 8%
|
||||
// 6%
|
||||
rarity = RewardRarity.RARE;
|
||||
}
|
||||
else if (rand >= 0.60)
|
||||
else if (rand <= 0.40)
|
||||
{
|
||||
// 30%
|
||||
rarity = RewardRarity.UNCOMMON;
|
||||
|
@ -0,0 +1,57 @@
|
||||
package mineplex.core.treasure.reward.rewards;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-12.
|
||||
*/
|
||||
public class InventoryReward extends AbstractReward
|
||||
{
|
||||
private Random _random;
|
||||
|
||||
private InventoryManager _inventoryManager;
|
||||
private String _name;
|
||||
private String _packageName;
|
||||
private int _minAmount;
|
||||
private int _maxAmount;
|
||||
|
||||
public InventoryReward(InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||
{
|
||||
this(RANDOM, inventoryManager, name, packageName, minAmount, maxAmount, itemStack, rarity, weight);
|
||||
}
|
||||
|
||||
public InventoryReward(Random random, InventoryManager inventoryManager, String name, String packageName, int minAmount, int maxAmount, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||
{
|
||||
super(itemStack, rarity, weight);
|
||||
|
||||
_random = random;
|
||||
_name = name;
|
||||
_packageName = packageName;
|
||||
_minAmount = minAmount;
|
||||
_maxAmount = maxAmount;
|
||||
_inventoryManager = inventoryManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String giveReward(Player player)
|
||||
{
|
||||
int amountToGive = _random.nextInt(_maxAmount - _minAmount) + _minAmount;
|
||||
|
||||
_inventoryManager.addItemToInventory(player, "Item", _packageName, amountToGive);
|
||||
|
||||
return C.cAqua + amountToGive + " " + _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGiveReward(Player player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package mineplex.core.treasure.reward.rewards;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.treasure.reward.RewardRarity;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-12.
|
||||
*/
|
||||
public class UnknownPackageReward extends AbstractReward
|
||||
{
|
||||
private DonationManager _donationManager;
|
||||
private String _name;
|
||||
private String _packageName;
|
||||
|
||||
public UnknownPackageReward(DonationManager donationManager, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight)
|
||||
{
|
||||
super(itemStack, rarity, weight);
|
||||
_donationManager = donationManager;
|
||||
_name = name;
|
||||
_packageName = packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String giveReward(Player player)
|
||||
{
|
||||
_donationManager.Get(player.getName()).AddUnknownSalesPackagesOwned(_packageName);
|
||||
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGiveReward(Player player)
|
||||
{
|
||||
return _donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName);
|
||||
}
|
||||
}
|
@ -159,7 +159,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
_inventoryManager = new InventoryManager(plugin);
|
||||
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin));
|
||||
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, false);
|
||||
new TreasureManager(_plugin, donationManager);
|
||||
new TreasureManager(_plugin, donationManager, _inventoryManager);
|
||||
|
||||
_partyManager = partyManager;
|
||||
_preferences = preferences;
|
||||
|
Loading…
Reference in New Issue
Block a user