Treasure Stuff

This commit is contained in:
Shaun Bennett 2014-08-30 14:27:11 -05:00
parent e52f6deab4
commit 5905ef5ef7
11 changed files with 999 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package mineplex.core.treasure;
/**
* Created by Shaun on 8/28/2014.
*/
public class BlockInfo
{
private int _id;
private byte _data;
public BlockInfo(int id, byte data)
{
_id = id;
_data = data;
}
public int getId()
{
return _id;
}
public byte getData()
{
return _data;
}
}

View File

@ -0,0 +1,51 @@
package mineplex.core.treasure;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.common.util.UtilServer;
/**
* Created by Shaun on 8/29/2014.
*/
public class ChestData
{
private Block _block;
private boolean _opened;
public ChestData(Block block)
{
_block = block;
_opened = false;
}
public boolean isOpened()
{
return _opened;
}
public Block getBlock()
{
return _block;
}
public void open()
{
if (!isOpened())
{
PacketPlayOutBlockAction packet = new PacketPlayOutBlockAction(_block.getX(), _block.getY(), _block.getZ(), CraftMagicNumbers.getBlock(_block), 1, 1);
for (Player other : UtilServer.getPlayers())
{
((CraftPlayer) other).getHandle().playerConnection.sendPacket(packet);
other.playSound(_block.getLocation(), Sound.CHEST_OPEN, 1, 1);
}
_opened = true;
}
}
}

View File

@ -0,0 +1,322 @@
package mineplex.core.treasure;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.animation.ChestTask;
import mineplex.core.treasure.animation.ItemTask;
import mineplex.core.treasure.animation.ParticleTask;
import mineplex.core.treasure.animation.Task;
/**
* Created by Shaun on 8/27/2014.
*/
public class Treasure
{
private NautHashMap<Block, BlockInfo> _blockRestoreMap = new NautHashMap<Block, BlockInfo>();
private Player _player;
private Random _random;
private Block _centerBlock;
private int _tickCount;
private ChestData[] _chestData;
private LinkedList<Task> _tasks;
private TreasureStyle _style;
public Treasure(Player player)
{
this(player, new Random());
}
public Treasure(Player player, Random seed)
{
_player = player;
_random = seed;
_style = TreasureStyle.values()[_random.nextInt(TreasureStyle.values().length)];
_centerBlock = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
_tasks = new LinkedList<Task>();
_tasks.add(new ParticleTask(this));
_chestData = new ChestData[4];
_chestData[0] = new ChestData(_centerBlock.getRelative(2, 1, 0));
_chestData[1] = new ChestData(_centerBlock.getRelative(-2, 1, 0));
_chestData[2] = new ChestData(_centerBlock.getRelative(0, 1, 2));
_chestData[3] = new ChestData(_centerBlock.getRelative(0, 1, -2));
}
private void createCenterClay()
{
for (int x = -1; x <= 1; x++)
{
for (int z = -1; z <= 1; z++)
{
if (Math.abs(x) == 1 || Math.abs(z) == 1)
{
Block block = _centerBlock.getRelative(x, 0, z);
setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData());
}
}
}
}
private void createOuterClay()
{
for (int x = -2; x <= 2; x++)
{
{
Block block = _centerBlock.getRelative(x, 0, -2);
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
{
Block block = _centerBlock.getRelative(x, 0, 2);
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
}
for (int z = -1; z <= 1; z++)
{
{
Block block = _centerBlock.getRelative(-2, 0, z);
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
{
Block block = _centerBlock.getRelative(2, 0, z);
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
}
}
}
private void createGlass()
{
for (int z = -2; z <= 2; z++)
{
for (int x = -2; x <= 2; x++)
{
if ((Math.abs(x) == 2 || Math.abs(z) == 2) && (x != 0 && z != 0))
{
Block playerBlock = getPlayerBlock();
Block block = playerBlock.getRelative(x, 0, z);
setBlock(block, _style.getWallMaterial(), _style.getWallData());
}
}
}
}
private void dropChests()
{
for (int z = -2; z <= 2; z++)
{
for (int x = -2; x <= 2; x++)
{
if ((Math.abs(x) == 2 || Math.abs(z) == 2) && (x == 0 || z == 0))
{
byte direction;
if (x == 2)
direction = (byte) 4;
else if (x == -2)
direction = (byte) 5;
else if (z == 2)
direction = (byte) 2;
else
direction = (byte) 3;
Block block = getPlayerBlock().getRelative(x, 0, z);
ChestTask task = new ChestTask(this, block, direction);
_tasks.add(task);
}
}
}
}
// private void updateParticles()
// {
// double modifier;
// if (_tickCount % 2 == 0)
// modifier = 0.5;
// else
// modifier = 0;
//
// for (int x = -2; x <= 2; x++)
// {
// for (int z = -2; z <= 2; z++)
// {
// if (Math.abs(x) == 2 || Math.abs(z) == 2)
// {
// if (Math.abs(x) == 2)
// z += modifier;
// else
// x += modifier;
//
// UtilParticle.PlayParticle(_style., getCenterBlock().getLocation().add(x, 7, z), 0F, 0F, 0F, 1, 1);
// }
// }
// }
// }
public void update()
{
if (_tickCount == 5)
{
Block block = _centerBlock;
setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData());
}
else if (_tickCount == 10)
{
createCenterClay();
}
else if (_tickCount == 20)
{
createOuterClay();
}
else if (_tickCount == 30)
{
createGlass();
}
else if (_tickCount == 50)
{
Block block = getPlayerBlock().getRelative(2, 0, 0);
ChestTask task = new ChestTask(this, block, (byte)4);
_tasks.add(task);
}
else if (_tickCount == 80)
{
Block block = getPlayerBlock().getRelative(-2, 0, 0);
ChestTask task = new ChestTask(this, block, (byte)5);
_tasks.add(task);
}
else if (_tickCount == 110)
{
Block block = getPlayerBlock().getRelative(0, 0, 2);
ChestTask task = new ChestTask(this, block, (byte)2);
_tasks.add(task);
}
else if (_tickCount == 140)
{
Block block = getPlayerBlock().getRelative(0, 0, -2);
ChestTask task = new ChestTask(this, block, (byte)3);
_tasks.add(task);
}
Block block = _player.getTargetBlock(null, 3);
if (block.getType() == Material.CHEST)
{
ChestData data = getChestData(block);
if (data != null && !data.isOpened())
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.ENCHANTMENT_TABLE, block.getLocation().add(0.5, 0.5, 0.5), 0F, 0F, 0F, 1, 4);
}
}
Iterator<Task> taskIterator = _tasks.iterator();
while (taskIterator.hasNext())
{
Task task = taskIterator.next();
if (task.isRunning())
{
task.run();
}
else
{
taskIterator.remove();
}
}
_tickCount++;
}
public Block getCenterBlock()
{
return _centerBlock;
}
public Block getPlayerBlock()
{
return _centerBlock.getRelative(BlockFace.UP);
}
public void setBlock(Block block, Material material, byte data)
{
_blockRestoreMap.put(block, new BlockInfo(block.getTypeId(), block.getData()));
block.setType(material);
block.setData(data);
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
}
public void openChest(Block block)
{
ChestData data = getChestData(block);
if (data != null && !data.isOpened())
{
data.open();
ItemTask itemTask = new ItemTask(this, block, ChatColor.GREEN + "100 Gems", Material.EMERALD, (byte) 0);
_tasks.add(itemTask);
}
}
public ChestData getChestData(Block block)
{
for (ChestData data : _chestData)
{
if (data.getBlock().equals(block))
{
return data;
}
}
return null;
}
public boolean isFinished()
{
boolean allOpened = true;
for (int i = 0; i < _chestData.length; i++)
{
if (!_chestData[i].isOpened())
allOpened = false;
}
return allOpened;
}
public void clean()
{
for (Map.Entry<Block, BlockInfo> entry : _blockRestoreMap.entrySet())
{
Block block = entry.getKey();
BlockInfo data = entry.getValue();
block.setTypeId(data.getId());
block.setData(data.getData());
}
for (Task task : _tasks)
{
task.cancel();
}
_tasks.clear();
}
public TreasureStyle getStyle()
{
return _style;
}
}

View File

@ -0,0 +1,182 @@
package mineplex.core.treasure;
import java.util.Iterator;
import java.util.Map;
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_7_R4.block.CraftBlock;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
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.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
/**
* Created by Shaun on 8/27/2014.
*/
public class TreasureManager extends MiniPlugin
{
private NautHashMap<Player, Treasure> _playerTreasureMap;
public TreasureManager(JavaPlugin plugin)
{
super("Treasure", plugin);
_playerTreasureMap = new NautHashMap<Player, Treasure>();
}
@Override
public void Disable()
{
for (Treasure treasure : _playerTreasureMap.values())
{
treasure.clean();
}
}
public void attemptOpenTreasure(Player player)
{
if (!checkNearbyBlocks(player))
return;
Treasure treasure = new Treasure(player);
_playerTreasureMap.put(player, treasure);
}
private boolean checkNearbyBlocks(Player player)
{
return true;
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Treasure treasure : _playerTreasureMap.values())
{
treasure.update();
}
}
@EventHandler
public void checkFinish(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
return;
Iterator<Map.Entry<Player, Treasure>> iterator = _playerTreasureMap.entrySet().iterator();
while (iterator.hasNext())
{
Treasure treasure = iterator.next().getValue();
if (treasure.isFinished())
{
iterator.remove();
treasure.clean();
}
}
}
@EventHandler
public void quit(PlayerQuitEvent event)
{
if (_playerTreasureMap.containsKey(event.getPlayer()))
{
Treasure treasure = _playerTreasureMap.remove(event.getPlayer());
treasure.clean();
}
}
@EventHandler
public void cancelMove(PlayerMoveEvent event)
{
Player player = event.getPlayer();
if (_playerTreasureMap.containsKey(player))
{
Treasure treasure = _playerTreasureMap.get(player);
Block playerBlock = treasure.getPlayerBlock();
if (!event.getTo().getBlock().equals(playerBlock))
{
Location newTo = event.getFrom().clone();
newTo.setPitch(event.getTo().getPitch());
newTo.setYaw(event.getTo().getYaw());
event.setTo(newTo);
}
}
else
{
for (Treasure treasure : _playerTreasureMap.values())
{
Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5);
if (centerLocation.distanceSquared(event.getTo()) <= 4)
{
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), centerLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
event.setTo(event.getFrom());
// event.setCancelled(true);
}
}
}
}
@EventHandler
public void interact(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (_playerTreasureMap.containsKey(player))
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
{
Block block = event.getClickedBlock();
event.setCancelled(true);
Treasure treasure = _playerTreasureMap.get(player);
treasure.openChest(event.getClickedBlock());
}
}
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
{
for (Treasure treasure : _playerTreasureMap.values())
{
ChestData data = treasure.getChestData(event.getClickedBlock());
if (data != null)
{
event.setCancelled(true);
}
}
}
}
@EventHandler
public void command(PlayerCommandPreprocessEvent event)
{
if (event.getMessage().startsWith("/treasure"))
{
attemptOpenTreasure(event.getPlayer());
event.getPlayer().sendMessage("Attempting to open treasure...");
}
}
}

View File

@ -0,0 +1,89 @@
package mineplex.core.treasure;
import org.bukkit.Material;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.animation.ParticleTask;
/**
* Created by Shaun on 8/28/2014.
*/
public enum TreasureStyle
{
RED(Material.STAINED_CLAY, (byte) 14,
Material.STAINED_CLAY, (byte) 6,
Material.STAINED_GLASS_PANE, (byte) 14,
UtilParticle.ParticleType.HEART,
UtilParticle.ParticleType.HAPPY_VILLAGER),
GREEN(Material.STAINED_CLAY,(byte) 5,
Material.STAINED_CLAY, (byte) 13,
Material.STAINED_GLASS_PANE, (byte) 5,
UtilParticle.ParticleType.FLAME,
UtilParticle.ParticleType.RED_DUST);
private Material _primaryMaterial;
private byte _primaryData;
private Material _secondaryMaterial;
private byte _secondaryData;
private Material _wallMaterial;
private byte _wallData;
private UtilParticle.ParticleType _primaryParticle;
private UtilParticle.ParticleType _secondaryParticle;
TreasureStyle(Material primaryMaterial, byte primaryData, Material secondaryMaterial, byte secondaryData, Material wallMaterial, byte wallData, UtilParticle.ParticleType primaryParticle, UtilParticle.ParticleType secondaryParticle)
{
_primaryMaterial = primaryMaterial;
_primaryData = primaryData;
_secondaryMaterial = secondaryMaterial;
_secondaryData = secondaryData;
_wallMaterial = wallMaterial;
_wallData = wallData;
_primaryParticle = primaryParticle;
_secondaryParticle = secondaryParticle;
}
public Material getPrimaryMaterial()
{
return _primaryMaterial;
}
public byte getPrimaryData()
{
return _primaryData;
}
public Material getSecondaryMaterial()
{
return _secondaryMaterial;
}
public byte getSecondaryData()
{
return _secondaryData;
}
public Material getWallMaterial()
{
return _wallMaterial;
}
public byte getWallData()
{
return _wallData;
}
public UtilParticle.ParticleType getPrimaryParticle()
{
return _primaryParticle;
}
public UtilParticle.ParticleType getSecondaryParticle()
{
return _secondaryParticle;
}
}

View File

@ -0,0 +1,64 @@
package mineplex.core.treasure.animation;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure;
/**
* Created by Shaun on 8/29/2014.
*/
public class ChestTask extends Task
{
private static final int ANIMATION_DURATION = 30;
private Block _block;
private byte _direction;
private Location _centerLocation;
public ChestTask(Treasure tresure, Block block, byte direction)
{
super(tresure);
_block = block;
_direction = direction;
_centerLocation = block.getLocation().clone().add(0.5, 0.5, 0.5);
_centerLocation.getWorld().playSound(_centerLocation, Sound.LAVA, 1, 1);
}
@Override
public void tick()
{
int ticks = getTicks();
float scale = (float)((double)(ANIMATION_DURATION - ticks)/(double)ANIMATION_DURATION);
float y = 5 * scale;
double width = 1.4 * ((double)ticks / (double)ANIMATION_DURATION);
for (int i=0 ; i < 2 ; i++)
{
double lead = i * ((2d * Math.PI)/2);
float x = (float) (Math.sin(ticks/4D + lead));
float z = (float) (Math.cos(ticks/4D + lead));
UtilParticle.PlayParticle(getTreasure().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1);
}
if (ticks >= ANIMATION_DURATION)
{
getTreasure().setBlock(_block, Material.CHEST, _direction);
_block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f);
UtilParticle.PlayParticle(UtilParticle.ParticleType.LAVA, _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50);
cancel();
}
}
@Override
protected void cleanup()
{
}
}

View File

@ -0,0 +1,83 @@
package mineplex.core.treasure.animation;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.EntityFireball;
import net.minecraft.server.v1_7_R4.EntityHorse;
import net.minecraft.server.v1_7_R4.EntityLargeFireball;
import net.minecraft.server.v1_7_R4.EntitySmallFireball;
import net.minecraft.server.v1_7_R4.EntityWither;
import net.minecraft.server.v1_7_R4.EntityWitherSkull;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PlayerConnection;
import net.minecraft.server.v1_7_R4.World;
import mineplex.core.common.util.UtilServer;
/**
* Created by Shaun on 8/29/2014.
*/
public class Hologram
{
private Location _location;
private String _text;
private boolean spawned;
private int horseId;
private int fireballId;
public Hologram(Location location, String text)
{
_location = location;
_text = text;
}
public void spawn()
{
World nmsWorld = ((CraftWorld) _location.getWorld()).getHandle();
EntityWitherSkull fireball = new EntityWitherSkull(nmsWorld);
fireball.setLocation(_location.getX(), _location.getY() + 55, _location.getZ(), 0, 0);
PacketPlayOutSpawnEntity fireballPacket = new PacketPlayOutSpawnEntity(fireball, 64);
fireballId = fireball.getId();
EntityHorse horse = new EntityHorse(nmsWorld);
horse.setLocation(_location.getX(), _location.getY() + 55, _location.getZ(), 0, 0);
horse.setAge(-1700000);
horse.setCustomName(_text);
horse.setCustomNameVisible(true);
PacketPlayOutSpawnEntityLiving horsePacket = new PacketPlayOutSpawnEntityLiving(horse);
horseId = horse.getId();
for (Player player : UtilServer.getPlayers())
{
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(horsePacket);
connection.sendPacket(fireballPacket);
PacketPlayOutAttachEntity attachPacket = new PacketPlayOutAttachEntity(0, horse, fireball);
connection.sendPacket(attachPacket);
}
}
public void remove()
{
PacketPlayOutEntityDestroy horseDestroy = new PacketPlayOutEntityDestroy(horseId);
PacketPlayOutEntityDestroy fireballDestroy = new PacketPlayOutEntityDestroy(fireballId);
for (Player player : UtilServer.getPlayers())
{
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(horseDestroy);
connection.sendPacket(fireballDestroy);
}
}
}

View File

@ -0,0 +1,58 @@
package mineplex.core.treasure.animation;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import mineplex.core.treasure.Treasure;
/**
* Created by Shaun on 8/29/2014.
*/
public class ItemTask extends Task
{
private String _itemName;
private Material _material;
private byte _data;
private Item _itemEntity;
private Block _chestBlock;
private Hologram _hologram;
public ItemTask(Treasure treasure, Block chestBlock, String itemName, Material material, byte data)
{
super(treasure);
_itemName = itemName;
_material = material;
_data = data;
_chestBlock = chestBlock;
}
@Override
protected void tick()
{
if (getTicks() == 5)
{
Location location = _chestBlock.getLocation().add(0.5, 0.8, 0.5);
_itemEntity = location.getWorld().dropItem(location, new ItemStack(_material, 1, _data));
_itemEntity.setVelocity(new Vector(0, 0, 0));
_itemEntity.setPickupDelay(Integer.MAX_VALUE);
}
else if (getTicks() == 15)
{
_hologram = new Hologram(_chestBlock.getLocation().add(0.5, 1.5, 0.5), _itemName);
_hologram.spawn();
}
}
public void cleanup()
{
if (_hologram != null)
{
_hologram.remove();
_itemEntity.remove();
}
}
}

View File

@ -0,0 +1,71 @@
package mineplex.core.treasure.animation;
import java.util.ArrayList;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.treasure.Treasure;
/**
* Created by Shaun on 8/29/2014.
*/
public class ParticleTask extends Task
{
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));
}
z = 3;
for (x = 3; x >= -3; x -= MODIFIER)
{
PATH.add(new Vector(x, y, z));
}
x = -3;
for (z = 3; z >= -3; z -= MODIFIER)
{
PATH.add(new Vector(x, y, z));
}
z = -3;
for (x = -3; x <= 3; x += MODIFIER)
{
PATH.add(new Vector(x, y, z));
}
}
private int pathPosition = 0;
public ParticleTask(Treasure treasure)
{
super(treasure);
}
@Override
protected void tick()
{
Vector position = PATH.get(pathPosition);
UtilParticle.PlayParticle(getTreasure().getStyle().getPrimaryParticle(), getTreasure().getCenterBlock().getLocation().add(0.5, 0, 0.5).add(position), 0, 0, 0, 0, 1);
pathPosition = (pathPosition + 1) % PATH.size();
}
@Override
protected void cleanup()
{
}
}

View File

@ -0,0 +1,51 @@
package mineplex.core.treasure.animation;
import mineplex.core.treasure.Treasure;
/**
* Created by Shaun on 8/29/2014.
*/
public abstract class Task
{
private Treasure _treasure;
private boolean _running;
private int _ticks;
public Task(Treasure treasure)
{
_treasure = treasure;
_running = true;
}
public void run()
{
tick();
_ticks++;
}
protected abstract void tick();
protected abstract void cleanup();
public void cancel()
{
_running = false;
cleanup();
}
public boolean isRunning()
{
return _running;
}
public int getTicks()
{
return _ticks;
}
public Treasure getTreasure()
{
return _treasure;
}
}

View File

@ -54,6 +54,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.treasure.TreasureManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.disguise.DisguiseManager;
@ -159,6 +160,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);
_partyManager = partyManager;
_preferences = preferences;