Merge pull request #165 in MIN/mineplex from virizion_speed_builder to develop

* commit '51d152d48473f820ab6d03586fb41f890750f645':
  Perfect build all fix
  Only eliminated players are guardians. Broken blocks/mobs go directly into inventory.
  Stop mid game joiners from getting participation gems.
  Mob egg baby fix. Also fixed non build entities from being "broken"
  spec command add guardian
  The infamous look direction bounce bug
  Chiss' double jump mechanic
  Moar fixes
  Hopper item pickup fix.
This commit is contained in:
Shaun Bennett 2016-02-11 22:59:35 -06:00
commit 2eeddb828b
5 changed files with 176 additions and 110 deletions

View File

@ -1408,6 +1408,11 @@ public class UtilBlock
case ANVIL:
itemStack.setDurability((short) (itemStack.getDurability() / 4));
break;
case QUARTZ_BLOCK:
if (itemStack.getDurability() == 4 || itemStack.getDurability() == 3)
itemStack.setDurability((short) 2);
break;
}
return itemStacks;

View File

@ -241,7 +241,7 @@ public class Explosion extends MiniPlugin
}
Block block = cur.getLocation().getBlock();
block.setTypeIdAndData(0, (byte)0, true);
//block.setTypeIdAndData(0, (byte)0, true);
//Block Replace
if (_enableDebris)

View File

