mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2025-02-01 12:41:24 +01:00
Initial draft for PlaceholderAPI support (needs performance improvements)
This commit is contained in:
parent
bbb397068b
commit
3f14a67b73
@ -114,6 +114,11 @@
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit-lite</artifactId>
|
||||
|
@ -12,6 +12,7 @@ import me.filoghost.fcommons.config.exception.ConfigException;
|
||||
import me.filoghost.fcommons.logging.ErrorCollector;
|
||||
import me.filoghost.holographicdisplays.api.internal.HolographicDisplaysAPIProvider;
|
||||
import me.filoghost.holographicdisplays.bridge.bungeecord.BungeeServerTracker;
|
||||
import me.filoghost.holographicdisplays.bridge.placeholderapi.PlaceholderAPIHook;
|
||||
import me.filoghost.holographicdisplays.bridge.protocollib.ProtocolLibHook;
|
||||
import me.filoghost.holographicdisplays.commands.HologramCommandManager;
|
||||
import me.filoghost.holographicdisplays.core.nms.NMSManager;
|
||||
@ -112,6 +113,7 @@ public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacke
|
||||
load(true, errorCollector);
|
||||
|
||||
ProtocolLibHook.setup(this, nmsManager, this, errorCollector);
|
||||
PlaceholderAPIHook.setup();
|
||||
|
||||
placeholderManager.startUpdaterTask(this);
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) filoghost and contributors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package me.filoghost.holographicdisplays.bridge.placeholderapi;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlaceholderAPIHook {
|
||||
|
||||
private static boolean enabled;
|
||||
|
||||
public static void setup() {
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
return;
|
||||
}
|
||||
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
public static boolean containsPlaceholders(String text) {
|
||||
return PlaceholderAPI.containsPlaceholders(text);
|
||||
}
|
||||
|
||||
public static String replacePlaceholders(Player player, String text) {
|
||||
return PlaceholderAPI.setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,7 @@ import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
import me.filoghost.holographicdisplays.bridge.placeholderapi.PlaceholderAPIHook;
|
||||
import me.filoghost.holographicdisplays.bridge.protocollib.packet.AbstractPacket;
|
||||
import me.filoghost.holographicdisplays.bridge.protocollib.packet.WrapperPlayServerEntityMetadata;
|
||||
import me.filoghost.holographicdisplays.bridge.protocollib.packet.WrapperPlayServerSpawnEntityLiving;
|
||||
@ -149,6 +150,10 @@ class PacketListener extends PacketAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
if (PlaceholderAPIHook.isEnabled() && PlaceholderAPIHook.containsPlaceholders(text)) {
|
||||
text = PlaceholderAPIHook.replacePlaceholders(player, text);
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ author: filoghost
|
||||
version: ${pluginVersion}
|
||||
api-version: 1.13
|
||||
|
||||
softdepend: [ProtocolLib]
|
||||
softdepend: [ProtocolLib, PlaceholderAPI]
|
||||
|
||||
commands:
|
||||
holograms:
|
||||
|
12
pom.xml
12
pom.xml
@ -56,6 +56,11 @@
|
||||
<id>dmulloy2-repo</id>
|
||||
<url>https://repo.dmulloy2.net/repository/public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>placeholderapi-repo</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencyManagement>
|
||||
@ -200,6 +205,13 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.8.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit-lite</artifactId>
|
||||
|
Loading…
Reference in New Issue
Block a user