Skip to content

Commit 3f06f65

Browse files
committed
Initial release: EchoRP v11.0 Modular RP Infrastructure
0 parents  commit 3f06f65

File tree

84 files changed

+3645
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+3645
-0
lines changed

.github/workflows/build.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Java CI with Gradle
2+
3+
on:
4+
push:
5+
branches: [ "main", "master" ]
6+
pull_request:
7+
branches: [ "main", "master" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v3
16+
with:
17+
java-version: '17'
18+
distribution: 'temurin'
19+
cache: gradle
20+
21+
- name: Grant execute permission for gradlew
22+
run: chmod +x gradlew
23+
24+
- name: Build with Gradle
25+
run: ./gradlew build
26+
27+
- name: Upload Core Artifact
28+
uses: actions/upload-artifact@v3
29+
with:
30+
name: EchoRP-Core
31+
path: core/build/libs/*.jar

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Gradle
2+
.gradle/
3+
build/
4+
*/build/
5+
6+
# IDE (IntelliJ IDEA, VS Code)
7+
.idea/
8+
*.iml
9+
.vscode/
10+
*.swp
11+
*.DS_Store
12+
13+
# Compiled files
14+
*.class
15+
*.jar
16+
!gradle-wrapper.jar
17+
18+
# Logs and DB (local testing)
19+
*.log
20+
*.db
21+
*.h2.db
22+
plugins/
23+
logs/
24+
25+
# Secrets & Local Configs
26+
config.yml

api/build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
id("java-library")
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
maven("https://repo.papermc.io/repository/maven-public/")
8+
}
9+
10+
dependencies {
11+
// Only Paper API and Lombok are required for the API layer (TS 1.4)
12+
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
13+
compileOnly("org.projectlombok:lombok:1.18.30")
14+
annotationProcessor("org.projectlombok:lombok:1.18.30")
15+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.echorp.api;
2+
3+
import com.echorp.api.module.ModuleProvider;
4+
import com.echorp.api.service.CacheService;
5+
import com.echorp.api.service.DatabaseService;
6+
import com.echorp.api.service.RatingService;
7+
8+
/**
9+
* Main entry point for EchoRP API (TS 1.4).
10+
* Provides access to core services for module developers.
11+
*/
12+
public interface EchoRPAPI {
13+
14+
/** @return Service for rating calculations and retrieval (TS 2.2) */
15+
RatingService getRatingService();
16+
17+
/** @return Asynchronous database access service (TS 2.2) */
18+
DatabaseService getDatabaseService();
19+
20+
/** @return Caching service with CAS support (TS 2.4) */
21+
CacheService getCacheService();
22+
23+
/** @return Manager for module discovery and lifecycle (TS 2.1) */
24+
ModuleProvider getModuleProvider();
25+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.echorp.api.event;
2+
3+
import org.bukkit.event.Event;
4+
import org.bukkit.event.HandlerList;
5+
import org.jetbrains.annotations.NotNull;
6+
7+
/**
8+
* Fired whenever a player's rating is updated (TS 1.4, 6.1).
9+
* Async by default to ensure no performance impact on the main thread.
10+
*/
11+
public class PlayerRatingChangeEvent extends Event {
12+
private static final HandlerList HANDLERS = new HandlerList();
13+
14+
private final String playerUuid;
15+
private final String category;
16+
private final double oldRating;
17+
private final double newRating;
18+
private final int version; // Required for Event Sourcing consistency (TS 6.2)
19+
20+
public PlayerRatingChangeEvent(String playerUuid, String category, double oldRating, double newRating, int version) {
21+
super(true); // Always asynchronous
22+
this.playerUuid = playerUuid;
23+
this.category = category;
24+
this.oldRating = oldRating;
25+
this.newRating = newRating;
26+
this.version = version;
27+
}
28+
29+
public String getPlayerUuid() { return playerUuid; }
30+
public String getCategory() { return category; }
31+
public double getOldRating() { return oldRating; }
32+
public double getNewRating() { return newRating; }
33+
public int getVersion() { return version; }
34+
35+
@NotNull @Override public HandlerList getHandlers() { return HANDLERS; }
36+
public static HandlerList getHandlerList() { return HANDLERS; }
37+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.echorp.api.event;
2+
3+
import org.bukkit.event.Event;
4+
import org.bukkit.event.HandlerList;
5+
import org.jetbrains.annotations.NotNull;
6+
7+
public class PlayerWeightCalculateEvent extends Event {
8+
private static final HandlerList HANDLERS = new HandlerList();
9+
10+
private final String giverUuid;
11+
private final String targetUuid;
12+
private final String category;
13+
private double weight;
14+
15+
public PlayerWeightCalculateEvent(String giverUuid, String targetUuid, String category, double initialWeight) {
16+
// ИСПРАВЛЕНИЕ: Говорим ядру сервера, что событие асинхронное (true)
17+
super(true);
18+
19+
this.giverUuid = giverUuid;
20+
this.targetUuid = targetUuid;
21+
this.category = category;
22+
this.weight = initialWeight;
23+
}
24+
25+
public String getGiverUuid() { return giverUuid; }
26+
public String getTargetUuid() { return targetUuid; }
27+
public String getCategory() { return category; }
28+
public double getWeight() { return weight; }
29+
public void setWeight(double weight) { this.weight = weight; }
30+
31+
@NotNull @Override public HandlerList getHandlers() { return HANDLERS; }
32+
public static HandlerList getHandlerList() { return HANDLERS; }
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.echorp.api.module;
2+
3+
import java.util.logging.Logger;
4+
5+
/**
6+
* Base interface for all EchoRP modules.
7+
* Every module in the /modules directory must implement this.
8+
*/
9+
public interface EchoModule {
10+
11+
/** Called when the module is being initialized */
12+
void onEnable();
13+
14+
/** Called when the module is being shut down or reloaded */
15+
void onDisable();
16+
17+
/** @return Unique module identifier */
18+
String getName();
19+
20+
/** @return Current module version */
21+
String getVersion();
22+
23+
/** Sets the logger provided by the Core */
24+
void setLogger(Logger logger);
25+
26+
/** @return Logger assigned to this module */
27+
Logger getLogger();
28+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.echorp.api.module;
2+
3+
import lombok.Builder;
4+
import lombok.Value;
5+
import java.util.List;
6+
7+
/**
8+
* Metadata for a module, typically loaded from module.yml (TS 2.1).
9+
*/
10+
@Value
11+
@Builder
12+
public class ModuleDescription {
13+
String name; // Unique name
14+
String version; // Version string
15+
String mainClass; // Path to the EchoModule implementation
16+
List<String> depends; // Hard dependencies
17+
List<String> softDepends; // Optional dependencies
18+
List<String> libraries; // Maven coordinates for runtime libraries
19+
boolean reloadable; // Supports hot-reload without server restart
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.echorp.api.module;
2+
3+
import java.util.Collection;
4+
import java.util.Optional;
5+
6+
/**
7+
* Service for managing and discovering active modules.
8+
*/
9+
public interface ModuleProvider {
10+
/** Find a loaded module by name */
11+
Optional<EchoModule> getModule(String name);
12+
13+
/** @return A list of all currently enabled modules */
14+
Collection<EchoModule> getEnabledModules();
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.echorp.api.service;
2+
3+
import java.util.Optional;
4+
5+
/**
6+
* Service for local and distributed caching (TS 2.4).
7+
*/
8+
public interface CacheService {
9+
10+
<K, V> void put(String cacheName, K key, V value);
11+
12+
<K, V> Optional<V> get(String cacheName, K key);
13+
14+
/**
15+
* Atomically updates a value if the current value matches expectations.
16+
* Crucial for Optimistic Locking (TS 6.2).
17+
*/
18+
<K, V> boolean compareAndSet(String cacheName, K key, V expect, V update);
19+
20+
void invalidate(String cacheName, Object key);
21+
}

0 commit comments

Comments
 (0)