Search in sources :

Example 6 with PlayerVoteEvent

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);
    }
}
Also used : PlayerVoteEvent(com.bencodez.votingplugin.events.PlayerVoteEvent)

Example 7 with PlayerVoteEvent

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);
    }
}
Also used : PlayerVoteEvent(com.bencodez.votingplugin.events.PlayerVoteEvent)

Example 8 with PlayerVoteEvent

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);
}
Also used : Vote(com.vexsoftware.votifier.model.Vote) PlayerVoteEvent(com.bencodez.votingplugin.events.PlayerVoteEvent) TimerTask(java.util.TimerTask) ArrayList(java.util.ArrayList) EventHandler(org.bukkit.event.EventHandler)

Example 9 with PlayerVoteEvent

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);
    }
}
Also used : PlayerVoteEvent(com.bencodez.votingplugin.events.PlayerVoteEvent)

Aggregations

PlayerVoteEvent (com.bencodez.votingplugin.events.PlayerVoteEvent)9 ArrayList (java.util.ArrayList)5 VoteSite (com.bencodez.votingplugin.objects.VoteSite)4 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)3 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)3 Player (org.bukkit.entity.Player)3 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)2 StringListener (com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)2 AdminVotePlaceholdersPlayer (com.bencodez.votingplugin.commands.gui.admin.AdminVotePlaceholdersPlayer)2 AdminVoteVotePlayer (com.bencodez.votingplugin.commands.gui.admin.AdminVoteVotePlayer)2 VoteURLVoteSite (com.bencodez.votingplugin.commands.gui.player.VoteURLVoteSite)2 VotingPluginUser (com.bencodez.votingplugin.user.VotingPluginUser)2 CommandHandler (com.bencodez.advancedcore.api.command.CommandHandler)1 BInventory (com.bencodez.advancedcore.api.inventory.BInventory)1 EditGUIButton (com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton)1 EditGUIValueBoolean (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean)1 EditGUIValueList (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList)1 EditGUIValueNumber (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber)1 EditGUIValueString (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)1 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)1