mirror of
https://github.com/SimplexDevelopment/SimplexSS.git
synced 2024-12-22 05:07:36 +00:00
Merge branch 'main' of https://github.com/SimplexDevelopment/SimplexSS
This commit is contained in:
commit
116fbe5847
76
.github/workflows/codeql.yml
vendored
Normal file
76
.github/workflows/codeql.yml
vendored
Normal file
@ -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}}"
|
34
.github/workflows/gradle.yml
vendored
Normal file
34
.github/workflows/gradle.yml
vendored
Normal file
@ -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
|
128
README.md
128
README.md
@ -1,2 +1,130 @@
|
||||
# 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)
|
||||
|
||||
# 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.
|
||||
|
||||
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
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
...
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>path.to.MainClass</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
...
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
```
|
||||
|
||||
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'
|
||||
}
|
||||
```
|
||||
|
||||
# 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<YourPlugin> 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<Disposable> object so we can cancel the services later on in `JavaPlugin#onDisable()`.
|
||||
|
||||
```Java
|
||||
private Flux<Disposable> 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<Disposable> 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());
|
||||
});
|
||||
}
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user