1
0
Fork 0
mirror of https://github.com/xHyroM/lighteco.git synced 2024-11-10 01:18:07 +01:00

feat: placeholderapi hook [WIP]

This commit is contained in:
Jozef Steinhübl 2023-08-27 23:23:42 +02:00
parent f937943bdd
commit eafed192d3
6 changed files with 50 additions and 2 deletions

View file

@ -4,6 +4,7 @@ plugins {
repositories { repositories {
maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.papermc.io/repository/maven-public/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi")
} }
dependencies { dependencies {
@ -14,6 +15,9 @@ dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
// PlaceholderAPI
compileOnly("me.clip:placeholderapi:2.11.3")
compileOnly("org.projectlombok:lombok:1.18.28") compileOnly("org.projectlombok:lombok:1.18.28")
annotationProcessor("org.projectlombok:lombok:1.18.28") annotationProcessor("org.projectlombok:lombok:1.18.28")

View file

@ -17,6 +17,7 @@ import java.util.UUID;
@Getter @Getter
public class BukkitLightEcoBootstrap implements LightEcoBootstrap, LoaderBootstrap { public class BukkitLightEcoBootstrap implements LightEcoBootstrap, LoaderBootstrap {
private final JavaPlugin loader; private final JavaPlugin loader;
@Getter
private final BukkitLightEcoPlugin plugin = new BukkitLightEcoPlugin(this); private final BukkitLightEcoPlugin plugin = new BukkitLightEcoPlugin(this);
@Getter @Getter

View file

@ -2,11 +2,13 @@ package dev.xhyrom.lighteco.bukkit;
import dev.jorel.commandapi.CommandAPI; import dev.jorel.commandapi.CommandAPI;
import dev.jorel.commandapi.CommandAPIBukkitConfig; import dev.jorel.commandapi.CommandAPIBukkitConfig;
import dev.xhyrom.lighteco.bukkit.hooks.PlaceholderAPIExpansion;
import dev.xhyrom.lighteco.common.plugin.bootstrap.LoaderBootstrap; import dev.xhyrom.lighteco.common.plugin.bootstrap.LoaderBootstrap;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class BukkitLightEcoLoader extends JavaPlugin { public class BukkitLightEcoLoader extends JavaPlugin {
private final LoaderBootstrap bootstrap; private final BukkitLightEcoBootstrap bootstrap;
public BukkitLightEcoLoader() { public BukkitLightEcoLoader() {
this.bootstrap = new BukkitLightEcoBootstrap(this); this.bootstrap = new BukkitLightEcoBootstrap(this);
@ -22,6 +24,9 @@ public class BukkitLightEcoLoader extends JavaPlugin {
public void onEnable() { public void onEnable() {
CommandAPI.onEnable(); CommandAPI.onEnable();
this.bootstrap.onEnable(); this.bootstrap.onEnable();
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null)
new PlaceholderAPIExpansion(this.bootstrap.getPlugin()).register();
} }
@Override @Override

View file

@ -0,0 +1,33 @@
package dev.xhyrom.lighteco.bukkit.hooks;
import dev.xhyrom.lighteco.bukkit.BukkitLightEcoPlugin;
import lombok.RequiredArgsConstructor;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@RequiredArgsConstructor
public class PlaceholderAPIExpansion extends PlaceholderExpansion {
private final BukkitLightEcoPlugin plugin;
@Override
public @NotNull String getIdentifier() {
return "lighteco";
}
@Override
public @NotNull String getAuthor() {
return this.plugin.getBootstrap().getLoader().getDescription().getAuthors().toString();
}
@Override
public @NotNull String getVersion() {
return this.plugin.getBootstrap().getLoader().getDescription().getVersion();
}
@Override
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
return "lighteco";
}
}

View file

@ -4,4 +4,7 @@ version: ${version}
main: dev.xhyrom.lighteco.bukkit.BukkitLightEcoLoader main: dev.xhyrom.lighteco.bukkit.BukkitLightEcoLoader
author: ${author} author: ${author}
api-version: 1.20 api-version: 1.20
load: STARTUP load: STARTUP
softdepend:
- PlaceholderAPI

View file

@ -9,7 +9,9 @@ repositories {
dependencies { dependencies {
compileOnly(project(":lighteco-api")) compileOnly(project(":lighteco-api"))
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("com.github.MilkBowl:VaultAPI:1.7") compileOnly("com.github.MilkBowl:VaultAPI:1.7")
compileOnly("org.projectlombok:lombok:1.18.28") compileOnly("org.projectlombok:lombok:1.18.28")