From a5a80378f708d6d1cd553e86722b4b730d78569f Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 23 Nov 2013 09:15:13 +1100 Subject: [PATCH] Loot fixes --- .../mineplex/core/common/util/UtilWorld.java | 26 ++++++++++++++++ .../game/games/hungergames/HungerGames.java | 31 ++++++++++++++++--- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java index 717534c66..af3aa4f91 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilWorld.java @@ -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 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); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java index fbc8a0eaf..286cf3fde 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hungergames/HungerGames.java @@ -77,6 +77,7 @@ public class HungerGames extends SoloGame //Misc private HashMap _tntMap = new HashMap(); private HashSet _placedBlocks = new HashSet(); + 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); + } }