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>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
<artifactId>bstats-bukkit-lite</artifactId>
|
<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.fcommons.logging.ErrorCollector;
|
||||||
import me.filoghost.holographicdisplays.api.internal.HolographicDisplaysAPIProvider;
|
import me.filoghost.holographicdisplays.api.internal.HolographicDisplaysAPIProvider;
|
||||||
import me.filoghost.holographicdisplays.bridge.bungeecord.BungeeServerTracker;
|
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.bridge.protocollib.ProtocolLibHook;
|
||||||
import me.filoghost.holographicdisplays.commands.HologramCommandManager;
|
import me.filoghost.holographicdisplays.commands.HologramCommandManager;
|
||||||
import me.filoghost.holographicdisplays.core.nms.NMSManager;
|
import me.filoghost.holographicdisplays.core.nms.NMSManager;
|
||||||
@ -112,6 +113,7 @@ public class HolographicDisplays extends FCommonsPlugin implements ProtocolPacke
|
|||||||
load(true, errorCollector);
|
load(true, errorCollector);
|
||||||
|
|
||||||
ProtocolLibHook.setup(this, nmsManager, this, errorCollector);
|
ProtocolLibHook.setup(this, nmsManager, this, errorCollector);
|
||||||
|
PlaceholderAPIHook.setup();
|
||||||
|
|
||||||
placeholderManager.startUpdaterTask(this);
|
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.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
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.AbstractPacket;
|
||||||
import me.filoghost.holographicdisplays.bridge.protocollib.packet.WrapperPlayServerEntityMetadata;
|
import me.filoghost.holographicdisplays.bridge.protocollib.packet.WrapperPlayServerEntityMetadata;
|
||||||
import me.filoghost.holographicdisplays.bridge.protocollib.packet.WrapperPlayServerSpawnEntityLiving;
|
import me.filoghost.holographicdisplays.bridge.protocollib.packet.WrapperPlayServerSpawnEntityLiving;
|
||||||
@ -148,6 +149,10 @@ class PacketListener extends PacketAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PlaceholderAPIHook.isEnabled() && PlaceholderAPIHook.containsPlaceholders(text)) {
|
||||||
|
text = PlaceholderAPIHook.replacePlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ author: filoghost
|
|||||||
version: ${pluginVersion}
|
version: ${pluginVersion}
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
|
||||||
softdepend: [ProtocolLib]
|
softdepend: [ProtocolLib, PlaceholderAPI]
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
holograms:
|
holograms:
|
||||||
|
12
pom.xml
12
pom.xml
@ -56,6 +56,11 @@
|
|||||||
<id>dmulloy2-repo</id>
|
<id>dmulloy2-repo</id>
|
||||||
<url>https://repo.dmulloy2.net/repository/public/</url>
|
<url>https://repo.dmulloy2.net/repository/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>placeholderapi-repo</id>
|
||||||
|
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -199,6 +204,13 @@
|
|||||||
<version>4.5.0</version>
|
<version>4.5.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.8.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bstats</groupId>
|
<groupId>org.bstats</groupId>
|
||||||
|
Loading…
Reference in New Issue
Block a user