Skip to content

Commit

Permalink
Initial PlaceholderAPI support
Browse files Browse the repository at this point in the history
  • Loading branch information
T14D3 committed Jan 6, 2025
1 parent 6cdd408 commit 010040d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ repositories {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
maven {
url = "https://repo.extendedclip.com/releases/"
}
}

dependencies {
//compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT")
compileOnly 'me.clip:placeholderapi:2.11.6'
}

def targetJavaVersion = 21
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/de/t14d3/zones/Zones.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.t14d3.zones;

import de.t14d3.zones.integrations.PlaceholderAPI;
import de.t14d3.zones.listeners.CommandListener;
import de.t14d3.zones.listeners.PlayerInteractListener;
import de.t14d3.zones.listeners.PlayerQuitListener;
Expand Down Expand Up @@ -91,6 +92,11 @@ public void onEnable() {
getLogger().info("Zones have been saved.");
}, 20L, getConfig().getInt("zone-saving.period", 60) * 20L);
}
// PlaceholderAPI integration
if (getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new PlaceholderAPI(this).register();
getLogger().info("PlaceholderAPI hooked!");
}

getLogger().info("Zones plugin has been enabled! Loaded " + regionManager.loadedRegions.size() + " regions.");
}
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/de/t14d3/zones/integrations/PlaceholderAPI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package de.t14d3.zones.integrations;

import de.t14d3.zones.Zones;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class PlaceholderAPI extends PlaceholderExpansion {
private final Zones plugin;

public PlaceholderAPI(Zones plugin) {
this.plugin = plugin;
}

@Override
@NotNull
public String getAuthor() {
return "T14D3";
}

@Override
@NotNull
public String getIdentifier() {
return "zones";
}

@Override
@NotNull
public String getVersion() {
return plugin.getPluginMeta().getVersion();
}

@Override
public boolean persist() {
return true;
}

@Override
public String onPlaceholderRequest(Player player, @NotNull String params) {
if (params.equalsIgnoreCase("get_here")) {
return plugin.getRegionManager().getRegionsAtAsync(player.getLocation()).join().get(0).getName();
}

return null;
}
}
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Zones
version: '${version}'
main: de.t14d3.zones.Zones
api-version: '1.21'
softdepend: [ "PlaceholderAPI" ]
commands:
zone:
description: Main Command
Expand Down

0 comments on commit 010040d

Please sign in to comment.