mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 21:51:19 -04:00
Use fast sqlite path for total number of players in /sinfo.
This commit is contained in:
parent
be59b95268
commit
96a947c044
@ -116,11 +116,11 @@ namespace MCGalaxy.Commands {
|
||||
CommandPerm[] addPerms = cmd.AdditionalPerms;
|
||||
if (addPerms == null) return;
|
||||
|
||||
Player.Message(p, "%TAdditional permissions:");
|
||||
Player.Message(p, "%TExtra permissions:");
|
||||
for (int i = 0; i < addPerms.Length; i++) {
|
||||
var addition = CommandOtherPerms.Find(cmd, i + 1);
|
||||
LevelPermission perm = (LevelPermission)addition.Permission;
|
||||
Player.Message(p, GetColoredRank(perm) + "%S" + addition.Description);
|
||||
var extra = CommandOtherPerms.Find(cmd, i + 1);
|
||||
LevelPermission perm = (LevelPermission)extra.Permission;
|
||||
Player.Message(p, "{0}) {1}%S{2}", i + 1, GetColoredRank(perm), extra.Description);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,14 +38,9 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message != "") { Help(p); return; }
|
||||
|
||||
// TODO: use max rowid to be faster
|
||||
DataTable table = Database.fillData("SELECT COUNT(id) FROM Players");
|
||||
int count = int.Parse(table.Rows[0]["COUNT(id)"].ToString());
|
||||
table.Dispose();
|
||||
|
||||
Player.Message(p, "Server's name: &b{0}%S", Server.name);
|
||||
Player.Message(p, "&a{0}%S players total. (&a{1}%S online, &8{2} banned%S)",
|
||||
count, Player.number, Player.GetBannedCount());
|
||||
GetPlayerCount(), Player.number, Player.GetBannedCount());
|
||||
Player.Message(p, "&a{0} %Slevels currently loaded. Currency is &3{1}%S.",
|
||||
LevelInfo.Loaded.Count, Server.moneys);
|
||||
|
||||
@ -66,6 +61,24 @@ namespace MCGalaxy.Commands {
|
||||
ShowServerStats(p);
|
||||
}
|
||||
|
||||
static int GetPlayerCount() {
|
||||
// Use fast path if possible TODO: fast path for mysql
|
||||
int count = 0;
|
||||
if (!Server.useMySQL) {
|
||||
DataTable maxTable = Database.fillData("SELECT MAX(_ROWID_) FROM Players LIMIT 1;");
|
||||
if (maxTable.Rows.Count > 0) {
|
||||
string row = maxTable.Rows[0]["MAX(_ROWID_)"].ToString();
|
||||
maxTable.Dispose();
|
||||
if (int.TryParse(row, out count) && count > 0) return count;
|
||||
}
|
||||
}
|
||||
|
||||
DataTable table = Database.fillData("SELECT COUNT(id) FROM Players");
|
||||
count = int.Parse(table.Rows[0]["COUNT(id)"].ToString());
|
||||
table.Dispose();
|
||||
return count;
|
||||
}
|
||||
|
||||
void ShowServerStats(Player p) {
|
||||
Process proc = Process.GetCurrentProcess();
|
||||
if (Server.PCCounter == null) {
|
||||
|
@ -64,12 +64,12 @@ namespace MCGalaxy.Commands {
|
||||
} else {
|
||||
CommandOtherPerms.OtherPerms perms = CommandOtherPerms.Find(cmd, otherPermIndex);
|
||||
if (perms == null) {
|
||||
Player.Message(p, "This command has no additional permission with that number."); return;
|
||||
Player.Message(p, "This command has no extra permission with that number."); return;
|
||||
}
|
||||
|
||||
perms.Permission = (int)grp.Permission;
|
||||
CommandOtherPerms.Save();
|
||||
string permName = "additional permission " + otherPermIndex;
|
||||
string permName = "extra permission " + otherPermIndex;
|
||||
Player.GlobalMessage("&d" + cmd.name + "%S's " + permName + " was set to " + grp.ColoredName);
|
||||
Player.Message(p, cmd.name + "'s " + permName + " was set to " + grp.ColoredName);
|
||||
}
|
||||
@ -89,9 +89,8 @@ namespace MCGalaxy.Commands {
|
||||
Player.Message(p, "%HAllows a specific rank to use [cmd]");
|
||||
Player.Message(p, "%T/cmdset [cmd] [rank] disallow");
|
||||
Player.Message(p, "%HPrevents a specific rank from using [cmd]");
|
||||
Player.Message(p, "%T/cmdset [cmd] [rank] <additional permission number>");
|
||||
Player.Message(p, "%HSet the lowest rank that has that additional permission for [cmd] " +
|
||||
"(Most commands do not use these)");
|
||||
Player.Message(p, "%T/cmdset [cmd] [rank] <extra permission number>");
|
||||
Player.Message(p, "%HSet the lowest rank that has that extra permission for [cmd]");
|
||||
Player.Message(p, "To see available ranks, type %T/viewranks");
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
namespace MCGalaxy.Commands {
|
||||
namespace MCGalaxy.Commands.World {
|
||||
public sealed class CmdMain : Command {
|
||||
|
||||
public override string name { get { return "main"; } }
|
||||
|
@ -17,9 +17,6 @@
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using MCGalaxy.Levels.IO;
|
||||
|
||||
namespace MCGalaxy.Commands.World {
|
||||
|
Loading…
x
Reference in New Issue
Block a user