Skip to content

Commit

Permalink
Added feature to determine and get server type
Browse files Browse the repository at this point in the history
Added method to determine server type, such as CraftBukkit, Spigot or PaperSpigot.
Added server type to startup message and status command.
  • Loading branch information
timvisee committed Oct 6, 2015
1 parent f81f5cf commit 0969730
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/main/java/com/timvisee/dungeonmaze/DungeonMaze.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public void onEnable() {

// Show a status message
Core.getLogger().info("Starting Dungeon Maze v" + getVersionName() + "...");
// TODO: Show proper detected Minecraft server name here, instead of just BUKKIT
Core.getLogger().info("Detected Minecraft version: v" + MinecraftUtils.getMinecraftVersion() + " (BUKKIT)");
Core.getLogger().info("Detected Minecraft version: v" + MinecraftUtils.getMinecraftVersion() + " (" + MinecraftUtils.getMinecraftServerName() + ")");

// Initialize the core
initCore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ public void printServerStatus(CommandSender sender) {
sender.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + "Server Status:");

// Print the server status
sender.sendMessage(ChatColor.GOLD + "Detected Minecraft Version: " + ChatColor.WHITE + MinecraftUtils.getMinecraftVersion());
sender.sendMessage(ChatColor.GOLD + "Detected Minecraft Server: " + ChatColor.WHITE + MinecraftUtils.getMinecraftServerName());
sender.sendMessage(ChatColor.GOLD + "Server Version: " + ChatColor.WHITE + Bukkit.getVersion());
sender.sendMessage(ChatColor.GOLD + "Bukkit Version: " + ChatColor.WHITE + Bukkit.getBukkitVersion());
sender.sendMessage(ChatColor.GOLD + "Detected Minecraft Version: " + ChatColor.WHITE + MinecraftUtils.getMinecraftVersion());
sender.sendMessage(ChatColor.GOLD + "Running Plugins: " + ChatColor.WHITE + Bukkit.getPluginManager().getPlugins().length);

// Get the world manager
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/timvisee/dungeonmaze/util/MinecraftUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,29 @@ public static String getMinecraftVersion() {
// Get and return the Minecraft version number
return rawVersion.substring(start, end);
}

/**
* Get the name of the current running Minecraft server system, such as CraftBukkit or Spigot.
*
* @return The current Minecraft server name.
*/
public static String getMinecraftServerName() {
// Get the raw version
final String rawVersion = Bukkit.getVersion();

// Check whether this is a CraftBukkit or Bukkit server
if(rawVersion.toLowerCase().contains("bukkit"))
return "CraftBukkit";

// Check whether this is a PaperSpigot server
if(rawVersion.toLowerCase().contains("paperspigot"))
return "PaperSpigot";

// Check whether this is a Spigot server
if(rawVersion.toLowerCase().contains("spigot"))
return "Spigot";

// Return unknown
return "Unknown";
}
}

0 comments on commit 0969730

Please sign in to comment.