use of io.github.nucleuspowered.nucleus.api.service.NucleusWarpService in project Nucleus by NucleusPowered.
the class DeleteWarpCommand method executeCommand.
@Override
public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
Warp warp = args.<Warp>getOne(WarpCommand.warpNameArg).get();
NucleusWarpService qs = Sponge.getServiceManager().provideUnchecked(NucleusWarpService.class);
DeleteWarpEvent event = new DeleteWarpEvent(CauseStackHelper.createCause(src), warp);
if (Sponge.getEventManager().post(event)) {
throw new ReturnMessageException(event.getCancelMessage().orElseGet(() -> plugin.getMessageProvider().getTextMessageWithFormat("nucleus.eventcancelled")));
}
if (qs.removeWarp(warp.getName())) {
// Worked. Tell them.
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.warps.del", warp.getName()));
return CommandResult.success();
}
// Didn't work. Tell them.
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.warps.delerror"));
return CommandResult.empty();
}
Aggregations