Fix /afk list

This commit is contained in:
UnknownShadow200 2017-08-05 13:00:15 +10:00
parent 7be031adfc
commit 2097da26da
3 changed files with 11 additions and 4 deletions

View File

@ -29,7 +29,7 @@ namespace MCGalaxy.Commands.Chatting {
Player[] players = PlayerInfo.Online.Items; Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) { foreach (Player pl in players) {
if (!Entities.CanSee(p, pl) || !pl.IsAfk) continue; if (!Entities.CanSee(p, pl) || !pl.IsAfk) continue;
Player.Message(p, p.name); Player.Message(p, pl.ColoredName);
} }
return; return;
} }

View File

@ -22,7 +22,7 @@ using MCGalaxy.Maths;
namespace MCGalaxy.DB { namespace MCGalaxy.DB {
public unsafe sealed class BlockDBFile_V1 : BlockDBFile { public unsafe sealed class BlockDBFile_V1 : BlockDBFile {
public override void WriteEntries(Stream s, FastList<BlockDBEntry> entries) { public override void WriteEntries(Stream s, FastList<BlockDBEntry> entries) {
byte[] bulk = new byte[BulkEntries * EntrySize]; byte[] bulk = new byte[BulkEntries * EntrySize];
@ -39,6 +39,10 @@ namespace MCGalaxy.DB {
node = node.Next; node = node.Next;
} }
} }
public override long CountEntries(Stream s) {
return (s.Length / BlockDBFile.EntrySize) - BlockDBFile.HeaderEntries;
}
static void WriteEntries(Stream s, byte[] bulk, BlockDBEntry[] entries, int count) { static void WriteEntries(Stream s, byte[] bulk, BlockDBEntry[] entries, int count) {
for (int i = 0; i < count; i += BulkEntries) { for (int i = 0; i < count; i += BulkEntries) {

View File

@ -74,6 +74,8 @@ namespace MCGalaxy.DB {
/// <returns> whether an entry before start time was reached. </returns> /// <returns> whether an entry before start time was reached. </returns>
public abstract bool FindChangesBy(Stream s, int[] ids, int start, int end, Action<BlockDBEntry> output); public abstract bool FindChangesBy(Stream s, int[] ids, int start, int end, Action<BlockDBEntry> output);
/// <summary> Returns number of entries in the backing file. </summary>
public abstract long CountEntries(Stream s);
/// <summary> Deletes the backing file on disc if it exists. </summary> /// <summary> Deletes the backing file on disc if it exists. </summary>
public static void DeleteBackingFile(string map) { public static void DeleteBackingFile(string map) {
@ -95,8 +97,9 @@ namespace MCGalaxy.DB {
string path = FilePath(map); string path = FilePath(map);
if (!File.Exists(path)) return 0; if (!File.Exists(path)) return 0;
using (Stream src = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite)) using (Stream src = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite)) {
return (src.Length / 16) - 1; return V1.CountEntries(src);
}
} }