public override void Enabled(OpenApi api) { api.CommandManager.RegisterPermissionChecker(new FactionPermissionChecker(FactionManager)); api.CommandManager.LoadCommands(CommandsClass); api.CommandManager.LoadCommands(new FactionCommands(FactionManager)); }
public override void Enabled(OpenApi api) { Host = api; GameManager = new GameManager(api.LevelManager); JoinQuitHandler = new JoinQuitHandler(GameManager); api.EventDispatcher.RegisterEvents(JoinQuitHandler); }
public WrappedCachedWorldProvider(OpenApi api, IWorldProvider worldProvider) : base(api, worldProvider) { if (worldProvider is ICachingWorldProvider) { CachingWorldProvider = (ICachingWorldProvider)worldProvider; } }
public OpenLevel(OpenApi openApi, OpenLevelManager levelManager, string levelId, IWorldProvider worldProvider, EntityManager entityManager, GameMode gameMode = GameMode.Survival, Difficulty difficulty = Difficulty.Normal, int viewDistance = 11) : base(levelManager, levelId, (worldProvider is ICachingWorldProvider) ? new WrappedCachedWorldProvider(openApi, worldProvider) : new WrappedWorldProvider(openApi, worldProvider), entityManager, gameMode, difficulty, viewDistance) { OpenAPI = openApi; CancelationToken = new CancellationTokenSource(); TickScheduler = new TickScheduler(); EventDispatcher = new EventDispatcher(openApi, OpenAPI.EventDispatcher); if (WorldProvider is WrappedWorldProvider wrapped) { wrapped.Level = this; } }
public override void Disabled(OpenApi api) { _timer?.Dispose(); _timer = null; Log.Info($"WorldGenerator plugin disabled!"); }
public override void Enabled(OpenApi api) { Api = api; if (Config.GetProperty("WorldGen.IsDefault", false)) { IWorldGenerator generator; /* generator = new MiNET.Worlds.SuperflatGenerator(Dimension.Overworld) * { * BlockLayers = new List<Block>() * { * new Bedrock(), * new Dirt(), * new Dirt(), * new Grass() * } * };*/ generator = new OverworldGeneratorV2(); var level = new OpenLevel(api, api.LevelManager, Dimension.Overworld.ToString(), new DebugWorldProvider(generator), api.LevelManager.EntityManager, GameMode.Creative, Difficulty.Peaceful); api.LevelManager.LoadLevel(level); api.LevelManager.SetDefaultLevel(level); } api.EventDispatcher.RegisterEvents(this); if (Config.GetProperty("WorldGen.Debug", false)) { _timer = new Timer(Callback, null, TimeSpan.Zero, TimeSpan.FromSeconds(1.25)); } }
public override void Enabled(OpenApi api) { Api = api; Host = new NancyHost(new Bootstrapper(this, api), new Uri("http://127.0.0.1:3000")); Host.Start(); }
/// <summary> /// The method that gets invoked as soon as a plugin gets Disabled. /// Any content initialized in <see cref="M:OpenAPI.Plugins.OpenPlugin.Enabled(OpenAPI.OpenApi)" /> should be de-initialized in here. /// </summary> /// <param name="api">An instance to OpenApi</param> public override void Disabled(OpenApi api) { api.EventDispatcher.UnregisterEvents(this); api.CommandManager.UnloadCommands(Commands); GeneratorManager.Close(); MultiVerseManager.Close(); }
public ActionResult Open([FromBody] OpenApi openApi) { if (openApi == null) { return(Json(new ResultsJson(new Message(CodeMessage.PostNull, "PostNull"), null))); } return(Json(Global.BUSS.BussResults(this, openApi))); }
public ActionResult Open([FromBody] OpenApi openApi) { Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n\r"); if (openApi == null) { return(Json(new ResultsJson(new Message(CodeMessage.PostNull, "PostNull"), null))); } return(Json(Global.BUSS.BussResults(this, openApi))); }
public ServerModule(OpenApi api, MemoryMetricsClient metricsClient) : base("/server") { Api = api; MetricsClient = metricsClient; Get("/", Root); Get("/levels", GetLevels); Get("/plugins", GetPlugins); }
public Bootstrapper(ManagementApiPlugin plugin, OpenApi api) { Plugin = plugin; Api = api; ModuleRegistrations = typeof(ManagementApiPlugin).Assembly.GetTypes().Where(x => typeof(INancyModule).IsAssignableFrom(x)) .Select(t => new ModuleRegistration(t)) .ToArray(); }
public void Broadcast(OpenPlayer source, OpenApi api, params string[] message) { string msg = String.Join(" ", message); foreach (var lvl in api.LevelManager.GetLevels) { lvl.BroadcastMessage(msg, MessageType.Chat, source); } source.SendMessage($"We tried broadcasting: {msg}"); }
public EventDispatcher(OpenApi openApi, params EventDispatcher[] dispatchers) { Api = openApi; ExtraDispatchers = dispatchers.Where(x => x != this).ToArray(); RegisteredEvents = new Dictionary <Type, EventDispatcherValues>(); foreach (var eventType in EventTypes) { RegisteredEvents.Add(eventType, new EventDispatcherValues()); } //Log.Info($"Registered {RegisteredEvents.Count} event types!"); }
/// <summary> /// Creates a new <see cref="OpenPlayer"/> instance. /// </summary> /// <param name="server">The server instance the player connected through</param> /// <param name="endPoint">The player's remote endpoint</param> /// <param name="api">An instance of the API</param> public OpenPlayer(OpenServer server, IPEndPoint endPoint, OpenApi api) : base(server, endPoint) { EnableCommands = true; _plugin = api; IsFlying = false; Permissions = new PermissionManager(); Inventory = new OpenPlayerInventory(this); _serverHaveResources = api.ResourcePackProvider.HasData; Commands = _plugin.CommandManager.GenerateCommandSet(this); //if (Config.GetProperty("useResourcePack")) }
internal OpenPluginManager(OpenApi parent) { Parent = parent; HostAssembly = Assembly.GetAssembly(typeof(OpenPluginManager)); LoadedAssemblies = new Dictionary <Assembly, LoadedAssembly>(); //References = new ConcurrentDictionary<Type, object>(); AssemblyManager = new AssemblyManager(); AssemblyResolver = new AssemblyResolver(AssemblyManager); Services = new DependencyContainer(); Services.RegisterSingleton <OpenApi>(parent); }
public MultiVerseManager(OpenApi api, GeneratorManager generatorManager) { Api = api; LevelManager = api.LevelManager; GeneratorManager = generatorManager; MultiVerses = new ConcurrentDictionary <string, MultiVerseInstance>(); WorldFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), WorldFolder); if (!Directory.Exists(WorldFolder)) { Directory.CreateDirectory(WorldFolder); } }
public ReturnResult BandWechatLogin() { try { var agentId = Request.Param("agentId").ToInt32(); string code = Request.ParamUtil("code"); if (code.IsNotNullOrWhiteSpace() && agentId > 0) { var info = new OpenApi().GetAccess_token(code); if (info != null) { if (new BLL.FX_Agent().BandWechatLogin(agentId, info.openid)) { return(new ReturnResult { code = ReturnCode.Success, desc = "绑定成功", data = "" }); } } } else { return(new ReturnResult { code = ReturnCode.NullOrEmpty, desc = "参数异常 agentId:" + agentId + "&code:" + code, data = "" }); } return(new ReturnResult { code = ReturnCode.Error, desc = "内部错误", data = "" }); } catch (Exception err) { return(new ReturnResult { code = ReturnCode.Error, data = "", desc = err.Message }); } }
public ReturnResult UserLoginOAuth() { try { string code = Request.ParamUtil("code"); if (code.IsNotNullOrWhiteSpace()) { var info = new OpenApi().GetAccess_token(code); if (info != null) { var userInfo = new Accounts().UserLoginThird(info.openid); if (userInfo != null) { return(new ReturnResult() { code = ReturnCode.Success, data = userInfo, desc = "第三方登录成功" }); } else { return(new ReturnResult() { code = ReturnCode.Error, data = "", desc = "该微信尚未绑定代理商,请先绑定" }); } } } return(new ReturnResult() { code = ReturnCode.Error, data = "", desc = "授权失败" }); } catch (Exception err) { return(new ReturnResult() { code = ReturnCode.Error, data = "", desc = err.Message }); } }
public override void Enabled(OpenApi api) { LoadConfig(); if (string.IsNullOrWhiteSpace(Config.Host)) { Log.Warn($"!!! Configuration required, please setup the config file !!!"); return; } SetupMetricsReporter(); Collector.Setup(api); Ready = true; }
/// <summary> /// The method that gets invoked as soon as a plugin gets Enabled. /// Any initialization should be done in here. /// </summary> /// <param name="api">An instance to OpenApi</param> public override void Enabled(OpenApi api) { if (!Config.GetProperty("save.enabled", false)) { Log.Warn( $"!!! World saving is disabled in the server configuration, enable it by updating your server.conf to include \"save.enabled=true\" to resolve this issue. !!!"); } if (!PermissionsEnabled) { Log.Warn( $"!!! Permissions are disabled! This means anyone can create MultiVerse instances! If you have a permission manager, you should add \"mv.permissions.enabled=true\" to your server.conf file !!!"); } api.EventDispatcher.RegisterEvents(this); api.CommandManager.LoadCommands(Commands); }
/// <summary> /// Write Open API document to the given writer. /// </summary> /// <param name="writer">The writer.</param> public virtual void Write(IOpenApiWriter writer) { if (writer == null) { throw Error.ArgumentNull("writer"); } // { for json, empty for YAML writer.WriteStartObject(); // openapi:3.0.0 writer.WriteRequiredProperty(OpenApiConstants.OpenApiDocOpenApi, OpenApi.ToString()); // info writer.WriteRequiredObject(OpenApiConstants.OpenApiDocInfo, Info); // servers writer.WriteOptionalCollection(OpenApiConstants.OpenApiDocServers, Servers); // paths writer.WriteRequiredObject(OpenApiConstants.OpenApiDocPaths, Paths); // components writer.WriteOptionalObject(OpenApiConstants.OpenApiDocComponents, Components); // security writer.WriteOptionalCollection(OpenApiConstants.OpenApiDocSecurity, Security); // tags writer.WriteOptionalCollection(OpenApiConstants.OpenApiDocTags, Tags); // external docs writer.WriteOptionalObject(OpenApiConstants.OpenApiDocExternalDocs, ExternalDoc); // specification extensions writer.WriteDictionary(Extensions); // } for json, empty for YAML writer.WriteEndObject(); // flush writer.Flush(); }
/// <summary> /// Called when the plugin is enabled /// </summary> /// <param name="api">The api<see cref="OpenApi"/>.</param> public override void Enabled(OpenApi api) { Events = new Events(this); api.CommandManager.LoadCommands(new OpCommand()); api.CommandManager.LoadCommands(new PluginsCommand(api)); api.CommandManager.LoadCommands(new TellCommand(this)); api.CommandManager.LoadCommands(new MeCommand(this)); api.CommandManager.LoadCommands(new ListCommand(this)); api.CommandManager.LoadCommands(new TeleportCommand(this)); api.CommandManager.LoadCommands(new SayCommand(this)); api.CommandManager.LoadCommands(new GiveCommand()); api.CommandManager.LoadCommands(new KillCommand(this)); api.CommandManager.LoadCommands(new TimeCommand(this)); api.CommandManager.LoadCommands(new EffectCommand(this)); api.CommandManager.LoadCommands(new SpawnCommand(this)); api.CommandManager.LoadCommands(new GamemodeCommand(this)); api.EventDispatcher.RegisterEvents(Events); Api = api; }
public async Task GetAll_Should_ReturnOk() { //Arrange var mockLog = Substitute.For <ILogger>(); var mockRequest = NSubstituteHttpRequest.CreateMockRequest(string.Empty); var mockExecution = new ExecutionContext(); var currentDirectory = new DirectoryInfo(Environment.CurrentDirectory).ToString(); mockExecution.FunctionAppDirectory = currentDirectory; //Act var result = await OpenApi.GetAll(mockRequest, mockLog, mockExecution); //Assert result.StatusCode.Should().Be(200); var content = await result.Content.ReadAsStringAsync(); string.IsNullOrEmpty(content).Should().BeFalse(); content.Should().NotBe("null"); }
private void InitializeApiObjects() { //New API needs to be instantiated here, in the same alphabetical order as above Acsrf = new Acsrf(this); AjaxSpider = new AjaxSpider(this); Alert = new Generated.Alert(this); AlertFilter = new AlertFilter(this); Ascan = new Ascan(this); Authentication = new Authentication(this); Authorization = new Authorization(this); AutoUpdate = new AutoUpdate(this); Brk = new Break(this); Context = new Context(this); Core = new Core(this); ForcedUser = new ForcedUser(this); HttpSessions = new HttpSessions(this); ImportLogFiles = new ImportLogFiles(this); ImportUrls = new ImportUrls(this); LocalProxies = new LocalProxies(this); OpenApi = new OpenApi(this); Parameters = new Params(this); Pnh = new Pnh(this); PScan = new PScan(this); Replacer = new Replacer(this); Reveal = new Reveal(this); RuleConfig = new RuleConfig(this); Script = new Script(this); Search = new Search(this); Selenium = new Selenium(this); SessionManagement = new SessionManagement(this); Soap = new Soap(this); Spider = new Spider(this); Stats = new Stats(this); Users = new Users(this); Websocket = new Websocket(this); }
public void EnqueueByReceivedQueue(OpenApi.Spell.SpellOpt message) { // lock (lockerReceivedQueue) // { receivedQueue.Enqueue(message); // } }
public WrappedWorldProvider(OpenApi api, IWorldProvider worldProvider) { Api = api; WorldProvider = worldProvider; }
public override void Disabled(OpenApi api) { api.CommandManager.UnloadCommands(CommandsClass); }
public void EnqueueByOrderQueue(OpenApi.Spell.SpellOpt message) { lock (lockerOrderQueue) { orderQueue.Enqueue(message); } }
public void EnqueueByRunQueue(OpenApi.Spell.SpellOpt message) { runQueue.Enqueue(message); }
public async Task <APITemplateResource> CreateAPITemplateResourceAsync(APIConfig api, bool isSplit, bool isInitial) { // create api resource APITemplateResource apiTemplateResource = new APITemplateResource() { name = MakeResourceName(api), type = ResourceTypeConstants.API, apiVersion = GlobalConstants.APIVersion, properties = new APITemplateProperties(), dependsOn = new string[] { } }; // add properties depending on whether the template is the initial, subsequent, or unified if (!isSplit || !isInitial) { // add metadata properties for initial and unified templates apiTemplateResource.properties.apiVersion = api.apiVersion; apiTemplateResource.properties.serviceUrl = MakeServiceUrl(api); apiTemplateResource.properties.type = api.type; apiTemplateResource.properties.apiType = api.type; apiTemplateResource.properties.description = api.description; apiTemplateResource.properties.subscriptionRequired = api.subscriptionRequired; apiTemplateResource.properties.apiRevision = api.apiRevision; apiTemplateResource.properties.apiRevisionDescription = api.apiRevisionDescription; apiTemplateResource.properties.apiVersionDescription = api.apiVersionDescription; apiTemplateResource.properties.authenticationSettings = api.authenticationSettings; apiTemplateResource.properties.subscriptionKeyParameterNames = api.subscriptionKeyParameterNames; apiTemplateResource.properties.path = api.suffix; apiTemplateResource.properties.isCurrent = api.isCurrent; apiTemplateResource.properties.displayName = string.IsNullOrEmpty(api.displayName) ? api.name : api.displayName; apiTemplateResource.properties.protocols = this.CreateProtocols(api); // set the version set id if (api.apiVersionSetId != null) { // point to the supplied version set if the apiVersionSetId is provided apiTemplateResource.properties.apiVersionSetId = $"[resourceId('Microsoft.ApiManagement/service/apiVersionSets', parameters('{ParameterNames.ApimServiceName}'), '{api.apiVersionSetId}')]"; } // set the authorization server id if (api.authenticationSettings != null && api.authenticationSettings.oAuth2 != null && api.authenticationSettings.oAuth2.authorizationServerId != null && apiTemplateResource.properties.authenticationSettings != null && apiTemplateResource.properties.authenticationSettings.oAuth2 != null && apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId != null) { apiTemplateResource.properties.authenticationSettings.oAuth2.authorizationServerId = api.authenticationSettings.oAuth2.authorizationServerId; } // set the subscriptionKey Parameter Names if (api.subscriptionKeyParameterNames != null) { if (api.subscriptionKeyParameterNames.header != null) { apiTemplateResource.properties.subscriptionKeyParameterNames.header = api.subscriptionKeyParameterNames.header; } if (api.subscriptionKeyParameterNames.query != null) { apiTemplateResource.properties.subscriptionKeyParameterNames.query = api.subscriptionKeyParameterNames.query; } } } if (!isSplit || isInitial) { // add open api spec properties for subsequent and unified templates string format; string value; // determine if the open api spec is remote or local, yaml or json bool isJSON = false; bool isUrl = IsUri(api, out var _); string fileContents = null; if (!isUrl || api.openApiSpecFormat == OpenApiSpecFormat.Unspecified) { fileContents = await this.fileReader.RetrieveFileContentsAsync(api.openApiSpec); } value = isUrl ? api.openApiSpec : fileContents ; bool isVersionThree = false; if (api.openApiSpecFormat == OpenApiSpecFormat.Unspecified) { isJSON = this.fileReader.isJSON(fileContents); if (isJSON == true) { var openAPISpecReader = new OpenAPISpecReader(); isVersionThree = await openAPISpecReader.isJSONOpenAPISpecVersionThreeAsync(api.openApiSpec); } format = GetOpenApiSpecFormat(isUrl, isJSON, isVersionThree); } else { isJSON = IsOpenApiSpecJson(api.openApiSpecFormat); format = GetOpenApiSpecFormat(isUrl, api.openApiSpecFormat); } // if the title needs to be modified // we need to embed the OpenAPI definition if (!string.IsNullOrEmpty(api.displayName)) { format = GetOpenApiSpecFormat(false, isJSON, isVersionThree); // download definition if (isUrl) { using (var client = new WebClient()) value = client.DownloadString(value); } // update title value = new OpenApi(value, format) .SetTitle(api.displayName) .GetDefinition() ; } // set the version set id if (api.apiVersionSetId != null) { // point to the supplied version set if the apiVersionSetId is provided apiTemplateResource.properties.apiVersionSetId = $"[resourceId('Microsoft.ApiManagement/service/apiVersionSets', parameters('{ParameterNames.ApimServiceName}'), '{api.apiVersionSetId}')]"; } apiTemplateResource.properties.format = format; apiTemplateResource.properties.value = value; apiTemplateResource.properties.path = api.suffix; if (!String.IsNullOrEmpty(api.serviceUrl)) { apiTemplateResource.properties.serviceUrl = MakeServiceUrl(api); } } return(apiTemplateResource); }
public MainModule(OpenApi api) { Api = api; Get("/", Index); }
public void AddSpellDictionary(String key, OpenApi.Spell.SpellOpt value) { lock (lockerSpellDictionary) { //FileLog.PrintF("AddSpellDictionary key=>" + key); if (!spellDictionary.ContainsKey(key)) { spellDictionary.Add(key, value); } } }
private void setCurrentRunSellOpt(OpenApi.Spell.SpellOpt value) { lock (lockerCurrentRunSpellOpt) { this.CurrentRunSpellOpt = value; } }
public static void threadJob(OpenApi.Spell.SpellOpt spellOpt) { List<String> stockCodeList = AppLib.getClass1Instance().getStockCodeList(); for (int i = 0; i < stockCodeList.Count; i++) { OpenApi.Spell.SpellOpt tmp = spellOpt.ShallowCopy(); String stockCode = stockCodeList[i]; String sScrNo = ScreenNumber.getClass1Instance().GetEosScrNum(); String keyStockCodeLayout = "sRQName:{0}|sTrCode:{1}|sScreenNo:{2}"; String keyStockCode = String.Format(keyStockCodeLayout , tmp.sRQNAME , tmp.sTrCode , sScrNo ); String keyLayout = "sRQName:{0}|sTrCode:{1}|sScreenNo:{2}|stockCode:{3}"; String key = String.Format(keyLayout , tmp.sRQNAME , tmp.sTrCode , sScrNo , stockCode ); tmp.sScreenNo = sScrNo; tmp.stockCode = stockCode; tmp.key = key; tmp.reportGubun = "FILE"; // FileLog.PrintF("threadJob keyStockCode="+ keyStockCode); // FileLog.PrintF("threadJob key=" + key); //String logDate = DateTime.Today.ToString("yyyyMMdd"); if (!(System.IO.File.Exists(Config.GetPath() + tmp.GetZipFileName()) || System.IO.File.Exists(Config.GetBackUpPath() + tmp.GetZipFileName())) ) { // FileLog.PrintF("threadJob zipPath=" + zipPath); if (!System.IO.File.Exists(Config.GetPath() + tmp.GetFileName())) { // FileLog.PrintF("threadJob path=" + path); AppLib.getClass1Instance().EnqueueByOrderQueue(tmp); AppLib.getClass1Instance().AddSpellDictionary(key, tmp); AppLib.getClass1Instance().AddStockCodeDictionary(keyStockCode, stockCode); AppLib.getClass1Instance().InCraeteOrderedCodeCount(); } } } }
public override void Disabled(OpenApi api) { api.EventDispatcher.UnregisterEvents(this); }
private void printRunTime(OpenApi.Spell.SpellOpt value) { DateTime startRunTime = value.startRunTime; DateTime checkRunTime = DateTime.Now; TimeSpan gap = checkRunTime - startRunTime; int iGap = gap.Milliseconds; String key ="[FINISH]"+ value.sTrCode + "::" + value.stockCode + "::" + value.endDate + "::iGap[Milliseconds]=> " + iGap; FileLog.PrintF(key); }