fixed bug where blockmorph was crashing hubs.

This commit is contained in:
Chiss 2014-10-13 14:56:19 +11:00
parent 25fbe24d20
commit a4b85053d9
2 changed files with 30 additions and 2 deletions

View File

@ -7,17 +7,20 @@ import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
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.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.BlockIterator;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.event.StackerEvent;
@ -122,7 +125,10 @@ public class MorphBlock extends MorphGadget
public void fallingBlockForm(EntityChangeBlockEvent event)
{
if (_blocks.remove(event.getEntity()))
{
event.getEntity().remove();
event.setCancelled(true);
}
}
@EventHandler
@ -144,4 +150,24 @@ public class MorphBlock extends MorphGadget
}
}
}
@EventHandler
public void itemSpawnCancel(ItemSpawnEvent event)
{
System.out.println("B");
Iterator<FallingBlock> blockIterator = _blocks.iterator();
while (blockIterator.hasNext())
{
FallingBlock block = blockIterator.next();
if (UtilMath.offset(block, event.getEntity()) < 0.1)
{
block.remove();
blockIterator.remove();
event.setCancelled(true);
}
}
}
}

View File

@ -31,6 +31,7 @@ import org.bukkit.entity.Chicken;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Minecart;
@ -49,6 +50,7 @@ import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
@ -207,7 +209,7 @@ public class WorldManager extends MiniPlugin
@EventHandler(priority = EventPriority.LOW)
public void ItemDespawn(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
if (event.getType() != UpdateType.SEC)
return;
for (Entity ent : UtilWorld.getWorld("world").getEntities())
@ -215,7 +217,7 @@ public class WorldManager extends MiniPlugin
if (!(ent instanceof Item))
continue;
if (ent.getTicksLived() > 600)
if (ent.getTicksLived() > 1200)
ent.remove();
}
}