Search in sources :

Example 16 with MassiveException

use of com.massivecraft.massivecore.MassiveException in project MassiveCore by MassiveCraft.

the class EditSettings method getUsedOrCommandException.

public O getUsedOrCommandException(String arg, CommandSender sender) throws MassiveException {
    if (arg == null) {
        O ret = this.getUsed(sender);
        if (ret != null)
            return ret;
        String noun = this.getObjectType().getName();
        String aan = Txt.aan(noun);
        throw new MassiveException().addMsg("<b>You must select %s %s for use to skip the optional argument.", aan, noun);
    }
    if (ALIASES_USED.contains(arg)) {
        O ret = this.getUsed(sender);
        if (ret == null)
            throw new MassiveException().addMsg("<b>You have no selected %s.", this.getObjectType().getName());
        return ret;
    }
    return null;
}
Also used : MassiveException(com.massivecraft.massivecore.MassiveException)

Example 17 with MassiveException

use of com.massivecraft.massivecore.MassiveException in project MassiveCore by MassiveCraft.

the class CmdMassiveCoreCmdurl method perform.

// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException {
    // Args
    String urlString = this.readArg();
    final URL url;
    try {
        url = new URL(urlString);
    } catch (MalformedURLException e) {
        msg("<b>Malformed URL: %s", e.getMessage());
        return;
    }
    // Apply
    final Player commander = me;
    msg("<i>Loading <aqua>%s <i>...", urlString);
    async(new Runnable() {

        @Override
        public void run() {
            try {
                final List<String> lines = WebUtil.getLines(url);
                sync(new Runnable() {

                    @Override
                    public void run() {
                        MixinMessage.get().msgOne(commander, "<i>... <h>%d <i>lines loaded. Now executing ...", lines.size());
                        for (int i = 0; i <= lines.size() - 1; i++) {
                            String line = lines.get(i);
                            line = line.trim();
                            if (line.length() == 0 || line.startsWith("#")) {
                                MixinMessage.get().msgOne(commander, "<b>#%d: <i>%s", i, line);
                            // Ignore the line
                            } else {
                                MixinMessage.get().msgOne(commander, "<g>#%d: <i>%s", i, line);
                                // Run the line
                                commander.chat(line);
                            }
                        }
                    }
                });
                return;
            } catch (final Exception e) {
                sync(new Runnable() {

                    @Override
                    public void run() {
                        MixinMessage.get().msgOne(commander, "<b>%s: %s", e.getClass().getSimpleName(), e.getMessage());
                    }
                });
                return;
            }
        }
    });
}
Also used : MalformedURLException(java.net.MalformedURLException) RequirementIsPlayer(com.massivecraft.massivecore.command.requirement.RequirementIsPlayer) Player(org.bukkit.entity.Player) List(java.util.List) TypeString(com.massivecraft.massivecore.command.type.primitive.TypeString) URL(java.net.URL) MassiveException(com.massivecraft.massivecore.MassiveException) MalformedURLException(java.net.MalformedURLException)

Example 18 with MassiveException

use of com.massivecraft.massivecore.MassiveException 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)18 Player (org.bukkit.entity.Player)4 EventMassiveCoreDestination (com.massivecraft.massivecore.event.EventMassiveCoreDestination)3 Destination (com.massivecraft.massivecore.teleport.Destination)3 Mson (com.massivecraft.massivecore.mson.Mson)2 PS (com.massivecraft.massivecore.ps.PS)2 EventHandler (org.bukkit.event.EventHandler)2 MassiveList (com.massivecraft.massivecore.collections.MassiveList)1 MassiveSet (com.massivecraft.massivecore.collections.MassiveSet)1 RequirementIsPlayer (com.massivecraft.massivecore.command.requirement.RequirementIsPlayer)1 RegistryType (com.massivecraft.massivecore.command.type.RegistryType)1 Type (com.massivecraft.massivecore.command.type.Type)1 TypePS (com.massivecraft.massivecore.command.type.TypePS)1 TypeDyeColor (com.massivecraft.massivecore.command.type.enumeration.TypeDyeColor)1 TypeString (com.massivecraft.massivecore.command.type.primitive.TypeString)1 PSBuilder (com.massivecraft.massivecore.ps.PSBuilder)1 DestinationJump (com.massivecraft.massivecore.teleport.DestinationJump)1 DestinationPlayer (com.massivecraft.massivecore.teleport.DestinationPlayer)1 DestinationSimple (com.massivecraft.massivecore.teleport.DestinationSimple)1 DestinationThat (com.massivecraft.massivecore.teleport.DestinationThat)1