Read() public static method

public static Read ( string filePath ) : Configuration
filePath string
return Configuration
Example #1
0
        private void InitUserInteractionHandler()
        {
            Func <Configuration> reloadConfiguration = () => {
                if (this.isDisposed)
                {
                    return(null);
                }

                this.Config = Configuration.Read(ProtectorPlugin.ConfigFilePath);
                this.ProtectionManager.Config = this.Config;

                return(this.Config);
            };

            this.UserInteractionHandler = new UserInteractionHandler(
                this.Trace, this.PluginInfo, this.Config, this.ServerMetadataHandler, this.WorldMetadata,
                this.ProtectionManager, this.ChestManager, this.PluginCooperationHandler, reloadConfiguration
                );
        }
Example #2
0
        private bool InitConfig()
        {
            if (File.Exists(ProtectorPlugin.ConfigFilePath))
            {
                try {
                    this.Config = Configuration.Read(ProtectorPlugin.ConfigFilePath);
                } catch (Exception ex) {
                    this.Trace.WriteLineError(
                        "Reading the configuration file failed. This plugin will be disabled. Exception details:\n{0}", ex
                        );
                    this.Trace.WriteLineError("THIS PLUGIN IS DISABLED, EVERYTHING IS UNPROTECTED!");

                    this.Dispose();
                    return(false);
                }
            }
            else
            {
                this.Config = new Configuration();
            }

            // Invalidate Configuration
            if (this.Config.ManuallyProtectableTiles[(int)BlockType.SandBlock] || this.Config.AutoProtectedTiles[(int)BlockType.SandBlock])
            {
                this.Trace.WriteLineWarning("Protector is configured to protect sand blocks, this is generally not recommended as protections will not move with falling sand and thus cause invalid protections.");
            }
            if (this.Config.ManuallyProtectableTiles[(int)BlockType.SiltBlock] || this.Config.AutoProtectedTiles[(int)BlockType.SiltBlock])
            {
                this.Trace.WriteLineWarning("Protector is configured to protect silt blocks, this is generally not recommended as protections will not move with falling silt and thus cause invalid protections.");
            }
            if (this.Config.ManuallyProtectableTiles[(int)BlockType.IceBlock] || this.Config.AutoProtectedTiles[(int)BlockType.IceBlock])
            {
                this.Trace.WriteLineWarning("Protector is configured to protect ice blocks, this is generally not recommended as protections will not be automatically removed when the ice block disappears.");
            }

            return(true);
        }