當前位置: 首頁>>代碼示例>>Java>>正文


Java Bukkit.getVersion方法代碼示例

本文整理匯總了Java中org.bukkit.Bukkit.getVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java Bukkit.getVersion方法的具體用法?Java Bukkit.getVersion怎麽用?Java Bukkit.getVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.Bukkit的用法示例。


在下文中一共展示了Bukkit.getVersion方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getServerData

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * Gets the server specific data.
 *
 * @return The server specific data.
 */
private JSONObject getServerData() {
    // Minecraft specific data
    int playerAmount = Bukkit.getOnlinePlayers().size();
    int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
    String bukkitVersion = Bukkit.getVersion();
    bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);

    // OS/Java specific data
    String javaVersion = System.getProperty("java.version");
    String osName = System.getProperty("os.name");
    String osArch = System.getProperty("os.arch");
    String osVersion = System.getProperty("os.version");
    int coreCount = Runtime.getRuntime().availableProcessors();

    JSONObject data = new JSONObject();

    data.put("serverUUID", serverUUID);

    data.put("playerAmount", playerAmount);
    data.put("onlineMode", onlineMode);
    data.put("bukkitVersion", bukkitVersion);

    data.put("javaVersion", javaVersion);
    data.put("osName", osName);
    data.put("osArch", osArch);
    data.put("osVersion", osVersion);
    data.put("coreCount", coreCount);

    return data;
}
 
開發者ID:Soldier233,項目名稱:ArchersBattle,代碼行數:36,代碼來源:Metrics.java

示例2: getServerData

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * Gets the server specific data.
 *
 * @return The server specific data.
 */
private JSONObject getServerData() {
    // Minecraft specific data
    int playerAmount;
    try {
        // Around MC 1.8 the return type was changed to a collection from an array,
        // This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
        Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
        playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
                ? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
                : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
    } catch (Exception e) {
        playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
    }
    int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
    String bukkitVersion = Bukkit.getVersion();
    bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);

    // OS/Java specific data
    String javaVersion = System.getProperty("java.version");
    String osName = System.getProperty("os.name");
    String osArch = System.getProperty("os.arch");
    String osVersion = System.getProperty("os.version");
    int coreCount = Runtime.getRuntime().availableProcessors();

    JSONObject data = new JSONObject();

    data.put("serverUUID", serverUUID);

    data.put("playerAmount", playerAmount);
    data.put("onlineMode", onlineMode);
    data.put("bukkitVersion", bukkitVersion);

    data.put("javaVersion", javaVersion);
    data.put("osName", osName);
    data.put("osArch", osArch);
    data.put("osVersion", osVersion);
    data.put("coreCount", coreCount);

    return data;
}
 
開發者ID:BtoBastian,項目名稱:bStats-Metrics,代碼行數:46,代碼來源:MetricsLite.java

示例3: getServerData

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * Gets the server specific data.
 *
 * @return The server specific data.
 */
private JSONObject getServerData() {
    // Minecraft specific data
    int playerAmount;
    try {
        // Around MC 1.8 the return type was changed to a collection from an array,
        // This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
        final Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
        playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
                ? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
                : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
    } catch (final Exception e) {
        playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
    }
    final int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
    String bukkitVersion = Bukkit.getVersion();
    bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);

    // OS/Java specific data
    final String javaVersion = System.getProperty("java.version");
    final String osName = System.getProperty("os.name");
    final String osArch = System.getProperty("os.arch");
    final String osVersion = System.getProperty("os.version");
    final int coreCount = Runtime.getRuntime().availableProcessors();

    final JSONObject data = new JSONObject();

    data.put("serverUUID", serverUUID);

    data.put("playerAmount", playerAmount);
    data.put("onlineMode", onlineMode);
    data.put("bukkitVersion", bukkitVersion);

    data.put("javaVersion", javaVersion);
    data.put("osName", osName);
    data.put("osArch", osArch);
    data.put("osVersion", osVersion);
    data.put("coreCount", coreCount);

    return data;
}
 
開發者ID:Shynixn,項目名稱:AstralEdit,代碼行數:46,代碼來源:Metrics.java


注:本文中的org.bukkit.Bukkit.getVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。