Java Code Examples for org.bukkit.Bukkit#getBukkitVersion()
The following examples show how to use
org.bukkit.Bukkit#getBukkitVersion() .
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: UhcCore.java From UhcCore with GNU General Public License v3.0 | 6 votes |
private void loadServerVersion(){ String versionString = Bukkit.getBukkitVersion(); version = 0; for (int i = MIN_VERSION; i <= MAX_VERSION; i ++){ if (versionString.contains("1." + i)){ version = i; } } if (version == 0) { version = MIN_VERSION; Bukkit.getLogger().warning("[UhcCore] Failed to detect server version! " + versionString + "?"); }else { Bukkit.getLogger().info("[UhcCore] 1." + version + " Server detected!"); } }
Example 2
Source File: StatzUtil.java From Statz with GNU General Public License v3.0 | 5 votes |
public static String getMinecraftVersion() { String version = Bukkit.getBukkitVersion(); String[] split = version.split("-"); if (split.length < 1) { return "Unknown"; } return split[0]; }
Example 3
Source File: MinecraftVersion.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
static void initialize(Logger logger) { String bukkitVersion = Bukkit.getBukkitVersion(); char[] chars = bukkitVersion.toCharArray(); StringBuilder majorVersionBuilder = new StringBuilder(); boolean hadDot = false; for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (!Character.isDigit(c) && c != '.') { break; } if (c == '.') { if (hadDot) { break; } else { hadDot = true; } } majorVersionBuilder.append(c); } String majorVersion = majorVersionBuilder.toString(); implementationVersion = Updater.Version.parse(majorVersion); implementationVersionString = majorVersion; String version = Bukkit.getVersion(); if (version.toLowerCase().contains("spigot")) { spigot = true; } }
Example 4
Source File: QuickShop.java From QuickShop-Reremake with GNU General Public License v3.0 | 4 votes |
private void submitMeritcs() { if (!getConfig().getBoolean("disabled-metrics")) { String serverVer = Bukkit.getVersion(); String bukkitVer = Bukkit.getBukkitVersion(); String vaultVer; Plugin vault = Bukkit.getPluginManager().getPlugin("Vault"); if (vault != null) { vaultVer = vault.getDescription().getVersion(); } else { vaultVer = "Vault not found"; } // Use internal Metric class not Maven for solve plugin name issues String display_Items; if (getConfig().getBoolean("shop.display-items")) { // Maybe mod server use this plugin more? Or have big // number items need disabled? display_Items = "Enabled"; } else { display_Items = "Disabled"; } String locks; if (getConfig().getBoolean("shop.lock")) { locks = "Enabled"; } else { locks = "Disabled"; } String sneak_action; if (getConfig().getBoolean("shop.interact.sneak-to-create") || getConfig().getBoolean("shop.interact.sneak-to-trade") || getConfig().getBoolean("shop.interact.sneak-to-control")) { sneak_action = "Enabled"; } else { sneak_action = "Disabled"; } String shop_find_distance = getConfig().getString("shop.find-distance"); String economyType = Economy.getNowUsing().name(); if (getEconomy() != null) { economyType = this.getEconomy().getName(); } String useDisplayAutoDespawn = String.valueOf(getConfig().getBoolean("shop.display-auto-despawn")); String useEnhanceDisplayProtect = String.valueOf(getConfig().getBoolean("shop.enchance-display-protect")); String useEnhanceShopProtect = String.valueOf(getConfig().getBoolean("shop.enchance-shop-protect")); String useOngoingFee = String.valueOf(getConfig().getBoolean("shop.ongoing-fee.enable")); String disableDebugLogger = String.valueOf(getConfig().getBoolean("disable-debuglogger")); String databaseType = this.getDatabase().getCore().getName(); String displayType = DisplayItem.getNowUsing().name(); String itemMatcherType = this.getItemMatcher().getName(); String useStackItem = String.valueOf(this.isAllowStack()); // Version metrics.addCustomChart(new Metrics.SimplePie("server_version", () -> serverVer)); metrics.addCustomChart(new Metrics.SimplePie("bukkit_version", () -> bukkitVer)); metrics.addCustomChart(new Metrics.SimplePie("vault_version", () -> vaultVer)); metrics.addCustomChart(new Metrics.SimplePie("use_display_items", () -> display_Items)); metrics.addCustomChart(new Metrics.SimplePie("use_locks", () -> locks)); metrics.addCustomChart(new Metrics.SimplePie("use_sneak_action", () -> sneak_action)); metrics.addCustomChart(new Metrics.SimplePie("shop_find_distance", () -> shop_find_distance)); String finalEconomyType = economyType; metrics.addCustomChart(new Metrics.SimplePie("economy_type", () -> finalEconomyType)); metrics.addCustomChart(new Metrics.SimplePie("use_display_auto_despawn", () -> useDisplayAutoDespawn)); metrics.addCustomChart(new Metrics.SimplePie("use_enhance_display_protect", () -> useEnhanceDisplayProtect)); metrics.addCustomChart(new Metrics.SimplePie("use_enhance_shop_protect", () -> useEnhanceShopProtect)); metrics.addCustomChart(new Metrics.SimplePie("use_ongoing_fee", () -> useOngoingFee)); metrics.addCustomChart(new Metrics.SimplePie("disable_background_debug_logger", () -> disableDebugLogger)); metrics.addCustomChart(new Metrics.SimplePie("database_type", () -> databaseType)); metrics.addCustomChart(new Metrics.SimplePie("display_type", () -> displayType)); metrics.addCustomChart(new Metrics.SimplePie("itemmatcher_type", () -> itemMatcherType)); metrics.addCustomChart(new Metrics.SimplePie("use_stack_item", () -> useStackItem)); // Exp for stats, maybe i need improve this, so i add this.// Submit now! getLogger().info("Metrics submitted."); } else { getLogger().info("You have disabled mertics, Skipping..."); } }
Example 5
Source File: ExprVersion.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public String get() { return "" + Bukkit.getBukkitVersion(); }
Example 6
Source File: Skript.java From Skript with GNU General Public License v3.0 | 4 votes |
/** * Checks if server software and Minecraft version are supported. * Prints errors or warnings to console if something is wrong. * @return Whether Skript can continue loading at all. */ private static boolean checkServerPlatform() { String bukkitV = Bukkit.getBukkitVersion(); Matcher m = Pattern.compile("\\d+\\.\\d+(\\.\\d+)?").matcher(bukkitV); if (!m.find()) { Skript.error("The Bukkit version '" + bukkitV + "' does not contain a version number which is required for Skript to enable or disable certain features. " + "Skript will still work, but you might get random errors if you use features that are not available in your version of Bukkit."); minecraftVersion = new Version(666, 0, 0); } else { minecraftVersion = new Version("" + m.group()); } Skript.debug("Loading for Minecraft " + minecraftVersion); // Check that MC version is supported if (!isRunningMinecraft(1, 9)) { if (isRunningMinecraft(1, 8)) { // 1.8 probably works, but let's spit a warning Skript.warning("Using this version of Skript on 1.8 is highly discouraged."); Skript.warning("Some features have been disabled; use older Skript to restore them."); Skript.warning("Also, there are probably bugs. And since 1.8 is not supported, they will not be fixed"); } else { // Older versions definitely do not work Skript.error("This version of Skript does not work with Minecraft " + minecraftVersion); Skript.error("You probably want Skript 2.2 or 2.1 (Google to find where to get them)"); Skript.error("Note that those versions are, of course, completely unsupported!"); return false; } } // Check that current server platform is somewhat supported serverPlatform = getServerPlatform(); Skript.debug("Server platform: " + serverPlatform); if (!serverPlatform.works) { Skript.error("It seems that this server platform (" + serverPlatform.name + ") does not work with Skript."); if (SkriptConfig.allowUnsafePlatforms.value()) { Skript.error("However, you have chosen to ignore this. Skript will probably still not work."); } else { Skript.error("To prevent potentially unsafe behaviour, Skript has been disabled."); Skript.error("You may re-enable it by adding a configuration option 'allow unsafe platforms: true'"); Skript.error("Note that it is unlikely that Skript works correctly even if you do so."); Skript.error("A better idea would be to install Paper or Spigot in place of your current server."); return false; } } else if (!serverPlatform.supported) { Skript.warning("This server platform (" + serverPlatform.name + ") is not supported by Skript."); Skript.warning("It will still probably work, but if it does not, you are on your own."); Skript.warning("Skript officially supports Paper and Spigot."); } // If nothing got triggered, everything is probably ok return true; }
Example 7
Source File: StatusCommand.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
@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); }