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;
}
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;
}
}
});
}
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);
}
}
Aggregations