Fix bugs
This commit is contained in:
parent
e7dbe48937
commit
ecb42d91fe
@ -50,6 +50,7 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class UtilEnt
|
||||
{
|
||||
public static final String FLAG_NO_REMOVE = "noremove";
|
||||
|
||||
//Custom Entity Names
|
||||
private static HashMap<Entity, String> _nameMap = new HashMap<Entity, String>();
|
||||
@ -76,6 +77,27 @@ public class UtilEnt
|
||||
// Not working right now
|
||||
//((CraftEntity)entity).getHandle().setSilent(silence);
|
||||
}
|
||||
|
||||
public static void addFlag(Entity entity, String flag)
|
||||
{
|
||||
if (entity == null)
|
||||
return;
|
||||
|
||||
entity.setMetadata("flag:" + flag, new FixedMetadataValue(UtilServer.getPlugin(), true));
|
||||
}
|
||||
|
||||
public static void removeFlag(Entity entity, String flag)
|
||||
{
|
||||
if (entity == null)
|
||||
return;
|
||||
|
||||
entity.removeMetadata("flag:" + flag, UtilServer.getPlugin());
|
||||
}
|
||||
|
||||
public static boolean hasFlag(Entity entity, String flag)
|
||||
{
|
||||
return entity.hasMetadata("flag:" + flag);
|
||||
}
|
||||
|
||||
public static void ghost(Entity entity, boolean ghost, boolean invisible)
|
||||
{
|
||||
|
@ -18,7 +18,6 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftSlime;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -84,6 +83,11 @@ public class BlockForm
|
||||
this._fallingBlockBase.setRemoveWhenFarAway(false);
|
||||
this._fallingBlockBase.setPassenger(this._fallingBlock);
|
||||
|
||||
UtilEnt.addFlag(this._fallingBlock, UtilEnt.FLAG_NO_REMOVE);
|
||||
UtilEnt.addFlag(this._fallingBlock, MorphBlock.FLAG_BLOCK_MORPH_COMPONENT);
|
||||
UtilEnt.addFlag(this._fallingBlockBase, UtilEnt.FLAG_NO_REMOVE);
|
||||
UtilEnt.addFlag(this._fallingBlockBase, MorphBlock.FLAG_BLOCK_MORPH_COMPONENT);
|
||||
|
||||
_nmsFallingBlockBase = ((CraftEntity) _fallingBlockBase).getHandle();
|
||||
_disguiseBlockBase = new DisguiseSlime(_fallingBlockBase);
|
||||
_disguiseBlockBase.SetSize(0);
|
||||
@ -209,18 +213,18 @@ public class BlockForm
|
||||
_block = block;
|
||||
|
||||
// Effect
|
||||
_player.playEffect(_player.getLocation(), Effect.STEP_SOUND, _blockMat);
|
||||
_player.playEffect(_block.getLocation(), Effect.STEP_SOUND, _blockMat);
|
||||
|
||||
removeFallingBlock();
|
||||
|
||||
// Display
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
other.sendBlockChange(_player.getLocation(), _blockMat, (byte) _blockData);
|
||||
other.sendBlockChange(_block.getLocation(), _blockMat, (byte) _blockData);
|
||||
}
|
||||
|
||||
// Sound
|
||||
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
|
||||
_player.playSound(_block.getLocation(), Sound.NOTE_PLING, 1f, 2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,12 @@ import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.LineFormat;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -32,6 +34,8 @@ import mineplex.core.utils.UtilScheduler;
|
||||
|
||||
public class MorphBlock extends MorphGadget implements IPacketHandler
|
||||
{
|
||||
public static final String FLAG_BLOCK_MORPH_COMPONENT = "block-morph-component";
|
||||
|
||||
private Map<Player, BlockForm> _active = new HashMap<>();
|
||||
|
||||
public MorphBlock(GadgetManager manager)
|
||||
@ -91,6 +95,15 @@ public class MorphBlock extends MorphGadget implements IPacketHandler
|
||||
form.reset(event.getClickedBlock());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (UtilEnt.hasFlag(event.getEntity(), FLAG_BLOCK_MORPH_COMPONENT))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketInfo packetInfo)
|
||||
{
|
||||
|
@ -60,6 +60,7 @@ import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -710,9 +711,11 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
event.getEntity().leaveVehicle();
|
||||
event.getEntity().teleport(GetSpawn());
|
||||
}
|
||||
|
||||
else
|
||||
event.getEntity().remove();
|
||||
{
|
||||
if (!UtilEnt.hasFlag(event.getEntity(), UtilEnt.FLAG_NO_REMOVE))
|
||||
event.getEntity().remove();
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user