use of com.destroystokyo.paper.profile.PlayerProfile in project Glowstone by GlowstoneMC.
the class StatusRequestHandler method handle.
@Override
@SuppressWarnings("unchecked")
public void handle(GlowSession session, StatusRequestMessage message) {
// create and call the event
GlowServer server = session.getServer();
StatusEvent event = new StatusEvent(new GlowStatusClient(session), server.getMotd(), server.getOnlinePlayers().size(), server.getMaxPlayers(), GlowServer.GAME_VERSION, GlowServer.PROTOCOL_VERSION, server.getServerIcon());
event.serverType = server.getServerType();
event.clientModsAllowed = server.getAllowClientMods();
choosePlayerSample(server, event);
EventFactory.getInstance().callEvent(event);
// Disconnect immediately if event is cancelled
if (event.isCancelled()) {
session.getChannel().close();
return;
}
// build the json
JSONObject json = new JSONObject();
JSONObject version = new JSONObject();
version.put("name", event.getVersion());
version.put("protocol", event.getProtocolVersion());
json.put("version", version);
if (!event.shouldHidePlayers()) {
JSONObject players = new JSONObject();
players.put("max", event.getMaxPlayers());
players.put("online", event.getNumPlayers());
JSONArray playersSample = new JSONArray();
for (PlayerProfile profile : event.getPlayerSample()) {
JSONObject p = new JSONObject();
p.put("name", Strings.nullToEmpty(profile.getName()));
p.put("id", UuidUtils.toString(MoreObjects.firstNonNull(profile.getId(), BLANK_UUID)));
playersSample.add(p);
}
players.put("sample", playersSample);
json.put("players", players);
}
JSONObject description = new JSONObject();
description.put("text", event.getMotd());
json.put("description", description);
if (event.getServerIcon() != null) {
json.put("favicon", event.getServerIcon().getData());
}
// Mod list must be included but can be empty
// TODO: support adding GS-ported Forge server-side mods?
JSONArray modList = new JSONArray();
JSONObject modinfo = new JSONObject();
modinfo.put("type", event.serverType);
modinfo.put("modList", modList);
if (!event.clientModsAllowed) {
modinfo.put("clientModsAllowed", false);
}
json.put("modinfo", modinfo);
// send it off
session.send(new StatusResponseMessage(json));
}
use of com.destroystokyo.paper.profile.PlayerProfile in project VoxelGamesLibv2 by VoxelGamesLib.
the class TextureHandler method getPlayerProfile.
public PlayerProfile getPlayerProfile(Skin skin) {
PlayerProfile playerProfile = Bukkit.createProfile(skin.data.uuid, skin.name);
playerProfile.setProperty(new ProfileProperty("textures", skin.data.texture.value, skin.data.texture.signature));
return playerProfile;
}
Aggregations