-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Initial for Player module, it is a work in progress.
- Loading branch information
Showing
7 changed files
with
87 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
### player | ||
|
||
This module is mainly used for processing player data in a distributed environment. | ||
It includes `L1 (caffeine)` and `L2 (Redis)` cache and ensures data consistency. | ||
|
||
This module will facilitate player data management, rapid development, and no longer need to worry about data consistency issues. | ||
|
||
### process design | ||
|
||
- When the player enters, load the Redis data into Java memory. | ||
- When the player data needs to be updated: | ||
- Use the Redis Streams mechanism to notify other services. | ||
- Each service checks whether the player is online. | ||
- If online, directly update the memory data of the service; otherwise update Redis. | ||
- When the player exits, save the memory data to Redis. | ||
- The scheduled task persists the Redis data to the MongoDB. | ||
|
||
### distributed implementation of scheduled tasks: | ||
|
||
Through the election mechanism, a master node is elected in the distributed system to be responsible for executing scheduled tasks. Other nodes serve as backup nodes and only take over tasks when the master node fails. |
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,35 @@ | ||
fun properties(key: String) = project.findProperty(key).toString() | ||
fun rootProperties(key: String) = rootProject.findProperty(key).toString() | ||
|
||
group = rootProperties("group") | ||
version = rootProperties("version") | ||
|
||
// Run server | ||
runServer { | ||
version.set(rootProperties("spigot.version")) | ||
javaVersion.set(JavaVersion.VERSION_21) | ||
} | ||
|
||
// Fairy configuration | ||
fairy { | ||
name.set(properties("name")) | ||
mainPackage.set(properties("package")) | ||
fairyPackage.set("io.fairyproject") | ||
|
||
bukkitProperties().depends.add("fairy-lib-plugin") | ||
|
||
bukkitProperties().foliaSupported = true | ||
bukkitProperties().bukkitApi = rootProperties("spigot.version") | ||
} | ||
|
||
// Dependencies | ||
dependencies { | ||
// Annotation module | ||
compileOnly(project(":annotation")) | ||
|
||
// Cache module | ||
compileOnly(project(":cache")) | ||
|
||
// Mongodb module | ||
compileOnly(project(":mongodb")) | ||
} |
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,3 @@ | ||
# player | ||
package=net.legacy.library.player | ||
name=player |
25 changes: 25 additions & 0 deletions
25
player/src/main/java/net/legacy/library/player/PlayerLauncher.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,25 @@ | ||
package net.legacy.library.player; | ||
|
||
import io.fairyproject.FairyLaunch; | ||
import io.fairyproject.container.InjectableComponent; | ||
import io.fairyproject.plugin.Plugin; | ||
|
||
/** | ||
* The type Player launcher. | ||
* | ||
* @author qwq-dev | ||
* @since 2025-1-3 14:12 | ||
*/ | ||
@FairyLaunch | ||
@InjectableComponent | ||
public class PlayerLauncher extends Plugin { | ||
@Override | ||
public void onPluginEnable() { | ||
// TODO: try get leader from redis | ||
} | ||
|
||
@Override | ||
public void onPluginDisable() { | ||
// TODO: if leader, then save redis data to mongodb | ||
} | ||
} |
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ include("annotation") | |
include("commons") | ||
include("mongodb") | ||
include("cache") | ||
include("player") |