Disable on tp and do not allow mounts

This commit is contained in:
LCastr0 2016-12-23 19:53:49 -02:00
parent 9fad633b88
commit 675642a100
3 changed files with 42 additions and 5 deletions

View File

@ -1112,6 +1112,17 @@ public class GadgetManager extends MiniPlugin
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(F.main("Cosmetics", "You cannot enable particles while vanished!")); player.sendMessage(F.main("Cosmetics", "You cannot enable particles while vanished!"));
} }
if (event.getGadget().getGadgetType() == GadgetType.MORPH)
{
if (event.getGadget() instanceof MorphDinnerbone)
{
if (_mountManager.getActive(player) != null)
{
event.setCancelled(true);
UtilPlayer.message(player, F.main("Cosmetics", "You cannot morph into " + event.getGadget().getName() + " with an active mount!"));
}
}
}
} }
@EventHandler @EventHandler

View File

@ -13,13 +13,16 @@ import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.skin.SkinData; import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.event.StackerEvent; import mineplex.core.event.StackerEvent;
@ -29,6 +32,7 @@ import mineplex.core.gadget.event.PlayerToggleSwimEvent;
import mineplex.core.gadget.gadgets.item.ItemEtherealPearl; import mineplex.core.gadget.gadgets.item.ItemEtherealPearl;
import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; import mineplex.core.gadget.gadgets.morph.managers.UtilMorph;
import mineplex.core.gadget.types.MorphGadget; import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.utils.UtilGameProfile; import mineplex.core.utils.UtilGameProfile;
public class MorphDinnerbone extends MorphGadget public class MorphDinnerbone extends MorphGadget
@ -158,4 +162,24 @@ public class MorphDinnerbone extends MorphGadget
} }
} }
@EventHandler
public void activateMount(MountActivateEvent event)
{
if (isActive(event.getPlayer()))
{
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main("Cosmetics", "You cannot use mounts while morphed as " + getName() + "!"));
}
}
@EventHandler
public void onTeleport(PlayerTeleportEvent event)
{
if (isActive(event.getPlayer()))
{
disable(event.getPlayer());
UtilPlayer.message(event.getPlayer(), F.main("Cosmetics", "You were unmorphed from " + getName() + "!"));
}
}
} }

View File

@ -1,13 +1,13 @@
package mineplex.core.mount.event; package mineplex.core.mount.event;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.mount.Mount;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
public class MountActivateEvent extends Event import mineplex.core.mount.Mount;
public class MountActivateEvent extends Event implements Cancellable
{ {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@ -42,11 +42,13 @@ public class MountActivateEvent extends Event
return _player; return _player;
} }
@Override
public void setCancelled(boolean cancel) public void setCancelled(boolean cancel)
{ {
_cancelled = cancel; _cancelled = cancel;
} }
@Override
public boolean isCancelled() public boolean isCancelled()
{ {
return _cancelled; return _cancelled;