private void a(ServerPing serverping) { File file1 = this.d("server-icon.png"); if (file1.isFile()) { ByteBuf bytebuf = Unpooled.buffer(); try { BufferedImage bufferedimage = ImageIO.read(file1); Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]); Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]); ImageIO.write(bufferedimage, "PNG", new ByteBufOutputStream(bytebuf)); ByteBuf bytebuf1 = Base64.encode(bytebuf); serverping.setFavicon("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8)); } catch (Exception exception) { i.error("Couldn\'t load server icon", exception); } finally { bytebuf.release(); } } }
public void load() throws IOException { // CraftBukkit - Added throws Collection collection = null; BufferedReader bufferedreader = null; try { bufferedreader = Files.newReader(this.c, Charsets.UTF_8); collection = (Collection) this.b.fromJson(bufferedreader, f); } finally { IOUtils.closeQuietly(bufferedreader); } if (collection != null) { this.d.clear(); Iterator iterator = collection.iterator(); while (iterator.hasNext()) { JsonListEntry jsonlistentry = (JsonListEntry) iterator.next(); if (jsonlistentry.getKey() != null) { this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry); } } } }
static List a(File file1, Map map) throws IOException { // CraftBukkit - Added throws List list = Files.readLines(file1, Charsets.UTF_8); Iterator iterator = list.iterator(); while (iterator.hasNext()) { String s = (String) iterator.next(); s = s.trim(); if (!s.startsWith("#") && s.length() >= 1) { String[] astring = s.split("\\|"); map.put(astring[0].toLowerCase(Locale.ROOT), astring); } } return list; }
public String c(int i) throws IOException { // CraftBukkit - throws IOException int j = this.a(); if (j > i * 4) { throw new IOException("The received encoded string buffer length is longer than maximum allowed (" + j + " > " + i * 4 + ")"); } else if (j < 0) { throw new IOException("The received encoded string buffer length is less than zero! Weird string!"); } else { String s = new String(this.readBytes(j).array(), Charsets.UTF_8); if (s.length() > i) { throw new IOException("The received string length is longer than maximum allowed (" + j + " > " + i + ")"); } else { return s; } } }
public void initUUID() { UUID uuid; if ( networkManager.spoofedUUID != null ) { uuid = networkManager.spoofedUUID; } else { uuid = UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + this.i.getName() ).getBytes( Charsets.UTF_8 ) ); } this.i = new GameProfile( uuid, this.i.getName() ); if (networkManager.spoofedProfile != null) { for ( Property property : networkManager.spoofedProfile ) { this.i.getProperties().put( property.getName(), property ); } } }
public void c() { String s = this.b.toJson(this.a(org.spigotmc.SpigotConfig.userCacheCap)); BufferedWriter bufferedwriter = null; try { bufferedwriter = Files.newWriter(this.g, Charsets.UTF_8); bufferedwriter.write(s); return; } catch (FileNotFoundException filenotfoundexception) { return; } catch (IOException ioexception) { ; } finally { IOUtils.closeQuietly(bufferedwriter); } }
@Override @Deprecated public OfflinePlayer getOfflinePlayer(String name) { Validate.notNull(name, "Name cannot be null"); // If the name given cannot ever be a valid username give a dummy return, for scoreboard plugins if (!validUserPattern.matcher(name).matches()) { return new CraftOfflinePlayer(this, new GameProfile(invalidUserUUID, name)); } OfflinePlayer result = getPlayerExact(name); if (result == null) { // This is potentially blocking :( GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(name); if (profile == null) { // Make an OfflinePlayer using an offline mode UUID since the name has no profile result = getOfflinePlayer(new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name)); } else { // Use the GameProfile even when we get a UUID so we ensure we still have a name result = getOfflinePlayer(profile); } } else { offlinePlayers.remove(result.getUniqueId()); } return result; }
static CraftIconCache loadServerIcon0(BufferedImage image) throws Exception { ByteBuf bytebuf = Unpooled.buffer(); Validate.isTrue(image.getWidth() == 64, "Must be 64 pixels wide"); Validate.isTrue(image.getHeight() == 64, "Must be 64 pixels high"); ImageIO.write(image, "PNG", new ByteBufOutputStream(bytebuf)); ByteBuf bytebuf1 = Base64.encode(bytebuf); return new CraftIconCache("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8)); }
public static UUID a(GameProfile gameprofile) { UUID uuid = gameprofile.getId(); if (uuid == null) { uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + gameprofile.getName()).getBytes(Charsets.UTF_8)); } return uuid; }
public void save() throws IOException { // CraftBukkit - Added throws Collection collection = this.d.values(); String s = this.b.toJson(collection); BufferedWriter bufferedwriter = null; try { bufferedwriter = Files.newWriter(this.c, Charsets.UTF_8); bufferedwriter.write(s); } finally { IOUtils.closeQuietly(bufferedwriter); } }
public static boolean c(MinecraftServer minecraftserver) { OpList oplist = new OpList(PlayerList.c); if (c.exists() && c.isFile()) { if (oplist.c().exists()) { try { oplist.load(); // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace } catch (IOException filenotfoundexception) { e.warn("Could not load existing file " + oplist.c().getName() + ", " + filenotfoundexception.getMessage()); } // CraftBukkit end } try { List list = Files.readLines(c, Charsets.UTF_8); OpListProfileCallback oplistprofilecallback = new OpListProfileCallback(minecraftserver, oplist); a(minecraftserver, list, oplistprofilecallback); oplist.save(); c(c); return true; } catch (IOException ioexception) { e.warn("Could not read old oplist to convert it!", ioexception); return false; } catch (FileConversionException fileconversionexception) { e.error("Conversion failed, please try again later", fileconversionexception); return false; } } else { return true; } }
public static boolean d(MinecraftServer minecraftserver) { WhiteList whitelist = new WhiteList(PlayerList.d); if (d.exists() && d.isFile()) { if (whitelist.c().exists()) { try { whitelist.load(); // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace } catch (IOException filenotfoundexception) { e.warn("Could not load existing file " + whitelist.c().getName() + ", " + filenotfoundexception.getMessage()); } // CraftBukkit end } try { List list = Files.readLines(d, Charsets.UTF_8); WhiteListProfileCallback whitelistprofilecallback = new WhiteListProfileCallback(minecraftserver, whitelist); a(minecraftserver, list, whitelistprofilecallback); whitelist.save(); c(d); return true; } catch (IOException ioexception) { e.warn("Could not read old whitelist to convert it!", ioexception); return false; } catch (FileConversionException fileconversionexception) { e.error("Conversion failed, please try again later", fileconversionexception); return false; } } else { return true; } }
public void a(String s) throws IOException { // CraftBukkit - throws IOException byte[] abyte = s.getBytes(Charsets.UTF_8); if (abyte.length > 32767) { throw new IOException("String too big (was " + s.length() + " bytes encoded, max " + 32767 + ")"); } else { this.b(abyte.length); this.writeBytes(abyte); } }
@Override @Deprecated public OfflinePlayer getOfflinePlayer(String name) { Validate.notNull(name, "Name cannot be null"); com.google.common.base.Preconditions.checkArgument( !org.apache.commons.lang.StringUtils.isBlank( name ), "Name cannot be blank" ); // Spigot OfflinePlayer result = getPlayerExact(name); if (result == null) { // Spigot Start GameProfile profile = null; // Only fetch an online UUID in online mode if ( MinecraftServer.getServer().getOnlineMode() || org.spigotmc.SpigotConfig.bungee ) { profile = MinecraftServer.getServer().getUserCache().getProfile( name ); } // Spigot end if (profile == null) { // Make an OfflinePlayer using an offline mode UUID since the name has no profile result = getOfflinePlayer(new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name)); } else { // Use the GameProfile even when we get a UUID so we ensure we still have a name result = getOfflinePlayer(profile); } } else { offlinePlayers.remove(result.getUniqueId()); } return result; }
protected GameProfile a(GameProfile gameprofile) { UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + gameprofile.getName()).getBytes(Charsets.UTF_8)); return new GameProfile(uuid, gameprofile.getName()); }
public void b() { List list = null; BufferedReader bufferedreader = null; label81: { try { bufferedreader = Files.newReader(this.g, Charsets.UTF_8); list = (List) this.b.fromJson(bufferedreader, h); break label81; } catch (FileNotFoundException filenotfoundexception) { ; // Spigot Start } catch (net.minecraft.util.com.google.gson.JsonSyntaxException ex) { JsonList.a.warn( "Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues." ); this.g.delete(); // Spigot End } finally { IOUtils.closeQuietly(bufferedreader); } return; } if (list != null) { this.c.clear(); this.d.clear(); LinkedList linkedlist = this.e; synchronized (this.e) { this.e.clear(); } list = Lists.reverse(list); Iterator iterator = list.iterator(); while (iterator.hasNext()) { UserCacheEntry usercacheentry = (UserCacheEntry) iterator.next(); if (usercacheentry != null) { this.a(usercacheentry.a(), usercacheentry.b()); } } } }
@Override public void spawn(Location inLocation) { if(this.isSpawned()) return; RemoteEntitySpawnEvent event = new RemoteEntitySpawnEvent(this, inLocation); Bukkit.getPluginManager().callEvent(event); if(event.isCancelled()) return; inLocation = event.getSpawnLocation(); WorldServer worldServer = ((CraftWorld)inLocation.getWorld()).getHandle(); UUID uuid = UUID.nameUUIDFromBytes(("NPC:" + this.getID() + this.getName()).getBytes(Charsets.UTF_8)); GameProfile profile = new GameProfile(uuid.toString().replaceAll("-", ""), this.getName()); this.m_entity = new RemotePlayerEntity(worldServer.getMinecraftServer(), worldServer, profile, new PlayerInteractManager(worldServer), this); worldServer.addEntity(m_entity); this.m_entity.world.players.remove(this.m_entity); Player player = this.getBukkitEntity(); if(player != null) { player.teleport(inLocation); player.setMetadata("remoteentity", new FixedMetadataValue(this.m_manager.getPlugin(), this)); } this.setHeadYaw(inLocation.getYaw()); this.setYaw(inLocation.getYaw()); ((RemotePlayerEntity)this.m_entity).updateSpawn(); if(!inLocation.getBlock().getRelative(BlockFace.DOWN).isEmpty()) this.m_entity.onGround = true; if(this.m_speed != -1) this.setSpeed(this.m_speed); else this.setSpeed(1d); if(this.m_speedModifier != null) { this.addSpeedModifier(this.m_speedModifier.d(), (this.m_speedModifier.c() == 0)); this.m_speedModifier = null; } }