Here are the examples of the java api com.mojang.authlib.GameProfile taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
556 Examples
19
Source : PlayerSkinProviderMixin.java
with GNU General Public License v3.0
from Wurst-Imperium
with GNU General Public License v3.0
from Wurst-Imperium
@Inject(at = { @At("HEAD") }, method = { "loadSkin(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/texture/PlayerSkinProvider$SkinTextureAvailableCallback;Z)V" }, cancellable = true)
private void onLoadSkin(GameProfile profile, PlayerSkinProvider.SkinTextureAvailableCallback callback, boolean requireSecure, CallbackInfo ci) {
// Can't @Inject nicely because everything is wrapped in a lambda.
// Had to replace the whole method.
Runnable runnable = () -> {
HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Maps.newHashMap();
try {
map.putAll(sessionService.getTextures(profile, requireSecure));
} catch (InsecureTextureException var7) {
}
if (map.isEmpty()) {
profile.getProperties().clear();
if (profile.getId().equals(MinecraftClient.getInstance().getSession().getProfile().getId())) {
profile.getProperties().putAll(MinecraftClient.getInstance().getSessionProperties());
map.putAll(sessionService.getTextures(profile, false));
} else {
sessionService.fillProfileProperties(profile, requireSecure);
try {
map.putAll(sessionService.getTextures(profile, requireSecure));
} catch (InsecureTextureException var6) {
}
}
}
addWurstCape(profile, map);
MinecraftClient.getInstance().execute(() -> {
RenderSystem.recordRenderCall(() -> {
ImmutableList.of(Type.SKIN, Type.CAPE).forEach((type) -> {
if (map.containsKey(type))
loadSkin(map.get(type), type, callback);
});
});
});
};
Util.getMainWorkerExecutor().execute(runnable);
ci.cancel();
}
19
Source : PlayerSkinProviderMixin.java
with GNU General Public License v3.0
from Wurst-Imperium
with GNU General Public License v3.0
from Wurst-Imperium
private void addWurstCape(GameProfile profile, HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture> map) {
String name = profile.getName();
String uuid = profile.getId().toString();
try {
if (capes == null)
setupWurstCapes();
if (capes.has(name)) {
String capeURL = capes.get(name).getreplacedtring();
map.put(Type.CAPE, new MinecraftProfileTexture(capeURL, null));
} else if (capes.has(uuid)) {
String capeURL = capes.get(uuid).getreplacedtring();
map.put(Type.CAPE, new MinecraftProfileTexture(capeURL, null));
}
} catch (Exception e) {
System.err.println("[Wurst] Failed to load cape for '" + name + "' (" + uuid + ")");
e.printStackTrace();
}
}
19
Source : PlayerListEntryHelper.java
with Mozilla Public License 2.0
from wagyourtail
with Mozilla Public License 2.0
from wagyourtail
/**
* @since 1.0.2
* @return
*/
public String getName() {
GameProfile prof = base.getProfile();
if (prof == null)
return null;
return prof.getName();
}
19
Source : PlayerListEntryHelper.java
with Mozilla Public License 2.0
from wagyourtail
with Mozilla Public License 2.0
from wagyourtail
/**
* @since 1.1.9
* @return
*/
public String getUUID() {
GameProfile prof = base.getProfile();
if (prof == null)
return null;
return prof.getId().toString();
}
19
Source : GameProfileBuilder.java
with GNU General Public License v3.0
from trainerlord
with GNU General Public License v3.0
from trainerlord
public static GameProfile getProfile(UUID uuid, String name, String skinUrl, String capeUrl) {
GameProfile profile = new GameProfile(uuid, name);
boolean cape = (capeUrl != null) && (!capeUrl.isEmpty());
List<Object> args = new ArrayList<>();
args.add(Long.valueOf(System.currentTimeMillis()));
args.add(UUIDTypeAdapter.fromUUID(uuid));
args.add(name);
args.add(skinUrl);
if (cape) {
args.add(capeUrl);
}
profile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString(String.format(cape ? "{\"timestamp\":%d,\"profileId\":\"%s\",\"profileName\":\"%s\",\"isPublic\":true,\"textures\":{\"SKIN\":{\"url\":\"%s\"},\"CAPE\":{\"url\":\"%s\"}}}" : "{\"timestamp\":%d,\"profileId\":\"%s\",\"profileName\":\"%s\",\"isPublic\":true,\"textures\":{\"SKIN\":{\"url\":\"%s\"}}}", args.toArray(new Object[0])))));
return profile;
}
19
Source : WorldConfig.java
with GNU General Public License v3.0
from trainerlord
with GNU General Public License v3.0
from trainerlord
public HashMap<UUID, String> getMembersWithNames() {
HashMap<UUID, String> map = new HashMap<>();
for (UUID uuid : permissions.keySet()) {
OfflinePlayer op = PlayerWrapper.getOfflinePlayer(uuid);
if (op == null || op.getName() == null) {
if (PluginConfig.contactAuth()) {
try {
GameProfile prof = GameProfileBuilder.fetch(uuid);
map.put(uuid, prof.getName());
} catch (IOException e) {
e.printStackTrace();
}
}
} else
map.put(uuid, op.getName());
}
return map;
}
19
Source : CompoundTagMixin.java
with MIT License
from TheRandomLabs
with MIT License
from TheRandomLabs
@Unique
@Nullable
private static MinecraftProfileTexture getSkin(GameProfile profile) {
final MinecraftTexturesPayload payload = getTexturesPayload(profile);
return payload == null ? null : payload.getTextures().get(MinecraftProfileTexture.Type.SKIN);
}
19
Source : ServerUtils.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
public static boolean isPlayerOP(UUID uuid) {
GameProfile profile = getServer().getPlayerProfileCache().getProfileByUUID(uuid);
return profile != null && getServer().getPlayerList().canSendCommands(profile);
}
19
Source : ServerUtils.java
with GNU Lesser General Public License v2.1
from TheCBProject
with GNU Lesser General Public License v2.1
from TheCBProject
public static boolean isPlayerOP(String username) {
GameProfile prof = getGameProfile(username);
return prof != null && getServer().getPlayerList().canSendCommands(prof);
}
19
Source : HeadsPlusConfigHeadsX.java
with MIT License
from Thatsmusic99
with MIT License
from Thatsmusic99
public ItemStack setTexture(String tex, ItemStack is) throws IllegalAccessException, NoSuchFieldException {
SkullMeta sm = (SkullMeta) is.gereplacedemMeta();
GameProfile gm = new GameProfile(UUID.randomUUID(), "HPXHead");
gm.getProperties().put("textures", new Property("texture", tex.replaceAll("=", "")));
Field profileField;
profileField = sm.getClreplaced().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(sm, gm);
is.sereplacedemMeta(sm);
return is;
}
19
Source : HeadsPlusAPI.java
with MIT License
from Thatsmusic99
with MIT License
from Thatsmusic99
public SkullMeta setSkullMeta(SkullMeta m, String t) {
GameProfile gm = new GameProfile(UUID.fromString("7091cdbc-ebdc-4eac-a6b2-25dd8acd3a0e"), "HPXHead");
gm.getProperties().put("textures", new Property("texture", t));
Field profileField = null;
try {
profileField = m.getClreplaced().getDeclaredField("profile");
} catch (NoSuchFieldException | SecurityException e) {
if (hp.getConfiguration().getMechanics().getBoolean("debug.print-stacktraces-in-console")) {
e.printStackTrace();
}
}
profileField.setAccessible(true);
try {
profileField.set(m, gm);
} catch (IllegalArgumentException | IllegalAccessException e) {
if (hp.getConfiguration().getMechanics().getBoolean("debug.print-stacktraces-in-console")) {
e.printStackTrace();
}
}
return m;
}
19
Source : HeadsPlusAPI.java
with MIT License
from Thatsmusic99
with MIT License
from Thatsmusic99
public String getTexture(String owner) {
OfflinePlayer p = Bukkit.getOfflinePlayer(owner);
GameProfile gm = new GameProfile(p.getUniqueId(), owner);
return gm.getProperties().get("textures").iterator().next().getValue();
}
19
Source : HeadsPlusAPI.java
with MIT License
from Thatsmusic99
with MIT License
from Thatsmusic99
public ItemStack createSkull(String texture, String displayname) {
NMSManager nms = hp.getNMS();
ItemStack s = nms.getSkullMaterial(1);
SkullMeta sm = (SkullMeta) s.gereplacedemMeta();
GameProfile gm = new GameProfile(UUID.fromString("7091cdbc-ebdc-4eac-a6b2-25dd8acd3a0e"), "HPXHead");
gm.getProperties().put("textures", new Property("texture", texture));
Field profileField = null;
try {
profileField = sm.getClreplaced().getDeclaredField("profile");
} catch (NoSuchFieldException | SecurityException e) {
if (hp.getConfiguration().getMechanics().getBoolean("debug.print-stacktraces-in-console")) {
e.printStackTrace();
}
}
profileField.setAccessible(true);
try {
profileField.set(sm, gm);
} catch (IllegalArgumentException | IllegalAccessException e) {
if (hp.getConfiguration().getMechanics().getBoolean("debug.print-stacktraces-in-console")) {
e.printStackTrace();
}
}
sm.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayname));
s.sereplacedemMeta(sm);
return s;
}
19
Source : HeadsPlusConfigCustomHeads.java
with GNU General Public License v3.0
from Thatsmusic99
with GNU General Public License v3.0
from Thatsmusic99
public ItemStack setTexture(String tex, ItemStack is) throws IllegalAccessException, NoSuchFieldException {
SkullMeta sm = (SkullMeta) is.gereplacedemMeta();
GameProfile gm = new GameProfile(UUID.nameUUIDFromBytes(tex.getBytes()), "HPXHead");
gm.getProperties().put("textures", new Property("textures", tex.replaceAll("=", "")));
Field profileField;
profileField = sm.getClreplaced().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(sm, gm);
is.sereplacedemMeta(sm);
return is;
}
19
Source : HeadsPlusConfigCustomHeads.java
with GNU General Public License v3.0
from Thatsmusic99
with GNU General Public License v3.0
from Thatsmusic99
public String getTexture(ItemStack skull) {
try {
GameProfile profile = ProfileFetcher.getProfile(skull);
if (profile == null)
return null;
String value = profile.getProperties().get("textures").iterator().next().getValue();
JSONObject json = (JSONObject) new JSONParser().parse(new String(Base64.getDecoder().decode(value.getBytes())));
return new String(Base64.getEncoder().encode(((JSONObject) ((JSONObject) json.get("textures")).get("SKIN")).get("url").toString().getBytes()));
} catch (IllegalAccessException | SecurityException ex) {
throw new RuntimeException("Reflection error while getting head texture", ex);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
19
Source : HeadsPlusAPI.java
with GNU General Public License v3.0
from Thatsmusic99
with GNU General Public License v3.0
from Thatsmusic99
public ItemStack createSkull(String texture, String displayname) {
NMSManager nms = hp.getNMS();
ItemStack s = nms.getSkullMaterial(1);
SkullMeta sm = (SkullMeta) s.gereplacedemMeta();
GameProfile gm = new GameProfile(UUID.nameUUIDFromBytes(texture.getBytes()), "HPXHead");
gm.getProperties().put("textures", new Property("texture", texture));
Field profileField = null;
try {
profileField = sm.getClreplaced().getDeclaredField("profile");
} catch (NoSuchFieldException | SecurityException e) {
if (hp.getConfiguration().getMechanics().getBoolean("debug.print-stacktraces-in-console")) {
e.printStackTrace();
}
}
profileField.setAccessible(true);
try {
profileField.set(sm, gm);
} catch (IllegalArgumentException | IllegalAccessException e) {
if (hp.getConfiguration().getMechanics().getBoolean("debug.print-stacktraces-in-console")) {
e.printStackTrace();
}
}
sm.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayname));
s.sereplacedemMeta(sm);
return s;
}
19
Source : PlayerTracker.java
with GNU General Public License v3.0
from TerminatorNL
with GNU General Public License v3.0
from TerminatorNL
@SuppressWarnings({ "WeakerAccess" })
public clreplaced PlayerTracker extends TrackerBase {
private final GameProfile profile;
private final Set<Long> sharedTo = new HashSet<>();
private final HashMap<String, ClaimOverrideRequester> pendingRequests = new HashMap<>();
private boolean notifyUser = true;
private long nextMessageMillis = 0L;
private TickWallet wallet = new TickWallet();
/**
* Required.
*/
public PlayerTracker() {
profile = ForgeData.GAME_PROFILE_NOBODY;
}
/**
* Creates the tracker
*
* @param profile a given game profile
*/
public PlayerTracker(@Nonnull GameProfile profile) {
super();
this.profile = profile;
}
/*
* Gets the tracker for a player, if no one exists yet, it will create one. Never returns null.
* @param profile the profile to bind this tracker to the profile MUST contain an UUID!
* @return the replacedociated PlayerTracker
*/
@Nonnull
public static PlayerTracker getOrCreatePlayerTrackerByProfile(TiqualityWorld world, @Nonnull final GameProfile profile) {
UUID id = profile.getId();
if (id == null) {
throw new IllegalArgumentException("GameProfile must have an UUID");
}
PlayerTracker tracker = TrackerManager.foreach(new TrackerManager.Action<PlayerTracker>() {
@Override
public void each(Tracker tracker) {
if (tracker instanceof PlayerTracker) {
PlayerTracker playerTracker = (PlayerTracker) tracker;
if (playerTracker.getOwner().getId().equals(id)) {
stop(playerTracker);
}
}
}
});
return tracker != null ? tracker : TrackerManager.createNewTrackerHolder(world, new PlayerTracker(profile)).getTracker();
}
public List<TextComponentString> getSharedToTextual(TiqualityWorld world) {
LinkedList<TextComponentString> list = new LinkedList<>();
for (long id : sharedTo) {
TrackerHolder holder = TrackerHolder.getTrackerHolder(world, id);
if (holder == null || holder.getTracker() instanceof PlayerTracker == false) {
switchSharedTo(id);
list.add(new TextComponentString(TextFormatting.RED + "Tracker ID: " + id + " removed!"));
} else {
list.add(new TextComponentString(TextFormatting.WHITE + ((PlayerTracker) holder.getTracker()).getOwner().getName()));
}
}
return list;
}
public boolean switchNotify() {
notifyUser = notifyUser == false;
return notifyUser;
}
public boolean switchSharedTo(long id) {
if (sharedTo.contains(id) == false) {
sharedTo.add(id);
getHolder().update();
return true;
} else {
sharedTo.remove(id);
getHolder().update();
return false;
}
}
/**
* Requests a claim override.
*
* @param world The world
* @param leastPos .
* @param mostPos .
* @param requester the callback to run upon success or failure.
* @throws CommandException If the user already has a pending request.
*/
public void requestClaimOverride(ClaimOverrideRequester requester, World world, BlockPos leastPos, BlockPos mostPos) throws CommandException {
EnreplacedyPlayerMP thisPlayer = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUUID(this.getOwner().getId());
// noinspection ConstantConditions (Player == null can be true.)
if (thisPlayer == null || thisPlayer.hasDisconnected()) {
requester.onOfflineOwner(this);
return;
}
String requesterName = requester.getProfile().getName();
String acceptString = "/tiquality acceptoverride " + requesterName;
String denyString = "/tiquality denyoverride " + requesterName;
if (pendingRequests.containsKey(requesterName.toLowerCase())) {
throw new CommandException("You already have another pending request. Inform the owner to run: '" + acceptString + "' to accept your last request, or '" + denyString + "' to reject it.");
} else {
pendingRequests.put(requesterName.toLowerCase(), requester);
}
thisPlayer.sendMessage(new TextComponentString(PREFIX + requesterName + " wishes to claim an area that overlaps or is near your claim:"));
thisPlayer.sendMessage(new TextComponentString(TextFormatting.GRAY + " Affected area: X=" + leastPos.getX() + " Z=" + leastPos.getZ() + " to X=" + mostPos.getX() + " Z=" + mostPos.getZ()));
thisPlayer.sendMessage(new TextComponentString(TextFormatting.GRAY + " Affected dimension: " + world.provider.getDimension()));
thisPlayer.sendMessage(new TextComponentString(TextFormatting.GRAY + " Surface area of total claim: " + (mostPos.getX() - leastPos.getX()) * (mostPos.getZ() - leastPos.getZ())));
thisPlayer.sendMessage(new TextComponentString(TextFormatting.GRAY + "To accept this request use: " + TextFormatting.GREEN + acceptString));
thisPlayer.sendMessage(new TextComponentString(TextFormatting.GRAY + "To deny this request use: " + TextFormatting.RED + denyString));
}
public List<String> getOverrideRequests() {
return new LinkedList<>(pendingRequests.keySet());
}
public void acceptOverride(ICommandSender sender, String name) throws CommandException {
ClaimOverrideRequester request = pendingRequests.remove(name.toLowerCase());
if (request != null) {
sender.sendMessage(new TextComponentString(PREFIX + "Accepted!"));
request.onAccept(this);
} else {
throw new CommandException("Request for: '" + name + "' was not found.");
}
}
public void denyOverride(ICommandSender sender, String name) throws CommandException {
ClaimOverrideRequester request = pendingRequests.remove(name.toLowerCase());
if (request != null) {
sender.sendMessage(new TextComponentString(PREFIX + "Denied override!"));
request.onDeny(this);
} else {
throw new CommandException("Request for: '" + name + "' was not found.");
}
}
public void addWallet(TickWallet wallet) {
this.wallet.addWallet(wallet);
}
public TickWallet getWallet() {
return this.wallet;
}
@Override
public void setNextTickTime(long time) {
super.setNextTickTime(time);
wallet.clearWallets();
wallet.setRemainingTime(time);
}
@Override
public void tick() {
super.tick();
for (Long id : sharedTo) {
Tracker tracker = TrackerManager.getTrackerByID(id);
if (tracker instanceof PlayerTracker) {
((PlayerTracker) tracker).addWallet(this.wallet);
}
}
}
/**
* Notify this tracker about it's performance falling behind.
*
* @param ratio the tracker's speed compared to the server tick time.
*/
public void notifyFallingBehind(double ratio) {
if (notifyUser && System.currentTimeMillis() > nextMessageMillis) {
nextMessageMillis = System.currentTimeMillis() + (TiqualityConfig.DEFAULT_THROTTLE_WARNING_INTERVAL_SECONDS * 1000);
Enreplacedy e = FMLCommonHandler.instance().getMinecraftServerInstance().getEnreplacedyFromUuid(getOwner().getId());
if (e instanceof EnreplacedyPlayer) {
EnreplacedyPlayer player = (EnreplacedyPlayer) e;
player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Warning: " + TextFormatting.GRAY + "Your blocks tick at " + (Math.round(ratio * 10000D) / 100D) + "% speed." + TextFormatting.DARK_GRAY + " (/tiquality notify)"), true);
double serverTPS_raw = Tiquality.TPS_MONITOR.getAverageTPS();
String serverTPS = TWO_DECIMAL_FORMATTER.format(Math.round(serverTPS_raw * 100D) / 100D);
String playerTPS = TWO_DECIMAL_FORMATTER.format(Math.round(serverTPS_raw * ratio * 100D) / 100D);
player.sendMessage(new TextComponentString(PREFIX + "Your TPS: " + TextFormatting.WHITE + playerTPS + TextFormatting.GRAY + " (" + TextFormatting.WHITE + Math.round(ratio * 100D) + "%" + TextFormatting.GRAY + ")" + TextFormatting.DARK_GRAY + " (/tiquality notify)"));
}
}
}
/**
* Decreases the remaining tick time for a tracker.
*
* @param time in nanoseconds
*/
@Override
public void consume(long time) {
wallet.consume(time);
}
@Override
public long getRemainingTime() {
return wallet.getTimeLeft();
}
@Override
public Tracker load(TiqualityWorld world, NBTTagCompound trackerTag) {
PlayerTracker tracker = new PlayerTracker(ForgeData.getGameProfileByUUID(new UUID(trackerTag.getLong("uuidMost"), trackerTag.getLong("uuidLeast"))));
if (trackerTag.hasKey("shared")) {
NBTTagList shared = trackerTag.getTagList("shared", 4);
for (NBTBase base : shared) {
tracker.sharedTo.add(((NBTTagLong) base).getLong());
}
}
tracker.notifyUser = trackerTag.getBoolean("notify");
return tracker;
}
/**
* Checks if the owner of this tracker is online or not.
*
* @param onlinePlayerProfiles an array of online players
* @return true if online
*/
public boolean isPlayerOnline(final GameProfile[] onlinePlayerProfiles) {
for (GameProfile profile : onlinePlayerProfiles) {
if (this.profile.getId().equals(profile.getId())) {
return true;
}
}
return false;
}
/**
* Gets the NBT data from this object, is called when the tracker is saved to disk.
*/
@Nonnull
@Override
public NBTTagCompound getNBT() {
NBTTagCompound tag = new NBTTagCompound();
tag.setLong("uuidMost", profile.getId().getMostSignificantBits());
tag.setLong("uuidLeast", profile.getId().getLeastSignificantBits());
tag.setBoolean("notify", notifyUser);
if (sharedTo.size() > 0) {
NBTTagList sharedToTag = new NBTTagList();
for (long id : sharedTo) {
sharedToTag.appendTag(new NBTTagLong(id));
}
tag.setTag("shared", sharedToTag);
}
/* Human readable names and UUID's. These are not accessed.*/
tag.setString("name", profile.getName());
tag.setString("uuid", profile.getId().toString());
return tag;
}
/**
* Gets the tick time multiplier for the PlayerTracker.
* This is used to distribute tick time in a more controlled manner.
*
* @param cache The current online player cache
* @return the multiplier
*/
public double getMultiplier(final GameProfile[] cache) {
return isPlayerOnline(cache) ? 1 : TiqualityConfig.OFFLINE_PLAYER_TICK_TIME_MULTIPLIER;
}
/**
* Gets the replacedociated player for this tracker
*
* @return a list containing just 1 player.
*/
@Override
@Nonnull
public List<GameProfile> getreplacedociatedPlayers() {
List<GameProfile> list = new ArrayList<>();
list.add(profile);
return list;
}
/**
* Gets the owner corresponding to this PlayerTracker.
*
* @return the owner's profile
*/
public GameProfile getOwner() {
return profile;
}
/**
* Debugging method. Do not use in production environments.
*
* @return description
*/
@Override
public String toString() {
return "PlayerTracker:{Owner: '" + getOwner().getName() + "', nsleft: " + tick_time_remaining_ns + ", unticked: " + tickQueue.size() + ", hashCode: " + System.idenreplacedyHashCode(this) + "}";
}
/**
* @return the info describing this TrackerBase (Like the owner)
*/
@Nonnull
@Override
public TextComponentString getInfo() {
return new TextComponentString(TextFormatting.GREEN + "Tracked by: " + TextFormatting.AQUA + getOwner().getName());
}
/**
* @return an unique identifier for this TrackerBase type, used to re-instantiate the tracker later on.
*/
@Nonnull
public String getIdentifier() {
return "PlayerTracker";
}
/**
* Required to check for colission with unloaded trackers.
*
* @return int the hash code, just like Object#hashCode().
*/
@Override
public int getHashCode() {
return getOwner().getId().hashCode();
}
/**
* Checks if the tracker is equal to one already in the database.
* Allows for flexibility for loading.
*
* @param tag tag
* @return equals
*/
@Override
public boolean equalsSaved(NBTTagCompound tag) {
UUID ownerUUID = new UUID(tag.getLong("uuidMost"), tag.getLong("uuidLeast"));
return ownerUUID.equals(getOwner().getId());
}
@SuppressWarnings("IfMayBeConditional")
/* Too confusing */
@Override
public boolean equals(Object o) {
if (o instanceof PlayerTracker == false) {
return false;
} else {
return o == this || this.getOwner().getId().equals(((PlayerTracker) o).getOwner().getId());
}
}
@Override
public int hashCode() {
return getOwner().getId().hashCode();
}
public interface ClaimOverrideRequester {
void onDeny(PlayerTracker tracker);
void onOfflineOwner(PlayerTracker tracker);
void onAccept(PlayerTracker tracker);
GameProfile getProfile();
}
}
19
Source : PlayerTracker.java
with GNU General Public License v3.0
from TerminatorNL
with GNU General Public License v3.0
from TerminatorNL
/**
* Gets the tick time multiplier for the PlayerTracker.
* This is used to distribute tick time in a more controlled manner.
*
* @param cache The current online player cache
* @return the multiplier
*/
public double getMultiplier(final GameProfile[] cache) {
return isPlayerOnline(cache) ? 1 : TiqualityConfig.OFFLINE_PLAYER_TICK_TIME_MULTIPLIER;
}
19
Source : PlayerTracker.java
with GNU General Public License v3.0
from TerminatorNL
with GNU General Public License v3.0
from TerminatorNL
/**
* Checks if the owner of this tracker is online or not.
*
* @param onlinePlayerProfiles an array of online players
* @return true if online
*/
public boolean isPlayerOnline(final GameProfile[] onlinePlayerProfiles) {
for (GameProfile profile : onlinePlayerProfiles) {
if (this.profile.getId().equals(profile.getId())) {
return true;
}
}
return false;
}
19
Source : PlayerTracker.java
with GNU General Public License v3.0
from TerminatorNL
with GNU General Public License v3.0
from TerminatorNL
/*
* Gets the tracker for a player, if no one exists yet, it will create one. Never returns null.
* @param profile the profile to bind this tracker to the profile MUST contain an UUID!
* @return the replacedociated PlayerTracker
*/
@Nonnull
public static PlayerTracker getOrCreatePlayerTrackerByProfile(TiqualityWorld world, @Nonnull final GameProfile profile) {
UUID id = profile.getId();
if (id == null) {
throw new IllegalArgumentException("GameProfile must have an UUID");
}
PlayerTracker tracker = TrackerManager.foreach(new TrackerManager.Action<PlayerTracker>() {
@Override
public void each(Tracker tracker) {
if (tracker instanceof PlayerTracker) {
PlayerTracker playerTracker = (PlayerTracker) tracker;
if (playerTracker.getOwner().getId().equals(id)) {
stop(playerTracker);
}
}
}
});
return tracker != null ? tracker : TrackerManager.createNewTrackerHolder(world, new PlayerTracker(profile)).getTracker();
}
19
Source : ForcedTracker.java
with GNU General Public License v3.0
from TerminatorNL
with GNU General Public License v3.0
from TerminatorNL
/**
* Since we're a TrackerBase without an owner, we replacedign 0 time to it's tick time.
*
* @param cache The current online player cache
* @return 0
*/
@Override
public double getMultiplier(final GameProfile[] cache) {
return 0;
}
19
Source : DenyTracker.java
with GNU General Public License v3.0
from TerminatorNL
with GNU General Public License v3.0
from TerminatorNL
@Override
public double getMultiplier(GameProfile[] cache) {
throw new UnsupportedOperationException();
}
19
Source : GriefPreventionHook.java
with GNU General Public License v3.0
from TerminatorNL
with GNU General Public License v3.0
from TerminatorNL
@Nullable
public static Tracker findOrGetTrackerByClaim(@Nonnull Claim claim) {
if (claim.isWilderness()) {
return null;
} else if (claim.isAdminClaim()) {
return AdminClaimTracker.INSTANCE;
} else if (claim.getOwnerUniqueId() == null) {
throw new IllegalArgumentException("Claim owner is null!");
}
GameProfile profile = ForgeData.getGameProfileByUUID(claim.getOwnerUniqueId());
return PlayerTracker.getOrCreatePlayerTrackerByProfile((TiqualityWorld) claim.getWorld(), profile);
}
19
Source : TileEntitySecurityStation.java
with GNU General Public License v3.0
from TeamPneumatic
with GNU General Public License v3.0
from TeamPneumatic
private ListNBT toNBTList(Collection<GameProfile> profiles) {
ListNBT res = new ListNBT();
for (GameProfile profile : profiles) {
CompoundNBT tagCompound = new CompoundNBT();
tagCompound.putString("name", profile.getName());
if (profile.getId() != null)
tagCompound.putString("uuid", profile.getId().toString());
res.add(tagCompound);
}
return res;
}
19
Source : TileEntitySecurityStation.java
with GNU General Public License v3.0
from TeamPneumatic
with GNU General Public License v3.0
from TeamPneumatic
private boolean gameProfileEquals(GameProfile profile1, GameProfile profile2) {
return profile1.getId() != null && profile2.getId() != null ? profile1.getId().equals(profile2.getId()) : profile1.getName().equals(profile2.getName());
}
19
Source : TileEntitySecurityStation.java
with GNU General Public License v3.0
from TeamPneumatic
with GNU General Public License v3.0
from TeamPneumatic
public void addHacker(GameProfile user) {
for (GameProfile hackedUser : hackedUsers) {
if (gameProfileEquals(hackedUser, user)) {
return;
}
}
for (GameProfile sharedUser : sharedUsers) {
if (gameProfileEquals(sharedUser, user))
return;
}
hackedUsers.add(user);
if (!world.isRemote)
sendDescriptionPacket();
}
19
Source : TileEntitySecurityStation.java
with GNU General Public License v3.0
from TeamPneumatic
with GNU General Public License v3.0
from TeamPneumatic
public void addTrustedUser(GameProfile user) {
for (GameProfile sharedUser : sharedUsers) {
if (gameProfileEquals(sharedUser, user))
return;
}
sharedUsers.add(user);
if (!world.isRemote)
sendDescriptionPacket();
}
19
Source : Village.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* Write this village's data to NBT.
*/
public void writeVillageDataToNBT(NBTTagCompound compound) {
compound.setInteger("PopSize", this.numVillagers);
compound.setInteger("Radius", this.villageRadius);
compound.setInteger("Golems", this.numIronGolems);
compound.setInteger("Stable", this.lastAddDoorTimestamp);
compound.setInteger("Tick", this.tickCounter);
compound.setInteger("MTick", this.noBreedTicks);
compound.setInteger("CX", this.center.getX());
compound.setInteger("CY", this.center.getY());
compound.setInteger("CZ", this.center.getZ());
compound.setInteger("ACX", this.centerHelper.getX());
compound.setInteger("ACY", this.centerHelper.getY());
compound.setInteger("ACZ", this.centerHelper.getZ());
NBTTagList nbttaglist = new NBTTagList();
for (VillageDoorInfo villagedoorinfo : this.villageDoorInfoList) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("X", villagedoorinfo.getDoorBlockPos().getX());
nbttagcompound.setInteger("Y", villagedoorinfo.getDoorBlockPos().getY());
nbttagcompound.setInteger("Z", villagedoorinfo.getDoorBlockPos().getZ());
nbttagcompound.setInteger("IDX", villagedoorinfo.getInsideOffsetX());
nbttagcompound.setInteger("IDZ", villagedoorinfo.getInsideOffsetZ());
nbttagcompound.setInteger("TS", villagedoorinfo.getInsidePosY());
nbttaglist.appendTag(nbttagcompound);
}
compound.setTag("Doors", nbttaglist);
NBTTagList nbttaglist1 = new NBTTagList();
for (String s : this.playerReputation.keySet()) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
PlayerProfileCache playerprofilecache = this.worldObj.getMinecraftServer().getPlayerProfileCache();
try {
GameProfile gameprofile = playerprofilecache.getGameProfileForUsername(s);
if (gameprofile != null) {
nbttagcompound1.setString("UUID", gameprofile.getId().toString());
nbttagcompound1.setInteger("S", ((Integer) this.playerReputation.get(s)).intValue());
nbttaglist1.appendTag(nbttagcompound1);
}
} catch (RuntimeException var9) {
;
}
}
compound.setTag("Players", nbttaglist1);
}
19
Source : Village.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* Read this village's data from NBT.
*/
public void readVillageDataFromNBT(NBTTagCompound compound) {
this.numVillagers = compound.getInteger("PopSize");
this.villageRadius = compound.getInteger("Radius");
this.numIronGolems = compound.getInteger("Golems");
this.lastAddDoorTimestamp = compound.getInteger("Stable");
this.tickCounter = compound.getInteger("Tick");
this.noBreedTicks = compound.getInteger("MTick");
this.center = new BlockPos(compound.getInteger("CX"), compound.getInteger("CY"), compound.getInteger("CZ"));
this.centerHelper = new BlockPos(compound.getInteger("ACX"), compound.getInteger("ACY"), compound.getInteger("ACZ"));
NBTTagList nbttaglist = compound.getTagList("Doors", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
VillageDoorInfo villagedoorinfo = new VillageDoorInfo(new BlockPos(nbttagcompound.getInteger("X"), nbttagcompound.getInteger("Y"), nbttagcompound.getInteger("Z")), nbttagcompound.getInteger("IDX"), nbttagcompound.getInteger("IDZ"), nbttagcompound.getInteger("TS"));
this.villageDoorInfoList.add(villagedoorinfo);
}
NBTTagList nbttaglist1 = compound.getTagList("Players", 10);
for (int j = 0; j < nbttaglist1.tagCount(); ++j) {
NBTTagCompound nbttagcompound1 = nbttaglist1.getCompoundTagAt(j);
if (nbttagcompound1.hasKey("UUID") && this.worldObj != null && this.worldObj.getMinecraftServer() != null) {
PlayerProfileCache playerprofilecache = this.worldObj.getMinecraftServer().getPlayerProfileCache();
GameProfile gameprofile = playerprofilecache.getProfileByUUID(UUID.fromString(nbttagcompound1.getString("UUID")));
if (gameprofile != null) {
this.playerReputation.put(gameprofile.getName(), Integer.valueOf(nbttagcompound1.getInteger("S")));
}
} else {
this.playerReputation.put(nbttagcompound1.getString("Name"), Integer.valueOf(nbttagcompound1.getInteger("S")));
}
}
}
19
Source : TileEntitySkull.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public void setPlayerProfile(@Nullable GameProfile playerProfile) {
this.skullType = 3;
this.playerProfile = playerProfile;
this.updatePlayerProfile();
}
19
Source : TileEntitySkull.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public static GameProfile updateGameprofile(GameProfile input) {
if (input != null && !StringUtils.isNullOrEmpty(input.getName())) {
if (input.isComplete() && input.getProperties().containsKey("textures")) {
return input;
} else if (profileCache != null && sessionService != null) {
GameProfile gameprofile = profileCache.getGameProfileForUsername(input.getName());
if (gameprofile == null) {
return input;
} else {
Property property = (Property) Iterables.getFirst(gameprofile.getProperties().get("textures"), null);
if (property == null) {
gameprofile = sessionService.fillProfileProperties(gameprofile, true);
}
return gameprofile;
}
} else {
return input;
}
} else {
return input;
}
}
19
Source : NetHandlerLoginServer.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
protected GameProfile getOfflineProfile(GameProfile original) {
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + original.getName()).getBytes(Charsets.UTF_8));
return new GameProfile(uuid, original.getName());
}
19
Source : MinecraftServer.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* Main function called by run() every loop.
*/
public void tick() {
long i = System.nanoTime();
++this.tickCounter;
if (this.startProfiling) {
this.startProfiling = false;
this.theProfiler.profilingEnabled = true;
this.theProfiler.clearProfiling();
}
this.theProfiler.startSection("root");
this.updateTimeLightAndEnreplacedies();
if (i - this.nanoTimeSinceStatusRefresh >= 5000000000L) {
this.nanoTimeSinceStatusRefresh = i;
this.statusResponse.setPlayers(new ServerStatusResponse.Players(this.getMaxPlayers(), this.getCurrentPlayerCount()));
GameProfile[] agameprofile = new GameProfile[Math.min(this.getCurrentPlayerCount(), 12)];
int j = MathHelper.getInt(this.random, 0, this.getCurrentPlayerCount() - agameprofile.length);
for (int k = 0; k < agameprofile.length; ++k) {
agameprofile[k] = ((EnreplacedyPlayerMP) this.playerList.getPlayerList().get(j + k)).getGameProfile();
}
Collections.shuffle(Arrays.asList(agameprofile));
this.statusResponse.getPlayers().setPlayers(agameprofile);
}
if (this.tickCounter % 900 == 0) {
this.theProfiler.startSection("save");
this.playerList.saveAllPlayerData();
this.saveAllWorlds(true);
this.theProfiler.endSection();
}
this.theProfiler.startSection("tallying");
this.tickTimeArray[this.tickCounter % 100] = System.nanoTime() - i;
this.theProfiler.endSection();
this.theProfiler.startSection("snooper");
if (!this.usageSnooper.isSnooperRunning() && this.tickCounter > 100) {
this.usageSnooper.startSnooper();
}
if (this.tickCounter % 6000 == 0) {
this.usageSnooper.addMemoryStatsToSnooper();
}
this.theProfiler.endSection();
this.theProfiler.endSection();
}
19
Source : UserListWhitelist.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* Gets the key value for the given object
*/
protected String getObjectKey(GameProfile obj) {
return obj.getId().toString();
}
19
Source : UserListOps.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* Get the OP permission level this player has
*/
public int getPermissionLevel(GameProfile profile) {
UserListOpsEntry userlistopsentry = (UserListOpsEntry) this.getEntry(profile);
return userlistopsentry != null ? userlistopsentry.getPermissionLevel() : 0;
}
19
Source : UserListOps.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public boolean bypreplacedesPlayerLimit(GameProfile profile) {
UserListOpsEntry userlistopsentry = (UserListOpsEntry) this.getEntry(profile);
return userlistopsentry != null ? userlistopsentry.bypreplacedesPlayerLimit() : false;
}
19
Source : UserListBans.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public boolean isBanned(GameProfile profile) {
return this.hasEntry(profile);
}
19
Source : PlayerProfileCache.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* Add an entry to this cache
*/
public void addEntry(GameProfile gameProfile) {
this.addEntry(gameProfile, (Date) null);
}
19
Source : PlayerProfileCache.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* Get a {@link ProfileEntry} by UUID
*/
private PlayerProfileCache.ProfileEntry getByUUID(UUID uuid) {
PlayerProfileCache.ProfileEntry playerprofilecache$profileentry = (PlayerProfileCache.ProfileEntry) this.uuidToProfileEntryMap.get(uuid);
if (playerprofilecache$profileentry != null) {
GameProfile gameprofile = playerprofilecache$profileentry.getGameProfile();
this.gameProfiles.remove(gameprofile);
this.gameProfiles.addFirst(gameprofile);
}
return playerprofilecache$profileentry;
}
19
Source : PlayerProfileCache.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
@Nullable
public /**
* Get a player's GameProfile given their username. Mojang's server's will be contacted if the entry is not cached
* locally.
*/
GameProfile getGameProfileForUsername(String username) {
String s = username.toLowerCase(Locale.ROOT);
PlayerProfileCache.ProfileEntry playerprofilecache$profileentry = (PlayerProfileCache.ProfileEntry) this.usernameToProfileEntryMap.get(s);
if (playerprofilecache$profileentry != null && (new Date()).getTime() >= playerprofilecache$profileentry.expirationDate.getTime()) {
this.uuidToProfileEntryMap.remove(playerprofilecache$profileentry.getGameProfile().getId());
this.usernameToProfileEntryMap.remove(playerprofilecache$profileentry.getGameProfile().getName().toLowerCase(Locale.ROOT));
this.gameProfiles.remove(playerprofilecache$profileentry.getGameProfile());
playerprofilecache$profileentry = null;
}
if (playerprofilecache$profileentry != null) {
GameProfile gameprofile = playerprofilecache$profileentry.getGameProfile();
this.gameProfiles.remove(gameprofile);
this.gameProfiles.addFirst(gameprofile);
} else {
GameProfile gameprofile1 = lookupProfile(this.profileRepo, s);
if (gameprofile1 != null) {
this.addEntry(gameprofile1);
playerprofilecache$profileentry = (PlayerProfileCache.ProfileEntry) this.usernameToProfileEntryMap.get(s);
}
}
this.save();
return playerprofilecache$profileentry == null ? null : playerprofilecache$profileentry.getGameProfile();
}
19
Source : PlayerProfileCache.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
private List<PlayerProfileCache.ProfileEntry> getEntriesWithLimit(int limitSize) {
List<PlayerProfileCache.ProfileEntry> list = Lists.<PlayerProfileCache.ProfileEntry>newArrayList();
for (GameProfile gameprofile : Lists.newArrayList(Iterators.limit(this.gameProfiles.iterator(), limitSize))) {
PlayerProfileCache.ProfileEntry playerprofilecache$profileentry = this.getByUUID(gameprofile.getId());
if (playerprofilecache$profileentry != null) {
list.add(playerprofilecache$profileentry);
}
}
return list;
}
19
Source : PlayerList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public void addOp(GameProfile profile) {
int i = this.mcServer.getOpPermissionLevel();
this.ops.addEntry(new UserListOpsEntry(profile, this.mcServer.getOpPermissionLevel(), this.ops.bypreplacedesPlayerLimit(profile)));
this.sendPlayerPermissionLevel(this.getPlayerByUUID(profile.getId()), i);
}
19
Source : PlayerList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* checks ban-lists, then white-lists, then space for the server. Returns null on success, or an error message
*/
public String allowUserToConnect(SocketAddress address, GameProfile profile) {
if (this.bannedPlayers.isBanned(profile)) {
UserListBansEntry userlistbansentry = (UserListBansEntry) this.bannedPlayers.getEntry(profile);
String s1 = "You are banned from this server!\nReason: " + userlistbansentry.getBanReason();
if (userlistbansentry.getBanEndDate() != null) {
s1 = s1 + "\nYour ban will be removed on " + DATE_FORMAT.format(userlistbansentry.getBanEndDate());
}
return s1;
} else if (!this.canJoin(profile)) {
return "You are not white-listed on this server!";
} else if (this.bannedIPs.isBanned(address)) {
UserListIPBansEntry userlistipbansentry = this.bannedIPs.getBanEntry(address);
String s = "Your IP address is banned from this server!\nReason: " + userlistipbansentry.getBanReason();
if (userlistipbansentry.getBanEndDate() != null) {
s = s + "\nYour ban will be removed on " + DATE_FORMAT.format(userlistipbansentry.getBanEndDate());
}
return s;
} else {
return this.playerEnreplacedyList.size() >= this.maxPlayers && !this.bypreplacedesPlayerLimit(profile) ? "The server is full!" : null;
}
}
19
Source : PlayerList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public void removePlayerFromWhitelist(GameProfile profile) {
this.whiteListedPlayers.removeEntry(profile);
}
19
Source : PlayerList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public void addWhitelistedPlayer(GameProfile profile) {
this.whiteListedPlayers.addEntry(new UserListWhitelistEntry(profile));
}
19
Source : PlayerList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public void updatePermissionLevel(EnreplacedyPlayerMP player) {
GameProfile gameprofile = player.getGameProfile();
int i = this.canSendCommands(gameprofile) ? this.ops.getPermissionLevel(gameprofile) : 0;
i = this.mcServer.isSinglePlayer() && this.mcServer.worldServers[0].getWorldInfo().areCommandsAllowed() ? 4 : i;
i = this.commandsAllowedForAll ? 4 : i;
this.sendPlayerPermissionLevel(player, i);
}
19
Source : PlayerList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* also checks for multiple logins across servers
*/
public EnreplacedyPlayerMP createPlayerForUser(GameProfile profile) {
UUID uuid = EnreplacedyPlayer.getUUID(profile);
List<EnreplacedyPlayerMP> list = Lists.<EnreplacedyPlayerMP>newArrayList();
for (int i = 0; i < this.playerEnreplacedyList.size(); ++i) {
EnreplacedyPlayerMP enreplacedyplayermp = (EnreplacedyPlayerMP) this.playerEnreplacedyList.get(i);
if (enreplacedyplayermp.getUniqueID().equals(uuid)) {
list.add(enreplacedyplayermp);
}
}
EnreplacedyPlayerMP enreplacedyplayermp2 = (EnreplacedyPlayerMP) this.uuidToPlayerMap.get(profile.getId());
if (enreplacedyplayermp2 != null && !list.contains(enreplacedyplayermp2)) {
list.add(enreplacedyplayermp2);
}
for (EnreplacedyPlayerMP enreplacedyplayermp1 : list) {
enreplacedyplayermp1.connection.kickPlayerFromServer("You logged in from another location");
}
PlayerInteractionManager playerinteractionmanager;
if (this.mcServer.isDemo()) {
playerinteractionmanager = new DemoWorldManager(this.mcServer.worldServerForDimension(0));
} else {
playerinteractionmanager = new PlayerInteractionManager(this.mcServer.worldServerForDimension(0));
}
return new EnreplacedyPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), profile, playerinteractionmanager);
}
19
Source : PlayerList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public boolean canSendCommands(GameProfile profile) {
return this.ops.hasEntry(profile) || this.mcServer.isSinglePlayer() && this.mcServer.worldServers[0].getWorldInfo().areCommandsAllowed() && this.mcServer.getServerOwner().equalsIgnoreCase(profile.getName()) || this.commandsAllowedForAll;
}
19
Source : PlayerList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public GameProfile[] getAllProfiles() {
GameProfile[] agameprofile = new GameProfile[this.playerEnreplacedyList.size()];
for (int i = 0; i < this.playerEnreplacedyList.size(); ++i) {
agameprofile[i] = ((EnreplacedyPlayerMP) this.playerEnreplacedyList.get(i)).getGameProfile();
}
return agameprofile;
}
19
Source : PlayerList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public boolean canJoin(GameProfile profile) {
return !this.whiteListEnforced || this.ops.hasEntry(profile) || this.whiteListedPlayers.hasEntry(profile);
}
See More Examples