mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Remove /pcount, integrate it into /sinfo.
This commit is contained in:
parent
d343804aae
commit
9dae5ff8fb
@ -1,59 +0,0 @@
|
||||
/*
|
||||
Copyright 2010 MCLawl Team - Written by Valek (Modified for use with MCGalaxy)
|
||||
|
||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||
not use this file except in compliance with the Licenses. You may
|
||||
obtain a copy of the Licenses at
|
||||
|
||||
http://www.opensource.org/licenses/ecl2.php
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the Licenses are distributed on an "AS IS"
|
||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System.Data;
|
||||
using MCGalaxy.SQL;
|
||||
|
||||
namespace MCGalaxy.Commands {
|
||||
|
||||
public sealed class CmdPCount : Command {
|
||||
|
||||
public override string name { get { return "pcount"; } }
|
||||
public override string shortcut { get { return ""; } }
|
||||
public override string type { get { return CommandTypes.Information; } }
|
||||
public override bool museumUsable { get { return true; } }
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.Banned; } }
|
||||
|
||||
public override void Use(Player p, string message) {
|
||||
int bancount = Group.findPerm(LevelPermission.Banned).playerList.All().Count;
|
||||
|
||||
DataTable table = Database.fillData("SELECT COUNT(id) FROM Players");
|
||||
Player.Message(p, "A total of " + table.Rows[0]["COUNT(id)"] + " unique players have visited this server.");
|
||||
Player.Message(p, "Of these players, " + bancount + " have been banned.");
|
||||
table.Dispose();
|
||||
int count = 0, hiddenCount = 0;
|
||||
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players) {
|
||||
if (!Entities.CanSee(p, pl)) continue;
|
||||
count++;
|
||||
if (pl.hidden) hiddenCount++;
|
||||
}
|
||||
|
||||
string verb = count == 1 ? "is " : "are ";
|
||||
string qualifier = count == 1 ? " player" : " players";
|
||||
if (hiddenCount == 0)
|
||||
Player.Message(p, "There " + verb + count + qualifier + " online.");
|
||||
else
|
||||
Player.Message(p, "There " + verb + count + qualifier + " online (" + hiddenCount + " hidden).");
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "/pcount - Displays the number of players online and total.");
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,9 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using MCGalaxy.SQL;
|
||||
|
||||
namespace MCGalaxy.Commands {
|
||||
public sealed class CmdServerInfo : Command {
|
||||
@ -36,25 +38,29 @@ namespace MCGalaxy.Commands {
|
||||
public override void Use(Player p, string message) {
|
||||
if (message != "") { Help(p); return; }
|
||||
|
||||
Player.Message(p, "Server's name: &b" + Server.name + "%S");
|
||||
Player.Message(p, "&a" + Player.number + " %Splayers online, &8"
|
||||
+ Player.GetBannedCount() + " banned%S players total.");
|
||||
Player.Message(p, "&a" + LevelInfo.Loaded.Count + " %Slevels currently loaded. " +
|
||||
"Currency is &3" + Server.moneys + "%S.");
|
||||
// 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());
|
||||
Player.Message(p, "&a{0} %Slevels currently loaded. Currency is &3{1}%S.",
|
||||
LevelInfo.Loaded.Count, Server.moneys);
|
||||
|
||||
TimeSpan up = DateTime.UtcNow - Server.StartTime;
|
||||
Player.Message(p, "Been up for &b" + WhoInfo.Shorten(up, true) +
|
||||
"%S, and is running &bMCGalaxy &a" + Server.VersionString +
|
||||
"%S, running &bMCGalaxy &a" + Server.VersionString +
|
||||
"%S (based on &bMCForge %Sand &bMCLawl%S).");
|
||||
Command.all.Find("devs").Use(p, "");
|
||||
|
||||
Player.Message(p, "Player positions are updated every &b"
|
||||
+ Server.updateTimer.Interval + " %Smilliseconds.");
|
||||
string owner = Server.server_owner;
|
||||
if (!owner.CaselessEq("Notch"))
|
||||
Player.Message(p, "Owner is &3" + owner + ". %SConsole state: &3" + Server.ZallState);
|
||||
Player.Message(p, "Owner is &3{0}. %SConsole state: &3{1}", owner, Server.ZallState);
|
||||
else
|
||||
Player.Message(p, "Console state: &3" + Server.ZallState);
|
||||
Player.Message(p, "Console state: &3{0}", Server.ZallState);
|
||||
|
||||
if (CheckAdditionalPerm(p))
|
||||
ShowServerStats(p);
|
||||
|
@ -248,7 +248,6 @@
|
||||
<Compile Include="Commands\Information\CmdOpRules.cs" />
|
||||
<Compile Include="Commands\Information\CmdOpStats.cs" />
|
||||
<Compile Include="Commands\Information\CmdPClients.cs" />
|
||||
<Compile Include="Commands\Information\CmdPCount.cs" />
|
||||
<Compile Include="Commands\Information\CmdPlayers.cs" />
|
||||
<Compile Include="Commands\Information\CmdRankReqs.cs" />
|
||||
<Compile Include="Commands\Information\CmdRules.cs" />
|
||||
|
@ -689,13 +689,8 @@ Next: continue;
|
||||
}
|
||||
|
||||
public static int GetBannedCount() {
|
||||
try {
|
||||
return File.ReadAllLines("ranks/banned.txt").Length;
|
||||
}
|
||||
catch/* (Exception ex)*/
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Group group = Group.findPerm(LevelPermission.Banned);
|
||||
return group == null ? 0 : group.playerList.Count;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -47,6 +47,11 @@ namespace MCGalaxy {
|
||||
return new List<string>(players);
|
||||
}
|
||||
|
||||
public int Count { get {
|
||||
lock (locker)
|
||||
return players.Count;
|
||||
} }
|
||||
|
||||
public void Save() { Save(group.fileName, true); }
|
||||
|
||||
public void Save(string path, bool console) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user