Administrator's Toolkit VS plugin
Revision | 5d4bc37c03db327db9863ed14c4adec06d5cc76d (tree) |
---|---|
Zeit | 2022-06-26 03:27:02 |
Autor | melchior <melchior@user...> |
Commiter | melchior |
0.3.9-rc Changes
@@ -102,7 +102,6 @@ | ||
102 | 102 | <None Include="assets\atk\lang\en.json"> |
103 | 103 | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
104 | 104 | </None> |
105 | - <None Include="MultiLang.cs" /> | |
106 | 105 | </ItemGroup> |
107 | 106 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
108 | 107 | </Project> |
\ No newline at end of file |
@@ -26,7 +26,7 @@ namespace AdminToolkit | ||
26 | 26 | playerPositions = new Dictionary<string, EntityPos>(32); |
27 | 27 | this.Command = "idlekick"; |
28 | 28 | this.Description = "Adjust Idle-ejector system settings."; |
29 | - this.Syntax = @" set {time} | stats "; | |
29 | + this.Syntax = @" set {minutes} | stats "; | |
30 | 30 | this.RequiredPrivilege = Privilege.kick; |
31 | 31 | this.handler += HandleIdlerCommand; |
32 | 32 | ServerAPI.Event.PlayerLeave += PlayerLeft; |
@@ -46,36 +46,46 @@ namespace AdminToolkit | ||
46 | 46 | case @"set": |
47 | 47 | //Change default & next cycle check time |
48 | 48 | var timeMinutes = args.PopInt(0); |
49 | - if (timeMinutes >= 5) { | |
49 | + if (timeMinutes > 0) { | |
50 | 50 | TimeSpan newTimeout = new TimeSpan(0, timeMinutes.Value, 0); |
51 | 51 | this.CachedConfiguration.IdleTimeout = newTimeout; |
52 | 52 | player.SendMessage(groupId, $"Changed Idle timeout to: {newTimeout}", EnumChatType.CommandSuccess); |
53 | 53 | RestartTimers(); |
54 | 54 | } else |
55 | - player.SendMessage(groupId, "no change; Value must be >= 5", EnumChatType.CommandError); | |
55 | + { | |
56 | + player.SendMessage(groupId, "Idle-check disabled.", EnumChatType.CommandError); | |
57 | + HaltIdleCheck( ); | |
58 | + } | |
56 | 59 | break; |
57 | 60 | |
58 | 61 | case @"stats": |
59 | - if (this.CachedConfiguration.IdleTimeout.TotalMinutes >= 5f) | |
62 | + if (this.CachedConfiguration.IdleTimeout.TotalMinutes > 0f) | |
60 | 63 | { player.SendMessage(groupId, $"Ejected: {kick_tally} player(s), Timeout = {this.CachedConfiguration.IdleTimeout}", EnumChatType.CommandSuccess); } |
61 | 64 | else { player.SendMessage(groupId, "offline.", EnumChatType.CommandSuccess); } |
62 | 65 | break; |
63 | 66 | |
64 | 67 | default: |
65 | - player.SendMessage(groupId, $"Unrecognised command: {command}", EnumChatType.CommandError); | |
68 | + player.SendMessage(groupId, $"Unrecognised command: '{command}'", EnumChatType.CommandError); | |
66 | 69 | break; |
67 | 70 | } |
68 | 71 | } |
69 | 72 | |
73 | + private void HaltIdleCheck( ) | |
74 | + { | |
75 | + if (timerIdent != 0L) { | |
76 | + ServerAPI.Event.UnregisterCallback(timerIdent); | |
77 | + playerPositions.Clear( ); | |
78 | + } | |
79 | + } | |
80 | + | |
70 | 81 | private void RestartTimers( ) |
71 | 82 | { |
72 | 83 | if (timerIdent != 0L) |
73 | 84 | { |
74 | 85 | ServerAPI.Event.UnregisterCallback(timerIdent); |
75 | - playerPositions.Clear( ); | |
76 | - FindIdlers(0f ); | |
86 | + playerPositions.Clear( ); | |
77 | 87 | } |
78 | - timerIdent = ServerAPI.Event.RegisterCallback(FindIdlers, ( int )this.CachedConfiguration.IdleTimeout.TotalMilliseconds); | |
88 | + FindIdlers(0f); | |
79 | 89 | } |
80 | 90 | |
81 | 91 | private void FindIdlers(float delta ) |
@@ -85,10 +95,10 @@ namespace AdminToolkit | ||
85 | 95 | #endif |
86 | 96 | |
87 | 97 | foreach (var srvPlayer in ServerAPI.Server.Players.Where(plr => plr.ConnectionState == EnumClientState.Playing)) { |
88 | - if (srvPlayer?.WorldData?.CurrentGameMode != EnumGameMode.Spectator) { | |
98 | + if (srvPlayer?.WorldData?.CurrentGameMode == EnumGameMode.Survival) { | |
89 | 99 | EntityPos oldPos; |
90 | 100 | if (playerPositions.TryGetValue(srvPlayer.PlayerUID, out oldPos)) { |
91 | - if (oldPos.BasicallySameAsIgnoreAngles(srvPlayer.Entity.ServerPos, 0.001f)) { | |
101 | + if (oldPos.BasicallySameAsIgnoreAngles(srvPlayer.Entity.ServerPos, 0.01f)) { | |
92 | 102 | if ( srvPlayer.Entity.CurrentControls.HasFlag( EnumEntityActivity.Idle) || |
93 | 103 | srvPlayer.Entity.CurrentControls.HasFlag(EnumEntityActivity.FloorSitting) || |
94 | 104 | srvPlayer.Entity.CurrentControls.HasFlag(EnumEntityActivity.Dead) || |
@@ -105,14 +115,17 @@ namespace AdminToolkit | ||
105 | 115 | } |
106 | 116 | } |
107 | 117 | } |
118 | + | |
119 | + timerIdent = ServerAPI.Event.RegisterCallback(FindIdlers, ( int )this.CachedConfiguration.IdleTimeout.TotalMilliseconds); | |
108 | 120 | } |
109 | 121 | |
122 | + | |
110 | 123 | private void KickIdler(IServerPlayer them) |
111 | 124 | { |
112 | 125 | kick_tally++; |
113 | 126 | var message = MultiLang.Get(them.LanguageCode, idleKick_Key, them.PlayerName); |
114 | 127 | them.Disconnect(message); |
115 | - ServerAPI.BroadcastMessageToAllGroups(message, EnumChatType.Notification); | |
128 | + //ServerAPI.BroadcastMessageToAllGroups(message, EnumChatType.Notification); | |
116 | 129 | } |
117 | 130 | |
118 | 131 | private void PlayerLeft(IServerPlayer byPlayer) |
@@ -153,7 +153,7 @@ namespace AdminToolkit | ||
153 | 153 | if (!AdminToolkit.AdminRoles.Contains(byPlayer.Role.Code)) { |
154 | 154 | //For regular players |
155 | 155 | if (RulesCommand.CheckRuleAccepted(byPlayer) == false) { |
156 | - //TODO: localize | |
156 | + | |
157 | 157 | byPlayer.SendMessage(GlobalConstants.CurrentChatGroup, MultiLang.GetUnformatted(byPlayer,"atk:type-rules"), EnumChatType.Notification); |
158 | 158 | |
159 | 159 | if (this.CachedConfiguration.RuleRoleChangerEnabled) { |
@@ -1,11 +0,0 @@ | ||
1 | -using System; | |
2 | -namespace AdminToolkit | |
3 | -{ | |
4 | - public class MultiLang | |
5 | - { | |
6 | - public MultiLang( ) | |
7 | - { | |
8 | - } | |
9 | - } | |
10 | -} | |
11 | - |
@@ -4,7 +4,7 @@ | ||
4 | 4 | "ModID":"atk", |
5 | 5 | "description" : "Provides Admin functions;\n admin listing, rules display (multi-lingual), auto-backup & more.", |
6 | 6 | "authors": ["Melchior", ], |
7 | - "version": "0.3.8", | |
7 | + "version": "0.3.9-rc.0", | |
8 | 8 | "dependencies": { |
9 | 9 | "game": "1.16.0" |
10 | 10 | }, |