diff --git a/src/main/java/me/zax71/svl/SVL.java b/src/main/java/me/zax71/svl/SVL.java index 41fa8dd..d80de70 100644 --- a/src/main/java/me/zax71/svl/SVL.java +++ b/src/main/java/me/zax71/svl/SVL.java @@ -1,19 +1,27 @@ package me.zax71.svl; import me.zax71.svl.events.vote; +import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.java.JavaPlugin; public final class SVL extends JavaPlugin { - FileConfiguration config = this.getConfig(); + public static SVL plugin; + @Override public void onEnable() { // Config + plugin = this; saveDefaultConfig(); + FileConfiguration config = getConfig(); // Register vote class this.getServer().getPluginManager().registerEvents(new vote(), this); + + if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") == null) { + getLogger().warning("PlaceholderAPI not found. This is recommended for the use of this plugin, download it at: https://www.spigotmc.org/resources/placeholderapi.6245"); + } } @Override diff --git a/src/main/java/me/zax71/svl/events/vote.java b/src/main/java/me/zax71/svl/events/vote.java index be8fcb9..2b7a242 100644 --- a/src/main/java/me/zax71/svl/events/vote.java +++ b/src/main/java/me/zax71/svl/events/vote.java @@ -2,10 +2,11 @@ import com.vexsoftware.votifier.model.Vote; import com.vexsoftware.votifier.model.VotifierEvent; +import me.clip.placeholderapi.PlaceholderAPI; import me.zax71.svl.SVL; -import me.zax71.svl.config.config; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -17,14 +18,22 @@ public void onVotifierEvent(VotifierEvent event) { // Getting variables Vote vote = event.getVote(); - String player = vote.getUsername(); + String playerName = vote.getUsername(); String voteSite = vote.getServiceName(); - String command = SVL.getConfig("command"); + // Turn the player name in to a Player type + Player player = Bukkit.getServer().getPlayer(playerName); + + // Get the command from config + String command = SVL.plugin.getConfig().getString("command"); + // Phrase it with PAPI + String papiCommand = PlaceholderAPI.setPlaceholders(player, command); + + // Check if player that voted is online - if(Bukkit.getPlayer(player) != null) { - Bukkit.getServer().broadcastMessage(ChatColor.GOLD + player + " voted on " + voteSite + "!"); - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); + if(Bukkit.getPlayer(playerName) != null) { + Bukkit.getServer().broadcastMessage(ChatColor.GOLD + playerName + " voted on " + voteSite + "!"); + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), papiCommand); } } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 49ce2e9..b256473 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,4 +1,4 @@ # SVL - Simple Votifier Listener # Command to run when you receive a vote -command: "msg %player_name% This is the default command from SVL, edit it in config.yml" \ No newline at end of file +command: 'msg %player_name% This is the default command from SVL, edit it in config.yml' \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 96a7c89..d8734b6 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,5 +4,6 @@ main: me.zax71.svl.SVL api-version: 1.17 prefix: SVL depend: [ Votifier ] +softdepend: [PlaceholderAPI] authors: [ Zax71 ] description: SVL - A simple vote listner diff --git a/target/classes/config.yml b/target/classes/config.yml index 49ce2e9..b256473 100644 --- a/target/classes/config.yml +++ b/target/classes/config.yml @@ -1,4 +1,4 @@ # SVL - Simple Votifier Listener # Command to run when you receive a vote -command: "msg %player_name% This is the default command from SVL, edit it in config.yml" \ No newline at end of file +command: 'msg %player_name% This is the default command from SVL, edit it in config.yml' \ No newline at end of file diff --git a/target/classes/me/zax71/svl/SVL.class b/target/classes/me/zax71/svl/SVL.class index f69ac30..30efb71 100644 Binary files a/target/classes/me/zax71/svl/SVL.class and b/target/classes/me/zax71/svl/SVL.class differ diff --git a/target/classes/me/zax71/svl/events/vote.class b/target/classes/me/zax71/svl/events/vote.class index 31b8cf8..18cac2e 100644 Binary files a/target/classes/me/zax71/svl/events/vote.class and b/target/classes/me/zax71/svl/events/vote.class differ diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml index c0bc2f2..a897a55 100644 --- a/target/classes/plugin.yml +++ b/target/classes/plugin.yml @@ -1,8 +1,9 @@ name: SVL -version: '0.3' +version: '1.0' main: me.zax71.svl.SVL api-version: 1.17 prefix: SVL depend: [ Votifier ] +softdepend: [PlaceholderAPI] authors: [ Zax71 ] description: SVL - A simple vote listner diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties index 7a553e1..4120fd6 100644 --- a/target/maven-archiver/pom.properties +++ b/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Thu Nov 18 18:07:46 GMT 2021 +#Fri Nov 19 17:24:26 GMT 2021 groupId=me.zax71 artifactId=SVL -version=0.3 +version=1.0