Skip to content

Commit cc8ec21

Browse files
CopilotTheMeinerLP
andcommitted
Address code review feedback: Add Javadoc tags, improve Folia detection, and add Mermaid diagram
Co-authored-by: TheMeinerLP <[email protected]>
1 parent 93b0f3b commit cc8ec21

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

SERVICE_ARCHITECTURE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This document explains the Service Layer Architecture implemented for the `Redst
66

77
The architecture follows the Service Layer pattern with abstraction to allow multiple implementations:
88

9+
### Text-based Diagram
910
```
1011
┌─────────────────────────────────────────────────────────┐
1112
│ Client Code │
@@ -31,6 +32,31 @@ The architecture follows the Service Layer pattern with abstraction to allow mul
3132
└─────────────────────────────────────────────────────────┘
3233
```
3334

35+
### Mermaid Diagram
36+
```mermaid
37+
graph TD
38+
A[Client Code<br/>Plugin, Listeners, Commands] --> B[Service Interface<br/>RedstoneClockService]
39+
B --> C[Service Factory<br/>RedstoneClockServiceFactory]
40+
C --> D[Platform Detection<br/>isFolia()]
41+
D --> E[BukkitRedstoneClockService<br/>Standard Bukkit Implementation]
42+
D --> F[FoliaRedstoneClockService<br/>Region-aware Implementation]
43+
44+
style A fill:#e1f5fe
45+
style B fill:#f3e5f5
46+
style C fill:#fff3e0
47+
style D fill:#fce4ec
48+
style E fill:#e8f5e8
49+
style F fill:#fff8e1
50+
51+
classDef interfaceBox fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px
52+
classDef factoryBox fill:#fff3e0,stroke:#ff9800,stroke-width:2px
53+
classDef implBox fill:#e8f5e8,stroke:#4caf50,stroke-width:2px
54+
55+
class B interfaceBox
56+
class C,D factoryBox
57+
class E,F implBox
58+
```
59+
3460
## Components
3561

3662
### 1. Service Interface

src/main/java/net/onelitefeather/antiredstoneclockremastered/service/api/RedstoneClockService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
/**
1313
* Service interface for managing redstone clock detection and handling.
1414
* This abstraction allows for different implementations (e.g., Bukkit, Folia).
15+
*
16+
* @author OneLiteFeather
17+
* @version 1.0.0
18+
* @since 1.0.0
1519
*/
1620
public interface RedstoneClockService {
1721

src/main/java/net/onelitefeather/antiredstoneclockremastered/service/factory/RedstoneClockServiceFactory.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
import net.onelitefeather.antiredstoneclockremastered.service.api.RedstoneClockService;
55
import net.onelitefeather.antiredstoneclockremastered.service.impl.BukkitRedstoneClockService;
66
// import net.onelitefeather.antiredstoneclockremastered.service.impl.FoliaRedstoneClockService;
7+
import io.papermc.paper.ServerBuildInfo;
78
import org.jetbrains.annotations.NotNull;
89

910
/**
1011
* Factory for creating RedstoneClockService implementations.
1112
* This factory determines the appropriate implementation based on the server platform.
13+
*
14+
* @author OneLiteFeather
15+
* @version 1.0.0
16+
* @since 1.0.0
1217
*/
1318
public final class RedstoneClockServiceFactory {
1419

@@ -37,14 +42,22 @@ public static RedstoneClockService createService(@NotNull AntiRedstoneClockRemas
3742

3843
/**
3944
* Detects if the server is running on Folia.
40-
* This method can be extended in the future to detect Folia and return a FoliaRedstoneClockService.
45+
* Folia support is available starting from Paper version 1.20 and above.
4146
*
4247
* @return true if Folia is detected, false otherwise
4348
*/
4449
private static boolean isFolia() {
4550
try {
46-
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
47-
return true;
51+
ServerBuildInfo buildInfo = ServerBuildInfo.buildInfo();
52+
String version = buildInfo.minecraftVersionId();
53+
54+
// Check if running Paper 1.20+ which supports Folia
55+
if (version.startsWith("1.20") || version.startsWith("1.21") || version.startsWith("1.22")) {
56+
// Additional check for Folia-specific classes
57+
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
58+
return true;
59+
}
60+
return false;
4861
} catch (ClassNotFoundException e) {
4962
return false;
5063
}

src/main/java/net/onelitefeather/antiredstoneclockremastered/service/impl/BukkitRedstoneClockService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
/**
2727
* Bukkit/Paper implementation of the RedstoneClockService.
2828
* This implementation uses the standard Bukkit scheduler and APIs.
29+
*
30+
* @author OneLiteFeather
31+
* @version 1.0.0
32+
* @since 1.0.0
2933
*/
3034
public final class BukkitRedstoneClockService implements RedstoneClockService {
3135

0 commit comments

Comments
 (0)