use of com.bencodez.votingplugin.events.PlayerVoteEvent in project VotingPlugin by Ben12345rocks.
the class VotingPluginUser method bungeeVote.
public void bungeeVote(String service, BungeeMessageData text, boolean setTotals) {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
plugin.debug("Bungee vote for " + getPlayerName() + " on " + service);
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service, true), getPlayerName(), service, true);
voteEvent.setBungee(true);
voteEvent.setForceBungee(true);
voteEvent.setAddTotals(setTotals);
voteEvent.setBungeeTextTotals(text);
voteEvent.setVotingPluginUser(this);
plugin.getServer().getPluginManager().callEvent(voteEvent);
}
}
use of com.bencodez.votingplugin.events.PlayerVoteEvent in project VotingPlugin by Ben12345rocks.
the class VotingPluginUser method bungeeVotePluginMessaging.
public void bungeeVotePluginMessaging(String service, long time, BungeeMessageData text, boolean setTotals, boolean wasOnline, boolean broadcast) {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
plugin.debug("Pluginmessaging vote for " + getPlayerName() + " on " + service);
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service, true), getPlayerName(), service, true);
voteEvent.setBungee(true);
voteEvent.setVotingPluginUser(this);
voteEvent.setForceBungee(true);
voteEvent.setTime(time);
voteEvent.setAddTotals(setTotals);
voteEvent.setBungeeTextTotals(text);
voteEvent.setWasOnline(wasOnline);
voteEvent.setBroadcast(broadcast);
plugin.getServer().getPluginManager().callEvent(voteEvent);
}
}
use of com.bencodez.votingplugin.events.PlayerVoteEvent in project VotingPlugin by Ben12345rocks.
the class VotiferEvent method onVotiferEvent.
/**
* On votifer event.
*
* @param event the event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onVotiferEvent(VotifierEvent event) {
Vote vote = event.getVote();
String str = vote.getServiceName();
if (str.isEmpty()) {
str = "Empty";
}
final String voteSite = str;
final String IP = vote.getAddress();
final String voteUsername = vote.getUsername().trim();
if (IP.equals("VotingPlugin")) {
// ignore own plugin calls of event
return;
}
if (voteUsername.length() == 0) {
plugin.getLogger().warning("No name from vote on " + voteSite);
return;
}
plugin.getLogger().info("Received a vote from service site '" + voteSite + "' by player '" + voteUsername + "'!");
plugin.debug("PlayerUsername: " + voteUsername);
plugin.debug("VoteSite: " + voteSite);
plugin.debug("IP: " + IP);
plugin.getVoteTimer().schedule(new TimerTask() {
@Override
public void run() {
plugin.getServerData().addServiceSite(voteSite);
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getBungeeSettings().isVotifierBypass() && (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING) || plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS))) {
plugin.getLogger().severe("Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled, this means you aren't setup correctly for those methods, please check: https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups");
return;
}
String voteSiteNameStr = plugin.getVoteSiteName(false, voteSite);
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames(false);
boolean createSite = false;
if (sites != null) {
if (!ArrayUtils.getInstance().containsIgnoreCase(sites, voteSiteNameStr)) {
createSite = true;
}
} else {
createSite = true;
}
if (plugin.getConfigFile().isAutoCreateVoteSites() && createSite) {
plugin.getLogger().warning("VoteSite with service site '" + voteSiteNameStr + "' does not exist, attempting to generaterate...");
plugin.getConfigVoteSites().generateVoteSite(voteSiteNameStr);
plugin.getLogger().info("Current known service sites: " + ArrayUtils.getInstance().makeStringList(plugin.getServerData().getServiceSites()));
}
String voteSiteName = plugin.getVoteSiteName(true, voteSite);
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName, true), voteUsername, voteSite, true);
plugin.getServer().getPluginManager().callEvent(voteEvent);
if (voteEvent.isCancelled()) {
plugin.debug("Vote cancelled");
return;
}
}
}, 0);
}
use of com.bencodez.votingplugin.events.PlayerVoteEvent in project VotingPlugin by Ben12345rocks.
the class VotingPluginUser method bungeeVoteOnline.
public void bungeeVoteOnline(String service, BungeeMessageData text, boolean setTotals) {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
plugin.debug("Bungee online vote for " + getPlayerName() + " on " + service);
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service, true), getPlayerName(), service, true);
voteEvent.setBungee(true);
voteEvent.setForceBungee(true);
voteEvent.setAddTotals(setTotals);
voteEvent.setBungeeTextTotals(text);
voteEvent.setVotingPluginUser(this);
plugin.getServer().getPluginManager().callEvent(voteEvent);
}
}
Aggregations