Skip to content

Commit 851eb01

Browse files
wjddusrb03claude
andcommitted
Initial release: DisplayAPI v1.0.0 - Lightweight Display Entity API for Paper 1.21.4
Full-featured Display Entity framework with fluent builder API, keyframe animations, click detection, entity following, leaderboards, and YAML persistence. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0 parents  commit 851eb01

26 files changed

Lines changed: 2967 additions & 0 deletions

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
target/
2+
*.class
3+
*.jar
4+
*.log
5+
.idea/
6+
*.iml
7+
.settings/
8+
.classpath
9+
.project
10+
.env
11+
.env.*
12+
*.pem
13+
*.key
14+
*.p12
15+
credentials.json
16+
secrets.yaml
17+
secrets.json
18+
*.sqlite
19+
*.db

pom.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.wjddusrb03</groupId>
8+
<artifactId>DisplayAPI</artifactId>
9+
<version>1.0.0</version>
10+
<packaging>jar</packaging>
11+
12+
<name>DisplayAPI</name>
13+
<description>Lightweight Display Entity API for Paper plugins</description>
14+
15+
<properties>
16+
<maven.compiler.source>21</maven.compiler.source>
17+
<maven.compiler.target>21</maven.compiler.target>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
</properties>
20+
21+
<repositories>
22+
<repository>
23+
<id>papermc</id>
24+
<url>https://repo.papermc.io/repository/maven-public/</url>
25+
</repository>
26+
<repository>
27+
<id>placeholderapi</id>
28+
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
29+
</repository>
30+
</repositories>
31+
32+
<dependencies>
33+
<dependency>
34+
<groupId>io.papermc.paper</groupId>
35+
<artifactId>paper-api</artifactId>
36+
<version>1.21.4-R0.1-SNAPSHOT</version>
37+
<scope>provided</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>me.clip</groupId>
41+
<artifactId>placeholderapi</artifactId>
42+
<version>2.11.6</version>
43+
<scope>provided</scope>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<resources>
49+
<resource>
50+
<directory>src/main/resources</directory>
51+
<filtering>true</filtering>
52+
</resource>
53+
</resources>
54+
<plugins>
55+
<plugin>
56+
<groupId>org.apache.maven.plugins</groupId>
57+
<artifactId>maven-compiler-plugin</artifactId>
58+
<version>3.13.0</version>
59+
<configuration>
60+
<source>21</source>
61+
<target>21</target>
62+
</configuration>
63+
</plugin>
64+
</plugins>
65+
</build>
66+
</project>
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
package com.wjddusrb03.displayapi;
2+
3+
import com.wjddusrb03.displayapi.animation.AnimationBuilder;
4+
import com.wjddusrb03.displayapi.builder.*;
5+
import com.wjddusrb03.displayapi.display.*;
6+
import com.wjddusrb03.displayapi.manager.DisplayManager;
7+
import com.wjddusrb03.displayapi.manager.PersistenceManager;
8+
import org.bukkit.Location;
9+
import org.bukkit.entity.Entity;
10+
import org.bukkit.plugin.Plugin;
11+
12+
/**
13+
* Main entry point for the DisplayAPI.
14+
*
15+
* <p>Usage examples:
16+
* <pre>
17+
* // Text hologram
18+
* DisplayAPI.text(location)
19+
* .text(Component.text("Hello!").color(NamedTextColor.GOLD))
20+
* .billboard(Billboard.CENTER)
21+
* .spawn();
22+
*
23+
* // Block display
24+
* DisplayAPI.block(location)
25+
* .block(Material.DIAMOND_BLOCK)
26+
* .scale(0.5f)
27+
* .spawn();
28+
*
29+
* // Damage popup
30+
* DisplayAPI.popup(location)
31+
* .text(Component.text("-25").color(NamedTextColor.RED))
32+
* .duration(30)
33+
* .visibleTo(player)
34+
* .spawn();
35+
* </pre>
36+
*/
37+
public final class DisplayAPI {
38+
39+
private static DisplayAPIPlugin plugin;
40+
private static DisplayManager manager;
41+
private static PersistenceManager persistenceManager;
42+
43+
private DisplayAPI() {}
44+
45+
static void init(DisplayAPIPlugin pluginInstance, DisplayManager mgr, PersistenceManager persistence) {
46+
plugin = pluginInstance;
47+
manager = mgr;
48+
persistenceManager = persistence;
49+
}
50+
51+
// ========================
52+
// Builder factory methods
53+
// ========================
54+
55+
public static TextDisplayBuilder text(Location location) {
56+
checkInit();
57+
return new TextDisplayBuilder(location);
58+
}
59+
60+
public static BlockDisplayBuilder block(Location location) {
61+
checkInit();
62+
return new BlockDisplayBuilder(location);
63+
}
64+
65+
public static ItemDisplayBuilder item(Location location) {
66+
checkInit();
67+
return new ItemDisplayBuilder(location);
68+
}
69+
70+
public static PopupBuilder popup(Location location) {
71+
checkInit();
72+
return new PopupBuilder(location);
73+
}
74+
75+
// ========================
76+
// Animation factory
77+
// ========================
78+
79+
public static AnimationBuilder animate(SpawnedDisplay display) {
80+
checkInit();
81+
return new AnimationBuilder(display);
82+
}
83+
84+
public static Leaderboard leaderboard(Location location) {
85+
checkInit();
86+
return new Leaderboard(location);
87+
}
88+
89+
public static InteractiveBuilder interactive(Location location) {
90+
checkInit();
91+
return new InteractiveBuilder(location);
92+
}
93+
94+
public static FollowDisplay follow(SpawnedDisplay display, Entity target) {
95+
checkInit();
96+
return new FollowDisplay(display, target);
97+
}
98+
99+
// ========================
100+
// Group factory
101+
// ========================
102+
103+
public static DisplayGroup group(String id, Location anchor) {
104+
checkInit();
105+
return new DisplayGroup(id, anchor);
106+
}
107+
108+
// ========================
109+
// Management methods
110+
// ========================
111+
112+
public static SpawnedDisplay getById(String id) {
113+
checkInit();
114+
return manager.getById(id);
115+
}
116+
117+
public static void remove(String id) {
118+
checkInit();
119+
manager.remove(id);
120+
}
121+
122+
public static void removeAll() {
123+
checkInit();
124+
manager.removeAll();
125+
}
126+
127+
// ========================
128+
// Internal accessors
129+
// ========================
130+
131+
public static Plugin getPlugin() {
132+
checkInit();
133+
return plugin;
134+
}
135+
136+
public static DisplayManager getManager() {
137+
checkInit();
138+
return manager;
139+
}
140+
141+
public static PersistenceManager getPersistenceManager() {
142+
checkInit();
143+
return persistenceManager;
144+
}
145+
146+
public static float getDefaultViewRange() {
147+
if (plugin != null) {
148+
return (float) plugin.getConfig().getDouble("default-view-range", 1.0);
149+
}
150+
return 1.0f;
151+
}
152+
153+
private static void checkInit() {
154+
if (plugin == null) {
155+
throw new IllegalStateException("DisplayAPI is not initialized. Is the DisplayAPI plugin enabled?");
156+
}
157+
}
158+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.wjddusrb03.displayapi;
2+
3+
import com.wjddusrb03.displayapi.command.DisplayAPICommand;
4+
import com.wjddusrb03.displayapi.listener.DisplayListener;
5+
import com.wjddusrb03.displayapi.listener.InteractionListener;
6+
import com.wjddusrb03.displayapi.manager.DisplayManager;
7+
import com.wjddusrb03.displayapi.manager.PersistenceManager;
8+
import org.bukkit.plugin.java.JavaPlugin;
9+
import org.bukkit.scheduler.BukkitRunnable;
10+
11+
public class DisplayAPIPlugin extends JavaPlugin {
12+
13+
private DisplayManager displayManager;
14+
private PersistenceManager persistenceManager;
15+
16+
@Override
17+
public void onEnable() {
18+
saveDefaultConfig();
19+
20+
displayManager = new DisplayManager();
21+
persistenceManager = new PersistenceManager(this);
22+
23+
// Initialize static API
24+
DisplayAPI.init(this, displayManager, persistenceManager);
25+
26+
// Register commands
27+
var cmd = new DisplayAPICommand();
28+
getCommand("displayapi").setExecutor(cmd);
29+
getCommand("displayapi").setTabCompleter(cmd);
30+
31+
// Register listeners
32+
getServer().getPluginManager().registerEvents(new DisplayListener(), this);
33+
getServer().getPluginManager().registerEvents(new InteractionListener(), this);
34+
35+
// Load persistent displays after all worlds are loaded
36+
new BukkitRunnable() {
37+
@Override
38+
public void run() {
39+
persistenceManager.load();
40+
int count = displayManager.getPersistentDisplays().size();
41+
if (count > 0) {
42+
getLogger().info("Loaded " + count + " persistent displays.");
43+
}
44+
}
45+
}.runTaskLater(this, 1L);
46+
47+
// Auto-save and cleanup task
48+
long saveInterval = getConfig().getLong("auto-save-interval", 6000L);
49+
new BukkitRunnable() {
50+
@Override
51+
public void run() {
52+
displayManager.cleanup();
53+
persistenceManager.save();
54+
}
55+
}.runTaskTimer(this, saveInterval, saveInterval);
56+
57+
getLogger().info("DisplayAPI v" + getDescription().getVersion() + " enabled.");
58+
}
59+
60+
@Override
61+
public void onDisable() {
62+
if (persistenceManager != null) {
63+
persistenceManager.save();
64+
}
65+
if (displayManager != null) {
66+
displayManager.removeAll();
67+
}
68+
getLogger().info("DisplayAPI disabled.");
69+
}
70+
71+
public DisplayManager getDisplayManager() {
72+
return displayManager;
73+
}
74+
75+
public PersistenceManager getPersistenceManager() {
76+
return persistenceManager;
77+
}
78+
}

0 commit comments

Comments
 (0)