-
Notifications
You must be signed in to change notification settings - Fork 6
feat: expand the about command #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df49264
407c607
d7e8083
209976a
c05106d
1ad3b0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1 +1,12 @@ | ||||||||||||||||||||||
| rootProject.name = "CyberLevels" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Builds these from source and substitutes them for their com.bitaspire coordinates, so this | ||||||||||||||||||||||
| // plugin can be developed against unpublished changes. Locally the checkouts are sibling folders; | ||||||||||||||||||||||
| // CI checks them out inside this repository instead. They are not on any maven repository, so the | ||||||||||||||||||||||
| // checkout is required rather than a fallback. | ||||||||||||||||||||||
| listOf("CyberCore").forEach { dependency -> | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fail fast when no CyberCore checkout is found so a fresh clone doesn't fall through to Maven Central and produce a confusing resolution error.
Suggested change
|
||||||||||||||||||||||
| listOf("../$dependency", dependency) | ||||||||||||||||||||||
| .map(::file) | ||||||||||||||||||||||
| .firstOrNull { it.resolve("settings.gradle.kts").isFile } | ||||||||||||||||||||||
| ?.let(::includeBuild) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,16 +3,17 @@ | |||||||||
| import com.bitaspire.cyberlevels.CyberLevels; | ||||||||||
| import com.bitaspire.cyberlevels.cache.Lang; | ||||||||||
| import com.bitaspire.cyberlevels.level.LevelSystem; | ||||||||||
| import com.bitaspire.cyberlevels.user.Database; | ||||||||||
| import com.bitaspire.cyberlevels.user.LevelUser; | ||||||||||
| import com.bitaspire.libs.common.util.ReplaceUtils; | ||||||||||
| import com.bitaspire.libs.prismatic.PrismaticAPI; | ||||||||||
| import com.bitaspire.libs.vnc.VNC; | ||||||||||
| import java.util.Arrays; | ||||||||||
| import java.util.LinkedHashMap; | ||||||||||
| import java.util.List; | ||||||||||
| import java.util.Map; | ||||||||||
| import java.util.function.Function; | ||||||||||
| import lombok.Getter; | ||||||||||
| import org.bukkit.Bukkit; | ||||||||||
| import org.bukkit.ChatColor; | ||||||||||
| import org.bukkit.OfflinePlayer; | ||||||||||
| import org.bukkit.command.Command; | ||||||||||
| import org.bukkit.command.CommandExecutor; | ||||||||||
|
|
@@ -90,23 +91,7 @@ public boolean onCommand( | |||||||||
| switch (sub) { | ||||||||||
| case "about": | ||||||||||
| if (isRestricted(player, "player.about")) return true; | ||||||||||
| if (player == null) { | ||||||||||
| main.logger( | ||||||||||
| " &d&lCyber&f&lLevels &fv" + | ||||||||||
| main.getDescription().getVersion() + | ||||||||||
| " &7(&7&nhttps://bit.ly/2YSlqYq&7).", | ||||||||||
| " &fDeveloped by &d" + main.getAuthors() + "&f.", | ||||||||||
| " A leveling system plugin with MySQL support and custom events." | ||||||||||
| ); | ||||||||||
| return true; | ||||||||||
| } | ||||||||||
| return main.createSender(player).send( | ||||||||||
| " &d&lCyber&f&lLevels &fv" + | ||||||||||
| main.getDescription().getVersion() + | ||||||||||
| " &7(&7&nhttps://bit.ly/2YSlqYq&7).", | ||||||||||
| " &fDeveloped by &d" + main.getAuthors() + "&f.", | ||||||||||
| " A leveling system plugin with MySQL support and custom events." | ||||||||||
| ); | ||||||||||
| return sendAbout(sender, player); | ||||||||||
| case "reload": | ||||||||||
| if (isRestricted(player, "admin.reload")) return true; | ||||||||||
|
|
||||||||||
|
|
@@ -281,6 +266,35 @@ public boolean onCommand( | |||||||||
| return sendLangMessage(sender, player, Lang::getNoPermission); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| private boolean sendAbout(CommandSender sender, Player player) { | ||||||||||
| Database<?> database = main.userManager() == null ? | ||||||||||
| null : | ||||||||||
| main.userManager().getDatabase(); | ||||||||||
| boolean databaseEnabled = main.cache().config().database().isEnabled(); | ||||||||||
| boolean databaseConnected = database != null && database.isConnected(); | ||||||||||
|
|
||||||||||
| String[] lines = new String[] { | ||||||||||
| " &d&lCyber&f&lLevels &fv" + main.getDescription().getVersion() + "&7.", | ||||||||||
| " &7Server: &f" + serverInfo(), | ||||||||||
| " &7Authors: &f" + main.getAuthors(), | ||||||||||
| " &7Database: &f" + databaseConnected + " &7(enabled: &f" + databaseEnabled + | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make the disconnected state visually obvious so operators can spot a broken DB at a glance.
Suggested change
|
||||||||||
| "&7, type: &f" + main.cache().config().database().getType() + "&7)", | ||||||||||
| " &7Config: &fauto-save " + main.cache().config().isAutoSaveEnabled() + | ||||||||||
| " / " + main.cache().config().getAutoSaveInterval() + "s&7, &fleaderboard " + | ||||||||||
| main.cache().config().isLeaderboardEnabled() + " / " + | ||||||||||
| main.cache().config().getLeaderboardMaxPositions() + " positions", | ||||||||||
| " &7Engine: &f" + (main.cache().config().useBigDecimalSystem() ? "BigDecimal" : "Double") + | ||||||||||
| "&7, &fEXP integer-only " + main.cache().config().isExpIntegerOnly() | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| if (player == null) { | ||||||||||
| main.logger(lines); | ||||||||||
| return true; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return main.createSender(player).send(lines); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| private boolean sendLangMessage( | ||||||||||
| CommandSender cmdSender, | ||||||||||
| Player player, | ||||||||||
|
|
@@ -297,7 +311,7 @@ private boolean sendLangMessage( | |||||||||
| String out = stripConsoleChannels(line); | ||||||||||
| if (!out.isEmpty()) { | ||||||||||
| cmdSender.sendMessage( | ||||||||||
| ChatColor.translateAlternateColorCodes('&', out) | ||||||||||
| PrismaticAPI.colorize(out) | ||||||||||
| ); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
@@ -348,7 +362,7 @@ private boolean sendLangMessage( | |||||||||
| out = stripConsoleChannels(out); | ||||||||||
| if (!out.isEmpty()) { | ||||||||||
| cmdSender.sendMessage( | ||||||||||
| ChatColor.translateAlternateColorCodes('&', out) | ||||||||||
| PrismaticAPI.colorize(out) | ||||||||||
| ); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
@@ -369,15 +383,19 @@ private LevelUser<?> resolveUserByName(String name) { | |||||||||
| LevelUser<?> user = main.userManager().getUser(name); | ||||||||||
| if (user != null) return user; | ||||||||||
|
|
||||||||||
| Player online = Bukkit.getPlayerExact(name); | ||||||||||
| Player online = main.getServer().getPlayerExact(name); | ||||||||||
| if (online != null) return main.userManager().getUser(online); | ||||||||||
|
|
||||||||||
| OfflinePlayer offline = Bukkit.getOfflinePlayer(name); | ||||||||||
| OfflinePlayer offline = main.getServer().getOfflinePlayer(name); | ||||||||||
| if (!offline.hasPlayedBefore() && !offline.isOnline()) return null; | ||||||||||
|
|
||||||||||
| return main.userManager().getUser(offline.getUniqueId()); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| private static String serverInfo() { | ||||||||||
| return VNC.SERVER != null ? VNC.SERVER.getImplementationVersion() : "Unknown"; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| private boolean sendLevelInfo(Player player) { | ||||||||||
| if (player == null) return true; | ||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pin the CyberCore checkout to the ref that matches the 2.1.0 coordinate so releases aren't built against an unrelated HEAD.