use of org.spongepowered.api.profile.GameProfile in project Nucleus by NucleusPowered.
the class UnbanCommand method executeCommand.
@Override
public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
GameProfile gp;
if (args.hasAny(key)) {
gp = args.<GameProfile>getOne(key).get();
} else {
gp = args.<GameProfile>getOne(key2).get();
}
BanService service = Sponge.getServiceManager().provideUnchecked(BanService.class);
Optional<Ban.Profile> obp = service.getBanFor(gp);
if (!obp.isPresent()) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.checkban.notset", gp.getName().orElse(plugin.getMessageProvider().getMessageWithFormat("standard.unknown"))));
return CommandResult.empty();
}
service.removeBan(obp.get());
MutableMessageChannel notify = new PermissionMessageChannel(BanCommand.notifyPermission).asMutable();
notify.addMember(src);
notify.send(plugin.getMessageProvider().getTextMessageWithFormat("command.unban.success", obp.get().getProfile().getName().orElse("standard.unknown"), src.getName()));
return CommandResult.success();
}
use of org.spongepowered.api.profile.GameProfile in project SpongeCommon by SpongePowered.
the class MixinPlayerProfileCache method lookupByNames.
@Override
public Map<String, Optional<GameProfile>> lookupByNames(Iterable<String> names) {
checkNotNull(names, "names");
Map<String, Optional<GameProfile>> result = Maps.newHashMap();
SpongeImpl.getServer().getGameProfileRepository().findProfilesByNames(Iterables.toArray(names, String.class), Agent.MINECRAFT, new MapProfileLookupCallback(result));
if (!result.isEmpty()) {
for (Optional<GameProfile> entry : result.values()) {
if (entry.isPresent()) {
this.addEntry((com.mojang.authlib.GameProfile) entry.get(), null);
}
}
return ImmutableMap.copyOf(result);
}
return ImmutableMap.of();
}
use of org.spongepowered.api.profile.GameProfile in project SpongeCommon by SpongePowered.
the class MixinPlayerProfileCache method lookupByName.
@Override
public Optional<GameProfile> lookupByName(String name) {
SingleProfileLookupCallback callback = new SingleProfileLookupCallback();
SpongeImpl.getServer().getGameProfileRepository().findProfilesByNames(new String[] { name }, Agent.MINECRAFT, callback);
Optional<GameProfile> profile = callback.getResult();
if (profile.isPresent()) {
this.addEntry((com.mojang.authlib.GameProfile) profile.get(), null);
}
return profile;
}
use of org.spongepowered.api.profile.GameProfile in project SpongeCommon by SpongePowered.
the class MixinPlayerProfileCache method getByIds.
@Override
public Map<UUID, Optional<GameProfile>> getByIds(Iterable<UUID> uniqueIds) {
checkNotNull(uniqueIds, "unique ids");
Map<UUID, Optional<GameProfile>> result = Maps.newHashMap();
for (UUID uniqueId : uniqueIds) {
result.put(uniqueId, Optional.ofNullable((GameProfile) this.getProfileByUUID(uniqueId)));
}
return result.isEmpty() ? ImmutableMap.of() : ImmutableMap.copyOf(result);
}
use of org.spongepowered.api.profile.GameProfile in project SpongeCommon by SpongePowered.
the class SkullUtils method updatePlayerProfile.
public static void updatePlayerProfile(IMixinTileEntitySkull skull) {
GameProfile profile = (GameProfile) skull.getPlayerProfile();
if (profile != null && profile.getName().isPresent() && !profile.getName().get().isEmpty()) {
if (profile.isFilled() && profile.getPropertyMap().containsKey("textures")) {
skull.markDirty();
} else {
Sponge.getServer().getGameProfileManager().get(profile.getName().get()).handle((newProfile, thrown) -> {
if (newProfile != null) {
skull.setPlayerProfile((com.mojang.authlib.GameProfile) newProfile, false);
skull.markDirty();
} else {
SpongeImpl.getLogger().warn("Could not update player GameProfile for Skull: ", thrown.getMessage());
}
return newProfile;
});
}
} else {
skull.markDirty();
}
}
Aggregations