Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
246f2e91d9
@ -0,0 +1,123 @@
|
||||
package mineplex.core.hologram;
|
||||
|
||||
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.EntitySmallFireball;
|
||||
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.World;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/29/2014.
|
||||
*/
|
||||
public class SimpleHologram
|
||||
{
|
||||
/**
|
||||
* SimpleHologram creates the required entities to spawn in a hologram. It is possible to send the packets for the entities to a player,
|
||||
* but it is also possible to add the entities to the nmsWorld to keep them loaded into the server.
|
||||
*/
|
||||
|
||||
private Location _location;
|
||||
private String _text;
|
||||
|
||||
private World _nmsWorld;
|
||||
private EntityFireball _fireball;
|
||||
private EntityHorse _horse;
|
||||
|
||||
public SimpleHologram(Location location, String text)
|
||||
{
|
||||
_location = location;
|
||||
_text = text;
|
||||
|
||||
_nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
|
||||
|
||||
// Create Entities
|
||||
_fireball = new EntitySmallFireball(_nmsWorld);
|
||||
_horse = new EntityHorse(_nmsWorld);
|
||||
|
||||
// Location Data
|
||||
_fireball.setLocation(_location.getX(), _location.getY() + 55.25, _location.getZ(), 0, 0);
|
||||
_horse.setLocation(_location.getX(), _location.getY() + 55.25, _location.getZ(), 0, 0);
|
||||
_horse.setAge(-1700000);
|
||||
_horse.setCustomName(_text);
|
||||
_horse.setCustomNameVisible(true);
|
||||
}
|
||||
|
||||
public void spawnWithPackets()
|
||||
{
|
||||
Packet fireballSpawn = getFireballSpawnPacket();
|
||||
Packet horseSpawn = getHorseSpawnPacket();
|
||||
Packet attachPacket = getAttachEntityPacket();
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
sendPacket(player, fireballSpawn);
|
||||
sendPacket(player, horseSpawn);
|
||||
sendPacket(player, attachPacket);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeWithPackets()
|
||||
{
|
||||
Packet horseDestroy = getHorseDestroyPacket();
|
||||
Packet fireballDestroy = getFireballDestroyPacket();
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
sendPacket(player, horseDestroy);
|
||||
sendPacket(player, fireballDestroy);
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
_text = text;
|
||||
_horse.setCustomName(_text);
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return _text;
|
||||
}
|
||||
|
||||
private Packet getHorseSpawnPacket()
|
||||
{
|
||||
return new PacketPlayOutSpawnEntityLiving(_horse);
|
||||
}
|
||||
|
||||
private Packet getFireballSpawnPacket()
|
||||
{
|
||||
return new PacketPlayOutSpawnEntity(_fireball, 64);
|
||||
}
|
||||
|
||||
private Packet getAttachEntityPacket()
|
||||
{
|
||||
return new PacketPlayOutAttachEntity(0, _horse, _fireball);
|
||||
}
|
||||
|
||||
private Packet getHorseDestroyPacket()
|
||||
{
|
||||
return new PacketPlayOutEntityDestroy(_horse.getId());
|
||||
}
|
||||
|
||||
private Packet getFireballDestroyPacket()
|
||||
{
|
||||
return new PacketPlayOutEntityDestroy(_fireball.getId());
|
||||
}
|
||||
|
||||
private void sendPacket(Player player, Packet packet)
|
||||
{
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
}
|
@ -100,16 +100,22 @@ public class HorseMount extends Mount<Horse>
|
||||
horse.setMaxDomestication(1);
|
||||
horse.setJumpStrength(_jump);
|
||||
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
|
||||
|
||||
|
||||
if (horse.getVariant() == Variant.MULE)
|
||||
horse.setCarryingChest(true);
|
||||
|
||||
if (_armor != null)
|
||||
horse.getInventory().setArmor(new ItemStack(_armor));
|
||||
|
||||
horse.setCustomName(player.getName() + "'s " + GetName());
|
||||
horse.setCustomNameVisible(true);
|
||||
|
||||
if (player.getName().equals("Phinary"))
|
||||
{
|
||||
horse.setCustomName("Dinnerbone");
|
||||
}
|
||||
else
|
||||
{
|
||||
horse.setCustomName(player.getName() + "'s " + GetName());
|
||||
horse.setCustomNameVisible(true);
|
||||
}
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
|
||||
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
@ -173,9 +174,9 @@ public class MountCart extends Mount<Minecart>
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void cancelBreak(EntityDamageEvent event)
|
||||
public void cancelBreak(VehicleDamageEvent event)
|
||||
{
|
||||
if (GetActive().values().contains(event.getEntity()))
|
||||
if (GetActive().values().contains(event.getVehicle()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package mineplex.core.treasure;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.treasure.reward.ITreasureReward;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/29/2014.
|
||||
*/
|
||||
public class ChestData
|
||||
{
|
||||
private Block _block;
|
||||
private ITreasureReward _reward;
|
||||
private boolean _opened;
|
||||
private boolean _finishedOpen;
|
||||
|
||||
public ChestData(Block block, ITreasureReward reward)
|
||||
{
|
||||
_block = block;
|
||||
_opened = false;
|
||||
_finishedOpen = false;
|
||||
_reward = reward;
|
||||
}
|
||||
|
||||
public boolean isOpened()
|
||||
{
|
||||
return _opened;
|
||||
}
|
||||
|
||||
public boolean isFinishedOpen()
|
||||
{
|
||||
return _finishedOpen;
|
||||
}
|
||||
|
||||
public void setOpened(boolean opened)
|
||||
{
|
||||
_opened = opened;
|
||||
}
|
||||
|
||||
public void setFinishedOpen(boolean finishedOpen)
|
||||
{
|
||||
_finishedOpen = finishedOpen;
|
||||
}
|
||||
|
||||
public Block getBlock()
|
||||
{
|
||||
return _block;
|
||||
}
|
||||
|
||||
public ITreasureReward getReward()
|
||||
{
|
||||
return _reward;
|
||||
}
|
||||
|
||||
}
|
280
Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java
Normal file
280
Plugins/Mineplex.Core/src/mineplex/core/treasure/Treasure.java
Normal file
@ -0,0 +1,280 @@
|
||||
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.ChestSpawnAnimation;
|
||||
import mineplex.core.treasure.animation.ChestOpenAnimation;
|
||||
import mineplex.core.treasure.animation.ParticleAnimation;
|
||||
import mineplex.core.treasure.animation.Animation;
|
||||
import mineplex.core.treasure.reward.ExampleReward;
|
||||
import mineplex.core.treasure.reward.ITreasureReward;
|
||||
|
||||
/**
|
||||
* 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 ITreasureReward[] _rewards;
|
||||
|
||||
private LinkedList<Animation> _animations;
|
||||
|
||||
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);
|
||||
_animations = new LinkedList<Animation>();
|
||||
|
||||
// _animations.add(new ParticleAnimation(this));
|
||||
|
||||
_chestData = new ChestData[4];
|
||||
_chestData[0] = new ChestData(_centerBlock.getRelative(2, 1, 0), new ExampleReward());
|
||||
_chestData[1] = new ChestData(_centerBlock.getRelative(-2, 1, 0), new ExampleReward());
|
||||
_chestData[2] = new ChestData(_centerBlock.getRelative(0, 1, 2), new ExampleReward());
|
||||
_chestData[3] = new ChestData(_centerBlock.getRelative(0, 1, -2), new ExampleReward());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)4);
|
||||
_animations.add(task);
|
||||
}
|
||||
else if (_tickCount == 80)
|
||||
{
|
||||
Block block = getPlayerBlock().getRelative(-2, 0, 0);
|
||||
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)5);
|
||||
_animations.add(task);
|
||||
}
|
||||
else if (_tickCount == 110)
|
||||
{
|
||||
Block block = getPlayerBlock().getRelative(0, 0, 2);
|
||||
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)2);
|
||||
_animations.add(task);
|
||||
}
|
||||
else if (_tickCount == 140)
|
||||
{
|
||||
Block block = getPlayerBlock().getRelative(0, 0, -2);
|
||||
ChestSpawnAnimation task = new ChestSpawnAnimation(this, block, (byte)3);
|
||||
_animations.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<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 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.setOpened(true);
|
||||
|
||||
ChestOpenAnimation chestOpenTask = new ChestOpenAnimation(this, data);
|
||||
_animations.add(chestOpenTask);
|
||||
|
||||
if (isFinished())
|
||||
{
|
||||
System.out.println("finished");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 finish()
|
||||
{
|
||||
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 (Animation animation : _animations)
|
||||
{
|
||||
animation.finish();
|
||||
}
|
||||
_animations.clear();
|
||||
}
|
||||
|
||||
public TreasureStyle getStyle()
|
||||
{
|
||||
return _style;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
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.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
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.finish();
|
||||
}
|
||||
}
|
||||
|
||||
public void attemptOpenTreasure(Player player)
|
||||
{
|
||||
if (!checkNearbyBlocks(player))
|
||||
return;
|
||||
|
||||
Treasure treasure = new Treasure(player);
|
||||
_playerTreasureMap.put(player, treasure);
|
||||
|
||||
Location teleportLocation = treasure.getPlayerBlock().getLocation().add(0.5, 0, 0.5);
|
||||
teleportLocation.setPitch(player.getLocation().getPitch());
|
||||
teleportLocation.setYaw(player.getLocation().getYaw());
|
||||
|
||||
player.teleport(teleportLocation);
|
||||
|
||||
}
|
||||
|
||||
private boolean checkNearbyBlocks(Player player)
|
||||
{
|
||||
Block centerBlock = player.getLocation().getBlock();
|
||||
|
||||
for (int y = 0; y <= 3; y++)
|
||||
{
|
||||
for (int x = -3; x <= 3; x++)
|
||||
{
|
||||
for (int z = -3; z <= 3; z++)
|
||||
{
|
||||
Block block = centerBlock.getRelative(x, y, z);
|
||||
if (UtilBlock.solid(block))
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Treasure", "You can not open a treasure at this spot. Please find a more open location"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for (Treasure treasure : _playerTreasureMap.values())
|
||||
{
|
||||
treasure.update();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void quit(PlayerQuitEvent event)
|
||||
{
|
||||
if (_playerTreasureMap.containsKey(event.getPlayer()))
|
||||
{
|
||||
Treasure treasure = _playerTreasureMap.remove(event.getPlayer());
|
||||
treasure.finish();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void cancelMove(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (_playerTreasureMap.containsKey(player))
|
||||
{
|
||||
Location to = event.getTo();
|
||||
Location from = event.getFrom();
|
||||
if (to.getX() != from.getX() || to.getY() != from.getY() || to.getZ() != from.getZ())
|
||||
{
|
||||
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()) <= 6)
|
||||
{
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), centerLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
|
||||
event.setTo(event.getFrom());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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)
|
||||
// {
|
||||
// //TODO Remove
|
||||
// if (event.getMessage().startsWith("/treasure"))
|
||||
// {
|
||||
// event.getPlayer().sendMessage("Attempting to open treasure...");
|
||||
// attemptOpenTreasure(event.getPlayer());
|
||||
// event.setCancelled(true);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package mineplex.core.treasure;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/28/2014.
|
||||
*/
|
||||
public enum TreasureStyle
|
||||
{
|
||||
/**
|
||||
* These are examples, not final!
|
||||
*/
|
||||
RED(Material.STAINED_CLAY, (byte) 14,
|
||||
Material.STAINED_CLAY, (byte) 6,
|
||||
Material.STAINED_GLASS_PANE, (byte) 14,
|
||||
ParticleType.HEART,
|
||||
ParticleType.HAPPY_VILLAGER,
|
||||
ParticleType.FLAME),
|
||||
|
||||
|
||||
GREEN(Material.STAINED_CLAY,(byte) 5,
|
||||
Material.STAINED_CLAY, (byte) 13,
|
||||
Material.STAINED_GLASS_PANE, (byte) 5,
|
||||
ParticleType.FLAME,
|
||||
ParticleType.RED_DUST,
|
||||
ParticleType.LAVA);
|
||||
|
||||
private Material _primaryMaterial;
|
||||
private byte _primaryData;
|
||||
|
||||
private Material _secondaryMaterial;
|
||||
private byte _secondaryData;
|
||||
|
||||
private Material _wallMaterial;
|
||||
private byte _wallData;
|
||||
|
||||
private ParticleType _primaryParticle;
|
||||
private ParticleType _secondaryParticle;
|
||||
private ParticleType _chestSpawnParticle;
|
||||
|
||||
TreasureStyle(Material primaryMaterial, byte primaryData, Material secondaryMaterial, byte secondaryData, Material wallMaterial, byte wallData, ParticleType primaryParticle, ParticleType secondaryParticle, ParticleType chestSpawnParticle)
|
||||
{
|
||||
_primaryMaterial = primaryMaterial;
|
||||
_primaryData = primaryData;
|
||||
|
||||
_secondaryMaterial = secondaryMaterial;
|
||||
_secondaryData = secondaryData;
|
||||
|
||||
_wallMaterial = wallMaterial;
|
||||
_wallData = wallData;
|
||||
|
||||
_primaryParticle = primaryParticle;
|
||||
_secondaryParticle = secondaryParticle;
|
||||
_chestSpawnParticle = chestSpawnParticle;
|
||||
}
|
||||
|
||||
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 ParticleType getPrimaryParticle()
|
||||
{
|
||||
return _primaryParticle;
|
||||
}
|
||||
|
||||
public ParticleType getSecondaryParticle()
|
||||
{
|
||||
return _secondaryParticle;
|
||||
}
|
||||
|
||||
public ParticleType getChestSpawnParticle()
|
||||
{
|
||||
return _chestSpawnParticle;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
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 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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package mineplex.core.treasure.animation;
|
||||
|
||||
import org.bukkit.Location;
|
||||
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.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutBlockAction;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.hologram.SimpleHologram;
|
||||
import mineplex.core.treasure.ChestData;
|
||||
import mineplex.core.treasure.Treasure;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/29/2014.
|
||||
*/
|
||||
public class ChestOpenAnimation extends Animation
|
||||
{
|
||||
private ChestData _chestData;
|
||||
|
||||
private Item _itemEntity;
|
||||
private SimpleHologram _hologram;
|
||||
|
||||
public ChestOpenAnimation(Treasure treasure, ChestData chestData)
|
||||
{
|
||||
super(treasure);
|
||||
_chestData = chestData;
|
||||
|
||||
// Send chest open packet
|
||||
Block block = chestData.getBlock();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick()
|
||||
{
|
||||
if (getTicks() == 5)
|
||||
{
|
||||
Location location = _chestData.getBlock().getLocation().add(0.5, 0.8, 0.5);
|
||||
_itemEntity = location.getWorld().dropItem(location, _chestData.getReward().getItem());
|
||||
_itemEntity.setVelocity(new Vector(0, 0, 0));
|
||||
_itemEntity.setPickupDelay(Integer.MAX_VALUE);
|
||||
}
|
||||
else if (getTicks() == 15)
|
||||
{
|
||||
_hologram = new SimpleHologram(_chestData.getBlock().getLocation().add(0.5, 1.1, 0.5), _chestData.getReward().getText());
|
||||
_hologram.spawnWithPackets();
|
||||
|
||||
_chestData.setFinishedOpen(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void onFinish()
|
||||
{
|
||||
if (_hologram != null)
|
||||
{
|
||||
_hologram.removeWithPackets();
|
||||
_itemEntity.remove();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
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 ChestSpawnAnimation extends Animation
|
||||
{
|
||||
private static final int ANIMATION_DURATION = 30;
|
||||
|
||||
private Block _block;
|
||||
private byte _direction;
|
||||
private Location _centerLocation;
|
||||
|
||||
public ChestSpawnAnimation(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()
|
||||
{
|
||||
float scale = (float)((double)(ANIMATION_DURATION - getTicks()) / (double)ANIMATION_DURATION);
|
||||
|
||||
float y = 5 * scale;
|
||||
double width = 1.4 * ((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));
|
||||
UtilParticle.PlayParticle(getTreasure().getStyle().getSecondaryParticle(), _centerLocation.clone().add(x * width, y, z * width), 0f, 0f, 0f, 0, 1);
|
||||
}
|
||||
|
||||
if (getTicks() >= ANIMATION_DURATION)
|
||||
{
|
||||
getTreasure().setBlock(_block, Material.CHEST, _direction);
|
||||
_block.getLocation().getWorld().playSound(_centerLocation, Sound.ANVIL_LAND, 0.5f, 1f);
|
||||
|
||||
UtilParticle.PlayParticle(getTreasure().getStyle().getChestSpawnParticle(), _centerLocation, 0.2f, 0.2f, 0.2f, 0, 50);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinish()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
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 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().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 onFinish()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package mineplex.core.treasure.reward;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 9/2/2014.
|
||||
*/
|
||||
public class ExampleReward implements ITreasureReward
|
||||
{
|
||||
@Override
|
||||
public String getText()
|
||||
{
|
||||
return C.cGreen + "100 Gems";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem()
|
||||
{
|
||||
return new ItemStack(Material.EMERALD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RewardRarity getRarity()
|
||||
{
|
||||
return RewardRarity.COMMON;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package mineplex.core.treasure.reward;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 9/2/2014.
|
||||
*/
|
||||
public interface ITreasureReward
|
||||
{
|
||||
public String getText();
|
||||
|
||||
public ItemStack getItem();
|
||||
|
||||
public RewardRarity getRarity();
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package mineplex.core.treasure.reward;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 9/2/2014.
|
||||
*/
|
||||
public enum RewardRarity
|
||||
{
|
||||
|
||||
/**
|
||||
* This will probably be used to figure out what effects are shown when the chest is opened
|
||||
*
|
||||
* (Fireworks, sounds, etc)
|
||||
*/
|
||||
|
||||
COMMON, UNCOMMON, RARE, VERY_RARE;
|
||||
|
||||
}
|
@ -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;
|
||||
|
@ -132,10 +132,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ChatColor.RESET + "Dragon Escape",
|
||||
ChatColor.RESET + "Milk the Cow",
|
||||
ChatColor.RESET + "Super Paintball",
|
||||
ChatColor.RESET + "Turf Forts",
|
||||
ChatColor.RESET + "Turf Wars",
|
||||
ChatColor.RESET + "Death Tag",
|
||||
ChatColor.RESET + "Bacon Brawl",
|
||||
ChatColor.RESET + "Squid Sauce"
|
||||
}));
|
||||
|
||||
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.GOLD_BOOTS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
||||
@ -167,10 +166,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ChatColor.RESET + "Dragon Escape",
|
||||
ChatColor.RESET + "Milk the Cow",
|
||||
ChatColor.RESET + "Super Paintball",
|
||||
ChatColor.RESET + "Turf Forts",
|
||||
ChatColor.RESET + "Turf Wars",
|
||||
ChatColor.RESET + "Death Tag",
|
||||
ChatColor.RESET + "Bacon Brawl",
|
||||
ChatColor.RESET + "Squid Sauce"
|
||||
}));
|
||||
|
||||
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
||||
@ -185,10 +183,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ChatColor.RESET + "Dragon Escape",
|
||||
ChatColor.RESET + "Milk the Cow",
|
||||
ChatColor.RESET + "Super Paintball",
|
||||
ChatColor.RESET + "Turf Forts",
|
||||
ChatColor.RESET + "Turf Wars",
|
||||
ChatColor.RESET + "Death Tag",
|
||||
ChatColor.RESET + "Bacon Brawl",
|
||||
ChatColor.RESET + "Squid Sauce"
|
||||
}));
|
||||
|
||||
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.LEATHER_BOOTS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
||||
@ -203,10 +200,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Dragon Escape",
|
||||
ChatColor.RESET + "Milk the Cow",
|
||||
ChatColor.RESET + "Super Paintball",
|
||||
ChatColor.RESET + "Turf Forts",
|
||||
ChatColor.RESET + "Turf Wars",
|
||||
ChatColor.RESET + "Death Tag",
|
||||
ChatColor.RESET + "Bacon Brawl",
|
||||
ChatColor.RESET + "Squid Sauce"
|
||||
}));
|
||||
|
||||
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.MILK_BUCKET.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
||||
@ -221,10 +217,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ChatColor.RESET + "Dragon Escape",
|
||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Milk the Cow",
|
||||
ChatColor.RESET + "Super Paintball",
|
||||
ChatColor.RESET + "Turf Forts",
|
||||
ChatColor.RESET + "Turf Wars",
|
||||
ChatColor.RESET + "Death Tag",
|
||||
ChatColor.RESET + "Bacon Brawl",
|
||||
ChatColor.RESET + "Squid Sauce"
|
||||
}));
|
||||
|
||||
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_BARDING.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
||||
@ -239,10 +234,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ChatColor.RESET + "Dragon Escape",
|
||||
ChatColor.RESET + "Milk the Cow",
|
||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Super Paintball",
|
||||
ChatColor.RESET + "Turf Forts",
|
||||
ChatColor.RESET + "Turf Wars",
|
||||
ChatColor.RESET + "Death Tag",
|
||||
ChatColor.RESET + "Bacon Brawl",
|
||||
ChatColor.RESET + "Squid Sauce"
|
||||
}));
|
||||
|
||||
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(159, (byte)14, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
||||
@ -257,10 +251,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ChatColor.RESET + "Dragon Escape",
|
||||
ChatColor.RESET + "Milk the Cow",
|
||||
ChatColor.RESET + "Super Paintball",
|
||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Turf Forts",
|
||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Turf Wars",
|
||||
ChatColor.RESET + "Death Tag",
|
||||
ChatColor.RESET + "Bacon Brawl",
|
||||
ChatColor.RESET + "Squid Sauce"
|
||||
}));
|
||||
|
||||
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(309, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
||||
@ -275,10 +268,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ChatColor.RESET + "Dragon Escape",
|
||||
ChatColor.RESET + "Milk the Cow",
|
||||
ChatColor.RESET + "Super Paintball",
|
||||
ChatColor.RESET + "Turf Forts",
|
||||
ChatColor.RESET + "Turf Wars",
|
||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Death Tag",
|
||||
ChatColor.RESET + "Bacon Brawl",
|
||||
ChatColor.RESET + "Squid Sauce"
|
||||
}));
|
||||
|
||||
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(319, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
||||
@ -293,28 +285,9 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
ChatColor.RESET + "Dragon Escape",
|
||||
ChatColor.RESET + "Milk the Cow",
|
||||
ChatColor.RESET + "Super Paintball",
|
||||
ChatColor.RESET + "Turf Forts",
|
||||
ChatColor.RESET + "Turf Wars",
|
||||
ChatColor.RESET + "Death Tag",
|
||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Bacon Brawl",
|
||||
ChatColor.RESET + "Squid Sauce"
|
||||
}));
|
||||
|
||||
_minigameCycle.add(ItemStackFactory.Instance.CreateStack(351, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String []
|
||||
{
|
||||
ChatColor.RESET + "",
|
||||
ChatColor.RESET + "Play all of these fun minigames:",
|
||||
ChatColor.RESET + "",
|
||||
ChatColor.RESET + "Super Spleef",
|
||||
ChatColor.RESET + "Runner",
|
||||
ChatColor.RESET + "Dragons",
|
||||
ChatColor.RESET + "One in the Quiver",
|
||||
ChatColor.RESET + "Dragon Escape",
|
||||
ChatColor.RESET + "Milk the Cow",
|
||||
ChatColor.RESET + "Super Paintball",
|
||||
ChatColor.RESET + "Turf Forts",
|
||||
ChatColor.RESET + "Death Tag",
|
||||
ChatColor.RESET + "Bacon Brawl",
|
||||
ChatColor.RESET + C.Bold + ChatColor.GREEN + "Squid Sauce"
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,6 @@ public class ClassCombatShop extends ShopBase<ClassShopManager>
|
||||
if (!CanOpenShop(player))
|
||||
return false;
|
||||
|
||||
System.out.println(this.getClass().getName() + " - I CAN OPEN SHOP");
|
||||
|
||||
OpenedShop.add(player.getName());
|
||||
|
||||
OpenShopForPlayer(player);
|
||||
|
@ -736,25 +736,18 @@ public class PlayerConnection implements PacketPlayInListener
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
|
||||
// CraftBukkit start
|
||||
if (this.player.dead)
|
||||
return;
|
||||
if (this.player.dead) return;
|
||||
|
||||
// This is a horrible hack needed because the client sends 2 packets on
|
||||
// 'right mouse click'
|
||||
// aimed at a block. We shouldn't need to get the second packet if the
|
||||
// data is handled
|
||||
// This is a horrible hack needed because the client sends 2 packets on 'right mouse click'
|
||||
// aimed at a block. We shouldn't need to get the second packet if the data is handled
|
||||
// but we cannot know what the client will do, so we might still get it
|
||||
//
|
||||
// If the time between packets is small enough, and the 'signature'
|
||||
// similar, we discard the
|
||||
// second one. This sadly has to remain until Mojang makes their packets
|
||||
// saner. :(
|
||||
// -- Grum
|
||||
// If the time between packets is small enough, and the 'signature' similar, we discard the
|
||||
// second one. This sadly has to remain until Mojang makes their packets saner. :(
|
||||
// -- Grum
|
||||
if (packetplayinblockplace.getFace() == 255)
|
||||
{
|
||||
if (packetplayinblockplace.getItemStack() != null
|
||||
&& packetplayinblockplace.getItemStack().getItem() == this.lastMaterial && this.lastPacket != null
|
||||
&& packetplayinblockplace.timestamp - this.lastPacket < 100)
|
||||
if (packetplayinblockplace.getItemStack() != null && packetplayinblockplace.getItemStack().getItem() == this.lastMaterial && this.lastPacket != null && packetplayinblockplace.timestamp - this.lastPacket < 100)
|
||||
{
|
||||
this.lastPacket = null;
|
||||
return;
|
||||
@ -762,23 +755,14 @@ public class PlayerConnection implements PacketPlayInListener
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lastMaterial = packetplayinblockplace.getItemStack() == null ? null : packetplayinblockplace
|
||||
.getItemStack().getItem();
|
||||
this.lastMaterial = packetplayinblockplace.getItemStack() == null ? null : packetplayinblockplace.getItemStack().getItem();
|
||||
this.lastPacket = packetplayinblockplace.timestamp;
|
||||
}
|
||||
// CraftBukkit - if rightclick decremented the item, always send the
|
||||
// update packet. */
|
||||
// this is not here for CraftBukkit's own functionality; rather it is to
|
||||
// fix
|
||||
// CraftBukkit - if rightclick decremented the item, always send the update packet. */
|
||||
// this is not here for CraftBukkit's own functionality; rather it is to fix
|
||||
// a notch bug where the item doesn't update correctly.
|
||||
boolean always = false;
|
||||
// CraftBukkit end
|
||||
// Spigot start
|
||||
if (player.activeContainer != player.defaultContainer)
|
||||
{
|
||||
getPlayer().closeInventory();
|
||||
}
|
||||
// Spigot end
|
||||
|
||||
ItemStack itemstack = this.player.inventory.getItemInHand();
|
||||
boolean flag = false;
|
||||
@ -800,8 +784,7 @@ public class PlayerConnection implements PacketPlayInListener
|
||||
// Spigot start - skip the event if throttled
|
||||
if (!throttled)
|
||||
{
|
||||
org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(
|
||||
this.player, Action.RIGHT_CLICK_AIR, itemstack);
|
||||
org.bukkit.event.player.PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack);
|
||||
if (event.useItemInHand() != Event.Result.DENY)
|
||||
{
|
||||
this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack);
|
||||
@ -809,20 +792,15 @@ public class PlayerConnection implements PacketPlayInListener
|
||||
}
|
||||
// Spigot end
|
||||
|
||||
// CraftBukkit - notch decrements the counter by 1 in the above
|
||||
// method with food,
|
||||
// snowballs and so forth, but he does it in a place that doesn't
|
||||
// cause the
|
||||
// CraftBukkit - notch decrements the counter by 1 in the above method with food,
|
||||
// snowballs and so forth, but he does it in a place that doesn't cause the
|
||||
// inventory update packet to get sent
|
||||
always = (itemstack.count != itemstackAmount) || itemstack.getItem() == Item.getItemOf(Blocks.WATER_LILY);
|
||||
// CraftBukkit end
|
||||
}
|
||||
else if (packetplayinblockplace.d() >= this.minecraftServer.getMaxBuildHeight() - 1
|
||||
&& (packetplayinblockplace.getFace() == 1 || packetplayinblockplace.d() >= this.minecraftServer
|
||||
.getMaxBuildHeight()))
|
||||
else if (packetplayinblockplace.d() >= this.minecraftServer.getMaxBuildHeight() - 1 && (packetplayinblockplace.getFace() == 1 || packetplayinblockplace.d() >= this.minecraftServer.getMaxBuildHeight()))
|
||||
{
|
||||
ChatMessage chatmessage = new ChatMessage("build.tooHigh",
|
||||
new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight()) });
|
||||
ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[]{Integer.valueOf(this.minecraftServer.getMaxBuildHeight())});
|
||||
|
||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutChat(chatmessage));
|
||||
@ -830,23 +808,17 @@ public class PlayerConnection implements PacketPlayInListener
|
||||
}
|
||||
else
|
||||
{
|
||||
// CraftBukkit start - Check if we can actually do something over
|
||||
// this large a distance
|
||||
// CraftBukkit start - Check if we can actually do something over this large a distance
|
||||
Location eyeLoc = this.getPlayer().getEyeLocation();
|
||||
double reachDistance = NumberConversions.square(eyeLoc.getX() - i)
|
||||
+ NumberConversions.square(eyeLoc.getY() - j) + NumberConversions.square(eyeLoc.getZ() - k);
|
||||
if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED
|
||||
: SURVIVAL_PLACE_DISTANCE_SQUARED))
|
||||
double reachDistance = NumberConversions.square(eyeLoc.getX() - i) + NumberConversions.square(eyeLoc.getY() - j) + NumberConversions.square(eyeLoc.getZ() - k);
|
||||
if (reachDistance > (this.getPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (throttled
|
||||
|| !this.player.playerInteractManager.interact(this.player, worldserver, itemstack, i, j, k, l,
|
||||
packetplayinblockplace.h(), packetplayinblockplace.i(), packetplayinblockplace.j()))
|
||||
if (throttled || !this.player.playerInteractManager.interact(this.player, worldserver, itemstack, i, j, k, l, packetplayinblockplace.h(), packetplayinblockplace.i(), packetplayinblockplace.j()))
|
||||
{ // Spigot - skip the event if throttled
|
||||
always = true; // force PacketPlayOutSetSlot to be sent to
|
||||
// client to update ItemStack count
|
||||
always = true; // force PacketPlayOutSetSlot to be sent to client to update ItemStack count
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
@ -899,21 +871,15 @@ public class PlayerConnection implements PacketPlayInListener
|
||||
if (itemstack == null || itemstack.n() == 0)
|
||||
{
|
||||
this.player.g = true;
|
||||
this.player.inventory.items[this.player.inventory.itemInHandIndex] = ItemStack
|
||||
.b(this.player.inventory.items[this.player.inventory.itemInHandIndex]);
|
||||
Slot slot = this.player.activeContainer.getSlot((IInventory) this.player.inventory,
|
||||
this.player.inventory.itemInHandIndex);
|
||||
this.player.inventory.items[this.player.inventory.itemInHandIndex] = ItemStack.b(this.player.inventory.items[this.player.inventory.itemInHandIndex]);
|
||||
Slot slot = this.player.activeContainer.getSlot((IInventory) this.player.inventory, this.player.inventory.itemInHandIndex);
|
||||
|
||||
this.player.activeContainer.b();
|
||||
this.player.g = false;
|
||||
// CraftBukkit - TODO CHECK IF NEEDED -- new if structure might not
|
||||
// need 'always'. Kept it in for now, but may be able to remove in
|
||||
// future
|
||||
if (!ItemStack.matches(this.player.inventory.getItemInHand(), packetplayinblockplace.getItemStack())
|
||||
|| always)
|
||||
// CraftBukkit - TODO CHECK IF NEEDED -- new if structure might not need 'always'. Kept it in for now, but may be able to remove in future
|
||||
if (!ItemStack.matches(this.player.inventory.getItemInHand(), packetplayinblockplace.getItemStack()) || always)
|
||||
{
|
||||
this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex,
|
||||
this.player.inventory.getItemInHand()));
|
||||
this.sendPacket(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -16,6 +17,7 @@ import org.bukkit.entity.Chicken;
|
||||
import org.bukkit.entity.Cow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -29,12 +31,12 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.CraftingInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scoreboard.Score;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
@ -57,7 +59,6 @@ import nautilus.game.arcade.events.PlayerDeathOutEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
import nautilus.game.arcade.game.games.bridge.kits.*;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.ore.OreHider;
|
||||
@ -70,6 +71,11 @@ import nautilus.game.arcade.stats.TntMinerStatTracker;
|
||||
|
||||
public class Bridge extends TeamGame implements OreObsfucation
|
||||
{
|
||||
/**
|
||||
* When a block is broken of one of these materials, the item drop will be locked to the player that broke the block for 8 seconds. After that, anyone can pick up the item.
|
||||
*/
|
||||
private static final Material[] PLAYER_DROP_DELAY_MATERIALS = new Material[] { Material.LOG, Material.LOG_2, Material.IRON_ORE, Material.DIAMOND_ORE, Material.COAL_ORE, Material.GOLD_ORE, Material.WORKBENCH, Material.FURNACE };
|
||||
|
||||
//Bridge Timer
|
||||
private int _bridgeTime = 600000;
|
||||
private boolean _bridgesDown = false;
|
||||
@ -98,7 +104,6 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
private OreHider _ore;
|
||||
private double _oreDensity = 2.2;
|
||||
|
||||
|
||||
//Map Flags
|
||||
private int _buildHeight = -1;
|
||||
private int _iceForm = -1;
|
||||
@ -111,6 +116,9 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
private HashMap<GameTeam, Integer> _tournamentKills = new HashMap<GameTeam, Integer>();
|
||||
private long _tournamentKillMessageTimer = 0;
|
||||
|
||||
//Item pickup delay for players that don't break the block
|
||||
private HashMap<Block, UUID> _blockToUUIDMap = new HashMap<Block, UUID>();
|
||||
|
||||
|
||||
public Bridge(ArcadeManager manager)
|
||||
{
|
||||
@ -1009,6 +1017,61 @@ public class Bridge extends TeamGame implements OreObsfucation
|
||||
}
|
||||
}
|
||||
|
||||
private void addBlockPickupDelay(Player owner, Block block)
|
||||
{
|
||||
Material blockMaterial = block.getType();
|
||||
boolean shouldAddToMap = false;
|
||||
|
||||
for (int i = 0; i < PLAYER_DROP_DELAY_MATERIALS.length && !shouldAddToMap; i++)
|
||||
{
|
||||
if (blockMaterial.equals(PLAYER_DROP_DELAY_MATERIALS[i]))
|
||||
{
|
||||
shouldAddToMap = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldAddToMap)
|
||||
_blockToUUIDMap.put(block, owner.getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void dropItem(BlockBreakEvent event)
|
||||
{
|
||||
addBlockPickupDelay(event.getPlayer(), event.getBlock());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void itemSpawn(ItemSpawnEvent event)
|
||||
{
|
||||
Item item = event.getEntity();
|
||||
Block block = event.getLocation().getBlock();
|
||||
|
||||
UUID uuid = _blockToUUIDMap.remove(block);
|
||||
|
||||
if (uuid != null)
|
||||
{
|
||||
item.setMetadata("owner", new FixedMetadataValue(Manager.GetPlugin(), uuid));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void itemPickup(PlayerPickupItemEvent event)
|
||||
{
|
||||
Item item = event.getItem();
|
||||
|
||||
if (item.hasMetadata("owner"))
|
||||
{
|
||||
FixedMetadataValue ownerData = (FixedMetadataValue) item.getMetadata("owner").get(0);
|
||||
UUID ownerUUID = (UUID) ownerData.value();
|
||||
|
||||
// 8 Seconds
|
||||
if (item.getTicksLived() <= 160 && !event.getPlayer().getUniqueId().equals(ownerUUID))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void ChestProtect(EntityExplodeEvent event)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user