diff --git a/README.md b/README.md index a610de0e..2c34e329 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Maven automatically fetches all dependencies and builds DungeonsXL; just run _bu [BRCommons](https://github.com/DRE2N/BRCommons) is a util library for common tasks. DungeonsXL contains BRCommons 1.0. #### Caliburn API -[Caliburn](https://github.com/DRE2N/CaliburnAPI) is an API to read custom items and mobs from config files. DungeonsXL contains Caliburn Beta 0.1.5. +[Caliburn](https://github.com/DRE2N/CaliburnAPI) is an API to read custom items and mobs from config files. DungeonsXL contains Caliburn Beta 0.1.6. ### Java Make sure that your server uses Java 7 or higher. diff --git a/pom.xml b/pom.xml index 6a803a99..2e21989f 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 io.github.dre2n dungeonsxl - 0.13${buildNo} + 0.13.1-SNAPSHOT${buildNo} jar DungeonsXL https://dre2n.github.io diff --git a/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java b/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java index 7f74c90a..b4a71a66 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/DungeonsXL.java @@ -412,6 +412,7 @@ public class DungeonsXL extends BRPlugin { new DeletePortalCommand(), new ReloadCommand(), new SaveCommand(), + new StatusCommand(), new TestCommand() ); diff --git a/src/main/java/io/github/dre2n/dungeonsxl/command/StatusCommand.java b/src/main/java/io/github/dre2n/dungeonsxl/command/StatusCommand.java new file mode 100644 index 00000000..9ad40349 --- /dev/null +++ b/src/main/java/io/github/dre2n/dungeonsxl/command/StatusCommand.java @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2012-2016 Frank Baumann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package io.github.dre2n.dungeonsxl.command; + +import io.github.dre2n.commons.command.BRCommand; +import io.github.dre2n.commons.compatibility.CompatibilityHandler; +import io.github.dre2n.commons.util.messageutil.MessageUtil; +import io.github.dre2n.dungeonsxl.DungeonsXL; +import io.github.dre2n.dungeonsxl.config.DMessages; +import io.github.dre2n.dungeonsxl.player.DPermissions; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginManager; + +/** + * @author Daniel Saukel + */ +public class StatusCommand extends BRCommand { + + DungeonsXL plugin = DungeonsXL.getInstance(); + CompatibilityHandler compat = CompatibilityHandler.getInstance(); + PluginManager manager = Bukkit.getPluginManager(); + + public static final String TRUE = ChatColor.GREEN + "\u2714"; + public static final String FALSE = ChatColor.DARK_RED + "\u2718"; + + public StatusCommand() { + setCommand("status"); + setMinArgs(0); + setMaxArgs(0); + setHelp(DMessages.HELP_CMD_STATUS.getMessage()); + setPermission(DPermissions.STATUS.getNode()); + setPlayerCommand(true); + setConsoleCommand(true); + } + + @Override + public void onExecute(String[] args, CommandSender sender) { + String minecraftVersion = compat.getVersion().toString(); + String bukkitVersion = Bukkit.getName() + " " + Bukkit.getBukkitVersion(); + String internalsVersion = compat.getInternals().toString(); + String dungeonsxlVersion = plugin.getDescription().getVersion(); + + String internalsVersionCorrect = getSymbol(plugin.getSettings().getInternals().contains(compat.getInternals())); + String bukkitVersionCorrect = getSymbol(bukkitVersion.startsWith("Spigot")); + 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 + " " + bukkitVersionCorrect); + 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.5")); + 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.1.6")); + String citizensVersionCorrect = getSymbol(citizensVersion.startsWith("2.0")); + String custommobsVersionCorrect = getSymbol(custommobsVersion.startsWith("4.")); + String insanemobsVersionCorrect = getSymbol(insanemobsVersion.startsWith("2.")); + String mythicmobsVersionCorrect = getSymbol(mythicmobsVersion.startsWith("2.")); + String holographicdisplaysVersionCorrect = getSymbol(holographicdisplaysVersion.startsWith("2.2")); + + 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); + } + + public static String getSymbol(boolean value) { + return value ? TRUE : FALSE; + } + +} diff --git a/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java b/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java index 3d3ddf4c..abad9751 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/config/DMessages.java @@ -116,6 +116,7 @@ public enum DMessages implements Messages { HELP_CMD_PORTAL("Help_Cmd_Portal", "/dxl portal - Creates a portal that leads into a dungeon"), HELP_CMD_RELOAD("Help_Cmd_Reload", "/dxl reload - Reloads the plugin"), HELP_CMD_SAVE("Help_Cmd_Save", "/dxl save - Saves the current dungeon"), + HELP_CMD_STATUS("Help_Cmd_Status", "/dxl status - Shows the technical status of DungeonsXL"), HELP_CMD_SETTINGS("Help_Cmd_Settings", "/dxl settings ([edit|global|player])- Opens the settings menu"), HELP_CMD_TEST("Help_Cmd_Test", "/dxl test - Starts the game in test mode"), HELP_CMD_UNINVITE("Help_Cmd_Uninvite", "/dxl uninvite [player] [dungeon] - Uninvite a player to edit a dungeon"), diff --git a/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java b/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java index d6e6d5e5..0535bbf4 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/player/DPermissions.java @@ -59,6 +59,7 @@ public enum DPermissions { PORTAL("portal", OP), RELOAD("reload", OP), SAVE("save", OP), + STATUS("status", OP), /** * Allows to open the settings menu. */ diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 36c167d2..0d928e4a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,7 +4,7 @@ version: ${project.version} authors: [Frank Baumann, Milan Albrecht, Tobias Schmitz, Daniel Saukel] description: ${project.description} website: ${project.url} -softdepend: [BlueRoseCommons, CommandsXL, ItemsXL, Vault, CustomMobs, InsaneMobs, MythicMobs, HolographicDisplays] +softdepend: [BlueRoseCommons, CommandsXL, ItemsXL, Vault, Citizens, CustomMobs, InsaneMobs, MythicMobs, HolographicDisplays] commands: dungeonsxl: description: Reference command for DungeonsXL.