-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix
- Loading branch information
Showing
24 changed files
with
593 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,25 +5,27 @@ on: | |
push: | ||
branches: | ||
- '*' # 所有分支 | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- '*' # 所有分支 | ||
- '*' | ||
|
||
permissions: | ||
contents: write | ||
discussions: write | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
java-version: ['8', '11', '17', '21'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK ${{ matrix.java-version }} | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: ${{ matrix.java-version }} | ||
java-version: 8 | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Build with Maven | ||
|
@@ -32,5 +34,11 @@ jobs: | |
- name: Upload Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: CatSeedLogin-${{ matrix.java-version }} | ||
path: target/*.jar | ||
name: CatSeedLogin | ||
path: target/CatSeedLogin*.jar | ||
|
||
- name: Create Release and Upload Release Asset | ||
uses: softprops/[email protected] | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: target/CatSeedLogin*.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,4 @@ | ||
{ | ||
"java.jdt.ls.java.home": "D:\\Program Files\\Java\\jdk-21", | ||
"java.compile.nullAnalysis.mode": "automatic", | ||
"java.configuration.runtimes": [ | ||
{ | ||
"name": "JavaSE-21", | ||
"path": "D:\\Program Files\\Java\\jdk-21", | ||
"default": true | ||
}, | ||
], | ||
"java.configuration.updateBuildConfiguration": "interactive" | ||
"java.configuration.updateBuildConfiguration": "automatic" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/cc/baka9/catseedlogin/bukkit/CatScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cc.baka9.catseedlogin.bukkit; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
|
||
import space.arim.morepaperlib.scheduling.ScheduledTask; | ||
|
||
public class CatScheduler { | ||
private static final boolean folia = CatSeedLogin.morePaperLib.scheduling().isUsingFolia(); | ||
private static final Method teleportAsync = initTeleportAsync(); | ||
|
||
private static Method initTeleportAsync() { | ||
if (folia) { | ||
try { | ||
return Player.class.getMethod("teleportAsync", Location.class); | ||
} catch (NoSuchMethodException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public static void teleport(Player player, Location location) { | ||
if (!folia) { | ||
player.teleport(location); | ||
return; | ||
} | ||
CatSeedLogin.morePaperLib.scheduling().entitySpecificScheduler(player).run(() -> { | ||
try { | ||
teleportAsync.invoke(player, location); | ||
} catch (IllegalAccessException | InvocationTargetException e) { | ||
throw new RuntimeException(e); | ||
} | ||
}, null); | ||
} | ||
|
||
public static void updateInventory(Player player) { | ||
CatSeedLogin.morePaperLib.scheduling().entitySpecificScheduler(player).run(player::updateInventory, null); | ||
} | ||
|
||
public static ScheduledTask runTaskAsync(Runnable runnable) { | ||
return CatSeedLogin.morePaperLib.scheduling().asyncScheduler().run(runnable); | ||
} | ||
|
||
public static ScheduledTask runTaskTimer(Runnable runnable, long delay, long period) { | ||
return CatSeedLogin.morePaperLib.scheduling().globalRegionalScheduler().runAtFixedRate(runnable, delay == 0 ? 1 : delay, period); | ||
} | ||
|
||
public static ScheduledTask runTask(Runnable runnable) { | ||
return CatSeedLogin.morePaperLib.scheduling().globalRegionalScheduler().run(runnable); | ||
} | ||
|
||
public static ScheduledTask runTaskLater(Runnable runnable, long delay) { | ||
return CatSeedLogin.morePaperLib.scheduling().globalRegionalScheduler().runDelayed(runnable, delay); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.