@ -5,6 +5,52 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ItemMergeEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.material.Bed;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -45,52 +91,8 @@ import nautilus.game.arcade.game.games.speedbuilders.stattrackers.SpeediestBuild
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.stats.BlockPlaceStatTracker;
import net.minecraft.server.v1_8_R3.PacketPlayOutGameStateChange;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ItemMergeEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.material.Bed;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
public class SpeedBuilders extends SoloGame
{
private static final String GUARDIAN_NAME = "Gwen the Guardian";
@ -431,10 +433,10 @@ public class SpeedBuilders extends SoloGame
EndCheck();
}
@EventHandler(priority = EventPriority.MONITOR)
public void teamGen(GameStateChangeEvent event)
@EventHandler(priority = EventPriority.LOWEST)
public void onPrepare(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Live)
if (event.GetState() != GameState.Prepare)
return;
//Add 1 spawn so it doesn't freak out
@ -444,13 +446,6 @@ public class SpeedBuilders extends SoloGame
GameTeam guardians = new GameTeam(this, "Guardians", ChatColor.GRAY, spawns);
AddTeam(guardians);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPrepare(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
return;
spawnJudge();
//GUARDIAN LAZORZ WILL ROXORZ YOUR BOXORZ
@ -461,19 +456,21 @@ public class SpeedBuilders extends SoloGame
{
if (i >= WorldData.GetDataLocs("YELLOW").size())
{
Manager.addSpectator(players.get(i), true);
GetTeamList().get(0).RemovePlayer(players.get(i));
Manager.addSpectator(players.get(i), true);
}
}
}
@EventHandler
public void onLive(GameStateChangeEvent event)
{
if (!IsLive())
return;
if (WorldData.GetDataLocs("YELLOW").size() < GetPlayers(true).size())
if (WorldData.GetDataLocs("YELLOW").size() < GetTeamList().get(0).GetPlayers(true).size())
{
Announce(C.Bold + "Too many players...");
SetState(GameState.End);
@ -491,7 +488,7 @@ public class SpeedBuilders extends SoloGame
HashSet<Location> usedBuildLocs = new HashSet<Location>();
for (Player player : GetPlayers(true))
for (Player player : GetTeamList().get(0).GetPlayers(true))
{
Location buildLoc = UtilAlg.findClosest(player.getLocation(), WorldData.GetDataLocs("YELLOW"));
Location spawnLoc = UtilAlg.findClosest(buildLoc, GetTeamList().get(0).GetSpawns());
@ -648,7 +645,7 @@ public class SpeedBuilders extends SoloGame
_perfectBuild.put(player, System.currentTimeMillis());
if (_perfectBuild.size() == GetTeamList().get(0).GetPlayers(false).size())
if (_perfectBuild.size() == _buildRecreations.size())
{
// Everyone has a perfect build
_allPerfect = true;
@ -734,12 +731,20 @@ public class SpeedBuilders extends SoloGame
{
for (RecreationData recreation : _buildRecreations.values())
{
Vector vec = player.getLocation().getDirection().multiply(-1);
Vector vec = UtilAlg.getTrajectory(recreation.getMidpoint(), player.getLocation());
if (UtilMath.offsetSquared(player.getLocation(), recreation.getMidpoint()) < 64)
{
Location tpLoc = recreation.getMidpoint().add(vec.clone().multiply(8));
tpLoc.setDirection(player.getLocation().getDirection());
//First tp out this combats hacked clients with anti-KB
player.teleport(tpLoc);
//Then apply velocity as normal
UtilAction.velocity(player, vec, 1.8, false, 0, 0.4, vec.length(), false);
player.playSound(player.getEyeLocation(), Sound.NOTE_PLING, 10F, 0.5F);
UtilAction.velocity(player, vec, 1.6, false, 0, 0.4, vec.length(), false);
}
}
}
@ -1219,9 +1224,34 @@ public class SpeedBuilders extends SoloGame
if (!_buildRecreations.get(player).inBuildArea(event.getEntity().getLocation()))
return;
boolean hasMobType = false;
for (MobData mobData : _currentBuild.Mobs)
{
if (mobData.EntityType == event.getEntityType())
{
hasMobType = true;
break;
}
}
if (!hasMobType)
return;
_buildRecreations.get(player).addToDemolition(event.getEntity());
}
@EventHandler
public void stopBabyEgg(PlayerInteractEntityEvent event)
{
if (!IsLive())
return;
if (event.getPlayer().getItemInHand().getType() == Material.MONSTER_EGG)
event.setCancelled(true);
}
@EventHandler
public void updateDemolitionBlocks(UpdateEvent event)
{
@ -1393,6 +1423,9 @@ public class SpeedBuilders extends SoloGame
if (!IsLive())
return;
// Falling blocks disappear for some reason so we update to make it reappear
event.getBlock().getState().update(true, false);
event.setCancelled(true);
}
@ -1453,6 +1486,18 @@ public class SpeedBuilders extends SoloGame
@EventHandler
public void stopPhysics(BlockPhysicsEvent event)
{
if (!IsLive())
return;
if (event.getBlock().isLiquid())
return;
event.setCancelled(true);
}
@EventHandler
public void stopInventoryPickup(InventoryPickupItemEvent event)
{
if (!IsLive())
return;
@ -1567,34 +1612,6 @@ public class SpeedBuilders extends SoloGame
event.setCancelled(true);
}
//Add to guardians before arcade manager adds to spectator to trick it into thinking the player is "alive"
@EventHandler(priority = EventPriority.LOW)
public void joinAddGuardian(PlayerJoinEvent event)
{
if (!InProgress())
return;
moveToGuardians(event.getPlayer(), false);
event.getPlayer().teleport(GetSpectatorLocation());
//We need to disguise a tick after
Manager.runSyncLater(new Runnable()
{
@Override
public void run()
{
DisguiseGuardian disguise = new DisguiseGuardian(event.getPlayer());
disguise.setName(C.cGray + event.getPlayer().getName());
disguise.setCustomNameVisible(true);
Manager.GetDisguise().disguise(disguise);
event.getPlayer().setAllowFlight(true);
event.getPlayer().setFlying(true);
}
}, 1);
}
@EventHandler
public void setNextBuild(PlayerCommandPreprocessEvent event)
{
@ -1637,6 +1654,37 @@ public class SpeedBuilders extends SoloGame
}
}
@EventHandler
public void moveSetFlight(PlayerMoveEvent event)
{
if (!IsLive())
return;
if (_state != SpeedBuildersState.BUILDING)
return;
if (!GetTeamList().get(0).HasPlayer(event.getPlayer()))
return;
if (UtilEnt.isGrounded(event.getPlayer()) && !event.getPlayer().isFlying())
event.getPlayer().setAllowFlight(true);
}
@EventHandler
public void flightToggleJump(PlayerToggleFlightEvent event)
{
if (!GetTeamList().get(0).HasPlayer(event.getPlayer()))
return;
event.setCancelled(true);
event.getPlayer().setAllowFlight(false);
event.getPlayer().playSound(event.getPlayer().getEyeLocation(), Sound.GHAST_FIREBALL, 1f, 1f);
UtilAction.velocity(event.getPlayer(), new Vector(0, 1, 0));
}
@Override
public void EndCheck()
{
@ -1662,7 +1710,17 @@ public class SpeedBuilders extends SoloGame
if (places.size() >= 3)
AddGems(places.get(2), 10, "3rd Place", false, false);
for (Player player : GetPlayers(false))
ArrayList<Player> participants = new ArrayList<Player>();
ArrayList<Player> guardians = GetTeamList().get(1).GetPlayers(false);
participants.addAll(playersTeam.GetPlayers(true));
guardians.retainAll(playersTeam.GetPlacements(true));
participants.addAll(guardians);
for (Player player : participants)
if (player.isOnline())
AddGems(player, 10, "Participation", false, false);
@ -1734,7 +1792,7 @@ public class SpeedBuilders extends SoloGame
for (Player player : playersDead)
{
Scoreboard.Write(C.cGray + player.getName());
Scoreboard.Write(C.cDGray + player.getName());
}
Scoreboard.Draw();

View File

@ -2,14 +2,6 @@ package nautilus.game.arcade.game.games.speedbuilders.data;
import java.util.ArrayList;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilTime;
import mineplex.core.hologram.Hologram;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@ -17,11 +9,19 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Bed;
import org.bukkit.material.Door;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilTime;
import mineplex.core.hologram.Hologram;
public class DemolitionData
{
@ -170,9 +170,7 @@ public class DemolitionData
for (ItemStack itemStack : UtilBlock.blockToInventoryItemStacks(block))
{
Item item = block.getWorld().dropItem(block.getLocation().add(0.5, 0.5, 0.5), itemStack);
Parent.DroppedItems.put(item, System.currentTimeMillis());
UtilInv.insert(Parent.Player, itemStack);
}
//Destroy the other part
@ -210,9 +208,7 @@ public class DemolitionData
{
ItemStack spawnEgg = new ItemStack(Material.MONSTER_EGG, 1, entity.getType().getTypeId());
Item item = entity.getWorld().dropItem(entity.getLocation().add(0, 1, 0), spawnEgg);
Parent.DroppedItems.put(item, System.currentTimeMillis());
UtilInv.insert(Parent.Player, spawnEgg);
entity.remove();

View File

@ -297,10 +297,10 @@ public class RecreationData
}
//Ender portal direction fix & 0x4 is a check to see if the frame has an ender eye in it
if (currentBlock.getType() == Material.ENDER_PORTAL_FRAME && expectedState.getType() == Material.ENDER_PORTAL_FRAME && (currentBlock.getData() & 0x4) == (expectedState.getRawData() & 0x4))
if (currentBlock.getType() == Material.ENDER_PORTAL_FRAME && expectedState.getType() == Material.ENDER_PORTAL_FRAME)
{
if ((currentBlock.getData() & 0x4) == (expectedState.getRawData() & 0x4))
score++;
continue;
}
//Sapling growth fix
@ -317,6 +317,13 @@ public class RecreationData
score++;
}
//Fix for anvil facing direction
if (expectedState.getType() == Material.ANVIL && currentBlock.getType() == Material.ANVIL)
{
if (currentBlock.getData() / 4 == expectedState.getRawData() / 4 && currentBlock.getData() % 2 == expectedState.getRawData() % 2)
score++;
}
//Fix for corner stair shape
if (currentBlock.getState().getData() instanceof Stairs && expectedState.getData() instanceof Stairs)
{