From 84427539641e50c6b4a587c2c21b76eb95fa5233 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Wed, 14 Dec 2022 23:40:50 -0600 Subject: [PATCH 01/10] Create gradle.yml --- .github/workflows/gradle.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..f5e6591 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,34 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: build From 0805d44dc59ed3b24a9bbf621c664e24ba9e4742 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Wed, 14 Dec 2022 23:41:50 -0600 Subject: [PATCH 02/10] Create codeql.yml --- .github/workflows/codeql.yml | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..cb1b9c8 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '21 13 * * 0' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'java' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" From 6c0229e91054752c44a69249888c2df03c3cb34c Mon Sep 17 00:00:00 2001 From: Paldiu Date: Wed, 14 Dec 2022 23:46:34 -0600 Subject: [PATCH 03/10] Update README.md --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/README.md b/README.md index 0c300bc..f5606e4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,60 @@ # SimplexSS + !(https://img.shields.io/github/workflow/status/SimplexDevelopment/SimplexSS/CodeQL/main) !(https://img.shields.io/github/v/release/SimplexDevelopment/SimplexSS?include_prereleases) !(https://img.shields.io/github/license/SimplexDevelopment/SimplexSS) !(https://img.shields.io/github/issues/SimplexDevelopment/SimplexSS) !(https://img.shields.io/github/stars/SimplexDevelopment/SimplexSS?style=social) !(https://img.shields.io/github/forks/SimplexDevelopment/SimplexSS?style=social) !(https://img.shields.io/github/languages/top/SimplexDevelopment/SimplexSS) + A reactive non blocking api for scheduling runnable tasks (called services) + +# Using SimplexSS in your project + In order to use SimplexSS in your project, you need to add the jitpack repository to your build.gradle or pom.xml file. + Here's an example, in Gradle: + + ```gradle + repositories { + maven { + id 'jitpack' + url 'https://jitpack.io' + } + } + ``` + + Then, you can add the dependency. + The `groupId` is `com.github.SimplexDevelopment` + The `artifactId` is `SimplexSS` + The `version` is `1.0.1-SNAPSHOT` + + It is recommended you use either the Maven Shade Plugin, + + ```maven + + + + org.apache.maven.plugins + maven-jar-plugin + ... + + + + true + path.to.MainClass + + + + ... + + + + ``` + + or the Gradle Shadow Plugin (com.github.johnrengelman.shadow). + + ```gradle + plugins { + id 'com.github.johnrengelman.shadow' version '7.1.2' + } + ``` + + Here is an example of the dependency, in Gradle: + ```gradle + dependencies { + shadow 'com.github.SimplexDevelopment:SimplexSS:1.0.1-SNAPSHOT' + } + ``` From 42aef3b955bdb2bf5d94e16822062be4fe7943be Mon Sep 17 00:00:00 2001 From: Paldiu Date: Wed, 14 Dec 2022 23:46:55 -0600 Subject: [PATCH 04/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f5606e4..8b4ccc8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # SimplexSS - !(https://img.shields.io/github/workflow/status/SimplexDevelopment/SimplexSS/CodeQL/main) !(https://img.shields.io/github/v/release/SimplexDevelopment/SimplexSS?include_prereleases) !(https://img.shields.io/github/license/SimplexDevelopment/SimplexSS) !(https://img.shields.io/github/issues/SimplexDevelopment/SimplexSS) !(https://img.shields.io/github/stars/SimplexDevelopment/SimplexSS?style=social) !(https://img.shields.io/github/forks/SimplexDevelopment/SimplexSS?style=social) !(https://img.shields.io/github/languages/top/SimplexDevelopment/SimplexSS) + ![](https://img.shields.io/github/workflow/status/SimplexDevelopment/SimplexSS/CodeQL/main) ![](https://img.shields.io/github/v/release/SimplexDevelopment/SimplexSS?include_prereleases) ![](https://img.shields.io/github/license/SimplexDevelopment/SimplexSS) !(https://img.shields.io/github/issues/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/stars/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/forks/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/languages/top/SimplexDevelopment/SimplexSS) A reactive non blocking api for scheduling runnable tasks (called services) From 8f6b327d20e42c5157693da44dce5a05676c1dda Mon Sep 17 00:00:00 2001 From: Paldiu Date: Wed, 14 Dec 2022 23:48:27 -0600 Subject: [PATCH 05/10] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 8b4ccc8..374660e 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # SimplexSS + ![](https://img.shields.io/github/workflow/status/SimplexDevelopment/SimplexSS/CodeQL/main) ![](https://img.shields.io/github/v/release/SimplexDevelopment/SimplexSS?include_prereleases) ![](https://img.shields.io/github/license/SimplexDevelopment/SimplexSS) !(https://img.shields.io/github/issues/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/stars/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/forks/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/languages/top/SimplexDevelopment/SimplexSS) A reactive non blocking api for scheduling runnable tasks (called services) # Using SimplexSS in your project + In order to use SimplexSS in your project, you need to add the jitpack repository to your build.gradle or pom.xml file. + Here's an example, in Gradle: ```gradle @@ -17,8 +20,11 @@ ``` Then, you can add the dependency. + The `groupId` is `com.github.SimplexDevelopment` + The `artifactId` is `SimplexSS` + The `version` is `1.0.1-SNAPSHOT` It is recommended you use either the Maven Shade Plugin, @@ -53,6 +59,7 @@ ``` Here is an example of the dependency, in Gradle: + ```gradle dependencies { shadow 'com.github.SimplexDevelopment:SimplexSS:1.0.1-SNAPSHOT' From 5b2961fff1888e66d690c5d60e242af84e20eb3c Mon Sep 17 00:00:00 2001 From: Paldiu Date: Wed, 14 Dec 2022 23:48:44 -0600 Subject: [PATCH 06/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 374660e..25f6e9d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SimplexSS - ![](https://img.shields.io/github/workflow/status/SimplexDevelopment/SimplexSS/CodeQL/main) ![](https://img.shields.io/github/v/release/SimplexDevelopment/SimplexSS?include_prereleases) ![](https://img.shields.io/github/license/SimplexDevelopment/SimplexSS) !(https://img.shields.io/github/issues/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/stars/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/forks/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/languages/top/SimplexDevelopment/SimplexSS) + ![](https://img.shields.io/github/workflow/status/SimplexDevelopment/SimplexSS/CodeQL/main) ![](https://img.shields.io/github/v/release/SimplexDevelopment/SimplexSS?include_prereleases) ![](https://img.shields.io/github/license/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/issues/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/stars/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/forks/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/languages/top/SimplexDevelopment/SimplexSS) A reactive non blocking api for scheduling runnable tasks (called services) From 7e29987e7ff6bbf91ad59a24e62f8680f90da957 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Thu, 15 Dec 2022 00:09:37 -0600 Subject: [PATCH 07/10] Update README.md --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25f6e9d..d92235a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A reactive non blocking api for scheduling runnable tasks (called services) -# Using SimplexSS in your project +# Adding SimplexSS to your project In order to use SimplexSS in your project, you need to add the jitpack repository to your build.gradle or pom.xml file. @@ -65,3 +65,42 @@ shadow 'com.github.SimplexDevelopment:SimplexSS:1.0.1-SNAPSHOT' } ``` + +# Using SimplexSS + + To use Simplex Scheduling System, the first thing you need to do is initialize a new instance of the Scheduling System. + + ```Java + private SchedulingSystem scheduler; + + @Override + public void onEnable() { + this.scheduler = new SchedulingSystem<>(this); + } + ``` + + Then, you should use the Service Manager to create some new service pools. You can use `ServicePool#emptyBukkitServicePool(String, JavaPlugin)` for a service pool which will operate on the main server thread, or you can use `ServicePool#emptyServicePool(String, boolean)` for a completely separate, non-blocking scheduler which can be either singular or multithreaded. You should also use the service manager stream to register your services, and assign a Flux object so we can cancel the services later on in `JavaPlugin#onDisable()`. + + ```Java + private Flux disposables; + + @Override + public void onEnable() { + this.scheduler = new SchedulingSystem<>(this); + + YourFirstService firstService; + YourSecondService secondService; + YourThirdService thirdService; + + scheduler.getServiceManager().subscribe(manager -> { + manager.emptyBukkitServicePool("pool_name", this).subscribe(pool -> { + Set dispos = new HashSet<>(); + firstService = new YourFirstService(pool, "first_service_name"); + secondService = new YourSecondService(pool, "second_service_name", 20 * 60L); + thirdService = new YourThirdService(pool, "third_service_name", 20 * 60L, 20 * 60 * 10L, true, false); + scheduler.queue(firstService).subscribe(dispos::add); + scheduler.queue(secondService).subscribe(dispos::add); + scheduler.queue(thirdService).subscribe(dispos::add); + }); + }); + ``` From 5d66ea65823e13ceb1eb8b995acff6cac9bf391d Mon Sep 17 00:00:00 2001 From: Paldiu Date: Thu, 15 Dec 2022 00:13:09 -0600 Subject: [PATCH 08/10] Update README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index d92235a..c1e58ac 100644 --- a/README.md +++ b/README.md @@ -95,12 +95,29 @@ scheduler.getServiceManager().subscribe(manager -> { manager.emptyBukkitServicePool("pool_name", this).subscribe(pool -> { Set dispos = new HashSet<>(); + firstService = new YourFirstService(pool, "first_service_name"); secondService = new YourSecondService(pool, "second_service_name", 20 * 60L); thirdService = new YourThirdService(pool, "third_service_name", 20 * 60L, 20 * 60 * 10L, true, false); + scheduler.queue(firstService).subscribe(dispos::add); scheduler.queue(secondService).subscribe(dispos::add); scheduler.queue(thirdService).subscribe(dispos::add); + + disposables = Flux.fromIterable(dispos); }); }); + } + ``` + + You can then stop, cancel, and/or dispose of the tasks in your `JavaPlugin#onDisable()` method by calling: + ```Java + @Override + public void onDisable() { + scheduler.getServiceManager().subscribe(manager -> { + manager.getServicePools().doOnEach(signal -> Objects.requireNonNull(signal.get()) + .stopServices(disposables) + .subscribe()); + }); + } ``` From 9d726cc1e31d54b341282710da3f1fcef0d6312f Mon Sep 17 00:00:00 2001 From: Paldiu Date: Thu, 15 Dec 2022 00:25:42 -0600 Subject: [PATCH 09/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c1e58ac..a31476a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SimplexSS - ![](https://img.shields.io/github/workflow/status/SimplexDevelopment/SimplexSS/CodeQL/main) ![](https://img.shields.io/github/v/release/SimplexDevelopment/SimplexSS?include_prereleases) ![](https://img.shields.io/github/license/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/issues/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/stars/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/forks/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/languages/top/SimplexDevelopment/SimplexSS) + ![](https://img.shields.io/github/workflow/status/SimplexDevelopment/SimplexSS/CodeQL/main) ![](https://img.shields.io/github/v/release/SimplexDevelopment/SimplexSS?include_prereleases) ![](https://jitpack.io/v/SimplexDevelopment/SimplexSS.svg) ![](https://img.shields.io/github/license/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/issues/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/stars/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/forks/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/languages/top/SimplexDevelopment/SimplexSS) A reactive non blocking api for scheduling runnable tasks (called services) From 695b1f95497bc419c679398b8ed25fe7727fa502 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Thu, 15 Dec 2022 08:22:07 -0600 Subject: [PATCH 10/10] Update README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a31476a..dd42129 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ # SimplexSS - ![](https://img.shields.io/github/workflow/status/SimplexDevelopment/SimplexSS/CodeQL/main) ![](https://img.shields.io/github/v/release/SimplexDevelopment/SimplexSS?include_prereleases) ![](https://jitpack.io/v/SimplexDevelopment/SimplexSS.svg) ![](https://img.shields.io/github/license/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/issues/SimplexDevelopment/SimplexSS) ![](https://img.shields.io/github/stars/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/forks/SimplexDevelopment/SimplexSS?style=social) ![](https://img.shields.io/github/languages/top/SimplexDevelopment/SimplexSS) + ![](https://img.shields.io/github/license/SimplexDevelopment/SimplexSS) + ![](https://img.shields.io/github/languages/top/SimplexDevelopment/SimplexSS) + ![](https://img.shields.io/github/workflow/status/SimplexDevelopment/SimplexSS/CodeQL/main) + ![](https://img.shields.io/github/v/release/SimplexDevelopment/SimplexSS?include_prereleases) + ![](https://jitpack.io/v/SimplexDevelopment/SimplexSS.svg) + ![](https://img.shields.io/github/issues/SimplexDevelopment/SimplexSS) + ![](https://img.shields.io/github/stars/SimplexDevelopment/SimplexSS?style=social) + ![](https://img.shields.io/github/forks/SimplexDevelopment/SimplexSS?style=social) A reactive non blocking api for scheduling runnable tasks (called services)