From da5f953212229df022e9e49ffbd64d2b34b341ef Mon Sep 17 00:00:00 2001 From: Chiss Date: Wed, 27 Aug 2014 14:22:35 +1000 Subject: [PATCH] Fixed BlockMorph leaving blocks behind when player was teleported. --- .../core/gadget/gadgets/BlockForm.java | 4 +- .../core/gadget/gadgets/MorphBlock.java | 41 ++++++++++++++++++- .../Mineplex.Hub/src/mineplex/hub/Hub.java | 6 +-- .../nautilus/game/arcade/ArcadeManager.java | 3 +- .../src/nautilus/game/arcade/GameFactory.java | 3 +- 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java index 40c53b9e3..4941f2648 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/BlockForm.java @@ -4,7 +4,6 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguiseCat; @@ -22,7 +21,6 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFallingSand; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; public class BlockForm { @@ -228,6 +226,8 @@ public class BlockForm ((CraftFallingSand)block).getHandle().spectating = true; Player.setPassenger(block); + + Host.fallingBlockRegister(block); } //Ensure Falling doesnt Despawn diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java index dee262e66..6d868cc4b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphBlock.java @@ -2,12 +2,17 @@ package mineplex.core.gadget.gadgets; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import org.bukkit.Material; +import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.BlockIterator; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilEvent; @@ -23,6 +28,7 @@ import mineplex.core.updater.event.UpdateEvent; public class MorphBlock extends MorphGadget { private HashMap _active = new HashMap(); + private HashSet _blocks = new HashSet(); public MorphBlock(GadgetManager manager) { @@ -69,11 +75,10 @@ public class MorphBlock extends MorphGadget form.SolidifyUpdate(); form.FallingBlockCheck(); } - } @EventHandler - public void stacker(PlayerInteractEvent event) + public void formChange(PlayerInteractEvent event) { if (event.getClickedBlock() == null) return; @@ -100,4 +105,36 @@ public class MorphBlock extends MorphGadget if (_active.containsKey(event.getEntity())) event.setCancelled(true); } + + public void fallingBlockRegister(FallingBlock block) + { + _blocks.add(block); + } + + @EventHandler + public void fallingBlockForm(EntityChangeBlockEvent event) + { + if (_blocks.remove(event.getEntity())) + event.setCancelled(true); + } + + @EventHandler + public void fallingBlockClean(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + Iterator blockIterator = _blocks.iterator(); + + while (blockIterator.hasNext()) + { + FallingBlock block = blockIterator.next(); + + if (!block.isValid()) + { + block.remove(); + blockIterator.remove(); + } + } + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 983bf9614..7251dc428 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -57,8 +57,8 @@ import mineplex.minecraft.game.core.fire.Fire; public class Hub extends JavaPlugin implements IRelation { private String WEB_CONFIG = "webServer"; - - @Override + + @Override public void onEnable() { getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); @@ -68,7 +68,7 @@ public class Hub extends JavaPlugin implements IRelation String webServerAddress = getConfig().getString(WEB_CONFIG); Logger.initialize(this); - + //Static Modules CommandCenter.Initialize(this); CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 889b987aa..3c8f047d6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -623,7 +623,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation ((CraftEntity) player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0)); player.setSprinting(false); - + player.setSneaking(false); + player.setFoodLevel(20); player.setSaturation(3f); player.setExhaustion(0f); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java index 5ff22c544..6108fa4b3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameFactory.java @@ -26,6 +26,7 @@ import nautilus.game.arcade.game.games.halloween.Halloween; import nautilus.game.arcade.game.games.hideseek.HideSeek; import nautilus.game.arcade.game.games.micro.Micro; import nautilus.game.arcade.game.games.milkcow.MilkCow; +import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.mineware.MineWare; import nautilus.game.arcade.game.games.quiver.Quiver; import nautilus.game.arcade.game.games.quiver.QuiverTeams; @@ -78,7 +79,7 @@ public class GameFactory else if (gameType == GameType.Halloween) return new Halloween(_manager); else if (gameType == GameType.HideSeek) return new HideSeek(_manager); else if (gameType == GameType.Micro) return new Micro(_manager); - //else if (gameType == GameType.MineStrike) return new MineStrike(_manager); + else if (gameType == GameType.MineStrike) return new MineStrike(_manager); else if (gameType == GameType.MineWare) return new MineWare(_manager); else if (gameType == GameType.MilkCow) return new MilkCow(_manager); else if (gameType == GameType.Paintball) return new Paintball(_manager);