use of io.github.nucleuspowered.nucleus.internal.LocationData in project Nucleus by NucleusPowered.
the class DeleteJailCommand method executeCommand.
@Override
public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
LocationData wl = args.<LocationData>getOne(jailKey).get();
if (handler.removeJail(wl.getName())) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.jails.del.success", wl.getName()));
return CommandResult.success();
}
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.jails.del.error", wl.getName()));
return CommandResult.empty();
}
use of io.github.nucleuspowered.nucleus.internal.LocationData in project Nucleus by NucleusPowered.
the class JailCommand method onJail.
private CommandResult onJail(CommandSource src, CommandContext args, User user) throws ReturnMessageException {
Optional<LocationData> owl = args.getOne(jailKey);
if (!owl.isPresent()) {
throw ReturnMessageException.fromKey("command.jail.jail.nojail");
}
// This might not be there.
Optional<Long> duration = args.getOne(durationKey);
String reason = args.<String>getOne(reasonKey).orElse(plugin.getMessageProvider().getMessageWithFormat("command.jail.reason"));
JailData jd;
Text message;
Text messageTo;
if (duration.isPresent()) {
if (user.isOnline()) {
jd = new JailData(Util.getUUID(src), owl.get().getName(), reason, user.getPlayer().get().getLocation(), Instant.now().plusSeconds(duration.get()));
} else {
jd = new JailData(Util.getUUID(src), owl.get().getName(), reason, null, Duration.of(duration.get(), ChronoUnit.SECONDS));
}
message = plugin.getMessageProvider().getTextMessageWithFormat("command.checkjail.jailedfor", user.getName(), jd.getJailName(), src.getName(), Util.getTimeStringFromSeconds(duration.get()));
messageTo = plugin.getMessageProvider().getTextMessageWithFormat("command.jail.jailedfor", owl.get().getName(), src.getName(), Util.getTimeStringFromSeconds(duration.get()));
} else {
jd = new JailData(Util.getUUID(src), owl.get().getName(), reason, user.getPlayer().map(Locatable::getLocation).orElse(null));
message = plugin.getMessageProvider().getTextMessageWithFormat("command.checkjail.jailedperm", user.getName(), owl.get().getName(), src.getName());
messageTo = plugin.getMessageProvider().getTextMessageWithFormat("command.jail.jailedperm", owl.get().getName(), src.getName());
}
if (handler.jailPlayer(user, jd)) {
MutableMessageChannel mc = new PermissionMessageChannel(permissions.getPermissionWithSuffix("notify")).asMutable();
mc.addMember(src);
mc.send(message);
mc.send(plugin.getMessageProvider().getTextMessageWithFormat("standard.reasoncoloured", reason));
user.getPlayer().ifPresent(x -> {
x.sendMessage(messageTo);
x.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("standard.reasoncoloured", reason));
});
return CommandResult.success();
}
throw ReturnMessageException.fromKey("command.jail.error");
}
Aggregations