diff --git a/guilds.iml b/guilds.iml
index 2582de4..2577c74 100644
--- a/guilds.iml
+++ b/guilds.iml
@@ -14,6 +14,7 @@
+
diff --git a/pom.xml b/pom.xml
index b89e823..076072e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,6 +19,11 @@
MVdW Public Repositories
http://repo.mvdw-software.be/content/groups/public/
+
+
+ placeholderapi
+ http://repo.extendedclip.com/content/repositories/placeholderapi/
+
@@ -36,6 +41,13 @@
provided
+
+ me.clip
+ placeholderapi
+ 2.0.8
+ provided
+
+
com.google.code.gson
gson
diff --git a/src/main/java/me/bramhaag/guilds/Main.java b/src/main/java/me/bramhaag/guilds/Main.java
index 9d8ad21..909cf17 100644
--- a/src/main/java/me/bramhaag/guilds/Main.java
+++ b/src/main/java/me/bramhaag/guilds/Main.java
@@ -6,14 +6,20 @@
import co.aikar.taskchain.TaskChainFactory;
import me.bramhaag.guilds.commands.*;
import me.bramhaag.guilds.commands.base.CommandHandler;
-import me.bramhaag.guilds.database.Callback;
import me.bramhaag.guilds.database.DatabaseProvider;
import me.bramhaag.guilds.database.databases.json.Json;
import me.bramhaag.guilds.database.databases.mysql.MySql;
-import me.bramhaag.guilds.guild.Guild;
import me.bramhaag.guilds.guild.GuildHandler;
import me.bramhaag.guilds.listeners.ChatListener;
import me.bramhaag.guilds.listeners.JoinListener;
+import me.bramhaag.guilds.placeholders.mvdwplaceholderapi.MVdWGuild;
+import me.bramhaag.guilds.placeholders.mvdwplaceholderapi.MVdWGuildMaster;
+import me.bramhaag.guilds.placeholders.mvdwplaceholderapi.MVdWGuildMemberCount;
+import me.bramhaag.guilds.placeholders.mvdwplaceholderapi.MVdWGuildPrefix;
+import me.bramhaag.guilds.placeholders.placeholderapi.ClipGuild;
+import me.bramhaag.guilds.placeholders.placeholderapi.ClipGuildMaster;
+import me.bramhaag.guilds.placeholders.placeholderapi.ClipGuildMemberCount;
+import me.bramhaag.guilds.placeholders.placeholderapi.ClipGuildPrefix;
import me.bramhaag.guilds.scoreboard.GuildScoreboardHandler;
import me.bramhaag.guilds.updater.Updater;
import org.bukkit.Bukkit;
@@ -61,43 +67,7 @@ public void onEnable() {
//scoreboardHandler is enabled after the guilds are loaded
scoreboardHandler = new GuildScoreboardHandler();
- if (Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceholderAPI")) {
- PlaceholderAPI.registerPlaceholder(this, "guild", event -> {
- Guild guild = Guild.getGuild(event.getPlayer().getUniqueId());
- if (guild == null) {
- return "N/A";
- }
-
- return guild.getName();
- });
-
- PlaceholderAPI.registerPlaceholder(this, "guild-prefix", event -> {
- Guild guild = Guild.getGuild(event.getPlayer().getUniqueId());
- if (guild == null) {
- return "N/A";
- }
-
- return guild.getPrefix();
- });
-
- PlaceholderAPI.registerPlaceholder(this, "guild-master", event -> {
- Guild guild = Guild.getGuild(event.getPlayer().getUniqueId());
- if (guild == null) {
- return "N/A";
- }
-
- return Bukkit.getPlayer(guild.getGuildMaster().getUniqueId()).getName();
- });
-
- PlaceholderAPI.registerPlaceholder(this, "member-count", event -> {
- Guild guild = Guild.getGuild(event.getPlayer().getUniqueId());
- if (guild == null) {
- return "N/A";
- }
-
- return String.valueOf(guild.getMembers().size());
- });
- }
+ initializePlaceholder();
getCommand("guild").setExecutor(commandHandler);
@@ -209,4 +179,20 @@ public static long getCreationTime() {
public static Main getInstance() {
return instance;
}
+
+ private void initializePlaceholder() {
+ if (Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceholderAPI")) {
+ PlaceholderAPI.registerPlaceholder(this, "guild", new MVdWGuild());
+ PlaceholderAPI.registerPlaceholder(this, "guild-master", new MVdWGuildMaster());
+ PlaceholderAPI.registerPlaceholder(this, "guild-member-count", new MVdWGuildMemberCount());
+ PlaceholderAPI.registerPlaceholder(this, "guild-prefix", new MVdWGuildPrefix());
+ }
+
+ if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
+ new ClipGuild(this).hook();
+ new ClipGuildMaster(this).hook();
+ new ClipGuildMemberCount(this).hook();
+ new ClipGuildPrefix(this).hook();
+ }
+ }
}
diff --git a/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuild.java b/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuild.java
new file mode 100644
index 0000000..a33ff79
--- /dev/null
+++ b/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuild.java
@@ -0,0 +1,18 @@
+package me.bramhaag.guilds.placeholders.mvdwplaceholderapi;
+
+import be.maximvdw.placeholderapi.PlaceholderReplaceEvent;
+import be.maximvdw.placeholderapi.PlaceholderReplacer;
+import me.bramhaag.guilds.guild.Guild;
+
+public class MVdWGuild implements PlaceholderReplacer {
+
+ @Override
+ public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
+ Guild guild = Guild.getGuild(event.getPlayer().getUniqueId());
+ if (guild == null) {
+ return "N/A";
+ }
+
+ return guild.getPrefix();
+ }
+}
diff --git a/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuildMaster.java b/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuildMaster.java
new file mode 100644
index 0000000..dd941d3
--- /dev/null
+++ b/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuildMaster.java
@@ -0,0 +1,18 @@
+package me.bramhaag.guilds.placeholders.mvdwplaceholderapi;
+
+import be.maximvdw.placeholderapi.PlaceholderReplaceEvent;
+import be.maximvdw.placeholderapi.PlaceholderReplacer;
+import me.bramhaag.guilds.guild.Guild;
+import org.bukkit.Bukkit;
+
+public class MVdWGuildMaster implements PlaceholderReplacer {
+ @Override
+ public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
+ Guild guild = Guild.getGuild(event.getPlayer().getUniqueId());
+ if (guild == null) {
+ return "N/A";
+ }
+
+ return Bukkit.getPlayer(guild.getGuildMaster().getUniqueId()).getName();
+ }
+}
diff --git a/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuildMemberCount.java b/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuildMemberCount.java
new file mode 100644
index 0000000..3ef7a72
--- /dev/null
+++ b/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuildMemberCount.java
@@ -0,0 +1,18 @@
+package me.bramhaag.guilds.placeholders.mvdwplaceholderapi;
+
+import be.maximvdw.placeholderapi.PlaceholderReplaceEvent;
+import be.maximvdw.placeholderapi.PlaceholderReplacer;
+import me.bramhaag.guilds.guild.Guild;
+
+public class MVdWGuildMemberCount implements PlaceholderReplacer {
+
+ @Override
+ public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
+ Guild guild = Guild.getGuild(event.getPlayer().getUniqueId());
+ if (guild == null) {
+ return "N/A";
+ }
+
+ return String.valueOf(guild.getMembers().size());
+ }
+}
diff --git a/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuildPrefix.java b/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuildPrefix.java
new file mode 100644
index 0000000..09385f2
--- /dev/null
+++ b/src/main/java/me/bramhaag/guilds/placeholders/mvdwplaceholderapi/MVdWGuildPrefix.java
@@ -0,0 +1,18 @@
+package me.bramhaag.guilds.placeholders.mvdwplaceholderapi;
+
+import be.maximvdw.placeholderapi.PlaceholderReplaceEvent;
+import be.maximvdw.placeholderapi.PlaceholderReplacer;
+import me.bramhaag.guilds.guild.Guild;
+
+public class MVdWGuildPrefix implements PlaceholderReplacer {
+
+ @Override
+ public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
+ Guild guild = Guild.getGuild(event.getPlayer().getUniqueId());
+ if (guild == null) {
+ return "N/A";
+ }
+
+ return guild.getPrefix();
+ }
+}
diff --git a/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuild.java b/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuild.java
new file mode 100644
index 0000000..25d3473
--- /dev/null
+++ b/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuild.java
@@ -0,0 +1,23 @@
+package me.bramhaag.guilds.placeholders.placeholderapi;
+
+import me.bramhaag.guilds.guild.Guild;
+import me.clip.placeholderapi.external.EZPlaceholderHook;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+public class ClipGuild extends EZPlaceholderHook {
+
+ public ClipGuild(Plugin plugin) {
+ super(plugin, "guild");
+ }
+
+ @Override
+ public String onPlaceholderRequest(Player player, String s) {
+ Guild guild = Guild.getGuild(player.getUniqueId());
+ if (guild == null) {
+ return "N/A";
+ }
+
+ return guild.getName();
+ }
+}
diff --git a/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuildMaster.java b/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuildMaster.java
new file mode 100644
index 0000000..91090e4
--- /dev/null
+++ b/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuildMaster.java
@@ -0,0 +1,24 @@
+package me.bramhaag.guilds.placeholders.placeholderapi;
+
+import me.bramhaag.guilds.guild.Guild;
+import me.clip.placeholderapi.external.EZPlaceholderHook;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+public class ClipGuildMaster extends EZPlaceholderHook {
+
+ public ClipGuildMaster(Plugin plugin) {
+ super(plugin, "guild-master");
+ }
+
+ @Override
+ public String onPlaceholderRequest(Player player, String s) {
+ Guild guild = Guild.getGuild(player.getUniqueId());
+ if (guild == null) {
+ return "N/A";
+ }
+
+ return Bukkit.getPlayer(guild.getGuildMaster().getUniqueId()).getName();
+ }
+}
diff --git a/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuildMemberCount.java b/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuildMemberCount.java
new file mode 100644
index 0000000..a0a3fa6
--- /dev/null
+++ b/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuildMemberCount.java
@@ -0,0 +1,23 @@
+package me.bramhaag.guilds.placeholders.placeholderapi;
+
+import me.bramhaag.guilds.guild.Guild;
+import me.clip.placeholderapi.external.EZPlaceholderHook;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+public class ClipGuildMemberCount extends EZPlaceholderHook {
+
+ public ClipGuildMemberCount(Plugin plugin) {
+ super(plugin, "guild-member-count");
+ }
+
+ @Override
+ public String onPlaceholderRequest(Player player, String s) {
+ Guild guild = Guild.getGuild(player.getUniqueId());
+ if (guild == null) {
+ return "N/A";
+ }
+
+ return String.valueOf(guild.getMembers().size());
+ }
+}
diff --git a/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuildPrefix.java b/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuildPrefix.java
new file mode 100644
index 0000000..1a1b2a9
--- /dev/null
+++ b/src/main/java/me/bramhaag/guilds/placeholders/placeholderapi/ClipGuildPrefix.java
@@ -0,0 +1,22 @@
+package me.bramhaag.guilds.placeholders.placeholderapi;
+
+import me.bramhaag.guilds.guild.Guild;
+import me.clip.placeholderapi.external.EZPlaceholderHook;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+public class ClipGuildPrefix extends EZPlaceholderHook {
+
+ public ClipGuildPrefix(Plugin plugin) {
+ super(plugin, "guild-prefix");
+ }
+
+ @Override
+ public String onPlaceholderRequest(Player player, String s) {
+ Guild guild = Guild.getGuild(player.getUniqueId());
+ if (guild == null) {
+ return "N/A";
+ }
+
+ return guild.getPrefix(); }
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 4030e31..a21e2fe 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,7 +1,7 @@
name: ${project.name}
version: ${project.version}
main: me.bramhaag.guilds.Main
-softdepends: [MVdWPlaceholderAPI]
+softdepends: [MVdWPlaceholderAPI, PlaceholderAPI]
author: bramhaag
commands: