• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamephpguiwindowsc翻訳pythonomegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

Administrator's Toolkit VS plugin


コミットメタ情報

リビジョンa79b6df86e1d05bc0ca69a70c6179d7113106713 (tree)
日時2019-08-07 03:59:33
作者melchior <melchior@user...>
コミッターmelchior

ログメッセージ

Corrected modinfo setting for server-side only
changed messages, added more verbosity

変更サマリ

差分

--- a/AdminToolkit/AdminModConfig.cs
+++ b/AdminToolkit/AdminModConfig.cs
@@ -20,6 +20,14 @@ namespace AdminToolkit
2020 [ProtoMember(1)]
2121 public string PlayerRoleNormal { get; set; }
2222
23+ /// <summary>
24+ /// Sets rule role changer swapping behavior on/off.
25+ /// </summary>
26+ /// <value>If rule role changer should be enabled.</value>
27+ [ProtoMember(2)]
28+ public bool RuleRoleChangerEnabled { get; set; }
29+
30+
2331 /*
2432 * "DefaultRoleCode": "suplayer",
2533 */
@@ -28,6 +36,7 @@ namespace AdminToolkit
2836 {
2937 this.PlayerRoleRestrain = "suvisitor";
3038 this.PlayerRoleNormal = "suplayer";
39+ this.RuleRoleChangerEnabled = false;
3140 }
3241
3342
--- a/AdminToolkit/AdminToolkitMod.cs
+++ b/AdminToolkit/AdminToolkitMod.cs
@@ -155,6 +155,8 @@ namespace AdminToolkit
155155 }
156156
157157 this.CachedConfiguration = config;
158+
159+ if (this.CachedConfiguration.RuleRoleChangerEnabled) { Mod.Logger.Notification("Admin toolkit; Role change on Rule accept: * ENABLED *"); }
158160 }
159161
160162 /// <summary>
--- a/AdminToolkit/RulesCommand.cs
+++ b/AdminToolkit/RulesCommand.cs
@@ -130,6 +130,7 @@ namespace AdminToolkit
130130 if (args.Length == 1) {
131131 string word = args.PopWord( );
132132
133+ /*
133134 #if DEBUG
134135 if (string.Compare("demote", word, StringComparison.InvariantCultureIgnoreCase) == 0)
135136 {
@@ -144,13 +145,12 @@ namespace AdminToolkit
144145 ServerAPI.Permissions.SetRole(player, normalRole.Code);
145146 }
146147 #endif
148+ */
147149
148150 if (string.Compare(_acceptKeyword, word, StringComparison.InvariantCultureIgnoreCase) == 0) {
149151
150152 if (CheckRuleAccepted(player) == false) {
151- player.SendMessage(groupId, $"{player.PlayerName} YOU HAVE ACCEPTED RULES!", EnumChatType.CommandSuccess);
152- player.ServerData.CustomPlayerData[_ruleAcceptKey] = true.ToString( );
153- ServerAPI.Server.LogNotification($"Player:{player.PlayerName} UID: {player.PlayerUID} HAS ACCEPTED RULES @ {DateTime.Now.ToShortDateString( )}");
153+
154154 PlayerAcceptsRulesAction( player);
155155 } else {
156156 player.SendMessage(groupId, $"{player.PlayerName} ALREADY ACCEPTED RULES!", EnumChatType.CommandSuccess);
@@ -192,36 +192,47 @@ namespace AdminToolkit
192192 byPlayer.ServerData.CustomPlayerData[AdminToolkit._lastLoginKey] = DateTimeOffset.UtcNow.ToString("u");
193193
194194 } else {
195-
195+ //For regular players
196196 if (RulesCommand.CheckRuleAccepted(byPlayer) == false) {
197197 //TODO: localize somehow?
198- byPlayer.SendMessage(GlobalConstants.CurrentChatGroup, "use '/rules' command for reading server rules.", EnumChatType.Notification);
199- PlayerNeverAcceptedRulesAction( byPlayer);
198+ byPlayer.SendMessage(GlobalConstants.CurrentChatGroup, "type ' /rules ' command for reading server rules.", EnumChatType.Notification);
199+
200+ if (this.CachedConfiguration.RuleRoleChangerEnabled) {
201+ PlayerNeverAcceptedRulesAction(byPlayer);
202+ }
200203 }
201204 }
202205 }
203206
204207 private void PlayerAcceptsRulesAction(IServerPlayer byPlayer )
205208 {
206- if (byPlayer.Role.Code == this.CachedConfiguration.PlayerRoleRestrain && this.rolesAreValid) {
209+ ServerAPI.BroadcastMessageToAllGroups($"{byPlayer.PlayerName} HAS ACCEPTED THE RULES!", EnumChatType.CommandSuccess);
210+ byPlayer.ServerData.CustomPlayerData[_ruleAcceptKey] = true.ToString( );
211+ ServerAPI.Server.LogNotification($"Player:{byPlayer.PlayerName} UID: {byPlayer.PlayerUID} HAS ACCEPTED RULES @ {DateTime.Now.ToShortDateString( )}");
212+
213+ if (byPlayer.Role.Code == this.CachedConfiguration.PlayerRoleRestrain && this.rolesAreValid && this.CachedConfiguration.RuleRoleChangerEnabled) {
207214 //Joined as 'restrained' player - will have their role changed to normal
208215
209216 IPlayerRole normalRole = ServerAPI.Server.Config.Roles.Single(rl => string.Compare(rl.Code, this.CachedConfiguration.PlayerRoleNormal, StringComparison.InvariantCultureIgnoreCase) == 0);
210217
211- ServerAPI.Permissions.SetRole(byPlayer,normalRole.Code);
218+ ServerAPI.Permissions.SetRole(byPlayer, normalRole.Code);
212219 Logger.Notification("Player {0} accepted the rules, and was promoted to role: {1}", byPlayer.PlayerName, byPlayer.Role.Name);
213- }
220+ byPlayer.SendMessage(GlobalConstants.GeneralChatGroup, $"{byPlayer.PlayerName} have been promoted to: {byPlayer.Role.Name}", EnumChatType.OthersMessage);
221+ } else {
222+ Logger.Debug("Role change process did not complete; not enabled or mis-configured");
223+ }
214224 }
215225
216226 private void PlayerNeverAcceptedRulesAction(IServerPlayer byPlayer )
217227 {
218- if (byPlayer.Role.Code == this.CachedConfiguration.PlayerRoleNormal && this.rolesAreValid) {
228+ if (byPlayer.Role.Code == this.CachedConfiguration.PlayerRoleNormal && this.rolesAreValid && this.CachedConfiguration.RuleRoleChangerEnabled ) {
219229 //Joined as 'normal' player - will have their role changed to restricted
220230
221231 IPlayerRole restrainRole = ServerAPI.Server.Config.Roles.Single(rl => string.Compare( rl.Code, this.CachedConfiguration.PlayerRoleRestrain, StringComparison.InvariantCultureIgnoreCase) == 0);
222232
223233 ServerAPI.Permissions.SetRole(byPlayer, restrainRole.Code);
224234 Logger.Notification("Player {0} never accepted rules, and was demoted to role: {1}", byPlayer.PlayerName, byPlayer.Role.Name);
235+ byPlayer.SendMessage(GlobalConstants.GeneralChatGroup, $"{byPlayer.PlayerName} have been demoted to: {byPlayer.Role.Name}", EnumChatType.OthersMessage);
225236 }
226237 }
227238 }
--- a/AdminToolkit/modinfo.json
+++ b/AdminToolkit/modinfo.json
@@ -3,10 +3,11 @@
33 "name": "Administrator's Toolkit mod",
44 "description" : "Provides misc. Admin functions; list admins, prints rules / accept rules, ect...",
55 "authors": ["Melchior", ],
6- "version": "0.1.0",
6+ "version": "0.2.0",
77 "dependencies": {
88 "game": "1.10.*"
99 },
10+ "requiredonclient":false,
1011 "website": "http://nowebsite.nope"
1112 }
1213