Fixed BlockMorph leaving blocks behind when player was teleported.

This commit is contained in:
Chiss 2014-08-27 14:22:35 +10:00
parent f25f7d3aa2
commit da5f953212
5 changed files with 48 additions and 9 deletions

View File

@ -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

View File

@ -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<Player, BlockForm> _active = new HashMap<Player, BlockForm>();
private HashSet<FallingBlock> _blocks = new HashSet<FallingBlock>();
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<FallingBlock> blockIterator = _blocks.iterator();
while (blockIterator.hasNext())
{
FallingBlock block = blockIterator.next();
if (!block.isValid())
{
block.remove();
blockIterator.remove();
}
}
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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);