Implement basic PlaceholderAPI support
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bea 2022-10-21 23:58:52 +02:00
parent f2d9594a77
commit a45b487868
4 changed files with 94 additions and 1 deletions

13
pom.xml
View File

@ -19,8 +19,12 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
@ -30,6 +34,13 @@
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.9</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -1,18 +1,36 @@
package wtf.beatrice.nounspicker;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import wtf.beatrice.nounspicker.objects.PAPIManager;
import java.util.logging.Level;
public class NounsPicker extends JavaPlugin
{
private static NounsPicker instance;
private PluginManager pluginManager;
@Override
public void onEnable()
{
pluginManager = getServer().getPluginManager();
instance = this;
// register PlaceholderAPI
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PAPIManager(this).register();
} else {
}
}
public static NounsPicker getInstance()
{
return instance;
}
}

View File

@ -0,0 +1,62 @@
package wtf.beatrice.nounspicker.objects;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import wtf.beatrice.nounspicker.NounsPicker;
public class PAPIManager extends PlaceholderExpansion
{
private final NounsPicker plugin;
public PAPIManager(NounsPicker plugin)
{
this.plugin = plugin;
}
@Override
public boolean persist(){
return true;
}
@Override
public boolean canRegister(){
return true;
}
@Override
public @NotNull String getIdentifier() {
return "nouns";
}
@Override
public @NotNull String getAuthor() {
return plugin.getDescription().getAuthors().toString();
}
@Override
public @NotNull String getVersion() {
return plugin.getDescription().getVersion();
}
@Override
public String onPlaceholderRequest(Player player, @NotNull String identifier) {
if (player == null) {
return "";
}
switch (identifier.toLowerCase()) {
case "main_pronoun":
break;
case "secondary_pronoun":
break;
}
return null;
}
}

View File

@ -3,6 +3,8 @@ version: 1.0
author: astro_bea
main: wtf.beatrice.nounspicker.NounsPicker
api-version: 1.19
depend:
- PlaceholderAPI
commands:
nouns: