Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
16214613fe
@ -1,17 +1,27 @@
|
|||||||
package mineplex.core.treasure;
|
package mineplex.core.treasure;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Shaun on 8/28/2014.
|
* Created by Shaun on 8/28/2014.
|
||||||
*/
|
*/
|
||||||
public class BlockInfo
|
public class BlockInfo
|
||||||
{
|
{
|
||||||
|
private Block _block;
|
||||||
|
|
||||||
private int _id;
|
private int _id;
|
||||||
private byte _data;
|
private byte _data;
|
||||||
|
|
||||||
public BlockInfo(int id, byte data)
|
public BlockInfo(Block block)
|
||||||
{
|
{
|
||||||
_id = id;
|
_block = block;
|
||||||
_data = data;
|
_id = block.getTypeId();
|
||||||
|
_data = block.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Block getBlock()
|
||||||
|
{
|
||||||
|
return _block;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId()
|
public int getId()
|
||||||
@ -23,4 +33,10 @@ public class BlockInfo
|
|||||||
{
|
{
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
return _block.hashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package mineplex.core.treasure;
|
package mineplex.core.treasure;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
@ -16,7 +17,6 @@ import org.bukkit.entity.Player;
|
|||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.treasure.animation.Animation;
|
import mineplex.core.treasure.animation.Animation;
|
||||||
import mineplex.core.treasure.animation.ChestExplodeAnimation;
|
import mineplex.core.treasure.animation.ChestExplodeAnimation;
|
||||||
@ -33,7 +33,13 @@ import mineplex.core.treasure.reward.RewardRarity;
|
|||||||
*/
|
*/
|
||||||
public class Treasure
|
public class Treasure
|
||||||
{
|
{
|
||||||
private NautHashMap<Block, BlockInfo> _blockRestoreMap = new NautHashMap<Block, BlockInfo>();
|
|
||||||
|
// Decay Sets
|
||||||
|
private HashSet<BlockInfo> _wallsBlockInfo = new HashSet<>();
|
||||||
|
private HashSet<BlockInfo> _outerRingBlockInfo = new HashSet<>();
|
||||||
|
private HashSet<BlockInfo> _centerBlockInfo = new HashSet<>();
|
||||||
|
private HashSet<BlockInfo> _chestBlockInfo = new HashSet<>();
|
||||||
|
|
||||||
private Player _player;
|
private Player _player;
|
||||||
private Random _random;
|
private Random _random;
|
||||||
private Block _centerBlock;
|
private Block _centerBlock;
|
||||||
@ -80,6 +86,7 @@ public class Treasure
|
|||||||
if (Math.abs(x) == 1 || Math.abs(z) == 1)
|
if (Math.abs(x) == 1 || Math.abs(z) == 1)
|
||||||
{
|
{
|
||||||
Block block = _centerBlock.getRelative(x, 0, z);
|
Block block = _centerBlock.getRelative(x, 0, z);
|
||||||
|
_centerBlockInfo.add(new BlockInfo(block));
|
||||||
setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData());
|
setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,11 +99,13 @@ public class Treasure
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
Block block = _centerBlock.getRelative(x, 0, -2);
|
Block block = _centerBlock.getRelative(x, 0, -2);
|
||||||
|
_outerRingBlockInfo.add(new BlockInfo(block));
|
||||||
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
|
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Block block = _centerBlock.getRelative(x, 0, 2);
|
Block block = _centerBlock.getRelative(x, 0, 2);
|
||||||
|
_outerRingBlockInfo.add(new BlockInfo(block));
|
||||||
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
|
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,17 +114,19 @@ public class Treasure
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
Block block = _centerBlock.getRelative(-2, 0, z);
|
Block block = _centerBlock.getRelative(-2, 0, z);
|
||||||
|
_outerRingBlockInfo.add(new BlockInfo(block));
|
||||||
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
|
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Block block = _centerBlock.getRelative(2, 0, z);
|
Block block = _centerBlock.getRelative(2, 0, z);
|
||||||
|
_outerRingBlockInfo.add(new BlockInfo(block));
|
||||||
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
|
setBlock(block, _style.getSecondaryMaterial(), _style.getSecondaryData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGlass()
|
private void createWalls()
|
||||||
{
|
{
|
||||||
for (int z = -2; z <= 2; z++)
|
for (int z = -2; z <= 2; z++)
|
||||||
{
|
{
|
||||||
@ -125,6 +136,7 @@ public class Treasure
|
|||||||
{
|
{
|
||||||
Block playerBlock = getPlayerBlock();
|
Block playerBlock = getPlayerBlock();
|
||||||
Block block = playerBlock.getRelative(x, 0, z);
|
Block block = playerBlock.getRelative(x, 0, z);
|
||||||
|
_wallsBlockInfo.add(new BlockInfo(block));
|
||||||
setBlock(block, _style.getWallMaterial(), _style.getWallData());
|
setBlock(block, _style.getWallMaterial(), _style.getWallData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +158,10 @@ public class Treasure
|
|||||||
if (_tickCount == 5)
|
if (_tickCount == 5)
|
||||||
{
|
{
|
||||||
Block block = _centerBlock;
|
Block block = _centerBlock;
|
||||||
setBlock(block, _style.getPrimaryMaterial(), _style.getPrimaryData());
|
_centerBlockInfo.add(new BlockInfo(block));
|
||||||
|
_centerBlockInfo.add(new BlockInfo(block.getRelative(BlockFace.DOWN)));
|
||||||
|
setBlock(block, Material.REDSTONE_LAMP_ON, (byte) 0);
|
||||||
|
setBlock(block.getRelative(BlockFace.DOWN), Material.REDSTONE_TORCH_ON, (byte) 0);
|
||||||
}
|
}
|
||||||
else if (_tickCount == 10)
|
else if (_tickCount == 10)
|
||||||
{
|
{
|
||||||
@ -158,30 +173,30 @@ public class Treasure
|
|||||||
}
|
}
|
||||||
else if (_tickCount == 30)
|
else if (_tickCount == 30)
|
||||||
{
|
{
|
||||||
createGlass();
|
createWalls();
|
||||||
}
|
}
|
||||||
else if (_tickCount == 50)
|
else if (_tickCount == 50)
|
||||||
{
|
{
|
||||||
Block block = getPlayerBlock().getRelative(2, 0, 0);
|
Block block = getPlayerBlock().getRelative(2, 0, 0);
|
||||||
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)4);
|
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)4, _chestBlockInfo);
|
||||||
_animations.add(task);
|
_animations.add(task);
|
||||||
}
|
}
|
||||||
else if (_tickCount == 80)
|
else if (_tickCount == 80)
|
||||||
{
|
{
|
||||||
Block block = getPlayerBlock().getRelative(-2, 0, 0);
|
Block block = getPlayerBlock().getRelative(-2, 0, 0);
|
||||||
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)5);
|
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)5, _chestBlockInfo);
|
||||||
_animations.add(task);
|
_animations.add(task);
|
||||||
}
|
}
|
||||||
else if (_tickCount == 110)
|
else if (_tickCount == 110)
|
||||||
{
|
{
|
||||||
Block block = getPlayerBlock().getRelative(0, 0, 2);
|
Block block = getPlayerBlock().getRelative(0, 0, 2);
|
||||||
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)2);
|
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)2, _chestBlockInfo);
|
||||||
_animations.add(task);
|
_animations.add(task);
|
||||||
}
|
}
|
||||||
else if (_tickCount == 140)
|
else if (_tickCount == 140)
|
||||||
{
|
{
|
||||||
Block block = getPlayerBlock().getRelative(0, 0, -2);
|
Block block = getPlayerBlock().getRelative(0, 0, -2);
|
||||||
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)3);
|
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)3, _chestBlockInfo);
|
||||||
_animations.add(task);
|
_animations.add(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,21 +238,13 @@ public class Treasure
|
|||||||
return _centerBlock.getRelative(BlockFace.UP);
|
return _centerBlock.getRelative(BlockFace.UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(Block block, Material material, byte data, boolean addToBlockRestoreMap)
|
public void setBlock(Block block, Material material, byte data)
|
||||||
{
|
{
|
||||||
if (addToBlockRestoreMap)
|
|
||||||
_blockRestoreMap.put(block, new BlockInfo(block.getTypeId(), block.getData()));
|
|
||||||
|
|
||||||
block.setType(material);
|
block.setType(material);
|
||||||
block.setData(data);
|
block.setData(data);
|
||||||
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
|
block.getLocation().getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(Block block, Material material, byte data)
|
|
||||||
{
|
|
||||||
setBlock(block, material, data, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openChest(Block block)
|
public void openChest(Block block)
|
||||||
{
|
{
|
||||||
ChestData data = getChestData(block);
|
ChestData data = getChestData(block);
|
||||||
@ -257,17 +264,17 @@ public class Treasure
|
|||||||
else if (data.getReward().getRarity() == RewardRarity.RARE)
|
else if (data.getReward().getRarity() == RewardRarity.RARE)
|
||||||
{
|
{
|
||||||
_animations.add(new CircleAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
|
_animations.add(new CircleAnimation(this, data.getBlock().getLocation().add(0.5, 1.5, 0.5)));
|
||||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " opened a Rare treasure!"));
|
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " opened the Rare treasure " + text));
|
||||||
}
|
}
|
||||||
else if (data.getReward().getRarity() == RewardRarity.VERY_RARE)
|
else if (data.getReward().getRarity() == RewardRarity.VERY_RARE)
|
||||||
{
|
{
|
||||||
_animations.add(new ChestExplodeAnimation(this, data.getBlock()));
|
_animations.add(new ChestExplodeAnimation(this, data.getBlock()));
|
||||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " opened a Legendary treasure!"));
|
Bukkit.broadcastMessage(F.main("Treasure", F.name(_player.getName()) + " opened the Legendary treasure " + text));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFinished())
|
if (isFinished())
|
||||||
{
|
{
|
||||||
TreasureRemoveAnimation animation = new TreasureRemoveAnimation(this, _blockRestoreMap);
|
TreasureRemoveAnimation animation = new TreasureRemoveAnimation(this, _centerBlockInfo, _outerRingBlockInfo, _wallsBlockInfo);
|
||||||
_animations.add(animation);
|
_animations.add(animation);
|
||||||
_finished = true;
|
_finished = true;
|
||||||
}
|
}
|
||||||
@ -337,20 +344,11 @@ public class Treasure
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<Block, BlockInfo> entry : _blockRestoreMap.entrySet())
|
// Remove any extra blocks
|
||||||
{
|
resetBlockInfo(_wallsBlockInfo);
|
||||||
Block block = entry.getKey();
|
resetBlockInfo(_centerBlockInfo);
|
||||||
BlockInfo data = entry.getValue();
|
resetBlockInfo(_outerRingBlockInfo);
|
||||||
|
resetBlockInfo(_chestBlockInfo);
|
||||||
if (block.getType().equals(Material.CHEST))
|
|
||||||
{
|
|
||||||
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(data.getId());
|
|
||||||
block.setData(data.getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Animation animation : _animations)
|
for (Animation animation : _animations)
|
||||||
{
|
{
|
||||||
@ -359,6 +357,26 @@ public class Treasure
|
|||||||
_animations.clear();
|
_animations.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetBlockInfo(Set<BlockInfo> blockInfoSet)
|
||||||
|
{
|
||||||
|
for (BlockInfo blockInfo : blockInfoSet)
|
||||||
|
{
|
||||||
|
Block block = blockInfo.getBlock();
|
||||||
|
|
||||||
|
if (block.getType().equals(Material.CHEST))
|
||||||
|
{
|
||||||
|
UtilParticle.PlayParticle(UtilParticle.ParticleType.EXPLODE, block.getLocation().add(0.5, 0.5, 0.5), 0F, 0F, 0F, 0F, 1);
|
||||||
|
// 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
blockInfoSet.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public TreasureStyle getStyle()
|
public TreasureStyle getStyle()
|
||||||
{
|
{
|
||||||
return _style;
|
return _style;
|
||||||
|
@ -11,12 +11,14 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@ -31,6 +33,7 @@ import mineplex.core.common.util.UtilEnt;
|
|||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
|
import mineplex.core.event.StackerEvent;
|
||||||
import mineplex.core.inventory.InventoryManager;
|
import mineplex.core.inventory.InventoryManager;
|
||||||
import mineplex.core.treasure.event.TreasureFinishEvent;
|
import mineplex.core.treasure.event.TreasureFinishEvent;
|
||||||
import mineplex.core.treasure.event.TreasureStartEvent;
|
import mineplex.core.treasure.event.TreasureStartEvent;
|
||||||
@ -66,7 +69,7 @@ public class TreasureManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
// Coins
|
// Coins
|
||||||
{
|
{
|
||||||
_rewardManager.addReward(new CoinReward(donationManager, 2000, 5000, 25, RewardRarity.VERY_RARE));
|
_rewardManager.addReward(new CoinReward(donationManager, 10000, 20000, 25, RewardRarity.VERY_RARE));
|
||||||
}
|
}
|
||||||
// Mounts
|
// Mounts
|
||||||
{
|
{
|
||||||
@ -330,7 +333,7 @@ public class TreasureManager extends MiniPlugin
|
|||||||
|
|
||||||
treasure.update();
|
treasure.update();
|
||||||
|
|
||||||
if (treasure.isFinished() && treasure.getFinishedTickCount() >= 100)
|
if (treasure.isFinished() && treasure.getFinishedTickCount() >= 80)
|
||||||
{
|
{
|
||||||
treasure.cleanup();
|
treasure.cleanup();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
@ -391,17 +394,52 @@ public class TreasureManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
for (Treasure treasure : _playerTreasureMap.values())
|
for (Treasure treasure : _playerTreasureMap.values())
|
||||||
{
|
{
|
||||||
|
Location fromLocation = event.getFrom();
|
||||||
|
Location toLocation = event.getTo();
|
||||||
Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5);
|
Location centerLocation = treasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5);
|
||||||
if (centerLocation.distanceSquared(event.getTo()) <= 9)
|
|
||||||
|
double toDistanceFromCenter = centerLocation.distanceSquared(toLocation);
|
||||||
|
|
||||||
|
if (toDistanceFromCenter <= 9)
|
||||||
{
|
{
|
||||||
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), centerLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
|
// Only cancel movement if they are moving towards the center
|
||||||
event.setTo(event.getFrom());
|
double fromDistanceFromCenter = centerLocation.distanceSquared(fromLocation);
|
||||||
|
if (toDistanceFromCenter < fromDistanceFromCenter)
|
||||||
|
{
|
||||||
|
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), centerLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
|
||||||
|
event.setTo(event.getFrom());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
public void cancelVelocity(PlayerVelocityEvent event)
|
||||||
|
{
|
||||||
|
// Need to prevent players
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (_playerTreasureMap.containsKey(player))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void cancelStacker(StackerEvent event)
|
||||||
|
{
|
||||||
|
if (event.getEntity() instanceof Player)
|
||||||
|
{
|
||||||
|
Player player = ((Player) event.getEntity());
|
||||||
|
if (_playerTreasureMap.containsKey(player))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void interact(PlayerInteractEvent event)
|
public void interact(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -409,11 +447,12 @@ public class TreasureManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
Treasure treasure = _playerTreasureMap.get(player);
|
Treasure treasure = _playerTreasureMap.get(player);
|
||||||
treasure.openChest(event.getClickedBlock());
|
treasure.openChest(event.getClickedBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Always cancel interact for treasure players, prevents players from being able to open up cosmetic menu and other menus
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
|
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST)
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package mineplex.core.treasure.animation;
|
package mineplex.core.treasure.animation;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||||
|
|
||||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutWorldEvent;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.treasure.BlockInfo;
|
||||||
import mineplex.core.treasure.Treasure;
|
import mineplex.core.treasure.Treasure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,13 +24,16 @@ public class ChestSpawnAnimation extends Animation
|
|||||||
private byte _direction;
|
private byte _direction;
|
||||||
private Location _centerLocation;
|
private Location _centerLocation;
|
||||||
|
|
||||||
public ChestSpawnAnimation(Treasure tresure, Block block, byte direction)
|
private HashSet<BlockInfo> _chestBlockInfo;
|
||||||
|
|
||||||
|
public ChestSpawnAnimation(Treasure tresure, Block block, byte direction, HashSet<BlockInfo> chestBlockInfo)
|
||||||
{
|
{
|
||||||
super(tresure);
|
super(tresure);
|
||||||
_block = block;
|
_block = block;
|
||||||
_direction = direction;
|
_direction = direction;
|
||||||
_centerLocation = block.getLocation().clone().add(0.5, 0.5, 0.5);
|
_centerLocation = block.getLocation().clone().add(0.5, 0.5, 0.5);
|
||||||
_centerLocation.getWorld().playSound(_centerLocation, Sound.LAVA, 1, 1);
|
_centerLocation.getWorld().playSound(_centerLocation, Sound.LAVA, 1, 1);
|
||||||
|
_chestBlockInfo = chestBlockInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,6 +54,7 @@ public class ChestSpawnAnimation extends Animation
|
|||||||
|
|
||||||
if (getTicks() >= ANIMATION_DURATION)
|
if (getTicks() >= ANIMATION_DURATION)
|
||||||
{
|
{
|
||||||
|
_chestBlockInfo.add(new BlockInfo(_block));
|
||||||
getTreasure().setBlock(_block, Material.CHEST, _direction);
|
getTreasure().setBlock(_block, Material.CHEST, _direction);
|
||||||
_block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f);
|
_block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f);
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package mineplex.core.treasure.animation;
|
package mineplex.core.treasure.animation;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.NautHashMap;
|
|
||||||
import mineplex.core.treasure.BlockInfo;
|
import mineplex.core.treasure.BlockInfo;
|
||||||
import mineplex.core.treasure.Treasure;
|
import mineplex.core.treasure.Treasure;
|
||||||
|
|
||||||
@ -16,21 +13,43 @@ public class TreasureRemoveAnimation extends Animation
|
|||||||
{
|
{
|
||||||
private Random _random = new Random();
|
private Random _random = new Random();
|
||||||
|
|
||||||
private NautHashMap<Block, BlockInfo> _blockRestoreMap;
|
private HashSet<BlockInfo> _wallsBlockInfo;
|
||||||
|
private HashSet<BlockInfo> _outerRingBlockInfo;
|
||||||
|
private HashSet<BlockInfo> _centerBlockInfo;
|
||||||
|
|
||||||
public TreasureRemoveAnimation(Treasure treasure, NautHashMap<Block, BlockInfo> blockRestoreMap)
|
public TreasureRemoveAnimation(Treasure treasure, HashSet<BlockInfo> centerBlockInfo, HashSet<BlockInfo> outerRingBlockInfo, HashSet<BlockInfo> wallsBlockInfo)
|
||||||
{
|
{
|
||||||
super(treasure);
|
super(treasure);
|
||||||
_blockRestoreMap = blockRestoreMap;
|
_wallsBlockInfo = wallsBlockInfo;
|
||||||
|
_centerBlockInfo = centerBlockInfo;
|
||||||
|
_outerRingBlockInfo = outerRingBlockInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tick()
|
protected void tick()
|
||||||
{
|
{
|
||||||
// first wait for 1 second
|
// Chests go away at 100 ticks
|
||||||
if (getTicks() <= 20)
|
HashSet<BlockInfo> blockInfoSet = null;
|
||||||
return;
|
|
||||||
|
|
||||||
|
if (getTicks() == 40)
|
||||||
|
{
|
||||||
|
blockInfoSet = _wallsBlockInfo;
|
||||||
|
}
|
||||||
|
else if (getTicks() == 50)
|
||||||
|
{
|
||||||
|
blockInfoSet = _outerRingBlockInfo;
|
||||||
|
}
|
||||||
|
else if (getTicks() == 60)
|
||||||
|
{
|
||||||
|
blockInfoSet = _centerBlockInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockInfoSet != null)
|
||||||
|
{
|
||||||
|
getTreasure().resetBlockInfo(blockInfoSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (getTicks() % 2 == 0)
|
if (getTicks() % 2 == 0)
|
||||||
{
|
{
|
||||||
if (_blockRestoreMap.size() > 4)
|
if (_blockRestoreMap.size() > 4)
|
||||||
@ -52,6 +71,7 @@ public class TreasureRemoveAnimation extends Animation
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,11 +6,9 @@ package mineplex.core.treasure.reward.rewards;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.treasure.reward.RewardRarity;
|
import mineplex.core.treasure.reward.RewardRarity;
|
||||||
@ -32,7 +30,7 @@ public class CoinReward extends AbstractReward
|
|||||||
|
|
||||||
public CoinReward(DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity, Random random)
|
public CoinReward(DonationManager donationManager, int minCoinCount, int maxCoinCount, int weight, RewardRarity rarity, Random random)
|
||||||
{
|
{
|
||||||
super(new ItemStack(Material.GOLD_INGOT), rarity, weight);
|
super(new ItemStack(175), rarity, weight);
|
||||||
_donationManager = donationManager;
|
_donationManager = donationManager;
|
||||||
_minCoinCount = minCoinCount;
|
_minCoinCount = minCoinCount;
|
||||||
_maxCoinCount = maxCoinCount;
|
_maxCoinCount = maxCoinCount;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package mineplex.core.treasure.reward.rewards;
|
package mineplex.core.treasure.reward.rewards;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user