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


Java Bukkit.getOnlineMode方法代碼示例

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


在下文中一共展示了Bukkit.getOnlineMode方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 = org.bukkit.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:Ladinn,項目名稱:JavaShell,代碼行數: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=Bukkit.getServer().getOnlinePlayers().size();
    int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
    String bukkitVersion = org.bukkit.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:UraniumMC,項目名稱:Uranium,代碼行數:36,代碼來源:BMetrics.java

示例3: getServerData

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
    * Gets the server specific data.
    *
    * @return The server specific data.
    */
   @SuppressWarnings("unchecked")
private JSONObject getServerData() {
       // Minecraft specific data
       int playerAmount = Bukkit.getOnlinePlayers().size();
       int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
       String bukkitVersion = org.bukkit.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:EverCraft,項目名稱:SayNoToMcLeaks,代碼行數:37,代碼來源:Metrics.java

示例4: 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

示例5: checkOnline

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public static void checkOnline() {
	if (!Bukkit.getOnlineMode()) {
		Bukkit.getConsoleSender().sendMessage("§6[!] §f이 서버는 오프라인 서버입니다.");
		Bukkit.getConsoleSender().sendMessage("§6[!] §f온라인으로 바꾸는 것을 권장드립니다.");
	}
}
 
開發者ID:SkyLightQP,項目名稱:ItemUtility,代碼行數:7,代碼來源:Util.java

示例6: 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 = org.bukkit.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:Slaymd,項目名稱:CaulCrafting,代碼行數:46,代碼來源:Metrics.java

示例7: 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 = org.bukkit.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,項目名稱:BlockBall,代碼行數:46,代碼來源:Metrics.java

示例8: 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

示例9: 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 = org.bukkit.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:RadBuilder,項目名稱:EmojiChat,代碼行數:46,代碼來源:Metrics.java

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