• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscapheguic翻訳omegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

Administrator's Toolkit VS plugin


Commit MetaInfo

Revision3f42590384d43d99145a5ba2b9eb17bbbe69c87d (tree)
Zeit2020-06-17 12:18:39
Autormelchior <melchior@user...>
Commitermelchior

Log Message

W.I.P: Added pinger command, assorted other work

Ändern Zusammenfassung

Diff

--- a/AdminToolkit/AdminModCommand.cs
+++ b/AdminToolkit/AdminModCommand.cs
@@ -19,7 +19,7 @@ namespace AdminToolkit
1919 Logger = ServerAPI.World.Logger;
2020 }
2121
22- AdminModCommand( )
22+ private AdminModCommand( )
2323 {
2424 throw new NotSupportedException( );
2525 }
--- a/AdminToolkit/AdminToolkit.csproj
+++ b/AdminToolkit/AdminToolkit.csproj
@@ -75,6 +75,7 @@
7575 <Compile Include="Commands\BackupCycleCommand.cs" />
7676 <Compile Include="Commands\RulesCommand.cs" />
7777 <Compile Include="Commands\BannerControl.cs" />
78+ <Compile Include="Commands\PingerCommand.cs" />
7879 </ItemGroup>
7980 <ItemGroup>
8081 <Folder Include="VS_libs\" />
--- a/AdminToolkit/AdminToolkitMod.cs
+++ b/AdminToolkit/AdminToolkitMod.cs
@@ -23,10 +23,10 @@ namespace AdminToolkit
2323 * [DONE] Optional: ACCEPTANCE / REJECT of server rules {changes players role}
2424 * [DONE] List all Admins (online or offline) & track last logoff date
2525 * [DONE] Keeps track of Elapsed game calendar days for players
26- * [DONE] Alter ADMIN text to look 'different'
26+ * [DONE] Alter ADMIN text to look 'different' (optional)
2727 * [DONE] Cyclic automatic Backups
28- * ?????? Broadcast messages, on a schedule ??????
29- * Status/MOTD/Server name : custom formats to indicate server state/time/things
28+ * [WIP} Broadcast messages, on a schedule ??????
29+ * [???] Custom Server name : custom formats to indicate server state/time/things
3030 */
3131
3232 private ICoreAPI API { get; set; }
@@ -97,7 +97,8 @@ namespace AdminToolkit
9797 this.ServerAPI.RegisterCommand(new RulesCommand(this.ServerAPI) );
9898 this.ServerAPI.RegisterCommand(new AdminListingCommand(this.ServerAPI) );
9999 this.ServerAPI.RegisterCommand(new BackupCycleCommand(this.ServerAPI) );
100- //this.ServerAPI.RegisterCommand(new BannerControl(this.ServerAPI));
100+ this.ServerAPI.RegisterCommand(new BannerControl(this.ServerAPI));
101+ this.ServerAPI.RegisterCommand(new PingerCommand(this.ServerAPI));
101102
102103 if (CachedConfiguration.BoomingVoice) {
103104 this.ServerAPI.Event.PlayerChat += BoomingVoiceOfAuthority;
--- a/AdminToolkit/Commands/BannerControl.cs
+++ b/AdminToolkit/Commands/BannerControl.cs
@@ -1,5 +1,7 @@
11 using System;
22
3+using ProtoBuf;
4+
35 using Vintagestory.API.Common;
46 using Vintagestory.API.Server;
57
@@ -13,7 +15,7 @@ namespace AdminToolkit
1315 public BannerControl(ICoreServerAPI _serverAPI) : base(_serverAPI)
1416 {
1517
16- //Add <slot#> "text" <repeat/once> <DD:HH:MM:SS - DD/MM
18+ //Add <slot#> <repeat/once> <DD:HH:MM:SS> "text"
1719 //Remove <slot#>
1820 //Replace <slot#> "text"
1921 //List
@@ -21,12 +23,12 @@ namespace AdminToolkit
2123 //Mode:
2224 //Repeating (Per unit of time), Once (Future-Date)
2325
24- //Delay;
26+ //Delay - Relative event time;
2527 //HH:MM:SS
2628 ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.RunGame, ReactivateBanners);
2729
2830 this.Command = "banners";
29- this.Description = "Control future broadcast 'banners' or repeating Messages";
31+ this.Description = "Control future broadcast 'banners' & repeating Messages";
3032 this.RequiredPrivilege = Privilege.announce;
3133 this.handler += HandleBannerCommand;
3234 }
@@ -41,6 +43,21 @@ namespace AdminToolkit
4143 {
4244
4345 }
46+
47+ [ProtoContract]
48+ public struct BannerEntry
49+ {
50+ [ProtoMember(1)]
51+ public string Message;
52+
53+ [ProtoMember(2)]
54+ public TimeSpan EventTime;
55+
56+ [ProtoMember(3)]
57+ public bool Repeat;
58+
59+
60+ }
4461 }
4562 }
4663
--- /dev/null
+++ b/AdminToolkit/Commands/PingerCommand.cs
@@ -0,0 +1,57 @@
1+using System;
2+
3+using System.Linq;
4+using System.Text;
5+
6+using Vintagestory.API.Common;
7+using Vintagestory.API.Server;
8+using Vintagestory.Server;
9+
10+namespace AdminToolkit
11+{
12+ public class PingerCommand : AdminModCommand
13+ {
14+ public PingerCommand(ICoreServerAPI _serverAPI) : base(_serverAPI)
15+ {
16+
17+
18+ this.Command = "pings";
19+ this.Description = "Display network Latency, per player(s)";
20+ this.Syntax = " (none) | all ";
21+ this.RequiredPrivilege = Privilege.chat;
22+ this.handler += HandlePingerCommand;
23+
24+ }
25+
26+ private void HandlePingerCommand(IServerPlayer player, int groupId, CmdArgs args)
27+ {
28+ var command = args.PopWord(string.Empty);
29+
30+ switch (command) {
31+ case "all":
32+ AllPlayerPings(groupId, player);
33+ break;
34+
35+ default:
36+ OwnPlayerPing(groupId, player);
37+ break;
38+ }
39+ }
40+
41+ private void OwnPlayerPing(int groupId, IServerPlayer player)
42+ {
43+ player.SendMessage(groupId, $"{player.PlayerName}\t:\t{player.Ping:F3}S\n", EnumChatType.CommandSuccess);
44+ }
45+
46+ private void AllPlayerPings(int groupId, IServerPlayer player)
47+ {
48+ StringBuilder pingsList = new StringBuilder( );
49+
50+ foreach (var srvPlayer in ServerAPI.Server.Players.Where(plr => plr.ConnectionState == EnumClientState.Playing)) {
51+ pingsList.Append($"{srvPlayer.PlayerName}\t:\t{srvPlayer.Ping:F3}S\n");
52+ }
53+ player.SendMessage(groupId, pingsList.ToString( ), EnumChatType.CommandSuccess);
54+ }
55+ }
56+
57+}
\ No newline at end of file
--- a/AdminToolkit/modinfo.json
+++ b/AdminToolkit/modinfo.json
@@ -3,9 +3,9 @@
33 "name": "Administrator's Toolkit mod",
44 "description" : "Provides misc. Admin functions;\n list admins, print & accept rules (multi-lingual) , auto-backup...",
55 "authors": ["Melchior", ],
6- "version": "0.3.4",
6+ "version": "0.3.5",
77 "dependencies": {
8- "game": "1.11.0"
8+ "game": "1.12.4"
99 },
1010 "requiredonclient":false,
1111 "website": "https://osdn.net/users/melchior/pf/admintoolkit/"