Administrator's Toolkit VS plugin
修訂 | d1e59dde8764d39e620ace3a46df64495471949b (tree) |
---|---|
時間 | 2020-04-26 06:50:39 |
作者 | melchior <melchior@user...> |
Commiter | melchior |
{VS: V1.12.X } = ATK 0.3.4, updated for API changes (backup sys.),
better Admin listing
@@ -74,7 +74,6 @@ | ||
74 | 74 | <Compile Include="Commands\AdminListingCommand.cs" /> |
75 | 75 | <Compile Include="Commands\BackupCycleCommand.cs" /> |
76 | 76 | <Compile Include="Commands\RulesCommand.cs" /> |
77 | - <Compile Include="MechTurk.cs" /> | |
78 | 77 | <Compile Include="Commands\BannerControl.cs" /> |
79 | 78 | </ItemGroup> |
80 | 79 | <ItemGroup> |
@@ -97,6 +97,7 @@ namespace AdminToolkit | ||
97 | 97 | this.ServerAPI.RegisterCommand(new RulesCommand(this.ServerAPI) ); |
98 | 98 | this.ServerAPI.RegisterCommand(new AdminListingCommand(this.ServerAPI) ); |
99 | 99 | this.ServerAPI.RegisterCommand(new BackupCycleCommand(this.ServerAPI) ); |
100 | + //this.ServerAPI.RegisterCommand(new BannerControl(this.ServerAPI)); | |
100 | 101 | |
101 | 102 | if (CachedConfiguration.BoomingVoice) { |
102 | 103 | this.ServerAPI.Event.PlayerChat += BoomingVoiceOfAuthority; |
@@ -28,7 +28,8 @@ namespace AdminToolkit | ||
28 | 28 | foreach (var srvPlayer in ServerAPI.Server.Players) { |
29 | 29 | if (AdminToolkit.AdminRoles.Contains(srvPlayer.Role.Code)) { |
30 | 30 | |
31 | - msgLine.AppendFormat("<font color='{2}'>[{0}]</font> -- \"{1}\" ", srvPlayer.Role.Name, srvPlayer.PlayerName, srvPlayer.Role.Color.Name); | |
31 | + string playerName = srvPlayer.PlayerName ?? srvPlayer?.ServerData.LastKnownPlayername ?? "?"; | |
32 | + msgLine.AppendFormat("<font color='{2}'>[{0}]</font> -- \"{1}\" ", srvPlayer.Role.Name, playerName, srvPlayer.Role.Color.Name); | |
32 | 33 | |
33 | 34 | if (srvPlayer.ConnectionState == EnumClientState.Playing) { |
34 | 35 | msgLine.AppendFormat("IS: <font color='lime'>*{0}*</font>", srvPlayer.ConnectionState); |
@@ -16,7 +16,7 @@ namespace AdminToolkit | ||
16 | 16 | { |
17 | 17 | private long backupTickerID; |
18 | 18 | private const string _timeFormat = @"d\D\ hh\H\ mm\M\ ss\S"; |
19 | - private MechTurk mechanicalTurk; | |
19 | + | |
20 | 20 | |
21 | 21 | private DateTimeOffset _lastBackupTime = DateTimeOffset.MinValue; |
22 | 22 |
@@ -30,7 +30,7 @@ namespace AdminToolkit | ||
30 | 30 | this.RequiredPrivilege = Privilege.controlserver;//"Backup" ? |
31 | 31 | this.Syntax = "enable / disable / delay [hours] / stats"; |
32 | 32 | |
33 | - mechanicalTurk = new MechTurk(ServerAPI.Server.Config.Roles.Find(ro => ro.Code == "admin"), this.Logger); | |
33 | + | |
34 | 34 | |
35 | 35 | ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.RunGame, ServerStarts); |
36 | 36 | } |
@@ -172,16 +172,8 @@ namespace AdminToolkit | ||
172 | 172 | } |
173 | 173 | |
174 | 174 | |
175 | - if (ServerAPI.World is ServerMain) { | |
176 | - | |
177 | - ServerMain serverMain = ServerAPI.World as ServerMain; | |
178 | - serverMain.EventManager.TriggerChatCommand(mechanicalTurk, GlobalConstants.ServerInfoChatGroup, @"genbackup", new CmdArgs( )); | |
179 | - _lastBackupTime = DateTimeOffset.UtcNow; | |
180 | - } else { | |
181 | - Logger.Warning("Could not invoke backup command - API (implimentation) has changed, Contact Developer!"); | |
182 | - this.backupTickerID = 0; | |
183 | - return; | |
184 | - } | |
175 | + ServerAPI.InjectConsole(@"/genbackup"); | |
176 | + _lastBackupTime = DateTimeOffset.UtcNow; | |
185 | 177 | |
186 | 178 | this.backupTickerID = ServerAPI.Event.RegisterCallback(BackupCycleHandler, ( int )this.CachedConfiguration.BackupDelay.TotalMilliseconds); |
187 | 179 | Logger.Notification("BackupCycle re-engaged, delay: {0} next time: {1}", this.CachedConfiguration.BackupDelay.ToString(_timeFormat), DateTimeOffset.UtcNow.Add(this.CachedConfiguration.BackupDelay).ToString("u")); |
@@ -1,15 +1,46 @@ | ||
1 | 1 | using System; |
2 | 2 | |
3 | +using Vintagestory.API.Common; | |
3 | 4 | using Vintagestory.API.Server; |
4 | 5 | |
5 | 6 | namespace AdminToolkit |
6 | 7 | { |
7 | 8 | public class BannerControl : AdminModCommand |
8 | 9 | { |
10 | + /// <summary> | |
11 | + /// Control and Configuration of automatic Broadcast 'banners' / M.O.T.H. | |
12 | + /// </summary> | |
9 | 13 | public BannerControl(ICoreServerAPI _serverAPI) : base(_serverAPI) |
10 | 14 | { |
11 | - | |
15 | + | |
16 | + //Add <slot#> "text" <repeat/once> <DD:HH:MM:SS - DD/MM | |
17 | + //Remove <slot#> | |
18 | + //Replace <slot#> "text" | |
19 | + //List | |
20 | + | |
21 | + //Mode: | |
22 | + //Repeating (Per unit of time), Once (Future-Date) | |
23 | + | |
24 | + //Delay; | |
25 | + //HH:MM:SS | |
26 | + ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.RunGame, ReactivateBanners); | |
27 | + | |
28 | + this.Command = "banners"; | |
29 | + this.Description = "Control future broadcast 'banners' or repeating Messages"; | |
30 | + this.RequiredPrivilege = Privilege.announce; | |
31 | + this.handler += HandleBannerCommand; | |
32 | + } | |
33 | + | |
34 | + private void ReactivateBanners( ) | |
35 | + { | |
36 | + | |
12 | 37 | } |
13 | - } | |
38 | + | |
39 | + | |
40 | + private void HandleBannerCommand(IServerPlayer player, int groupId, CmdArgs args) | |
41 | + { | |
42 | + | |
43 | + } | |
44 | +} | |
14 | 45 | } |
15 | 46 |
@@ -153,7 +153,7 @@ namespace AdminToolkit | ||
153 | 153 | |
154 | 154 | StringBuilder adminMessage = new StringBuilder( ); |
155 | 155 | |
156 | - adminMessage.AppendFormat("<font color='{1}' weight='bold'>«{0}» ̠{2}̠ </font> Present.", byPlayer.Role.Name, byPlayer.Role.Color.Name, byPlayer.PlayerName); | |
156 | + adminMessage.AppendFormat("<font color='{1}' weight='bold'>«{0}» {2}</font> Present.", byPlayer.Role.Name, byPlayer.Role.Color.Name, byPlayer.PlayerName); | |
157 | 157 | |
158 | 158 | ServerAPI.SendMessageToGroup(GlobalConstants.AllChatGroups, adminMessage.ToString( ), EnumChatType.AllGroups); |
159 | 159 |
@@ -1,210 +0,0 @@ | ||
1 | -using System; | |
2 | -using System.Collections.Generic; | |
3 | - | |
4 | -using Vintagestory.API.Common; | |
5 | -using Vintagestory.API.Common.Entities; | |
6 | -using Vintagestory.API.Server; | |
7 | - | |
8 | -namespace AdminToolkit | |
9 | -{ | |
10 | - public class MechTurk: IPlayer, IServerPlayer | |
11 | - { | |
12 | - private ILogger Logger; | |
13 | - | |
14 | - public MechTurk( IPlayerRole role, ILogger logger) | |
15 | - { | |
16 | - this.Role = role; | |
17 | - Logger = logger; | |
18 | - } | |
19 | - | |
20 | - public int ClientId { | |
21 | - get { | |
22 | - return -1; | |
23 | - } | |
24 | - } | |
25 | - | |
26 | - public EnumClientState ConnectionState { | |
27 | - get { | |
28 | - return EnumClientState.Connected; | |
29 | - } | |
30 | - } | |
31 | - | |
32 | - public BlockSelection CurrentBlockSelection { | |
33 | - get { | |
34 | - throw new NotImplementedException( ); | |
35 | - } | |
36 | - } | |
37 | - | |
38 | - public int CurrentChunkSentRadius { | |
39 | - get { | |
40 | - throw new NotImplementedException( ); | |
41 | - } | |
42 | - | |
43 | - set { | |
44 | - throw new NotImplementedException( ); | |
45 | - } | |
46 | - } | |
47 | - | |
48 | - public EntitySelection CurrentEntitySelection { | |
49 | - get { | |
50 | - throw new NotImplementedException( ); | |
51 | - } | |
52 | - } | |
53 | - | |
54 | - public List<Entitlement> Entitlements { | |
55 | - get { | |
56 | - throw new NotImplementedException( ); | |
57 | - } | |
58 | - } | |
59 | - | |
60 | - public EntityPlayer Entity { | |
61 | - get { | |
62 | - throw new NotImplementedException( ); | |
63 | - } | |
64 | - } | |
65 | - | |
66 | - public PlayerGroupMembership[] Groups { | |
67 | - get { | |
68 | - throw new NotImplementedException( ); | |
69 | - } | |
70 | - } | |
71 | - | |
72 | - public IPlayerInventoryManager InventoryManager { | |
73 | - get { | |
74 | - throw new NotImplementedException( ); | |
75 | - } | |
76 | - } | |
77 | - | |
78 | - public string IpAddress { | |
79 | - get { | |
80 | - return @"127.0.0.1"; | |
81 | - } | |
82 | - } | |
83 | - | |
84 | - public string LanguageCode { | |
85 | - get { | |
86 | - return @"en";//ISO639-2 ? | |
87 | - } | |
88 | - } | |
89 | - | |
90 | - public float Ping { | |
91 | - get { | |
92 | - return 0.0f; | |
93 | - } | |
94 | - } | |
95 | - | |
96 | - public string PlayerName { | |
97 | - get { | |
98 | - return @"Mechanical Turk"; | |
99 | - } | |
100 | - } | |
101 | - | |
102 | - public string PlayerUID { | |
103 | - get { | |
104 | - return @"console";//Keeps 'ServerEventManager' satisfied | |
105 | - } | |
106 | - } | |
107 | - | |
108 | - public string[] Privileges { | |
109 | - get { | |
110 | - return new[]{ | |
111 | - Privilege.buildblockseverywhere, | |
112 | - Privilege.useblockseverywhere, | |
113 | - Privilege.gamemode, | |
114 | - Privilege.pickingrange, | |
115 | - Privilege.kick, | |
116 | - Privilege.ban, | |
117 | - Privilege.whitelist, | |
118 | - Privilege.setwelcome, | |
119 | - Privilege.announce, | |
120 | - Privilege.readlists, | |
121 | - Privilege.give, | |
122 | - Privilege.setspawn, | |
123 | - Privilege.controlserver, | |
124 | - Privilege.tp, | |
125 | - Privilege.time, | |
126 | - Privilege.grantrevoke, | |
127 | - Privilege.root, | |
128 | - Privilege.commandplayer,}; | |
129 | - } | |
130 | - } | |
131 | - | |
132 | - public IPlayerRole Role { | |
133 | - get; private set; | |
134 | - } | |
135 | - | |
136 | - public IServerPlayerData ServerData { | |
137 | - get { | |
138 | - throw new NotImplementedException( ); | |
139 | - } | |
140 | - } | |
141 | - | |
142 | - public EntityPos SpawnPosition { | |
143 | - get { | |
144 | - throw new NotImplementedException( ); | |
145 | - } | |
146 | - } | |
147 | - | |
148 | - public IWorldPlayerData WorldData { | |
149 | - get { | |
150 | - throw new NotImplementedException( ); | |
151 | - } | |
152 | - } | |
153 | - | |
154 | - public void BroadcastPlayerData( ) | |
155 | - { | |
156 | - | |
157 | - } | |
158 | - | |
159 | - public void ClearSpawnPosition( ) | |
160 | - { | |
161 | - throw new NotImplementedException( ); | |
162 | - } | |
163 | - | |
164 | - public void Disconnect( ) | |
165 | - { | |
166 | - throw new NotImplementedException( ); | |
167 | - } | |
168 | - | |
169 | - public void Disconnect(string message) | |
170 | - { | |
171 | - throw new NotImplementedException( ); | |
172 | - } | |
173 | - | |
174 | - public PlayerGroupMembership GetGroup(int groupId) | |
175 | - { | |
176 | - throw new NotImplementedException( ); | |
177 | - } | |
178 | - | |
179 | - public PlayerGroupMembership[ ] GetGroups( ) | |
180 | - { | |
181 | - throw new NotImplementedException( ); | |
182 | - } | |
183 | - | |
184 | - public bool HasPrivilege(string privilegeCode) | |
185 | - { | |
186 | - return true;//Robot can do anything | |
187 | - } | |
188 | - | |
189 | - public void SendIngameError(string code, string message = null, params object[] langparams) | |
190 | - { | |
191 | - | |
192 | - } | |
193 | - | |
194 | - public void SendMessage(int groupId, string message, EnumChatType chatType, string data = null) | |
195 | - { | |
196 | - Logger.Chat("®TURK: «{0}»",message); | |
197 | - } | |
198 | - | |
199 | - public void SendPositionToClient( ) | |
200 | - { | |
201 | - throw new NotImplementedException( ); | |
202 | - } | |
203 | - | |
204 | - public void SetSpawnPosition(PlayerSpawnPos pos) | |
205 | - { | |
206 | - throw new NotImplementedException( ); | |
207 | - } | |
208 | - } | |
209 | -} | |
210 | - |
@@ -3,7 +3,7 @@ | ||
3 | 3 | "name": "Administrator's Toolkit mod", |
4 | 4 | "description" : "Provides misc. Admin functions;\n list admins, print & accept rules (multi-lingual) , auto-backup...", |
5 | 5 | "authors": ["Melchior", ], |
6 | - "version": "0.3.3", | |
6 | + "version": "0.3.4", | |
7 | 7 | "dependencies": { |
8 | 8 | "game": "1.11.0" |
9 | 9 | }, |