Skip to content

Commit

Permalink
V1.0!
Browse files Browse the repository at this point in the history
  • Loading branch information
zax71 authored Nov 19, 2021
1 parent fc9b1b6 commit 69867a4
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 12 deletions.
10 changes: 9 additions & 1 deletion src/main/java/me/zax71/svl/SVL.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 15 additions & 6 deletions src/main/java/me/zax71/svl/events/vote.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -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"
command: 'msg %player_name% This is the default command from SVL, edit it in config.yml'
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion target/classes/config.yml
Original file line number Diff line number Diff line change
@@ -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"
command: 'msg %player_name% This is the default command from SVL, edit it in config.yml'
Binary file modified target/classes/me/zax71/svl/SVL.class
Binary file not shown.
Binary file modified target/classes/me/zax71/svl/events/vote.class
Binary file not shown.
3 changes: 2 additions & 1 deletion target/classes/plugin.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 69867a4

Please sign in to comment.