use of org.spongepowered.api.profile.GameProfileManager in project ChangeSkin by games647.
the class SpongeSkinAPI method applyProperties.
@Override
public void applyProperties(GameProfile profile, SkinModel targetSkin) {
// remove existing skins
profile.getPropertyMap().clear();
if (targetSkin != null) {
GameProfileManager profileManager = Sponge.getServer().getGameProfileManager();
ProfileProperty profileProperty = profileManager.createProfileProperty(SkinProperty.SKIN_KEY, targetSkin.getEncodedValue(), targetSkin.getSignature());
profile.getPropertyMap().put(SkinProperty.SKIN_KEY, profileProperty);
}
}
use of org.spongepowered.api.profile.GameProfileManager in project modules-extra by CubeEngine.
the class HideListener method onServerPingList.
@Listener
public void onServerPingList(ClientPingServerEvent event) {
GameProfileManager gpm = Sponge.getServer().getGameProfileManager();
event.getResponse().getPlayers().ifPresent(l -> {
for (UUID uuid : module.getHiddenUsers()) {
GameProfile gp = gpm.get(uuid).join();
l.getProfiles().remove(gp);
}
});
}
use of org.spongepowered.api.profile.GameProfileManager in project Nucleus by NucleusPowered.
the class GetUserCommand method executeCommand.
@Override
protected CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
CompletableFuture<GameProfile> profile;
final String toGet;
final GameProfileManager manager = Sponge.getServer().getGameProfileManager();
if (args.hasAny(uuidKey)) {
UUID u = args.<UUID>getOne(uuidKey).get();
toGet = u.toString();
profile = manager.get(u, false);
} else {
toGet = args.<String>getOne(playerKey).get();
profile = manager.get(toGet, false);
}
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.nucleus.getuser.starting", toGet));
profile.handle((gp, th) -> {
if (th != null || gp == null) {
if (th != null && Nucleus.getNucleus().isDebugMode()) {
th.printStackTrace();
}
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.nucleus.getuser.failed", toGet));
// I have to return something, even though I don't care about it.
return 0;
}
// We have a game profile, it's been added to the cache. Create the user too, just in case.
Sponge.getServiceManager().provideUnchecked(UserStorageService.class).getOrCreate(gp);
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.nucleus.getuser.success", gp.getUniqueId().toString(), gp.getName().orElse("unknown")));
return 0;
});
return CommandResult.success();
}
use of org.spongepowered.api.profile.GameProfileManager in project Nucleus by NucleusPowered.
the class BanCommand method executeCommand.
@Override
public CommandResult executeCommand(final CommandSource src, CommandContext args) throws Exception {
final String r = args.<String>getOne(reason).orElse(plugin.getMessageProvider().getMessageWithFormat("ban.defaultreason"));
Optional<GameProfile> ou = Optional.ofNullable(args.<GameProfile>getOne(uuid).orElseGet(() -> args.<GameProfile>getOne(user).orElse(null)));
if (ou.isPresent()) {
Optional<User> optionalUser = Sponge.getServiceManager().provideUnchecked(UserStorageService.class).get(ou.get());
if ((!optionalUser.isPresent() || !optionalUser.get().isOnline()) && !permissions.testSuffix(src, "offline")) {
throw new ReturnMessageException(plugin.getMessageProvider().getTextMessageWithFormat("command.ban.offline.noperms"));
}
if (optionalUser.isPresent() && permissions.testSuffix(optionalUser.get(), "exempt.target", src, false)) {
throw new ReturnMessageException(plugin.getMessageProvider().getTextMessageWithFormat("command.ban.exempt", optionalUser.get().getName()));
}
return executeBan(src, ou.get(), r);
}
if (!permissions.testSuffix(src, "offline")) {
throw new ReturnMessageException(plugin.getMessageProvider().getTextMessageWithFormat("command.ban.offline.noperms"));
}
final String userToFind = args.<String>getOne(name).get();
// Get the profile async.
Sponge.getScheduler().createAsyncExecutor(plugin).execute(() -> {
GameProfileManager gpm = Sponge.getServer().getGameProfileManager();
try {
GameProfile gp = gpm.get(userToFind).get();
// Ban the user sync.
Sponge.getScheduler().createSyncExecutor(plugin).execute(() -> {
// Create the user.
UserStorageService uss = Sponge.getServiceManager().provideUnchecked(UserStorageService.class);
User user = uss.getOrCreate(gp);
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("gameprofile.new", user.getName()));
try {
executeBan(src, gp, r);
} catch (Exception e) {
Nucleus.getNucleus().printStackTraceIfDebugMode(e);
}
});
} catch (Exception e) {
Nucleus.getNucleus().printStackTraceIfDebugMode(e);
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.ban.profileerror", userToFind));
}
});
return CommandResult.empty();
}
Aggregations