• R/O
  • HTTP
  • SSH
  • HTTPS

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Administrator's Toolkit VS plugin


File Info

Rev. 5d4bc37c03db327db9863ed14c4adec06d5cc76d
크기 3,762 bytes
Time 2022-06-26 03:27:02
Author melchior
Log Message

0.3.9-rc Changes

Content

using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.IO;


using Vintagestory.API.Common;
using Vintagestory.API.Server;
using Vintagestory.API.Config;
using Vintagestory.API.Datastructures;

namespace AdminToolkit
{
	/// <summary>
	/// Admininstrators toolkit Mod system
	/// </summary>
	/// <remarks>
	/// Boilerplate; all Functions in 'ATK_BasicFeatures.cs'
	/// </remarks>
	public partial class AdminToolkit : ModSystem
	{
		/* Things it should do:
		 * ==============
		 * [DONE] Server RULES Printout {richtext / multi-linugual }
		 * [DONE] Optional: ACCEPTANCE / REJECT of server rules {changes players role}
		 * [DONE] List all Admins (online or offline) & track last logoff date
		 * [DONE] Keeps track of Elapsed game calendar days for players
		 * [DONE] Alter ADMIN text to look 'different' (optional)
		 * [DONE] Cyclic automatic Backups
		 * [WIP]  Broadcast messages, on a schedule ??????
		 * [RSCH] Custom Server name : custom formats to indicate server state/time/season/things		 
		 * [DONE?]: Variable Player (re)Spawn points from a list ~ at random
		 * [RSCH] Idle player eject on time(out)
		 * 
		 * WORKAROUND -- Localized messages are by SERVERS Native Language code...Not the players...
		 */

		private ICoreAPI API { get; set; }
		private ICoreServerAPI ServerAPI { get; set; }

		internal readonly string[] adminPriviledges = {
				Privilege.buildblockseverywhere,
				Privilege.useblockseverywhere,
				Privilege.gamemode,
				Privilege.pickingrange,
				Privilege.kick,
				Privilege.ban,
				Privilege.whitelist,
				Privilege.setwelcome,
				Privilege.announce,
				Privilege.readlists,
				Privilege.give,
				Privilege.setspawn,
				Privilege.controlserver,
				Privilege.tp,
				Privilege.time,
				Privilege.grantrevoke,
				Privilege.root,
				Privilege.commandplayer,
			};

		internal const string _lastLoginKey = @"LastLogin";
		internal const string _lastGameDayCountKey = @"LastDayCount";
		internal const string _configFilename = @"admintoolkit.json";

		internal static List<string> AdminRoles;	

		public AdminToolkit( )
		{
			
		}

		/// <summary>
		/// Gets or sets the cached configuration.
		/// </summary>
		/// <value>The cached configuration.</value>
		internal AdminModConfig CachedConfiguration {
			get {				
				return ( AdminModConfig )ServerAPI.ObjectCache[_configFilename];
			}
			set {
				ServerAPI.ObjectCache.Add(_configFilename, value);
			}
		}

		public override bool ShouldLoad(EnumAppSide forSide)
		{
			return forSide.IsServer( );
		}

		public override void StartServerSide(ICoreServerAPI api)
		{
			base.StartServerSide(api);

			Mod.Logger.Notification("Starting Administrators Toolkit mod");

			this.API = api;
			this.ServerAPI = API as ICoreServerAPI;

			PopulateAdminRoleTable( );
			PrepareServersideConfig( );

			MultiLang.Load(Mod.Logger, ServerAPI.Assets, Mod.Info.ModID);


			this.ServerAPI.RegisterCommand(new RulesCommand(this.ServerAPI)); 
			this.ServerAPI.RegisterCommand(new AdminListingCommand(this.ServerAPI) );
			this.ServerAPI.RegisterCommand(new BackupCycleCommand(this.ServerAPI) );
			//this.ServerAPI.RegisterCommand(new BannerControl(this.ServerAPI));
			this.ServerAPI.RegisterCommand(new PingerCommand(this.ServerAPI));
			this.ServerAPI.RegisterCommand(new IdlePlayerControl(this.ServerAPI));

			if (this.CachedConfiguration.VariableSpawnpoints) { this.ServerAPI.RegisterCommand(new VariableSpawnpoints(this.ServerAPI)); }

			if (CachedConfiguration.BoomingVoice) {
				this.ServerAPI.Event.PlayerChat += BoomingVoiceOfAuthority;
			}

			this.ServerAPI.Event.PlayerNowPlaying += WelcomeMessage;


			this.ServerAPI.Event.ServerRunPhase(EnumServerRunPhase.Shutdown, SaveConfigSettings);
		}



}
}