Search in sources :

Example 1 with SignHandler

use of com.Ben12345rocks.VotingPlugin.Objects.SignHandler in project VotingPlugin by Ben12345rocks.

the class Main method onEnable.

/*
	 * (non-Javadoc)
	 *
	 * @see org.bukkit.plugin.java.JavaPlugin#onEnable()
	 */
@Override
public void onEnable() {
    plugin = this;
    setupFiles();
    loadVoteSites();
    updateAdvancedCoreHook();
    AdvancedCoreHook.getInstance().loadHook(this);
    if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
        debug("UseBatchUpdates: " + AdvancedCoreHook.getInstance().getMysql().isUseBatchUpdates());
    }
    registerCommands();
    registerEvents();
    checkVotifier();
    CheckUpdate.getInstance().startUp();
    VoteReminding.getInstance().loadRemindChecking();
    plugin.signs = new ArrayList<SignHandler>();
    Bukkit.getScheduler().runTask(plugin, new Runnable() {

        @Override
        public void run() {
            Signs.getInstance().loadSigns();
        }
    });
    topVoterMonthly = new LinkedHashMap<User, Integer>();
    topVoterWeekly = new LinkedHashMap<User, Integer>();
    topVoterDaily = new LinkedHashMap<User, Integer>();
    voteToday = new LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>>();
    topVoterAllTime = new LinkedHashMap<User, Integer>();
    voteLog = new Logger(plugin, new File(plugin.getDataFolder() + File.separator + "Log", "votelog.txt"));
    AdminGUI.getInstance().loadHook();
    if (Config.getInstance().getVotePartyEnabled()) {
        VoteParty.getInstance().check();
    }
    VoteParty.getInstance().register();
    TopVoterHandler.getInstance().register();
    metrics();
    AdvancedCoreHook.getInstance().getJavascriptEngineRequests().add(new JavascriptPlaceholderRequest("User") {

        @Override
        public Object getObject(OfflinePlayer player) {
            return getUserManager().getVotingPluginUser(player);
        }
    });
    loadTimer();
    plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
    boolean hasRewards = RewardHandler.getInstance().hasRewards(ConfigVoteSites.getInstance().getData(), ConfigVoteSites.getInstance().getEverySiteRewardPath());
    boolean noIssues = true;
    ArrayList<String> services = ServerData.getInstance().getServiceSites();
    for (VoteSite site : getVoteSites()) {
        if (!site.hasRewards() && !hasRewards) {
            noIssues = false;
            plugin.getLogger().warning("No rewards detected for the site: " + site.getKey() + ". See https://github.com/Ben12345rocks/AdvancedCore/wiki/Rewards on how to add rewards");
        }
        boolean contains = false;
        for (String service : services) {
            if (service.equalsIgnoreCase(site.getServiceSite())) {
                contains = true;
            }
        }
        if (!contains) {
            noIssues = false;
            plugin.getLogger().warning("No vote has been recieved from " + site.getServiceSite() + ", may be an invalid service site. Vote on the site and look in console for a service site, if you get nothing then there is an issue with votifier");
        }
    }
    if (!noIssues) {
        Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {

            @Override
            public void run() {
                plugin.getLogger().warning("Detected an issue with voting sites, check the plugin startup log for more details");
            }
        }, 30l);
    }
}
Also used : User(com.Ben12345rocks.VotingPlugin.Objects.User) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Logger(com.Ben12345rocks.AdvancedCore.Util.Logger.Logger) JavascriptPlaceholderRequest(com.Ben12345rocks.AdvancedCore.Util.Javascript.JavascriptPlaceholderRequest) VoteSite(com.Ben12345rocks.VotingPlugin.Objects.VoteSite) OfflinePlayer(org.bukkit.OfflinePlayer) File(java.io.File) SignHandler(com.Ben12345rocks.VotingPlugin.Objects.SignHandler)

Example 2 with SignHandler

use of com.Ben12345rocks.VotingPlugin.Objects.SignHandler in project VotingPlugin by Ben12345rocks.

the class BlockBreak method onBlockBreak.

/**
 * On block break.
 *
 * @param event
 *            the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
    if (event.getBlock().getState() instanceof Sign) {
        Sign s = (Sign) event.getBlock().getState();
        final Location loc = s.getLocation();
        Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {

            @Override
            public void run() {
                for (SignHandler sign : plugin.signs) {
                    if (sign.getLocation().equals(loc)) {
                        sign.removeSign();
                        sign.setValid(false);
                    }
                }
            }
        });
    }
}
Also used : Sign(org.bukkit.block.Sign) SignHandler(com.Ben12345rocks.VotingPlugin.Objects.SignHandler) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 3 with SignHandler

use of com.Ben12345rocks.VotingPlugin.Objects.SignHandler in project VotingPlugin by Ben12345rocks.

the class ServerData method addSign.

/**
 * Adds the sign.
 *
 * @param location
 *            the location
 * @param data
 *            the data
 * @param position
 *            the position
 */
public void addSign(Location location, String data, int position) {
    int count = nextSignNumber();
    getData().set("Signs." + count + ".World", location.getWorld().getName());
    getData().set("Signs." + count + ".X", location.getBlockX());
    getData().set("Signs." + count + ".Y", location.getBlockY());
    getData().set("Signs." + count + ".Z", location.getBlockZ());
    getData().set("Signs." + count + ".Data", data);
    getData().set("Signs." + count + ".Position", position);
    saveData();
    plugin.signs.add(new SignHandler("" + count, getSignLocation("" + count), getSignData("" + count), getSignPosition("" + count)));
}
Also used : SignHandler(com.Ben12345rocks.VotingPlugin.Objects.SignHandler)

Aggregations

SignHandler (com.Ben12345rocks.VotingPlugin.Objects.SignHandler)3 JavascriptPlaceholderRequest (com.Ben12345rocks.AdvancedCore.Util.Javascript.JavascriptPlaceholderRequest)1 Logger (com.Ben12345rocks.AdvancedCore.Util.Logger.Logger)1 User (com.Ben12345rocks.VotingPlugin.Objects.User)1 VoteSite (com.Ben12345rocks.VotingPlugin.Objects.VoteSite)1 File (java.io.File)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Location (org.bukkit.Location)1 OfflinePlayer (org.bukkit.OfflinePlayer)1 Sign (org.bukkit.block.Sign)1 EventHandler (org.bukkit.event.EventHandler)1