Search in sources :

Example 1 with EventMassiveCoreDestination

use of com.massivecraft.massivecore.event.EventMassiveCoreDestination in project MassiveCore by MassiveCraft.

the class EngineMassiveCoreDestination method destinationArg.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void destinationArg(EventMassiveCoreDestination event) {
    final String arg = event.getArg().toLowerCase();
    final CommandSender sender = event.getSender();
    try {
        Destination destination = destinationArg(arg, sender);
        if (destination == null)
            return;
        event.setDestination(destination);
    } catch (MassiveException e) {
        event.setException(e);
    } catch (Exception e) {
        event.setException(new MassiveException().addMsg("<b>%s", e.getMessage()));
    }
    event.setCancelled(true);
}
Also used : EventMassiveCoreDestination(com.massivecraft.massivecore.event.EventMassiveCoreDestination) Destination(com.massivecraft.massivecore.teleport.Destination) MassiveException(com.massivecraft.massivecore.MassiveException) CommandSender(org.bukkit.command.CommandSender) MassiveException(com.massivecraft.massivecore.MassiveException) EventHandler(org.bukkit.event.EventHandler)

Example 2 with EventMassiveCoreDestination

use of com.massivecraft.massivecore.event.EventMassiveCoreDestination in project MassiveCore by MassiveCraft.

the class TypeDestination method read.

@Override
public Destination read(String arg, CommandSender sender) throws MassiveException {
    EventMassiveCoreDestination event = new EventMassiveCoreDestination(arg, sender, null);
    event.run();
    MassiveException exception = event.getException();
    if (exception != null)
        throw exception;
    Destination ret = event.getDestination();
    if (ret == null)
        throw new MassiveException().addMsg("<b>Unknown destination \"<h>%s<b>\".", arg);
    // Throw exeption if ps is null.
    ret.getPs(sender);
    return ret;
}
Also used : EventMassiveCoreDestination(com.massivecraft.massivecore.event.EventMassiveCoreDestination) Destination(com.massivecraft.massivecore.teleport.Destination) MassiveException(com.massivecraft.massivecore.MassiveException) EventMassiveCoreDestination(com.massivecraft.massivecore.event.EventMassiveCoreDestination)

Example 3 with EventMassiveCoreDestination

use of com.massivecraft.massivecore.event.EventMassiveCoreDestination in project MassiveCore by MassiveCraft.

the class EngineMassiveCoreDestination method destinationPs.

// -------------------------------------------- //
// DESTINATION ARG
// -------------------------------------------- //
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void destinationPs(EventMassiveCoreDestination event) {
    try {
        PS ps = TypePS.get().read(event.getArg(), event.getSender());
        Destination destination = new DestinationSimple(ps);
        event.setDestination(destination);
    } catch (MassiveException exception) {
        event.setException(exception);
        event.setCancelled(true);
    }
}
Also used : EventMassiveCoreDestination(com.massivecraft.massivecore.event.EventMassiveCoreDestination) Destination(com.massivecraft.massivecore.teleport.Destination) TypePS(com.massivecraft.massivecore.command.type.TypePS) PS(com.massivecraft.massivecore.ps.PS) MassiveException(com.massivecraft.massivecore.MassiveException) DestinationSimple(com.massivecraft.massivecore.teleport.DestinationSimple) EventHandler(org.bukkit.event.EventHandler)

Aggregations

MassiveException (com.massivecraft.massivecore.MassiveException)3 EventMassiveCoreDestination (com.massivecraft.massivecore.event.EventMassiveCoreDestination)3 Destination (com.massivecraft.massivecore.teleport.Destination)3 EventHandler (org.bukkit.event.EventHandler)2 TypePS (com.massivecraft.massivecore.command.type.TypePS)1 PS (com.massivecraft.massivecore.ps.PS)1 DestinationSimple (com.massivecraft.massivecore.teleport.DestinationSimple)1 CommandSender (org.bukkit.command.CommandSender)1