• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Charsets类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.minecraft.util.com.google.common.base.Charsets的典型用法代码示例。如果您正苦于以下问题:Java Charsets类的具体用法?Java Charsets怎么用?Java Charsets使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Charsets类属于net.minecraft.util.com.google.common.base包,在下文中一共展示了Charsets类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: a

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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();
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:23,代码来源:MinecraftServer.java


示例2: load

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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);
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:25,代码来源:JsonList.java


示例3: a

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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;
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:18,代码来源:NameReferencingFileConverter.java


示例4: c

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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;
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:18,代码来源:PacketDataSerializer.java


示例5: initUUID

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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 );
        }
    }
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:22,代码来源:LoginListener.java


示例6: c

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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);
    }
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:17,代码来源:UserCache.java


示例7: getOfflinePlayer

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
@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;
}
 
开发者ID:Techcable,项目名称:DiffUtils,代码行数:28,代码来源:CraftServer_1710.java


示例8: loadServerIcon0

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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));
}
 
开发者ID:Techcable,项目名称:DiffUtils,代码行数:11,代码来源:CraftServer_1710.java


示例9: a

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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;
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:10,代码来源:EntityHuman.java


示例10: save

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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);
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:13,代码来源:JsonList.java


示例11: c

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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;
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:34,代码来源:NameReferencingFileConverter.java


示例12: d

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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;
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:34,代码来源:NameReferencingFileConverter.java


示例13: a

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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);
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:11,代码来源:PacketDataSerializer.java


示例14: getOfflinePlayer

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
@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;
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:30,代码来源:CraftServer.java


示例15: a

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
protected GameProfile a(GameProfile gameprofile) {
    UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + gameprofile.getName()).getBytes(Charsets.UTF_8));

    return new GameProfile(uuid, gameprofile.getName());
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:6,代码来源:LoginListener.java


示例16: b

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
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());
            }
        }
    }
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:45,代码来源:UserCache.java


示例17: spawn

import net.minecraft.util.com.google.common.base.Charsets; //导入依赖的package包/类
@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;
	}
}
 
开发者ID:kumpelblase2,项目名称:remote-entities-nxt,代码行数:43,代码来源:RemotePlayer.java



注:本文中的net.minecraft.util.com.google.common.base.Charsets类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BluetoothSPP类代码示例发布时间:2022-05-23
下一篇:
Java Tr类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap