use of io.github.nucleuspowered.nucleus.api.nucleusdata.NamedLocation in project Nucleus by NucleusPowered.
the class JailTeleportCommand method executeCommand.
@Override
protected CommandResult executeCommand(Player src, CommandContext args) throws Exception {
NamedLocation location = args.<NamedLocation>getOne(jailKey).get();
Transform<World> location1 = location.getTransform().orElseThrow(() -> new ReturnMessageException(plugin.getMessageProvider().getTextMessageWithFormat("command.jails.tp.noworld", location.getName())));
src.setTransform(location1);
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.jails.tp.success", location.getName()));
return CommandResult.success();
}
use of io.github.nucleuspowered.nucleus.api.nucleusdata.NamedLocation in project Nucleus by NucleusPowered.
the class JailHandler method jailPlayer.
public boolean jailPlayer(User user, JailData data) {
ModularUserService modularUserService = plugin.getUserDataManager().getUnchecked(user);
JailUserDataModule jailUserDataModule = modularUserService.get(JailUserDataModule.class);
if (jailUserDataModule.getJailData().isPresent()) {
return false;
}
// Get the jail.
Optional<NamedLocation> owl = getJail(data.getJailName());
NamedLocation wl = owl.filter(x -> x.getLocation().isPresent()).orElseGet(() -> {
if (!getJails().isEmpty()) {
return null;
}
return getJails().entrySet().stream().findFirst().get().getValue();
});
if (wl == null) {
return false;
}
jailUserDataModule.setJailData(data);
if (user.isOnline()) {
Sponge.getScheduler().createSyncExecutor(plugin).execute(() -> {
Player player = user.getPlayer().get();
plugin.getTeleportHandler().teleportPlayer(player, owl.get().getLocation().get(), owl.get().getRotation(), NucleusTeleportHandler.StandardTeleportMode.NO_CHECK, Sponge.getCauseStackManager().getCurrentCause());
modularUserService.get(FlyUserDataModule.class).setFlying(false);
});
} else {
jailUserDataModule.setJailOnNextLogin(true);
}
this.jailDataCache.put(user.getUniqueId(), new Context(NucleusJailService.JAIL_CONTEXT, data.getJailName()));
Sponge.getEventManager().post(new JailEvent.Jailed(user, CauseStackHelper.createCause(Util.getObjectFromUUID(data.getJailerInternal())), data.getJailName(), TextSerializers.FORMATTING_CODE.deserialize(data.getReason()), data.getRemainingTime().orElse(null)));
return true;
}
Aggregations