File tree Expand file tree Collapse file tree 4 files changed +66
-0
lines changed
src/main/java/com/github/elic0de/thejpspit Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 7474 <id >jitpack.io</id >
7575 <url >https://jitpack.io</url >
7676 </repository >
77+ <repository >
78+ <id >placeholderapi</id >
79+ <url >https://repo.extendedclip.com/content/repositories/placeholderapi/</url >
80+ </repository >
7781 </repositories >
7882
7983 <dependencies >
138142 <version >2.0.1</version >
139143 <scope >compile</scope >
140144 </dependency >
145+ <dependency >
146+ <groupId >me.clip</groupId >
147+ <artifactId >placeholderapi</artifactId >
148+ <version >2.11.2</version >
149+ <scope >provided</scope >
150+ </dependency >
141151 </dependencies >
142152</project >
Original file line number Diff line number Diff line change 88import com .github .elic0de .thejpspit .config .Settings ;
99import com .github .elic0de .thejpspit .database .Database ;
1010import com .github .elic0de .thejpspit .database .SqLiteDatabase ;
11+ import com .github .elic0de .thejpspit .hook .PlaceholderHook ;
1112import com .github .elic0de .thejpspit .leveler .Levels ;
1213import com .github .elic0de .thejpspit .listener .CombatTagger ;
1314import com .github .elic0de .thejpspit .player .PitPlayer ;
2526import com .github .elic0de .thejpspit .villager .villagers .ShopVillager ;
2627import com .google .gson .Gson ;
2728import com .google .gson .GsonBuilder ;
29+ import me .clip .placeholderapi .configuration .PlaceholderAPIConfig ;
2830import net .william278 .annotaml .Annotaml ;
2931import org .bukkit .Bukkit ;
3032import org .bukkit .GameRule ;
@@ -180,6 +182,9 @@ private void registerHooks() {
180182 if (plugins .getPlugin ("Vault" ) != null ) {
181183 this .registerHook (new VaultEconomyHook (this ));
182184 }
185+ if (plugins .getPlugin ("PlaceholderAPI" ) != null ) {
186+ new PlaceholderHook ().register ();
187+ }
183188 }
184189
185190 private void createNPCs () {
Original file line number Diff line number Diff line change 1+ package com .github .elic0de .thejpspit .hook ;
2+
3+ import com .github .elic0de .thejpspit .TheJpsPit ;
4+ import com .github .elic0de .thejpspit .database .Database .RankType ;
5+ import com .github .elic0de .thejpspit .player .PitPlayer ;
6+ import com .github .elic0de .thejpspit .player .PitPlayerManager ;
7+ import me .clip .placeholderapi .expansion .PlaceholderExpansion ;
8+ import org .bukkit .OfflinePlayer ;
9+ import org .jetbrains .annotations .NotNull ;
10+ import org .jetbrains .annotations .Nullable ;
11+
12+ public class PlaceholderHook extends PlaceholderExpansion {
13+
14+ @ Override
15+ public @ NotNull String getIdentifier () {
16+ return "thejpspit" ;
17+ }
18+
19+ @ Override
20+ public @ NotNull String getAuthor () {
21+ return "Elic0de" ;
22+ }
23+
24+ @ Override
25+ public @ NotNull String getVersion () {
26+ return "2.0" ;
27+ }
28+
29+ @ Override
30+ public String onRequest (@ Nullable OfflinePlayer offlinePlayer , @ NotNull String params ) {
31+ // Ensure the player is online
32+ if (offlinePlayer == null || !offlinePlayer .isOnline ()) {
33+ return "Player offline" ;
34+ }
35+
36+ // Return the requested placeholder
37+ final PitPlayer player = PitPlayerManager .getPitPlayer (offlinePlayer .getPlayer ());
38+ return switch (params ) {
39+ case "kill_ranking" -> String .valueOf (TheJpsPit .getInstance ().getDatabase ().getPlayerRanking (player , RankType .KILLS ).join ()
40+ .orElse (0 ));
41+ case "kill" -> String .valueOf (player .getKills ());
42+ case "level" -> String .valueOf (player .getLevel ());
43+ default -> null ;
44+ };
45+ }
46+ }
Original file line number Diff line number Diff line change 1+ package com .github .elic0de .thejpspit .spigot .hook ;
2+
3+ public class PlacholderHook {
4+
5+ }
You can’t perform that action at this time.
0 commit comments