Java Code Examples for org.bukkit.Bukkit#getName()

The following examples show how to use org.bukkit.Bukkit#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Metrics.java    From Crazy-Auctions with MIT License 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 2
Source File: Metrics.java    From PlayerVaults with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 3
Source File: ApiMetricsLite.java    From Item-NBT-API with MIT License 4 votes vote down vote up
/**
 * 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();
	String bukkitName = Bukkit.getName();

	// 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.addProperty("serverUUID", serverUUID);

	data.addProperty("playerAmount", playerAmount);
	data.addProperty("onlineMode", onlineMode);
	data.addProperty("bukkitVersion", bukkitVersion);
	data.addProperty("bukkitName", bukkitName);

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

	return data;
}
 
Example 4
Source File: Metrics.java    From RedProtect with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 5
Source File: StatusCommand.java    From DungeonsXL with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onExecute(String[] args, CommandSender sender) {
    String minecraftVersion = compat.getVersion().toString();
    String bukkitVersion = Bukkit.getName() + (compat.isSpigot() ? " (Spigot)" : "") + " " + Bukkit.getBukkitVersion();
    String internalsVersion = compat.getInternals().toString();
    String dungeonsxlVersion = plugin.getDescription().getVersion();

    String internalsVersionCorrect = getSymbol(plugin.getSettings().getInternals().contains(compat.getInternals()));
    String dungeonsxlVersionCorrect = getSymbol(!dungeonsxlVersion.contains("SNAPSHOT"));

    MessageUtil.sendCenteredMessage(sender, "&4&l=> &6STATUS &4&l<=");
    MessageUtil.sendMessage(sender, ChatColor.GRAY + "Version info:");
    MessageUtil.sendMessage(sender, "= Minecraft: " + minecraftVersion + " " + internalsVersionCorrect);
    MessageUtil.sendMessage(sender, "= Bukkit: " + bukkitVersion + " " + internalsVersionCorrect);
    MessageUtil.sendMessage(sender, "= Internals (package version): " + internalsVersion + " " + internalsVersionCorrect);
    MessageUtil.sendMessage(sender, "= DungeonsXL: " + dungeonsxlVersion + " " + dungeonsxlVersionCorrect);

    Plugin vault = manager.getPlugin("Vault");
    Plugin commandsxl = manager.getPlugin("CommandsXL");
    Plugin itemsxl = manager.getPlugin("ItemsXL");
    Plugin citizens = manager.getPlugin("Citizens");
    Plugin custommobs = manager.getPlugin("CustomMobs");
    Plugin mythicmobs = manager.getPlugin("MythicMobs");
    Plugin holographicdisplays = manager.getPlugin("HolographicDisplays");

    String vaultVersion = "Not enabled";
    String permissionPlugin = "No plugin found";
    String economyPlugin = "No plugin found";
    String commandsxlVersion = "Not enabled";
    String itemsxlVersion = "Not enabled";
    String citizensVersion = "Not enabled";
    String custommobsVersion = "Not enabled";
    String insanemobsVersion = "Not enabled";
    String mythicmobsVersion = "Not enabled";
    String holographicdisplaysVersion = "Not enabled";

    if (vault != null) {
        vaultVersion = vault.getDescription().getVersion();
        if (plugin.getPermissionProvider() != null) {
            permissionPlugin = plugin.getPermissionProvider().getName();
        }
        if (plugin.getEconomyProvider() != null) {
            economyPlugin = plugin.getEconomyProvider().getName();
        }
    }
    if (commandsxl != null) {
        commandsxlVersion = commandsxl.getDescription().getVersion();
    }
    if (itemsxl != null) {
        itemsxlVersion = itemsxl.getDescription().getVersion();
    }
    if (citizens != null) {
        citizensVersion = citizens.getDescription().getVersion();
    }
    if (custommobs != null) {
        custommobsVersion = custommobs.getDescription().getVersion();
    }
    if (mythicmobs != null) {
        mythicmobsVersion = mythicmobs.getDescription().getVersion();
    }
    if (holographicdisplays != null) {
        holographicdisplaysVersion = holographicdisplays.getDescription().getVersion();
    }

    String vaultVersionCorrect = getSymbol(vaultVersion.startsWith("1.7"));
    String permissionPluginCorrect = getSymbol(plugin.getPermissionProvider() != null && plugin.getPermissionProvider().hasGroupSupport());
    String economyPluginCorrect = getSymbol(!plugin.getMainConfig().isEconomyEnabled() || plugin.getEconomyProvider() != null);
    String commandsxlVersionCorrect = getSymbol(commandsxlVersion.startsWith("2.1"));
    String itemsxlVersionCorrect = getSymbol(itemsxlVersion.equals("0.5.5"));
    String citizensVersionCorrect = getSymbol(citizensVersion.startsWith("2.0"));
    String custommobsVersionCorrect = getSymbol(custommobsVersion.startsWith("4."));
    String insanemobsVersionCorrect = getSymbol(insanemobsVersion.startsWith("3."));
    String mythicmobsVersionCorrect = getSymbol(mythicmobsVersion.startsWith("4."));
    String holographicdisplaysVersionCorrect = getSymbol(holographicdisplaysVersion.startsWith("2.3"));

    MessageUtil.sendMessage(sender, ChatColor.GRAY + "Dependency info:");
    MessageUtil.sendMessage(sender, "= Vault: " + vaultVersion + " " + vaultVersionCorrect);
    MessageUtil.sendMessage(sender, "  = Permissions: " + permissionPlugin + " " + permissionPluginCorrect);
    MessageUtil.sendMessage(sender, "  = Economy: " + economyPlugin + " " + economyPluginCorrect);
    MessageUtil.sendMessage(sender, "= CommandsXL: " + commandsxlVersion + " " + commandsxlVersionCorrect);
    MessageUtil.sendMessage(sender, "= ItemsXL: " + itemsxlVersion + " " + itemsxlVersionCorrect);
    MessageUtil.sendMessage(sender, "= Citizens: " + citizensVersion + " " + citizensVersionCorrect);
    MessageUtil.sendMessage(sender, "= CustomMobs: " + custommobsVersion + " " + custommobsVersionCorrect);
    MessageUtil.sendMessage(sender, "= InsaneMobs: " + insanemobsVersion + " " + insanemobsVersionCorrect);
    MessageUtil.sendMessage(sender, "= MythicMobs: " + mythicmobsVersion + " " + mythicmobsVersionCorrect);
    MessageUtil.sendMessage(sender, "= HolographicDisplays: " + holographicdisplaysVersion + " " + holographicdisplaysVersionCorrect);
}
 
Example 6
Source File: Metrics.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 7
Source File: BStats.java    From DiscordSRV with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 8
Source File: ApiMetricsLite.java    From Crazy-Crates with MIT License 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();
    
    // 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.addProperty("serverUUID", serverUUID);
    
    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);
    
    data.addProperty("javaVersion", javaVersion);
    data.addProperty("osName", osName);
    data.addProperty("osArch", osArch);
    data.addProperty("osVersion", osVersion);
    data.addProperty("coreCount", coreCount);
    
    return data;
}
 
Example 9
Source File: Metrics.java    From Crazy-Crates with MIT License 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();
    
    // 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.addProperty("serverUUID", serverUUID);
    
    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);
    
    data.addProperty("javaVersion", javaVersion);
    data.addProperty("osName", osName);
    data.addProperty("osArch", osArch);
    data.addProperty("osVersion", osVersion);
    data.addProperty("coreCount", coreCount);
    
    return data;
}
 
Example 10
Source File: Metrics.java    From UltimateChat with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 11
Source File: Metrics.java    From QuickShop-Reremake with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 12
Source File: Metrics.java    From PacketListenerAPI with MIT License 4 votes vote down vote up
/**
 * 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();
	String bukkitName = Bukkit.getName();

	// 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.addProperty("serverUUID", serverUUID);

	data.addProperty("playerAmount", playerAmount);
	data.addProperty("onlineMode", onlineMode);
	data.addProperty("bukkitVersion", bukkitVersion);
	data.addProperty("bukkitName", bukkitName);

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

	return data;
}
 
Example 13
Source File: Metrics.java    From ClaimChunk with MIT License 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 14
Source File: Metrics.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 15
Source File: MetricsLite.java    From bStats-Metrics with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 16
Source File: Metrics.java    From bStats-Metrics with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 17
Source File: Metrics.java    From Quests with MIT License 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 18
Source File: Metrics.java    From MineableSpawners with MIT License 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 19
Source File: CStats.java    From TabooLib with MIT License 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}
 
Example 20
Source File: Metrics.java    From Harbor with MIT License 4 votes vote down vote up
/**
 * 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();
    String bukkitName = Bukkit.getName();

    // 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.addProperty("serverUUID", serverUUID);

    data.addProperty("playerAmount", playerAmount);
    data.addProperty("onlineMode", onlineMode);
    data.addProperty("bukkitVersion", bukkitVersion);
    data.addProperty("bukkitName", bukkitName);

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

    return data;
}