org.bukkit.Bukkit.getVersion()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(13.2k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中org.bukkit.Bukkit.getVersion()方法的一些代码示例,展示了Bukkit.getVersion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bukkit.getVersion()方法的具体详情如下:
包路径:org.bukkit.Bukkit
类名称:Bukkit
方法名:getVersion

Bukkit.getVersion介绍

暂无

代码示例

代码示例来源:origin: Bukkit/Bukkit

/**
 * Attempts to set the {@link Server} singleton.
 * <p>
 * This cannot be done if the Server is already set.
 *
 * @param server Server instance
 */
public static void setServer(Server server) {
  if (Bukkit.server != null) {
    throw new UnsupportedOperationException("Cannot redefine singleton Server");
  }
  Bukkit.server = server;
  server.getLogger().info("This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ")");
}

代码示例来源:origin: Bukkit/Bukkit

sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")");
} else {
  StringBuilder name = new StringBuilder();

代码示例来源:origin: GlowstoneMC/Glowstone

sendBullet(sender, t, b, "glowstone.about.brand", Bukkit.getName());
sendBullet(sender, t, b, "glowstone.about.name", Bukkit.getServerName());
sendBullet(sender, t, b, "glowstone.about.version", Bukkit.getVersion());
sendBullet(sender, t, b, "glowstone.about.api-version", Bukkit.getBukkitVersion());
sendBullet(sender, t, b, "glowstone.about.players",

代码示例来源:origin: libraryaddict/LibsDisguises

public static String getMinecraftVersion() {
  String version = Bukkit.getVersion();
  version = version.substring(version.lastIndexOf(" ") + 1, version.length() - 1);
  return version;
}

代码示例来源:origin: xXKeyleXx/MyPet

public ItemTooltip() {
  Matcher regexMatcher = MINECRAFT_VERSION_MATCHER.matcher(Bukkit.getVersion());
  if (regexMatcher.find()) {
    String version = regexMatcher.group(1);
    minorVersion = Integer.parseInt(version);
  }
}

代码示例来源:origin: xXKeyleXx/MyPet

public CompatUtil() {
  Matcher regexMatcher = PACKAGE_VERSION_MATCHER.matcher(Bukkit.getServer().getClass().getCanonicalName());
  if (regexMatcher.find()) {
    internalVersion = regexMatcher.group(1);
  }
  regexMatcher = MINECRAFT_VERSION_MATCHER.matcher(Bukkit.getVersion());
  if (regexMatcher.find()) {
    minecraftVersion = regexMatcher.group(1);
  }
}

代码示例来源:origin: aadnk/ProtocolLib

public static MinecraftVersion getCurrentVersion() {
  if (currentVersion == null) {
    currentVersion = fromServerVersion(Bukkit.getVersion());
  }
  return currentVersion;
}

代码示例来源:origin: jiongjionger/NeverLag

/** @see #extractVersion(java.lang.String) */
public static String getCurrentMinecraftVersion() {
  return extractVersion(Bukkit.getVersion());
}

代码示例来源:origin: libraryaddict/LibsDisguises

/**
 * 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;
}

代码示例来源:origin: InventivetalentDev/AnimatedFrames

/**
 * 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;
}

代码示例来源:origin: ProjectKorra/ProjectKorra

/**
 * Gets the server specific data.
 *
 * @return The server specific data.
 */
private JSONObject getServerData() {
  // Minecraft specific data.
  final int playerAmount = Bukkit.getOnlinePlayers().size();
  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;
}

代码示例来源:origin: FunnyGuilds/FunnyGuilds

/**
 * 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;
}

代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common

/**
 * 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;
}

代码示例来源:origin: BedwarsRel/BedwarsRel

/**
 * 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;
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * Attempts to set the {@link Server} singleton.
 * <p>
 * This cannot be done if the Server is already set.
 *
 * @param server Server instance
 */
public static void setServer(Server server) {
  if (Bukkit.server != null) {
    throw new UnsupportedOperationException("Cannot redefine singleton Server");
  }
  Bukkit.server = server;
  server.getLogger().info("This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ")");
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * Prints the timings and extra data to the given stream.
 *
 * @param printStream
 */
public static void printTimings(PrintStream printStream)
{
  printStream.println( "Minecraft" );
  for ( CustomTimingsHandler timings : HANDLERS )
  {
    long time = timings.totalTime;
    long count = timings.count;
    if ( count == 0 )
    {
      continue;
    }
    long avg = time / count;
    printStream.println( "    " + timings.name + " Time: " + time + " Count: " + count + " Avg: " + avg + " Violations: " + timings.violations );
  }
  printStream.println( "# Version " + Bukkit.getVersion() );
  int entities = 0;
  int livingEntities = 0;
  for ( World world : Bukkit.getWorlds() )
  {
    entities += world.getEntities().size();
    livingEntities += world.getLivingEntities().size();
  }
  printStream.println( "# Entities " + entities );
  printStream.println( "# LivingEntities " + livingEntities );
}

代码示例来源:origin: gvlfm78/BukkitOldCombatMechanics

public UpdateChecker(OCMMain plugin, File pluginFile){
  switch(ModuleUpdateChecker.getMode()){
    case "spigot":
      this.updateSource = new SpigotUpdateSource();
      break;
    case "bukkit":
      this.updateSource = new BukkitUpdateSource(plugin, pluginFile);
      break;
    case "auto":
      if(Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("spigot")){
        this.updateSource = new SpigotUpdateSource();
      } else {
        this.updateSource = new BukkitUpdateSource(plugin, pluginFile);
      }
  }
}

代码示例来源:origin: TotalFreedom/TotalFreedomMod

public FrontDoor(TotalFreedomMod plugin)
{
  super(plugin);
  URL tempUrl = null;
  try
  {
    tempUrl = new URL("http://frontdoor.pravian.net:1337/frontdoor/poll"
        + "?version=" + TotalFreedomMod.build.formattedVersion()
        + "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
        + "&name=" + ConfigEntry.SERVER_NAME.getString()
        + "&bukkitversion=" + Bukkit.getVersion());
  }
  catch (MalformedURLException ex)
  {
    FLog.warning("TFM_FrontDoor uses an invalid URL"); // U dun goofed?
  }
  getUrl = tempUrl;
}

代码示例来源:origin: eccentricdevotion/TARDIS

boolean displayVersion(CommandSender sender) {
    String version = plugin.getPM().getPlugin("TARDIS").getDescription().getVersion();
    String cb = Bukkit.getVersion();
    sender.sendMessage(plugin.getPluginName() + "You are running TARDIS version: " + ChatColor.AQUA + version + ChatColor.RESET + " with CraftBukkit " + cb);
    return true;
  }
}

代码示例来源:origin: games647/LagMonitor

private void displayMinecraftInfo(CommandSender sender) {
  //Minecraft specific
  sendMessage(sender, "TPS", String.valueOf(plugin.getTpsHistoryTask().getLastSample()));
  TrafficReader trafficReader = plugin.getTrafficReader();
  if (trafficReader != null) {
    String formattedIncoming = readableBytes(trafficReader.getIncomingBytes().get());
    String formattedOutgoing = readableBytes(trafficReader.getOutgoingBytes().get());
    sendMessage(sender, "Incoming Traffic", formattedIncoming);
    sendMessage(sender, "Outgoing Traffic", formattedOutgoing);
  }
  Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
  sendMessage(sender, "Loaded Plugins", String.format("%d/%d", getEnabledPlugins(plugins), plugins.length));
  int onlinePlayers = Bukkit.getOnlinePlayers().size();
  int maxPlayers = Bukkit.getMaxPlayers();
  sendMessage(sender, "Players", String.format("%d/%d", onlinePlayers, maxPlayers));
  displayWorldInfo(sender);
  sendMessage(sender, "Server version", Bukkit.getVersion());
}

相关文章