use of io.github.nucleuspowered.nucleus.dataservices.modular.ModularUserService in project Nucleus by NucleusPowered.
the class InvulnerabilityService method setInvulnerable.
@Override
public void setInvulnerable(User user, boolean invulnerable) throws NucleusException {
ModularUserService mus = Nucleus.getNucleus().getUserDataManager().get(user).orElseThrow(() -> new NucleusException(Text.of("User does not have a data file available"), NucleusException.ExceptionType.DOES_NOT_EXIST));
mus.get(InvulnerabilityUserDataModule.class).setInvulnerable(invulnerable);
user.getPlayer().ifPresent(x -> this.invulnerabilityCache.put(user.getUniqueId(), invulnerable));
if (!mus.save()) {
throw new NucleusException(Text.of("Could not save data"), NucleusException.ExceptionType.UNKNOWN_ERROR);
}
}
use of io.github.nucleuspowered.nucleus.dataservices.modular.ModularUserService in project Nucleus by NucleusPowered.
the class TeleportHereCommand method executeCommand.
@Override
public CommandResult executeCommand(Player src, CommandContext args) throws Exception {
boolean beQuiet = args.<Boolean>getOne("q").orElse(this.isDefaultQuiet);
User target = args.<User>getOne(playerKey).get();
if (target.getPlayer().isPresent()) {
handler.getBuilder().setFrom(target.getPlayer().get()).setTo(src).setSilentSource(beQuiet).startTeleport();
} else {
permissions.checkSuffix(src, "offline", () -> ReturnMessageException.fromKey("command.tphere.noofflineperms"));
// Update the offline player's next location
ModularUserService mus = plugin.getUserDataManager().get(target).orElseThrow(() -> ReturnMessageException.fromKey("command.tphere.couldnotset", target.getName()));
mus.get(CoreUserDataModule.class).sendToLocationOnLogin(src.getLocation());
mus.save();
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.tphere.offlinesuccess", target.getName()));
}
return CommandResult.success();
}
Aggregations