Loot fixes
This commit is contained in:
parent
3d13fb0dc9
commit
a5a80378f7
|
@ -1,10 +1,13 @@
|
|||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class UtilWorld
|
||||
{
|
||||
|
@ -111,4 +114,27 @@ public class UtilWorld
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Location averageLocation(Collection<Location> locs)
|
||||
{
|
||||
if (locs.isEmpty())
|
||||
return null;
|
||||
|
||||
Vector vec = new Vector(0,0,0);
|
||||
double count = 0;
|
||||
|
||||
World world = null;
|
||||
|
||||
for (Location spawn : locs)
|
||||
{
|
||||
count++;
|
||||
vec.add(spawn.toVector());
|
||||
|
||||
world = spawn.getWorld();
|
||||
}
|
||||
|
||||
vec.multiply(1d/count);
|
||||
|
||||
return vec.toLocation(world);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ public class HungerGames extends SoloGame
|
|||
//Misc
|
||||
private HashMap<Entity, Player> _tntMap = new HashMap<Entity, Player>();
|
||||
private HashSet<Location> _placedBlocks = new HashSet<Location>();
|
||||
private Location _spawn;
|
||||
|
||||
//Creep
|
||||
private int _maxSpreadRate = 60;
|
||||
|
@ -213,6 +214,8 @@ public class HungerGames extends SoloGame
|
|||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
_spawn = UtilWorld.averageLocation(this.GetTeamList().get(0).GetSpawns());
|
||||
|
||||
CreateChestCraftEnchant();
|
||||
|
||||
_supplyLocations = WorldData.GetDataLocs("WHITE");
|
||||
|
@ -251,13 +254,13 @@ public class HungerGames extends SoloGame
|
|||
{
|
||||
Location loc = chests.remove(UtilMath.r(chests.size()));
|
||||
|
||||
if (UtilMath.offset2d(loc, GetSpectatorLocation()) < 10)
|
||||
if (UtilMath.offset2d(loc, _spawn) < 8)
|
||||
spawn++;
|
||||
}
|
||||
|
||||
for (Location loc : chests)
|
||||
{
|
||||
if (spawn < 10 && UtilMath.offset2d(loc, GetSpectatorLocation()) < 10)
|
||||
if (spawn < 10 && UtilMath.offset(loc, _spawn) < 8)
|
||||
{
|
||||
spawn++;
|
||||
continue;
|
||||
|
@ -322,9 +325,8 @@ public class HungerGames extends SoloGame
|
|||
if (Math.random() > 0.80) count++;
|
||||
if (Math.random() > 0.95) count++;
|
||||
|
||||
Announce("Offset from Spec: " + UtilMath.offset2d(chest.getLocation(), GetSpectatorLocation()));
|
||||
if (UtilMath.offset2d(chest.getLocation(), GetSpectatorLocation()) < 10)
|
||||
count += 2;
|
||||
if (UtilMath.offset(chest.getLocation(), _spawn) < 8)
|
||||
count += 3;
|
||||
|
||||
if (GetKit(event.getPlayer()) instanceof KitLooter)
|
||||
{
|
||||
|
@ -1123,4 +1125,23 @@ public class HungerGames extends SoloGame
|
|||
|
||||
killer.giveExpLevels(1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void DisableDamageLevel(CustomDamageEvent event)
|
||||
{
|
||||
event.SetDamageToLevel(false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Firework(UpdateEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.YELLOW).with(Type.BALL).trail(false).build();
|
||||
UtilFirework.playFirework(GetSpectatorLocation(), effect);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue