Merge branch 'update/skyfall-nolag' into develop
This commit is contained in:
commit
490fe56b34
@ -1,6 +1,7 @@
|
||||
package mineplex.core.loot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
|
||||
@ -32,9 +33,32 @@ public class ChestLoot
|
||||
|
||||
public ItemStack getLoot()
|
||||
{
|
||||
int no = UtilMath.r(_totalLoot);
|
||||
return getLoot(new ArrayList<>());
|
||||
}
|
||||
|
||||
for (RandomItem item : _randomItems)
|
||||
public ItemStack getLoot(ArrayList<Material> exclude)
|
||||
{
|
||||
int totalLoot = _totalLoot;
|
||||
ArrayList<RandomItem> items = (ArrayList<RandomItem>) _randomItems.clone();
|
||||
|
||||
Iterator<RandomItem> rItems = items.iterator();
|
||||
while (rItems.hasNext())
|
||||
{
|
||||
RandomItem item = rItems.next();
|
||||
|
||||
for (Material mat : exclude)
|
||||
{
|
||||
if (item.getItemStack().getType() == mat)
|
||||
{
|
||||
totalLoot -= item.getAmount();
|
||||
rItems.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int no = UtilMath.r(totalLoot);
|
||||
|
||||
for (RandomItem item : items)
|
||||
{
|
||||
no -= item.getAmount();
|
||||
|
||||
|
@ -48,4 +48,15 @@ public class RandomItem
|
||||
|
||||
return _item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!(obj instanceof RandomItem))
|
||||
return false;
|
||||
|
||||
RandomItem item = (RandomItem) obj;
|
||||
|
||||
return _item.getType() == item.getItemStack().getType();
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.omg.DynamicAny._DynUnionStub;
|
||||
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
@ -40,8 +41,8 @@ import nautilus.game.arcade.game.Game.GameState;
|
||||
*/
|
||||
public class BoosterRing extends Crumbleable implements Listener
|
||||
{
|
||||
private static int MAX_RING_BOUNDS = 15;
|
||||
private static int SEARCH_OUTER_RING_RANGE = 10;
|
||||
private static int MAX_RING_BOUNDS = 18;
|
||||
private static int SEARCH_OUTER_RING_RANGE = 12;
|
||||
|
||||
private Game _host;
|
||||
|
||||
@ -63,6 +64,11 @@ public class BoosterRing extends Crumbleable implements Listener
|
||||
private long _disabledSince;
|
||||
private long _disabledFor;
|
||||
|
||||
private long _disableDelay;
|
||||
private long _disableDelayStarted;
|
||||
|
||||
private CooldownData _delayedData;
|
||||
|
||||
private Hologram _hologram;
|
||||
private boolean _timer;
|
||||
|
||||
@ -89,6 +95,8 @@ public class BoosterRing extends Crumbleable implements Listener
|
||||
_boostStrength = boostStrength;
|
||||
_disabledSince = System.currentTimeMillis();
|
||||
|
||||
_disableDelayStarted = 0;
|
||||
|
||||
System.out.println("Registering Ring");
|
||||
|
||||
setupRing();
|
||||
@ -100,6 +108,8 @@ public class BoosterRing extends Crumbleable implements Listener
|
||||
|
||||
_hologram = new Hologram(host.getArcadeManager().getHologramManager(), _ringMiddle, "");
|
||||
_hologram.setViewDistance(300);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -305,7 +315,7 @@ public class BoosterRing extends Crumbleable implements Listener
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for (Player player : _host.GetPlayers(true))
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (!UtilPlayer.isGliding(player))
|
||||
continue;
|
||||
@ -331,7 +341,8 @@ public class BoosterRing extends Crumbleable implements Listener
|
||||
Vector vec = player.getEyeLocation().getDirection();
|
||||
UtilAction.velocity(player, vec.multiply(event.getStrength()));
|
||||
|
||||
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL_LARGE, Color.BLUE, true, false);
|
||||
if (_host.IsAlive(player))
|
||||
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL_LARGE, Color.BLUE, true, false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -346,6 +357,9 @@ public class BoosterRing extends Crumbleable implements Listener
|
||||
if (!_disabled)
|
||||
return;
|
||||
|
||||
if (isCrumbling())
|
||||
return;
|
||||
|
||||
double blocks = (double) _ring.size() / (double)(_disabledFor/1000);
|
||||
_blocksToFill += blocks;
|
||||
|
||||
@ -391,6 +405,42 @@ public class BoosterRing extends Crumbleable implements Listener
|
||||
enable();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
|
||||
if (_delayedData == null)
|
||||
return;
|
||||
|
||||
if (UtilTime.elapsed(_disableDelayStarted, _disableDelay))
|
||||
{
|
||||
disable(_delayedData.getTime(), _delayedData.getMaterial(), _delayedData.getData(), _delayedData.showTimer());
|
||||
_delayedData = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void disableLater(long delay, long time, Material mat, byte data, boolean showTimer)
|
||||
{
|
||||
if (_delayedData != null)
|
||||
return;
|
||||
|
||||
_delayedData = new CooldownData(time, mat, data, showTimer);
|
||||
_disableDelayStarted = System.currentTimeMillis();
|
||||
_disableDelay = delay;
|
||||
}
|
||||
|
||||
public void disableLater(long delay, long time, boolean showTimer)
|
||||
{
|
||||
disableLater(delay, time, Material.STAINED_CLAY, (byte) 14, showTimer);
|
||||
}
|
||||
|
||||
public void disableLater(long delay)
|
||||
{
|
||||
disableLater(delay, Long.MAX_VALUE, Material.STAINED_CLAY, (byte) 14, false);
|
||||
}
|
||||
|
||||
public void disable()
|
||||
{
|
||||
disable(Long.MAX_VALUE, false);
|
||||
@ -493,4 +543,40 @@ public class BoosterRing extends Crumbleable implements Listener
|
||||
return _ring;
|
||||
}
|
||||
|
||||
private class CooldownData
|
||||
{
|
||||
private long _time;
|
||||
private Material _mat;
|
||||
private byte _data;
|
||||
private boolean _showTimer;
|
||||
|
||||
public CooldownData(long time, Material mat, byte data, boolean showTimer)
|
||||
{
|
||||
_time = time;
|
||||
_mat = mat;
|
||||
_data = data;
|
||||
_showTimer = showTimer;
|
||||
}
|
||||
|
||||
public long getTime()
|
||||
{
|
||||
return _time;
|
||||
}
|
||||
|
||||
public Material getMaterial()
|
||||
{
|
||||
return _mat;
|
||||
}
|
||||
|
||||
public byte getData()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public boolean showTimer()
|
||||
{
|
||||
return _showTimer;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,27 @@
|
||||
package nautilus.game.arcade.game.games.skyfall;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.Chunk;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
/**
|
||||
* Crumbleable is a Superclass to create decayable/crumleable Objects like Sky Islands
|
||||
@ -15,9 +30,81 @@ import mineplex.core.common.util.UtilMath;
|
||||
*/
|
||||
public abstract class Crumbleable
|
||||
{
|
||||
private static final long CHUNK_CRUMBLE_DELAY = 1000;
|
||||
|
||||
private boolean _crumble;
|
||||
|
||||
private ArrayList<Location> _initBlocks;
|
||||
private ArrayList<Location> _realBlocks;
|
||||
private Map<Chunk, BitSet> _chunksToUpdate;
|
||||
|
||||
private boolean _onlyTop;
|
||||
private int _height;
|
||||
|
||||
private long _lastChunk;
|
||||
|
||||
public Crumbleable()
|
||||
{
|
||||
this(false, 0);
|
||||
}
|
||||
|
||||
public Crumbleable(boolean onlyTop, int height)
|
||||
{
|
||||
_onlyTop = onlyTop;
|
||||
_height = height;
|
||||
|
||||
_realBlocks = new ArrayList<>();
|
||||
_chunksToUpdate = new HashMap<>();
|
||||
|
||||
_lastChunk = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called when getBlocks is set
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
if (_onlyTop)
|
||||
{
|
||||
ArrayList<Location> flatMap = new ArrayList<>();
|
||||
ArrayList<Location> locs = getBlocks();
|
||||
int y = Integer.MIN_VALUE;
|
||||
for (Location loc : locs)
|
||||
{
|
||||
if (loc.getBlockY() > y)
|
||||
y = loc.getBlockY();
|
||||
}
|
||||
|
||||
for (Location loc : locs)
|
||||
{
|
||||
if (loc.getBlockY() == y)
|
||||
flatMap.add(loc.clone());
|
||||
}
|
||||
|
||||
for (Location loc : flatMap)
|
||||
{
|
||||
Block block = loc.getBlock();
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (i <= _height)
|
||||
{
|
||||
if (block.getType() != Material.AIR && block.getRelative(BlockFace.UP).getType() == Material.AIR)
|
||||
_realBlocks.add(block.getLocation());
|
||||
|
||||
block = block.getRelative(BlockFace.DOWN);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
_initBlocks = (ArrayList<Location>) _realBlocks.clone();
|
||||
}
|
||||
else
|
||||
{
|
||||
_realBlocks = (ArrayList<Location>) getBlocks().clone();
|
||||
_initBlocks = (ArrayList<Location>) getBlocks().clone();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #crumble(int, Material...)
|
||||
@ -44,26 +131,50 @@ public abstract class Crumbleable
|
||||
|
||||
crumblePercentage();
|
||||
|
||||
Material material = replacements[UtilMath.r(replacements.length)];
|
||||
|
||||
if (getBlocks().isEmpty())
|
||||
if (_realBlocks.isEmpty())
|
||||
{
|
||||
crumbledAway();
|
||||
if (!_chunksToUpdate.isEmpty())
|
||||
{
|
||||
if (UtilTime.elapsed(_lastChunk, CHUNK_CRUMBLE_DELAY))
|
||||
{
|
||||
Chunk chunk = _chunksToUpdate.keySet().iterator().next();
|
||||
BitSet bitSet = _chunksToUpdate.remove(chunk);
|
||||
|
||||
int mask = 0;
|
||||
|
||||
for (int i = 0; i < bitSet.length(); i++)
|
||||
{
|
||||
if (bitSet.get(i))
|
||||
{
|
||||
mask |= 1 << i;
|
||||
}
|
||||
}
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
UtilPlayer.sendPacket(player, new PacketPlayOutMapChunk(chunk, false, mask));
|
||||
}
|
||||
|
||||
_lastChunk = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < blocks; i++)
|
||||
{
|
||||
if (getBlocks().isEmpty())
|
||||
Material material = replacements[UtilMath.r(replacements.length)];
|
||||
if (_realBlocks.isEmpty())
|
||||
{
|
||||
crumbledAway();
|
||||
return true;
|
||||
}
|
||||
|
||||
Location toRemove = getBlocks().remove(UtilMath.r(getBlocks().size()));
|
||||
if (toRemove.getBlock().getType() == Material.CHEST && getBlocks().size() > 25)
|
||||
Location toRemove = _realBlocks.remove(UtilMath.r(_realBlocks.size()));
|
||||
if (toRemove.getBlock().getType() == Material.CHEST && _realBlocks.size() > 25)
|
||||
{
|
||||
getBlocks().add(toRemove);
|
||||
_realBlocks.add(toRemove);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -74,8 +185,19 @@ public abstract class Crumbleable
|
||||
|| toRemove.getBlock().getType() == Material.STATIONARY_LAVA)
|
||||
continue;
|
||||
|
||||
MapUtil.QuickChangeBlockAt(toRemove, material);
|
||||
byte id = 0;
|
||||
|
||||
if (toRemove.getBlock().getType() == Material.STAINED_GLASS ||
|
||||
toRemove.getBlock().getType() == Material.GLASS)
|
||||
{
|
||||
material = Material.STAINED_GLASS;
|
||||
id = DyeColor.BLACK.getData();
|
||||
}
|
||||
|
||||
MapUtil.ChunkBlockChange(toRemove, material.getId(), id, false);
|
||||
_chunksToUpdate.computeIfAbsent(((CraftChunk) toRemove.getChunk()).getHandle(), key -> new BitSet()).set(((int) toRemove.getY()) >> 4);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -86,7 +208,7 @@ public abstract class Crumbleable
|
||||
|
||||
public boolean isCrumbledAway()
|
||||
{
|
||||
return getBlocks().isEmpty();
|
||||
return _realBlocks.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,19 +216,21 @@ public abstract class Crumbleable
|
||||
*/
|
||||
public double crumblePercentage()
|
||||
{
|
||||
if (_initBlocks == null)
|
||||
_initBlocks = (ArrayList<Location>) getBlocks().clone();
|
||||
|
||||
try
|
||||
{
|
||||
return (getBlocks().size()/(_initBlocks.size()/100))/100;
|
||||
return (_realBlocks.size()/(_initBlocks.size()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 100;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<Location> getRealBlocks()
|
||||
{
|
||||
return _realBlocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrideable method which is called by
|
||||
* {@link #crumble(int, Material...)} or {@link #crumble(int)}
|
||||
|
@ -8,15 +8,15 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.loot.ChestLoot;
|
||||
import mineplex.core.titles.tracks.standard.LuckyTrack;
|
||||
import mineplex.core.titles.tracks.standard.UnluckyTrack;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
|
||||
/**
|
||||
* The Island Object represents a flying Island <br/>
|
||||
* which has it's own chests and is able to crumble away.
|
||||
@ -69,6 +69,8 @@ public class Island extends Crumbleable
|
||||
*/
|
||||
public Island(Location location, ChestLoot loot, int bounds, int height)
|
||||
{
|
||||
super(true, height);
|
||||
|
||||
_location = location;
|
||||
_bounds = bounds;
|
||||
_height = height;
|
||||
@ -78,9 +80,10 @@ public class Island extends Crumbleable
|
||||
_loot = loot;
|
||||
|
||||
registerBlocks();
|
||||
init();
|
||||
}
|
||||
|
||||
public void fillLoot(Block block, Player player, ArcadeManager arcadeManager)
|
||||
public void fillLoot(Block block)
|
||||
{
|
||||
if (block.getType() != Material.CHEST
|
||||
&& block.getType() != Material.TRAPPED_CHEST)
|
||||
@ -95,7 +98,7 @@ public class Island extends Crumbleable
|
||||
Inventory inventory = chest.getBlockInventory();
|
||||
inventory.clear();
|
||||
|
||||
int items = 3;
|
||||
int items = 5;
|
||||
if (Math.random() > 0.50)
|
||||
items++;
|
||||
if (Math.random() > 0.65)
|
||||
@ -105,23 +108,77 @@ public class Island extends Crumbleable
|
||||
if (Math.random() > 0.95)
|
||||
items++;
|
||||
|
||||
ArrayList<Material> exclude = new ArrayList<>();
|
||||
for (int i = 0; i < items; i++)
|
||||
{
|
||||
int trys = 0;
|
||||
int slot = UtilMath.r(27);
|
||||
int slot = UtilMath.r(26);
|
||||
while (inventory.getItem(slot) != null && trys <= 5)
|
||||
{
|
||||
trys++;
|
||||
slot = UtilMath.r(27);
|
||||
slot = UtilMath.r(26);
|
||||
}
|
||||
|
||||
inventory.setItem(slot, _loot.getLoot());
|
||||
}
|
||||
ItemStack item = _loot.getLoot(exclude);
|
||||
inventory.setItem(slot, item);
|
||||
if (item.getType() == Material.DIAMOND)
|
||||
{
|
||||
inventory.setItem(slot + 1, new ItemStack(Material.STICK, 2));
|
||||
}
|
||||
if (item.getType() == Material.BOW)
|
||||
{
|
||||
inventory.setItem(slot + 1, new ItemStack(Material.ARROW, UtilMath.r(6) + 1));
|
||||
}
|
||||
|
||||
if (UtilItem.isHelmet(item))
|
||||
{
|
||||
exclude.add(Material.CHAINMAIL_HELMET);
|
||||
exclude.add(Material.GOLD_HELMET);
|
||||
exclude.add(Material.IRON_HELMET);
|
||||
exclude.add(Material.LEATHER_HELMET);
|
||||
exclude.add(Material.DIAMOND_HELMET);
|
||||
}
|
||||
if (UtilItem.isChestplate(item))
|
||||
{
|
||||
exclude.add(Material.CHAINMAIL_CHESTPLATE);
|
||||
exclude.add(Material.GOLD_CHESTPLATE);
|
||||
exclude.add(Material.IRON_CHESTPLATE);
|
||||
exclude.add(Material.LEATHER_CHESTPLATE);
|
||||
exclude.add(Material.DIAMOND_CHESTPLATE);
|
||||
}
|
||||
if (UtilItem.isLeggings(item))
|
||||
{
|
||||
exclude.add(Material.CHAINMAIL_LEGGINGS);
|
||||
exclude.add(Material.GOLD_LEGGINGS);
|
||||
exclude.add(Material.IRON_LEGGINGS);
|
||||
exclude.add(Material.LEATHER_LEGGINGS);
|
||||
exclude.add(Material.DIAMOND_LEGGINGS);
|
||||
}
|
||||
if (UtilItem.isBoots(item))
|
||||
{
|
||||
exclude.add(Material.CHAINMAIL_BOOTS);
|
||||
exclude.add(Material.GOLD_BOOTS);
|
||||
exclude.add(Material.IRON_BOOTS);
|
||||
exclude.add(Material.LEATHER_BOOTS);
|
||||
exclude.add(Material.DIAMOND_BOOTS);
|
||||
}
|
||||
if (UtilItem.isSword(item))
|
||||
{
|
||||
exclude.add(Material.WOOD_SWORD);
|
||||
exclude.add(Material.STONE_SWORD);
|
||||
exclude.add(Material.IRON_SWORD);
|
||||
exclude.add(Material.DIAMOND_SWORD);
|
||||
}
|
||||
if (UtilItem.isAxe(item))
|
||||
{
|
||||
exclude.add(Material.WOOD_AXE);
|
||||
exclude.add(Material.STONE_AXE);
|
||||
exclude.add(Material.IRON_AXE);
|
||||
exclude.add(Material.DIAMOND_AXE);
|
||||
}
|
||||
if (item.getType() == Material.BOW)
|
||||
exclude.add(Material.BOW);
|
||||
|
||||
if (player != null && arcadeManager != null && arcadeManager.GetServerConfig().RewardStats)
|
||||
{
|
||||
arcadeManager.getTrackManager().getTrack(LuckyTrack.class).handleLoot(player, chest.getBlockInventory());
|
||||
arcadeManager.getTrackManager().getTrack(UnluckyTrack.class).handleLoot(player, chest.getBlockInventory());
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,10 +209,10 @@ public class Island extends Crumbleable
|
||||
|
||||
public boolean isOnIsland(Location location)
|
||||
{
|
||||
if (UtilMath.offset(location, _location) > _bounds)
|
||||
if (UtilMath.offset2d(location, _location) > _bounds + 1)
|
||||
return false;
|
||||
|
||||
for (int y = ((int) (Math.round(_location.getY()) - _height)); y <= _location.getBlockY(); y++)
|
||||
for (int y = (_location.getBlockY() - _height); y <= _location.getBlockY(); y++)
|
||||
{
|
||||
if (location.getBlockY() == y)
|
||||
return true;
|
||||
@ -175,7 +232,7 @@ public class Island extends Crumbleable
|
||||
|
||||
public void registerBlocks()
|
||||
{
|
||||
for (Block block : UtilBlock.getInBoundingBox(_location.clone().add(_bounds, 0, _bounds), _location.clone().subtract(_bounds, _height, _bounds)))
|
||||
for (Block block : UtilBlock.getInBoundingBox(_location.clone().add(_bounds, 0, _bounds), _location.clone().subtract(_bounds, _height, _bounds), false))
|
||||
{
|
||||
if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST)
|
||||
getChests().add(block.getLocation());
|
||||
@ -189,7 +246,7 @@ public class Island extends Crumbleable
|
||||
_lootedBlocks.clear();
|
||||
for (Location loc : _chests)
|
||||
{
|
||||
fillLoot(loc.getBlock(), null, null);
|
||||
fillLoot(loc.getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
package nautilus.game.arcade.game.games.skyfall;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
@ -14,15 +17,15 @@ import mineplex.core.loot.RandomItem;
|
||||
*/
|
||||
public class LootTable
|
||||
{
|
||||
public final static LootTable BASIC = new LootTable(
|
||||
// Survival Loot
|
||||
|
||||
public final static LootTable BASIC = new LootTable(true,
|
||||
new RandomItem(Material.BAKED_POTATO, 30, 1, 3),
|
||||
new RandomItem(Material.COOKED_BEEF, 30, 1, 2),
|
||||
new RandomItem(Material.COOKED_CHICKEN, 30, 1, 2),
|
||||
new RandomItem(Material.CARROT_ITEM, 30, 1, 3),
|
||||
new RandomItem(Material.MUSHROOM_SOUP, 15, 1, 1),
|
||||
new RandomItem(Material.WHEAT, 30, 1, 6),
|
||||
new RandomItem(Material.APPLE, 30, 1, 4),
|
||||
new RandomItem(Material.PORK, 30, 1, 4),
|
||||
new RandomItem(Material.ROTTEN_FLESH, 40, 1, 6),
|
||||
|
||||
new RandomItem(Material.WOOD_AXE, 100),
|
||||
@ -57,26 +60,28 @@ public class LootTable
|
||||
Material.TNT, (byte) 0, 1, F.item("Throwing TNT")), 15),
|
||||
new RandomItem(Material.MUSHROOM_SOUP, 15),
|
||||
|
||||
new RandomItem(Material.BAKED_POTATO, 20, 1, 5),
|
||||
new RandomItem(Material.MUSHROOM_SOUP, 20, 1, 1),
|
||||
new RandomItem(Material.COOKED_BEEF, 30, 1, 3),
|
||||
new RandomItem(Material.COOKED_CHICKEN, 30, 1, 3),
|
||||
new RandomItem(Material.COOKED_FISH, 30, 1, 6),
|
||||
new RandomItem(Material.GRILLED_PORK, 20, 1, 3),
|
||||
new RandomItem(Material.BAKED_POTATO, 25, 1, 5),
|
||||
new RandomItem(Material.MUSHROOM_SOUP, 25, 1, 1),
|
||||
new RandomItem(Material.COOKED_BEEF, 35, 1, 3),
|
||||
new RandomItem(Material.COOKED_CHICKEN, 35, 1, 3),
|
||||
new RandomItem(Material.COOKED_FISH, 35, 1, 6),
|
||||
new RandomItem(Material.GRILLED_PORK, 25, 1, 3),
|
||||
new RandomItem(Material.COOKIE, 30),
|
||||
new RandomItem(Material.PUMPKIN_PIE, 20, 1, 3),
|
||||
new RandomItem(Material.APPLE, 20, 2, 6),
|
||||
|
||||
new RandomItem(Material.IRON_INGOT, 30, 1, 2),
|
||||
new RandomItem(Material.DIAMOND, 30)
|
||||
);
|
||||
|
||||
public final static LootTable SUPPLY_DROP = new LootTable(
|
||||
public final static LootTable SUPPLY_DROP = new LootTable(true,
|
||||
new RandomItem(Material.DIAMOND_HELMET, 30),
|
||||
new RandomItem(Material.DIAMOND_LEGGINGS, 27),
|
||||
new RandomItem(Material.DIAMOND_BOOTS, 30),
|
||||
new RandomItem(Material.DIAMOND_SWORD, 16),
|
||||
new RandomItem(Material.DIAMOND_AXE, 24)
|
||||
new RandomItem(Material.DIAMOND_AXE, 24),
|
||||
new RandomItem(Material.GOLDEN_APPLE, 4),
|
||||
new RandomItem(Material.BOW, 4),
|
||||
new RandomItem(Material.ARROW, 2)
|
||||
// new RandomItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, 1, Enchantment.DAMAGE_ALL), 8),
|
||||
// new RandomItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, 1, Enchantment.DAMAGE_ALL), 4),
|
||||
//
|
||||
@ -86,10 +91,26 @@ public class LootTable
|
||||
// new RandomItem(new Potion(PotionType.STRENGTH, 2, false).toItemStack(1), 3)
|
||||
);
|
||||
|
||||
public final static LootTable ALL = new LootTable(BASIC.includes(SUPPLY_DROP));
|
||||
|
||||
private RandomItem[] _items;
|
||||
private boolean _unbreakable;
|
||||
|
||||
private LootTable(LootTable table)
|
||||
{
|
||||
_unbreakable = table.isUnbreakable();
|
||||
_items = table.getItems();
|
||||
}
|
||||
|
||||
private LootTable(RandomItem... items)
|
||||
{
|
||||
_unbreakable = false;
|
||||
_items = items;
|
||||
}
|
||||
|
||||
private LootTable(boolean unbreakable, RandomItem... items)
|
||||
{
|
||||
_unbreakable = unbreakable;
|
||||
_items = items;
|
||||
}
|
||||
|
||||
@ -98,9 +119,14 @@ public class LootTable
|
||||
return _items;
|
||||
}
|
||||
|
||||
public boolean isUnbreakable()
|
||||
{
|
||||
return _unbreakable;
|
||||
}
|
||||
|
||||
public ChestLoot getloot()
|
||||
{
|
||||
ChestLoot loot = new ChestLoot();
|
||||
ChestLoot loot = new ChestLoot(_unbreakable);
|
||||
for (RandomItem item : _items)
|
||||
{
|
||||
loot.addLoot(item);
|
||||
@ -127,6 +153,35 @@ public class LootTable
|
||||
i++;
|
||||
}
|
||||
|
||||
return new LootTable(items);
|
||||
return new LootTable(_unbreakable, items);
|
||||
}
|
||||
|
||||
public LootTable excludes(ArrayList<Material> randomItems)
|
||||
{
|
||||
int size = _items.length - randomItems.size();
|
||||
RandomItem[] items = new RandomItem[size];
|
||||
|
||||
int i = 0;
|
||||
|
||||
for (RandomItem item : _items)
|
||||
{
|
||||
boolean cont = false;
|
||||
|
||||
for (Material other : randomItems)
|
||||
{
|
||||
if (item.getItemStack().getType() == other)
|
||||
{
|
||||
cont = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (cont)
|
||||
continue;
|
||||
|
||||
items[i] = item;
|
||||
i++;
|
||||
}
|
||||
|
||||
return new LootTable(_unbreakable, items);
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,12 @@ import java.util.UUID;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
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.block.Chest;
|
||||
@ -29,12 +31,18 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.avaje.ebeaninternal.server.persist.dml.UpdatePlan;
|
||||
import com.mineplex.anticheat.checks.move.Glide;
|
||||
import com.mineplex.anticheat.checks.move.HeadRoll;
|
||||
import com.mineplex.anticheat.checks.move.Speed;
|
||||
@ -58,7 +66,10 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.loot.ChestLoot;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.titles.tracks.standard.LuckyTrack;
|
||||
import mineplex.core.titles.tracks.standard.UnluckyTrack;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
@ -68,6 +79,7 @@ import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.games.skyfall.kits.KitAeronaught;
|
||||
import nautilus.game.arcade.game.games.skyfall.kits.KitBooster;
|
||||
import nautilus.game.arcade.game.games.skyfall.kits.KitDeadeye;
|
||||
import nautilus.game.arcade.game.games.skyfall.kits.KitJouster;
|
||||
import nautilus.game.arcade.game.games.skyfall.kits.KitSpeeder;
|
||||
@ -89,31 +101,35 @@ import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
|
||||
*/
|
||||
public abstract class Skyfall extends Game
|
||||
{
|
||||
private static final long MAP_CRUMBLE_DELAY = 1000 * 30; // 30 Seconds
|
||||
private static final long CHEST_REFILL_TIME = 1000 * 60 * 3; // 3 minutes
|
||||
private static final long CHEST_REFILL_ANNOUNCE_TIME = 1000 * 60 * 3; // 3 minutes
|
||||
private static final int BIG_ISLAND_BOUNDS = 30;
|
||||
private static final int BIG_ISLAND_HEIGHT = 40;
|
||||
private static final long MAP_CRUMBLE_DELAY = 1000*20; // 2 Minutes
|
||||
private static final long RING_CRUMBLE_DELAY = 1000*60*2; // 2 Minutes
|
||||
private static final long CHEST_REFILL_TIME = 1000*60*3; // 3 minutes
|
||||
private static final long CHEST_REFILL_ANNOUNCE_TIME = 1000*60*3; // 3 minutes
|
||||
private static final long ELYTRA_TAKEAWAY = 1000;
|
||||
private static final int ROT_START = 256;
|
||||
private static final int ROT_Y_OFFSET = 25;
|
||||
|
||||
private static final int ISLAND_CRUMBLE_RATE = 7;
|
||||
private static final int BIG_ISLAND_CRUMBLE_RATE = 5;
|
||||
private static final int BOOSTER_RING_CRUMBLE_RATE = 3;
|
||||
private static final float RING_BOOST_STRENGTH = 2.5F;
|
||||
private static final float BIG_RING_BOOST_STRENGTH = 3.5F;
|
||||
private static final long ISLAND_ROT_TIME = 1000*60*5; // 5 Minutes
|
||||
|
||||
private static final long BOOSTER_COOLDOWN_TIME = 1000 * 20; // 20 Seconds
|
||||
private static final int RING_CRUMBLE_RATE = 10;
|
||||
|
||||
private static final long SUPPLY_DROP_TIME = 1000 * 60 * 5; // 5 Minutes
|
||||
private static final long DEATHMATCH_START_TIME = 1000 * 30; // 30 Seconds
|
||||
private static final long DEATHMATCH_WAIT_TIME = 1000 * 10; // 10 Seconds
|
||||
private static final float RING_BOOST_STRENGTH = 3.25F;
|
||||
private static final float BIG_RING_BOOST_STRENGTH = 4.3F;
|
||||
|
||||
private static final long BOOSTER_COOLDOWN_TIME = 1000*20; // 20 Seconds
|
||||
|
||||
private static final long SUPPLY_DROP_TIME = 1000*60*5; // 5 Minutes
|
||||
private static final long DEATHMATCH_START_TIME = 1000*30; // 30 Seconds
|
||||
private static final long DEATHMATCH_WAIT_TIME = 1000*10; // 10 Seconds
|
||||
|
||||
private static final int TNT_EXPLOSION_RADIUS = 14;
|
||||
|
||||
private static final long EAT_RECHARGE = 500; // 0.5 Second
|
||||
|
||||
private int _islandBounds;
|
||||
private int _islandHeight;
|
||||
private int _islandCrumbleRate;
|
||||
|
||||
private int _bigIslandBounds;
|
||||
private int _bigIslandHeight;
|
||||
|
||||
private Island _upperIsland;
|
||||
private Island _lowerIsland;
|
||||
@ -142,30 +158,34 @@ public abstract class Skyfall extends Game
|
||||
|
||||
private boolean _refillAnnounced;
|
||||
|
||||
private int _currentCrumble = 300;
|
||||
private boolean _supplyOpened;
|
||||
|
||||
private double _rotY;
|
||||
|
||||
//private int _ringCrumbleRate;
|
||||
|
||||
public Skyfall(ArcadeManager manager, GameType type)
|
||||
{
|
||||
super(manager, type,
|
||||
|
||||
new Kit[]
|
||||
{
|
||||
new KitSpeeder(manager),
|
||||
//new KitBooster(manager), // Broken? :(
|
||||
new KitJouster(manager),
|
||||
new KitStunner(manager),
|
||||
//new KitSurefoot(manager),
|
||||
new KitAeronaught(manager),
|
||||
new KitDeadeye(manager)
|
||||
new KitSpeeder(manager),
|
||||
new KitBooster(manager), // Broken? :(
|
||||
new KitJouster(manager),
|
||||
new KitStunner(manager),
|
||||
//new KitSurefoot(manager),
|
||||
new KitAeronaught(manager),
|
||||
new KitDeadeye(manager)
|
||||
},
|
||||
|
||||
new String[]
|
||||
{
|
||||
"Fly with your Elytra",
|
||||
"Try to land on Islands",
|
||||
"Get your gear from chests"
|
||||
});
|
||||
new String[]
|
||||
{
|
||||
"Fly with your Elytra",
|
||||
"Try to land on Islands",
|
||||
"Get your gear from chests"
|
||||
});
|
||||
|
||||
|
||||
|
||||
registerStatTrackers(new WinWithoutWearingArmorStatTracker(this),
|
||||
@ -183,7 +203,7 @@ public abstract class Skyfall extends Game
|
||||
BlankLine
|
||||
);
|
||||
|
||||
new VersionModule(MinecraftVersion.Version1_9).register(this);
|
||||
registerModule(new VersionModule(MinecraftVersion.Version1_9));
|
||||
|
||||
// Disable specific GWEN checks for this game
|
||||
AntiHack antiHack = Managers.get(AntiHack.class);
|
||||
@ -216,13 +236,54 @@ public abstract class Skyfall extends Game
|
||||
StrictAntiHack = false;
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompassToAlive(true)
|
||||
.register(this);
|
||||
.setGiveCompassToAlive(true)
|
||||
.register(this);
|
||||
|
||||
SpeedMeasurement = true;
|
||||
|
||||
_islandBounds = 25;
|
||||
_islandHeight = 15;
|
||||
_bigIslandBounds = 25;
|
||||
_bigIslandHeight = 15;
|
||||
|
||||
_rotY = ROT_START;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void testCommands(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if(GetState() != GameState.Live)
|
||||
return;
|
||||
|
||||
if (!UtilServer.isTestServer())
|
||||
return;
|
||||
|
||||
if(event.getMessage().contains("/Rate"))
|
||||
{
|
||||
int rate = Integer.parseInt(event.getMessage().split(" ")[1]);
|
||||
_islandCrumbleRate = rate;
|
||||
UtilPlayer.message(event.getPlayer(), "Crumble rate changed to " + rate);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getMessage().contains("/Rot"))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), "Current Rot value " + _rotY);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getMessage().contains("/Boost"))
|
||||
{
|
||||
float rate = Float.parseFloat(event.getMessage().split(" ")[1]);
|
||||
for (BoosterRing ring : _boosterRings)
|
||||
{
|
||||
ring.setBoostStrength(rate);
|
||||
}
|
||||
UtilPlayer.message(event.getPlayer(), "Boost changed to " + rate);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -268,10 +329,9 @@ public abstract class Skyfall extends Game
|
||||
_chestsRefilled = System.currentTimeMillis();
|
||||
_refillAnnounced = false;
|
||||
|
||||
_upperIsland.refillChests();
|
||||
_lowerIsland.refillChests();
|
||||
|
||||
Announce(ChatColor.AQUA + "" + ChatColor.BOLD + "Chests on the middle Islands have been refilled!", true);
|
||||
Announce(ChatColor.AQUA + "" + ChatColor.BOLD + "Chests on the lower middle Island have been refilled!", true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -347,7 +407,7 @@ public abstract class Skyfall extends Game
|
||||
if (UtilPlayer.isGliding(player))
|
||||
continue;
|
||||
|
||||
if (UtilMath.offset(player.getLocation(), ring.getMiddle()) > (ring.getSize() / 2))
|
||||
if (UtilMath.offset(player.getLocation(), ring.getMiddle()) > (ring.getSize()/2))
|
||||
continue;
|
||||
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 1, false, false, true, "Island Rot", "Island Rot");
|
||||
@ -355,63 +415,102 @@ public abstract class Skyfall extends Game
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void lowerRot(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC_05)
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (_rotY <= (0 - ROT_Y_OFFSET))
|
||||
return;
|
||||
|
||||
long startTime = GetStateTime() + MAP_CRUMBLE_DELAY;
|
||||
//System.out.println("starttime " + startTime);
|
||||
double current = System.currentTimeMillis() - startTime;
|
||||
//System.out.println("current " + current);
|
||||
|
||||
double percentage = current/((double) ISLAND_ROT_TIME);
|
||||
//System.out.println("precentage " + percentage);
|
||||
double value = ROT_START * percentage;
|
||||
//System.out.println("value " + value);
|
||||
|
||||
_rotY = (ROT_START - value);
|
||||
}
|
||||
|
||||
public ArrayList<Island> islandCrumble()
|
||||
{
|
||||
ArrayList<Island> islands = new ArrayList<>();
|
||||
|
||||
|
||||
for (Island island : _islands.get(_upperIsland).keySet())
|
||||
{
|
||||
if (island.crumblePercentage() <= 0.5)
|
||||
if (island.isCrumbledAway())
|
||||
islands.add(island);
|
||||
|
||||
Material[] mats = new Material[]{Material.COAL_BLOCK, Material.ENDER_STONE};
|
||||
if (island.getLocation().getBlockY() >= GetTeamList().get(0).GetSpawns().get(0).getBlockY())
|
||||
mats = new Material[]{Material.AIR};
|
||||
if (island.getLocation().getBlockY() < (_rotY + ROT_Y_OFFSET))
|
||||
continue;
|
||||
|
||||
if (!island.crumble(ISLAND_CRUMBLE_RATE, mats))
|
||||
{
|
||||
return islands;
|
||||
}
|
||||
island.crumble(_islandCrumbleRate, Material.COAL_BLOCK, Material.ENDER_STONE);
|
||||
}
|
||||
if (_upperIsland.crumblePercentage() <= 0.5)
|
||||
|
||||
|
||||
if (_upperIsland.isCrumbledAway())
|
||||
islands.add(_upperIsland);
|
||||
|
||||
if (!_upperIsland.crumble(BIG_ISLAND_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
|
||||
if (_upperIsland.getLocation().getBlockY() > (_rotY + ROT_Y_OFFSET))
|
||||
{
|
||||
_currentCrumble = _upperIsland.getLocation().getBlockY();
|
||||
return islands;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (!_upperIsland.getBoosterRing().isCrumbledAway())
|
||||
if (_upperIsland.crumble(_islandCrumbleRate, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
{
|
||||
_upperIsland.getBoosterRing().crumble(BOOSTER_RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE);
|
||||
while (!_upperIsland.getBoosterRing().isCrumbledAway())
|
||||
{
|
||||
_upperIsland.getBoosterRing().crumble(RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (Island island : _islands.get(_lowerIsland).keySet())
|
||||
{
|
||||
if (island.crumblePercentage() <= 0.5)
|
||||
if (island.isCrumbledAway())
|
||||
islands.add(island);
|
||||
|
||||
if (!island.crumble(ISLAND_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
{
|
||||
return islands;
|
||||
}
|
||||
if (island.getLocation().getBlockY() < (_rotY + ROT_Y_OFFSET))
|
||||
continue;
|
||||
|
||||
island.crumble(_islandCrumbleRate, Material.COAL_BLOCK, Material.ENDER_STONE);
|
||||
}
|
||||
if (_lowerIsland.crumblePercentage() <= 0.5)
|
||||
|
||||
|
||||
if (_lowerIsland.isCrumbledAway())
|
||||
islands.add(_lowerIsland);
|
||||
|
||||
_currentCrumble = _lowerIsland.getLocation().getBlockY();
|
||||
if (_lowerIsland.crumble(BIG_ISLAND_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
if (_lowerIsland.getLocation().getBlockY() > (_rotY + ROT_Y_OFFSET))
|
||||
{
|
||||
while (!_lowerIsland.getBoosterRing().isCrumbledAway())
|
||||
if (_lowerIsland.crumble(_islandCrumbleRate, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
{
|
||||
_lowerIsland.getBoosterRing().crumble(BOOSTER_RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE);
|
||||
while (!_lowerIsland.getBoosterRing().isCrumbledAway())
|
||||
{
|
||||
_lowerIsland.getBoosterRing().crumble(RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE);
|
||||
}
|
||||
}
|
||||
_currentCrumble = 0;
|
||||
}
|
||||
return islands;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableAC(PlayerTeleportEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (event.getCause() == TeleportCause.UNKNOWN)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
//@EventHandler
|
||||
public void deathMatch(UpdateEvent event)
|
||||
{
|
||||
@ -444,7 +543,7 @@ public abstract class Skyfall extends Game
|
||||
if (!_deathMatchStarted)
|
||||
{
|
||||
long time = (_deathMatchStartTime + DEATHMATCH_START_TIME + DEATHMATCH_WAIT_TIME) - System.currentTimeMillis();
|
||||
int real = Math.round(time / 1000) + 1;
|
||||
int real = Math.round(time/1000) + 1;
|
||||
|
||||
Announce(C.cRed + C.Bold + "Deathmatch is starting in " + real + "...", false);
|
||||
}
|
||||
@ -480,16 +579,41 @@ public abstract class Skyfall extends Game
|
||||
@EventHandler
|
||||
public void ringCrumble(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for (BoosterRing ring : _boosterRings)
|
||||
{
|
||||
if (ring.getMiddle().getBlockY() < _currentCrumble)
|
||||
if (ring == _upperIsland.getBoosterRing() || ring == _lowerIsland.getBoosterRing())
|
||||
continue;
|
||||
|
||||
if (!ring.crumble(BOOSTER_RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
if (!UtilTime.elapsed(GetStateTime(), RING_CRUMBLE_DELAY))
|
||||
return;
|
||||
|
||||
if (ring.getMiddle().getBlockY() > (_upperIsland.getLocation().getBlockY() - (_upperIsland.getHeight()*2)))
|
||||
{
|
||||
if (!ring.crumble(RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!UtilTime.elapsed(GetStateTime(), (RING_CRUMBLE_DELAY*2)))
|
||||
continue;
|
||||
|
||||
if (ring.getMiddle().getBlockY() > (_lowerIsland.getLocation().getBlockY() - (_lowerIsland.getHeight()*2)))
|
||||
{
|
||||
if (!ring.crumble(RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!UtilTime.elapsed(GetStateTime(), (RING_CRUMBLE_DELAY*3)))
|
||||
continue;
|
||||
|
||||
if (!ring.crumble(RING_CRUMBLE_RATE, Material.COAL_BLOCK, Material.ENDER_STONE))
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -556,9 +680,44 @@ public abstract class Skyfall extends Game
|
||||
block.setType(Material.CHEST);
|
||||
|
||||
Chest chest = (Chest) block.getState();
|
||||
for (int i = 0; i < UtilMath.rRange(5, 8); i++)
|
||||
ChestLoot loot = LootTable.SUPPLY_DROP.getloot();
|
||||
ArrayList<Material> exclude = new ArrayList<>();
|
||||
for (int i = 0; i < UtilMath.rRange(3, 5); i++)
|
||||
{
|
||||
chest.getInventory().setItem(UtilMath.r(27), LootTable.SUPPLY_DROP.getloot().getLoot());
|
||||
int slot = UtilMath.r(26);
|
||||
ItemStack item = loot.getLoot(exclude);
|
||||
Inventory inventory = chest.getInventory();
|
||||
inventory.setItem(slot, item);
|
||||
if (item.getType() == Material.BOW)
|
||||
{
|
||||
inventory.setItem(slot + 1, new ItemStack(Material.ARROW, UtilMath.r(6) + 1));
|
||||
}
|
||||
if (UtilItem.isHelmet(item))
|
||||
{
|
||||
exclude.add(Material.DIAMOND_HELMET);
|
||||
}
|
||||
if (UtilItem.isChestplate(item))
|
||||
{
|
||||
exclude.add(Material.DIAMOND_CHESTPLATE);
|
||||
}
|
||||
if (UtilItem.isLeggings(item))
|
||||
{
|
||||
exclude.add(Material.DIAMOND_LEGGINGS);
|
||||
}
|
||||
if (UtilItem.isBoots(item))
|
||||
{
|
||||
exclude.add(Material.DIAMOND_BOOTS);
|
||||
}
|
||||
if (UtilItem.isSword(item))
|
||||
{
|
||||
exclude.add(Material.DIAMOND_SWORD);
|
||||
}
|
||||
if (UtilItem.isAxe(item))
|
||||
{
|
||||
exclude.add(Material.DIAMOND_AXE);
|
||||
}
|
||||
if (item.getType() == Material.BOW)
|
||||
exclude.add(Material.BOW);
|
||||
}
|
||||
_supplyDropOver = true;
|
||||
}
|
||||
@ -570,6 +729,9 @@ public abstract class Skyfall extends Game
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (!IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
@ -593,11 +755,17 @@ public abstract class Skyfall extends Game
|
||||
Island island = getCurrentIsland(event.getPlayer());
|
||||
if (island == null)
|
||||
{
|
||||
_upperIsland.fillLoot(event.getClickedBlock(), event.getPlayer(), getArcadeManager());
|
||||
_upperIsland.fillLoot(event.getClickedBlock());
|
||||
return;
|
||||
}
|
||||
|
||||
island.fillLoot(event.getClickedBlock(), event.getPlayer(), getArcadeManager());
|
||||
island.fillLoot(event.getClickedBlock());
|
||||
|
||||
if (event.getPlayer() != null && Manager != null && Manager.GetServerConfig().RewardStats)
|
||||
{
|
||||
Manager.getTrackManager().getTrack(LuckyTrack.class).handleLoot(event.getPlayer(), ((Chest) event.getClickedBlock().getState()).getBlockInventory());
|
||||
Manager.getTrackManager().getTrack(UnluckyTrack.class).handleLoot(event.getPlayer(), ((Chest) event.getClickedBlock().getState()).getBlockInventory());
|
||||
}
|
||||
}
|
||||
|
||||
// I have no clue why, but this is fixing all food issues
|
||||
@ -675,21 +843,21 @@ public abstract class Skyfall extends Game
|
||||
_supplyDrop = WorldData.GetDataLocs("PINK").get(0);
|
||||
_deathMatchSpawns = (ArrayList<Location>) WorldData.GetDataLocs("BROWN").clone();
|
||||
|
||||
_upperIsland = new Island(WorldData.GetDataLocs("GREEN").get(0), LootTable.BASIC, BIG_ISLAND_BOUNDS, BIG_ISLAND_HEIGHT);
|
||||
_lowerIsland = new Island(WorldData.GetDataLocs("YELLOW").get(0), LootTable.BASIC, BIG_ISLAND_BOUNDS, BIG_ISLAND_HEIGHT);
|
||||
|
||||
for (String name : WorldData.GetAllCustomLocs().keySet())
|
||||
{
|
||||
if (name.split(" ")[0].equalsIgnoreCase("HEIGHT"))
|
||||
if (name.split(" ")[0].equalsIgnoreCase("BIG_HEIGHT"))
|
||||
{
|
||||
_islandHeight = Integer.parseInt(name.split(" ")[1]);
|
||||
_bigIslandHeight = Integer.parseInt(name.split(" ")[1]);
|
||||
}
|
||||
else if (name.split(" ")[0].equalsIgnoreCase("BOUNDS"))
|
||||
else if (name.split(" ")[0].equalsIgnoreCase("BIG_BOUNDS"))
|
||||
{
|
||||
_islandBounds = Integer.parseInt(name.split(" ")[1]);
|
||||
_bigIslandBounds = Integer.parseInt(name.split(" ")[1]);
|
||||
}
|
||||
}
|
||||
|
||||
_upperIsland = new Island(WorldData.GetDataLocs("GREEN").get(0), LootTable.BASIC, _bigIslandBounds, _bigIslandHeight);
|
||||
_lowerIsland = new Island(WorldData.GetDataLocs("YELLOW").get(0), LootTable.BASIC, _bigIslandBounds, _bigIslandHeight);
|
||||
|
||||
registerIslands();
|
||||
registerBoosters();
|
||||
|
||||
@ -699,7 +867,8 @@ public abstract class Skyfall extends Game
|
||||
@EventHandler
|
||||
public void ringBoost(PlayerBoostRingEvent event)
|
||||
{
|
||||
event.getRing().disable(BOOSTER_COOLDOWN_TIME, Material.STAINED_CLAY, (byte) 14, true);
|
||||
if (IsAlive(event.getPlayer()))
|
||||
event.getRing().disable(BOOSTER_COOLDOWN_TIME, Material.STAINED_CLAY, (byte) 14, true);
|
||||
}
|
||||
|
||||
public void registerBoosters()
|
||||
@ -731,17 +900,58 @@ public abstract class Skyfall extends Game
|
||||
HashMap<Island, Integer> upperIslandMap = new HashMap<>();
|
||||
HashMap<Island, Integer> lowerIslandMap = new HashMap<>();
|
||||
|
||||
ArrayList<Location> islands = WorldData.GetDataLocs("RED");
|
||||
|
||||
for (Location islandMid : islands)
|
||||
for (String string : WorldData.GetAllDataLocs().keySet())
|
||||
{
|
||||
if (islandMid.getBlockY() >= _lowerIsland.getLocation().getBlockY())
|
||||
if (string.equalsIgnoreCase("ORANGE") ||
|
||||
string.equalsIgnoreCase("PINK") ||
|
||||
string.equalsIgnoreCase("BROWN") ||
|
||||
string.equalsIgnoreCase("GREEN") ||
|
||||
string.equalsIgnoreCase("YELLOW"))
|
||||
continue;
|
||||
|
||||
ArrayList<Location> islands = WorldData.GetDataLocs(string);
|
||||
|
||||
int islandHeight = _bigIslandHeight;
|
||||
int islandBounds = _bigIslandBounds;
|
||||
String loot = "BASIC";
|
||||
|
||||
for (String name : WorldData.GetAllCustomLocs().keySet())
|
||||
{
|
||||
upperIslandMap.put(new Island(islandMid, LootTable.BASIC, _islandBounds, _islandHeight), islandMid.getBlockY());
|
||||
if (name.split(" ")[0].equalsIgnoreCase(string))
|
||||
{
|
||||
if (name.split(" ")[1].equalsIgnoreCase("H"))
|
||||
{
|
||||
islandHeight = Integer.parseInt(name.split(" ")[2]);
|
||||
}
|
||||
if (name.split(" ")[1].equalsIgnoreCase("B"))
|
||||
{
|
||||
islandBounds = Integer.parseInt(name.split(" ")[2]);
|
||||
}
|
||||
if (name.split(" ")[1].equalsIgnoreCase("L"))
|
||||
{
|
||||
islandBounds = Integer.parseInt(name.split(" ")[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
for (Location islandMid : islands)
|
||||
{
|
||||
lowerIslandMap.put(new Island(islandMid, LootTable.BASIC, _islandBounds, _islandHeight), islandMid.getBlockY());
|
||||
try
|
||||
{
|
||||
if (islandMid.getBlockY() >= _lowerIsland.getLocation().getBlockY())
|
||||
{
|
||||
upperIslandMap.put(new Island(islandMid, (LootTable) LootTable.class.getField(loot).get(null), islandBounds, islandHeight), islandMid.getBlockY());
|
||||
}
|
||||
else
|
||||
{
|
||||
lowerIslandMap.put(new Island(islandMid, (LootTable) LootTable.class.getField(loot).get(null), islandBounds, islandHeight), islandMid.getBlockY());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -753,6 +963,26 @@ public abstract class Skyfall extends Game
|
||||
|
||||
_islands.put(_lowerIsland, new TreeMap<>(lowerSorter));
|
||||
_islands.get(_lowerIsland).putAll(lowerIslandMap);
|
||||
|
||||
int blocks = 0;
|
||||
|
||||
for (Island island : _islands.get(_upperIsland).keySet())
|
||||
blocks += island.getRealBlocks().size();
|
||||
|
||||
for (Island island : _islands.get(_lowerIsland).keySet())
|
||||
blocks += island.getRealBlocks().size();
|
||||
|
||||
blocks += _upperIsland.getRealBlocks().size();
|
||||
blocks += _lowerIsland.getRealBlocks().size();
|
||||
|
||||
|
||||
int ticks = (int) (((ISLAND_ROT_TIME / 1000) *20) / 3);
|
||||
_islandCrumbleRate = blocks / ticks;
|
||||
|
||||
if (_islandCrumbleRate < 1)
|
||||
_islandCrumbleRate = 1;
|
||||
|
||||
_islandCrumbleRate = _islandCrumbleRate * 3;
|
||||
}
|
||||
|
||||
public Island getCurrentIsland(Player player)
|
||||
@ -771,7 +1001,7 @@ public abstract class Skyfall extends Game
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void elytraDrop(PlayerDeathEvent event)
|
||||
{
|
||||
Iterator<ItemStack> itemIterator = event.getDrops().iterator();
|
||||
@ -903,7 +1133,13 @@ public abstract class Skyfall extends Game
|
||||
Player player = _tntMap.remove(event.getEntity());
|
||||
|
||||
for (Player other : UtilPlayer.getNearby(event.getEntity().getLocation(), TNT_EXPLOSION_RADIUS))
|
||||
{
|
||||
Manager.GetCondition().Factory().Explosion("Throwing TNT", other, player, 50, 0.1, false, false);
|
||||
Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.ENTITY_EXPLOSION, 6, true, true, true, player.getName(), "Throwing TNT");
|
||||
}
|
||||
|
||||
event.getEntity().getLocation().getWorld().playEffect(event.getEntity().getLocation(), Effect.EXPLOSION_LARGE, 100);
|
||||
event.getEntity().getLocation().getWorld().playSound(event.getEntity().getLocation(), Sound.EXPLODE, 100, 1);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -987,7 +1223,7 @@ public abstract class Skyfall extends Game
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 8 ||
|
||||
player.getLocation().getBlock().getTypeId() == 9 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 9)
|
||||
player.getLocation().getBlock().getTypeId() == 9 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 9)
|
||||
{
|
||||
Recharge.Instance.useForce(player, "Elytra Removal", ELYTRA_TAKEAWAY, true);
|
||||
_disabledElytras.put(player.getUniqueId(), System.currentTimeMillis() + ELYTRA_TAKEAWAY);
|
||||
@ -1011,20 +1247,44 @@ public abstract class Skyfall extends Game
|
||||
if (System.currentTimeMillis() > _disabledElytras.get(player.getUniqueId()))
|
||||
{
|
||||
player.getInventory().setChestplate(new ItemStack(Material.ELYTRA));
|
||||
_disabledElytras.remove(player.getUniqueId());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.getInventory().getChestplate() != null)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Game", C.cRed + "Your Elytra is disabled!"));
|
||||
player.getInventory().setChestplate(null);
|
||||
}
|
||||
player.getInventory().setChestplate(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateSpecs(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (!IsAlive(player))
|
||||
player.getInventory().setChestplate(new ItemStack(Material.ELYTRA));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void craftedItems(CraftItemEvent event)
|
||||
{
|
||||
if (UtilItem.isWeapon(event.getCurrentItem()) || UtilItem.isArmor(event.getCurrentItem()))
|
||||
{
|
||||
UtilItem.makeUnbreakable(event.getCurrentItem());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDeathMatch()
|
||||
{
|
||||
return _deathmatch;
|
||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.skyfall;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
@ -25,6 +26,7 @@ import nautilus.game.arcade.game.modules.TeamModule;
|
||||
*/
|
||||
public class TeamSkyfall extends Skyfall
|
||||
{
|
||||
private static final long BOOSTER_COOLDOWN_TIME = 1000*20; // 20 Seconds
|
||||
|
||||
public TeamSkyfall(ArcadeManager manager)
|
||||
{
|
||||
@ -34,7 +36,6 @@ public class TeamSkyfall extends Skyfall
|
||||
FillTeamsInOrderToCount = 2;
|
||||
|
||||
SpawnNearAllies = true;
|
||||
SpawnNearEnemies = true;
|
||||
|
||||
DamageTeamSelf = false;
|
||||
|
||||
@ -156,6 +157,14 @@ public class TeamSkyfall extends Skyfall
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@Override
|
||||
public void ringBoost(PlayerBoostRingEvent event)
|
||||
{
|
||||
if (IsAlive(event.getPlayer()))
|
||||
event.getRing().disableLater(3000, BOOSTER_COOLDOWN_TIME, Material.STAINED_CLAY, (byte) 14, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getWinners()
|
||||
{
|
||||
|
@ -92,13 +92,12 @@ public class PerkElytraBoost extends Perk
|
||||
while (i < 10 && !UtilPlayer.isGliding(player))
|
||||
{
|
||||
UtilPlayer.setGliding(player, true);
|
||||
|
||||
Vector vec = player.getEyeLocation().getDirection();
|
||||
UtilAction.velocity(player, vec.multiply(2.5));
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
Vector vec = player.getEyeLocation().getDirection();
|
||||
UtilAction.velocity(player, vec.multiply(2.5));
|
||||
|
||||
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL_LARGE, Color.BLUE, true, false);
|
||||
}
|
||||
}, 4);
|
||||
|
@ -29,6 +29,9 @@ public class RingStatTracker extends StatTracker<Game>
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (!getGame().IsAlive(event.getPlayer()))
|
||||
return;
|
||||
|
||||
addStat(event.getPlayer(), "Rings", 1, false, false);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user