Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
566d688b57 | ||
|
|
e4209b15c3 | ||
|
|
bd5b26805a | ||
|
|
27c43b8e8e | ||
|
|
5b719141fe | ||
|
|
f8ee0bba17 | ||
|
|
d5ea3c60a9 | ||
|
|
3be9eaf47a | ||
|
|
f385927958 | ||
|
|
ec491a937c | ||
|
|
7bf879a08f | ||
|
|
18a0e1f338 | ||
|
|
c7cbf0230c | ||
|
|
cee519176a | ||
|
|
50d75449c0 | ||
|
|
316fbf7e62 | ||
|
|
7c82cbc6b4 | ||
|
|
8387b48e6b | ||
|
|
0e806a2985 | ||
|
|
d06041cfd8 | ||
|
|
1a257a3858 | ||
|
|
90c0104de3 | ||
|
|
b3473174de | ||
|
|
5b853b9ad4 | ||
|
|
3b3578fa87 | ||
|
|
6bf079068b |
No files matched your search
@@ -115,6 +115,7 @@ Format:
|
||||
HelpLine: '&3&l%Command% - &3%HelpMessage%'
|
||||
|
||||
# Broadcast vote message
|
||||
# Set to an empty message to disable
|
||||
BroadcastMsg: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%'
|
||||
|
||||
# Broadcast only when player is online
|
||||
@@ -229,10 +230,6 @@ Format:
|
||||
|
||||
# %Points% = player points
|
||||
Points: '&a%Player% currently has &a&l%Points%&a Points!'
|
||||
|
||||
# Login message if player can vote on all sites
|
||||
# Must be enabled in config.yml
|
||||
LoginMsg: '&cRemember to vote!'
|
||||
|
||||
# Msg on top voter award, will only send message if that place has a reward set
|
||||
# %place% = place - 1,2,3,etc
|
||||
@@ -272,6 +269,8 @@ Format:
|
||||
PrevPage: '&aPrevious Page'
|
||||
NextPage: '&aNext Page'
|
||||
|
||||
InvFull: '&cInventory full, dropping items on ground'
|
||||
|
||||
# Display text
|
||||
# Used in /vote top (GUI)
|
||||
TopVoter:
|
||||
@@ -343,6 +342,8 @@ GUI:
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Vote Shop'
|
||||
Lore:
|
||||
- '&aYou currently have %points% points'
|
||||
Slot: 6
|
||||
|
||||
# GUI for /vote url
|
||||
@@ -596,6 +597,8 @@ VoteParty:
|
||||
Enabled: false
|
||||
# Number of votes required to give rewards
|
||||
VotesRequired: 20
|
||||
# Increase the amount of votes required on each vote party reached
|
||||
#IncreaseVotesRquired: 10
|
||||
# If true, players who did not vote to reach the votes required will
|
||||
# recieve the reward
|
||||
GiveAllPlayers: false
|
||||
@@ -709,6 +712,7 @@ EnableMonthlyAwards: true
|
||||
# Rewards to give
|
||||
MonthlyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
# Using 1-10 will reward players in first to tenth place with the same reward
|
||||
1:
|
||||
Rewards:
|
||||
Messages:
|
||||
@@ -835,4 +839,7 @@ PurgeMin: 90
|
||||
|
||||
# Whether or not to disable checking names on mojang, disable if you hit the rate limit
|
||||
# Shouldn't make a noticeable impact if set to false
|
||||
CheckNameMojang: true
|
||||
CheckNameMojang: true
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get saved)
|
||||
CreateBackups: true
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>5.12.4</version>
|
||||
<version>5.12.8</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -148,6 +148,10 @@
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
|
||||
@@ -236,7 +236,7 @@ public class CommandLoader {
|
||||
user.setMilestoneCount(user.getAllTimeTotal());
|
||||
}
|
||||
sendMessage(sender, "&cFinished");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1015,10 +1015,6 @@ public class CommandLoader {
|
||||
|
||||
TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(Sitename)", sites) {
|
||||
|
||||
@Override
|
||||
public void updateReplacements() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
ArrayList<String> sites = new ArrayList<String>();
|
||||
@@ -1027,6 +1023,10 @@ public class CommandLoader {
|
||||
}
|
||||
setReplace(sites);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReplacements() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -835,6 +835,8 @@ public class Commands {
|
||||
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%url%", voteURL);
|
||||
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%SiteName%", voteSite.getDisplayName());
|
||||
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%player%", user.getPlayerName());
|
||||
msg = StringUtils.getInstance().replacePlaceHolder(msg, "Next",
|
||||
"" + voteCommandNextInfo(user, voteSite));
|
||||
sites.add(msg);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class CommandAliases implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* for (String arg : cmdHandle.getArgs()[0].split("&")) { argsNew.set(0, arg);
|
||||
* if (cmdHandle.runCommand(sender, Utils.getInstance().convertArray(argsNew)))
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.GUI;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -120,6 +122,7 @@ public class PlayerGUIs {
|
||||
String[] lore = new String[1];
|
||||
|
||||
lore = ArrayUtils.getInstance().convert(Config.getInstance().getVoteGUISlotLore(slot));
|
||||
|
||||
if (lore.length == 0) {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
lore = Commands.getInstance().voteURLs(user);
|
||||
@@ -147,7 +150,11 @@ public class PlayerGUIs {
|
||||
}
|
||||
}
|
||||
|
||||
builder.setLore(lore);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("points", "" + user.getPoints());
|
||||
|
||||
builder.setPlaceholders(placeholders);
|
||||
builder.setLore(ArrayUtils.getInstance().convert(lore));
|
||||
|
||||
inv.addButton(Config.getInstance().getVoteGUISlotSlot(slot), new BInventoryButton(builder) {
|
||||
|
||||
@@ -639,8 +646,13 @@ public class PlayerGUIs {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
player.performCommand("vote reward " + site.getKey());
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.performCommand("vote reward " + site.getKey());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -28,6 +28,8 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
/** The cmd handle. */
|
||||
public CommandHandler cmdHandle;
|
||||
|
||||
private boolean adminCommand;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -102,6 +104,4 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
return this;
|
||||
}
|
||||
|
||||
private boolean adminCommand;
|
||||
|
||||
}
|
||||
@@ -47,6 +47,10 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("AllowUnjoined");
|
||||
}
|
||||
|
||||
public boolean getAddTotals() {
|
||||
return getData().getBoolean("AddTotals", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all sites reward.
|
||||
*
|
||||
@@ -110,14 +114,18 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("BroadcastVote", true);
|
||||
}
|
||||
|
||||
public boolean getDisableCheckOnWorldChange() {
|
||||
return getData().getBoolean("DisableCheckOnWorldChange");
|
||||
public boolean getCheckNameMojang() {
|
||||
return getData().getBoolean("CheckNameMojang", true);
|
||||
}
|
||||
|
||||
public boolean getClearCacheOnUpdate() {
|
||||
return getData().getBoolean("ClearCacheOnUpdate");
|
||||
}
|
||||
|
||||
public boolean getClearCacheOnVote() {
|
||||
return getData().getBoolean("ClearCacheOnVote");
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUIBest() {
|
||||
return getData().getBoolean("Commands.UseGUI.Best");
|
||||
}
|
||||
@@ -208,15 +216,8 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameWeek");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the daily award rewards path
|
||||
*
|
||||
* @param pos
|
||||
* the pos
|
||||
* @return the daily award rewards
|
||||
*/
|
||||
public String getDailyAwardRewardsPath(int pos) {
|
||||
return "DailyAwards." + pos + ".Rewards";
|
||||
public String getDailyAwardRewardsPath(String path) {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,6 +269,10 @@ public class Config extends YMLFile {
|
||||
return getData().getInt("DelayBetweenUpdates", 3);
|
||||
}
|
||||
|
||||
public boolean getDisableCheckOnWorldChange() {
|
||||
return getData().getBoolean("DisableCheckOnWorldChange");
|
||||
}
|
||||
|
||||
public boolean getDisableNoServiceSiteMessage() {
|
||||
return getData().getBoolean("DisableNoServiceSiteMessage");
|
||||
}
|
||||
@@ -661,6 +666,10 @@ public class Config extends YMLFile {
|
||||
return getData().getString("Format.TopVoter.Weekly", "Weekly");
|
||||
}
|
||||
|
||||
public String getFormatUserNotExist() {
|
||||
return getData().getString("Format.UserNotExist", "&cUser does not exist: %player%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote help.
|
||||
*
|
||||
@@ -671,6 +680,10 @@ public class Config extends YMLFile {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public boolean getGiveDefaultPermission() {
|
||||
return getData().getBoolean("GiveDefaultPermission", true);
|
||||
}
|
||||
|
||||
public ConfigurationSection getGUIVoteBestDayBestItem() {
|
||||
return getData().getConfigurationSection("GUI.VoteBest.DayBest.Item");
|
||||
}
|
||||
@@ -807,14 +820,14 @@ public class Config extends YMLFile {
|
||||
return getData().getString("GUI.VoteURL.Name", "&cVoteURL");
|
||||
}
|
||||
|
||||
public String getGUIVoteURLURLText() {
|
||||
return getData().getString("GUI.VoteURL.URLText", "%VoteUrl%");
|
||||
}
|
||||
|
||||
public String getGUIVoteURLSiteName() {
|
||||
return getData().getString("GUI.VoteURLSite.Name", "VoteSite %site%");
|
||||
}
|
||||
|
||||
public String getGUIVoteURLURLText() {
|
||||
return getData().getString("GUI.VoteURL.URLText", "%VoteUrl%");
|
||||
}
|
||||
|
||||
public int getIdentifierCost(String identifier) {
|
||||
return getData().getInt("Shop." + identifier + ".Cost");
|
||||
}
|
||||
@@ -845,10 +858,6 @@ public class Config extends YMLFile {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
public boolean getCheckNameMojang() {
|
||||
return getData().getBoolean("CheckNameMojang", true);
|
||||
}
|
||||
|
||||
public ConfigurationSection getIdentifierSection(String identifier) {
|
||||
return getData().getConfigurationSection("Shop." + identifier);
|
||||
}
|
||||
@@ -930,15 +939,8 @@ public class Config extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly award rewards.
|
||||
*
|
||||
* @param pos
|
||||
* the pos
|
||||
* @return the monthly award rewards
|
||||
*/
|
||||
public String getMonthlyAwardRewardsPath(int pos) {
|
||||
return "MonthlyAwards." + pos + ".Rewards";
|
||||
public String getMonthlyAwardRewardsPath(String path) {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -971,6 +973,14 @@ public class Config extends YMLFile {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
|
||||
public int getPurgeMin() {
|
||||
return getData().getInt("PurgeMin", 90);
|
||||
}
|
||||
|
||||
public boolean getPurgeOldData() {
|
||||
return getData().getBoolean("PurgeOldData");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request API default method.
|
||||
*
|
||||
@@ -1030,6 +1040,10 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("StoreTopVoters.Weekly");
|
||||
}
|
||||
|
||||
public boolean getTopVoterAwardsTies() {
|
||||
return getData().getBoolean("TopVoterAwardsTies", true);
|
||||
}
|
||||
|
||||
public boolean getTopVoterIgnorePermission() {
|
||||
return getData().getBoolean("TopVoterIgnorePermission");
|
||||
}
|
||||
@@ -1038,6 +1052,10 @@ public class Config extends YMLFile {
|
||||
return getData().getInt("VoteParty.UserVotesRequired");
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRquired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRquired", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot command.
|
||||
*
|
||||
@@ -1059,7 +1077,7 @@ public class Config extends YMLFile {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getVoteGUISlotLore(String slot) {
|
||||
return (ArrayList<String>) getData().getList("GUI.VoteGUI." + slot + ".Lore", new ArrayList<String>());
|
||||
return (ArrayList<String>) getData().getList("GUI.VoteGUI." + slot + ".Item.Lore", new ArrayList<String>());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1094,6 +1112,11 @@ public class Config extends YMLFile {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getVotePartyCommands() {
|
||||
return (ArrayList<String>) getData().getList("VoteParty.Commands", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public boolean getVotePartyCountFakeVotes() {
|
||||
return getData().getBoolean("VoteParty.CountFakeVotes", true);
|
||||
}
|
||||
@@ -1120,10 +1143,6 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("VoteParty.ResetEachDay");
|
||||
}
|
||||
|
||||
public boolean getAddTotals() {
|
||||
return getData().getBoolean("AddTotals", true);
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetMontly() {
|
||||
return getData().getBoolean("VoteParty.ResetMonthly");
|
||||
}
|
||||
@@ -1137,11 +1156,6 @@ public class Config extends YMLFile {
|
||||
return "VoteParty.Rewards";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getVotePartyCommands() {
|
||||
return (ArrayList<String>) getData().getList("VoteParty.Commands", new ArrayList<String>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote party votes required.
|
||||
*
|
||||
@@ -1200,26 +1214,10 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("VoteShopBackButton", true);
|
||||
}
|
||||
|
||||
public boolean getGiveDefaultPermission() {
|
||||
return getData().getBoolean("GiveDefaultPermission", true);
|
||||
}
|
||||
|
||||
public String getVoteShopName() {
|
||||
return getData().getString("GUI.VoteShopName", "VoteShop");
|
||||
}
|
||||
|
||||
public String getFormatUserNotExist() {
|
||||
return getData().getString("Format.UserNotExist", "&cUser does not exist: %player%");
|
||||
}
|
||||
|
||||
public boolean getPurgeOldData() {
|
||||
return getData().getBoolean("PurgeOldData");
|
||||
}
|
||||
|
||||
public int getPurgeMin() {
|
||||
return getData().getInt("PurgeMin", 90);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site items.
|
||||
*
|
||||
@@ -1348,16 +1346,9 @@ public class Config extends YMLFile {
|
||||
public boolean getVoteURLViewAllUrlsButtonEnabled() {
|
||||
return getData().getBoolean("GUI.VoteURL.ViewAllUrlsButtonEnabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weekly award rewards.
|
||||
*
|
||||
* @param pos
|
||||
* the pos
|
||||
* @return the weekly award rewards
|
||||
*/
|
||||
public String getWeeklyAwardRewardsPath(int pos) {
|
||||
return "WeeklyAwards." + pos + ".Rewards";
|
||||
|
||||
public String getWeeklyAwardRewardsPath(String path) {
|
||||
return "WeeklyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1478,12 +1469,4 @@ public class Config extends YMLFile {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public boolean getClearCacheOnVote() {
|
||||
return getData().getBoolean("ClearCacheOnVote");
|
||||
}
|
||||
|
||||
public boolean getTopVoterAwardsTies() {
|
||||
return getData().getBoolean("TopVoterAwardsTies", true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -103,6 +103,15 @@ public class ServerData {
|
||||
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public int getVotePartyExtraRequired() {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
public void setVotePartyExtraRequired(int value) {
|
||||
getData().set("VotePartyExtraRequired", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign data.
|
||||
*
|
||||
|
||||
+15
-15
@@ -33,21 +33,6 @@ public class PlayerVoteAllSitesEvent extends Event {
|
||||
setUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user
|
||||
*/
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* the user to set
|
||||
*/
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -58,6 +43,13 @@ public class PlayerVoteAllSitesEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user
|
||||
*/
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
@@ -77,4 +69,12 @@ public class PlayerVoteAllSitesEvent extends Event {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* the user to set
|
||||
*/
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class VotiferEvent implements Listener {
|
||||
|
||||
public static void playerVote(final String playerName, final String voteSiteURL, final boolean realVote) {
|
||||
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName) && !config.allowUnJoined()) {
|
||||
if (!config.allowUnJoined() && !PlayerUtils.getInstance().isValidUser(playerName)) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
return;
|
||||
@@ -151,7 +151,13 @@ public class VotiferEvent implements Listener {
|
||||
Vote vote = event.getVote();
|
||||
final String voteSite = vote.getServiceName();
|
||||
final String voteUsername = vote.getUsername().trim();
|
||||
ServerData.getInstance().addServiceSite(voteSite);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ServerData.getInstance().addServiceSite(voteSite);
|
||||
}
|
||||
});
|
||||
|
||||
if (voteUsername.length() == 0) {
|
||||
plugin.getLogger().warning("No name from vote on " + voteSite);
|
||||
|
||||
@@ -29,13 +29,11 @@ import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
|
||||
import com.Ben12345rocks.AdvancedCore.Thread.Thread;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Javascript.JavascriptPlaceholderRequest;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Logger.Logger;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Metrics.BStatsMetrics;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Metrics.MCStatsMetrics;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Updater.Updater;
|
||||
import com.Ben12345rocks.AdvancedCore.mysql.MySQL;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.CommandLoader;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Executers.CommandAdminVote;
|
||||
@@ -131,7 +129,7 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
UserStorage cur = AdvancedCoreHook.getInstance().getStorageType();
|
||||
AdvancedCoreHook.getInstance().setStorageType(from);
|
||||
loadMySQL();
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
HashMap<User, HashMap<String, String>> data = new HashMap<User, HashMap<String, String>>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
try {
|
||||
@@ -153,7 +151,7 @@ public class Main extends JavaPlugin {
|
||||
plugin.getLogger().info("Finished getting data from " + from.toString());
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
loadMySQL();
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
|
||||
for (Entry<User, HashMap<String, String>> entry : data.entrySet()) {
|
||||
try {
|
||||
@@ -167,6 +165,7 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
AdvancedCoreHook.getInstance().setStorageType(cur);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
|
||||
plugin.getLogger().info("Finished convertting");
|
||||
}
|
||||
@@ -185,6 +184,34 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().debug(plugin, message);
|
||||
}
|
||||
|
||||
public ArrayList<CommandHandler> getAdminVoteCommand() {
|
||||
return adminVoteCommand;
|
||||
}
|
||||
|
||||
public ArrayList<SignHandler> getSigns() {
|
||||
return signs;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterAllTime() {
|
||||
return topVoterAllTime;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterDaily() {
|
||||
return topVoterDaily;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterMonthly() {
|
||||
return topVoterMonthly;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterWeekly() {
|
||||
return topVoterWeekly;
|
||||
}
|
||||
|
||||
public Updater getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user.
|
||||
*
|
||||
@@ -200,6 +227,14 @@ public class Main extends JavaPlugin {
|
||||
return UserManager.getInstance();
|
||||
}
|
||||
|
||||
public ArrayList<CommandHandler> getVoteCommand() {
|
||||
return voteCommand;
|
||||
}
|
||||
|
||||
public Logger getVoteLog() {
|
||||
return voteLog;
|
||||
}
|
||||
|
||||
public VoteParty getVoteParty() {
|
||||
return VoteParty.getInstance();
|
||||
}
|
||||
@@ -261,6 +296,10 @@ public class Main extends JavaPlugin {
|
||||
return voteSites;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> getVoteToday() {
|
||||
return voteToday;
|
||||
}
|
||||
|
||||
public boolean hasVoteSite(String site) {
|
||||
String siteName = getVoteSiteName(site);
|
||||
for (VoteSite voteSite : getVoteSites()) {
|
||||
@@ -271,18 +310,12 @@ public class Main extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void loadMySQL() {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
Thread.getInstance().run(new Runnable() {
|
||||
public boolean isUpdate() {
|
||||
return update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
AdvancedCoreHook.getInstance()
|
||||
.setMysql(new MySQL("VotingPlugin_Users", Config.getInstance().getMySql()));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
public boolean isUpdateStarted() {
|
||||
return updateStarted;
|
||||
}
|
||||
|
||||
private void loadTimer() {
|
||||
@@ -713,9 +746,14 @@ public class Main extends JavaPlugin {
|
||||
|
||||
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()) {
|
||||
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");
|
||||
}
|
||||
@@ -727,59 +765,23 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
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() {
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterAllTime() {
|
||||
return topVoterAllTime;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger()
|
||||
.warning("Detected an issue with voting sites, check the plugin startup log for more details");
|
||||
}
|
||||
}, 30l);
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterMonthly() {
|
||||
return topVoterMonthly;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterWeekly() {
|
||||
return topVoterWeekly;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterDaily() {
|
||||
return topVoterDaily;
|
||||
}
|
||||
|
||||
public Updater getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
public ArrayList<CommandHandler> getVoteCommand() {
|
||||
return voteCommand;
|
||||
}
|
||||
|
||||
public ArrayList<CommandHandler> getAdminVoteCommand() {
|
||||
return adminVoteCommand;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> getVoteToday() {
|
||||
return voteToday;
|
||||
}
|
||||
|
||||
public ArrayList<SignHandler> getSigns() {
|
||||
return signs;
|
||||
}
|
||||
|
||||
public Logger getVoteLog() {
|
||||
return voteLog;
|
||||
}
|
||||
|
||||
public boolean isUpdate() {
|
||||
return update;
|
||||
}
|
||||
|
||||
public boolean isUpdateStarted() {
|
||||
return updateStarted;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -844,6 +846,7 @@ public class Main extends JavaPlugin {
|
||||
configVoteSites.reloadData();
|
||||
updateAdvancedCoreHook();
|
||||
plugin.loadVoteSites();
|
||||
AdvancedCoreHook.getInstance().setConfigData(Config.getInstance().getData());
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
// loadTimer();
|
||||
|
||||
@@ -948,32 +951,9 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void updateAdvancedCoreHook() {
|
||||
AdvancedCoreHook.getInstance().setAutoDownload(Config.getInstance().getAutoDownload());
|
||||
AdvancedCoreHook.getInstance().getJavascriptEngine().put("VotingPlugin", this);
|
||||
AdvancedCoreHook.getInstance().allowDownloadingFromSpigot(15358);
|
||||
AdvancedCoreHook.getInstance().setExtraDebug(Config.getInstance().getExtraDebug());
|
||||
AdvancedCoreHook.getInstance().setStorageType(UserStorage.value(Config.getInstance().getDataStorage()));
|
||||
loadMySQL();
|
||||
|
||||
AdvancedCoreHook.getInstance()
|
||||
.setDisableCheckOnWorldChange(Config.getInstance().getDisableCheckOnWorldChange());
|
||||
AdvancedCoreHook.getInstance().setDebug(Config.getInstance().getDebugEnabled());
|
||||
AdvancedCoreHook.getInstance().setDebugIngame(Config.getInstance().getDebugInfoIngame());
|
||||
AdvancedCoreHook.getInstance().setDefaultRequestMethod(Config.getInstance().getRequestAPIDefaultMethod());
|
||||
AdvancedCoreHook.getInstance().setDisabledRequestMethods(Config.getInstance().getRequestAPIDisabledMethods());
|
||||
AdvancedCoreHook.getInstance().setFormatNoPerms(Config.getInstance().getFormatNoPerms());
|
||||
AdvancedCoreHook.getInstance().setFormatNotNumber(Config.getInstance().getFormatNotNumber());
|
||||
AdvancedCoreHook.getInstance().setHelpLine(Config.getInstance().getFormatHelpLine());
|
||||
AdvancedCoreHook.getInstance().setLogDebugToFile(Config.getInstance().getLogDebugToFile());
|
||||
AdvancedCoreHook.getInstance().setSendScoreboards(Config.getInstance().getSendScoreboards());
|
||||
AdvancedCoreHook.getInstance().setAlternateUUIDLookUp(Config.getInstance().getAlternateUUIDLookup());
|
||||
AdvancedCoreHook.getInstance().setAutoKillInvs(Config.getInstance().getAutoKillInvs());
|
||||
AdvancedCoreHook.getInstance().setPrevPageTxt(Config.getInstance().getFormatPrevPage());
|
||||
AdvancedCoreHook.getInstance().setNextPageTxt(Config.getInstance().getFormatNextPage());
|
||||
|
||||
AdvancedCoreHook.getInstance().setPurgeOldData(Config.getInstance().getPurgeOldData());
|
||||
AdvancedCoreHook.getInstance().setPurgeMinimumDays(Config.getInstance().getPurgeMin());
|
||||
AdvancedCoreHook.getInstance().setCheckNameMojang(Config.getInstance().getCheckNameMojang());
|
||||
AdvancedCoreHook.getInstance().setConfigData(Config.getInstance().getData());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
@@ -72,6 +73,17 @@ public class SignHandler {
|
||||
playerName = "";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean checkSkull(Block block) {
|
||||
if (block.getState() instanceof Skull) {
|
||||
Skull skull = (Skull) block.getState();
|
||||
skull.setOwner(playerName);
|
||||
skull.update();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check skulls.
|
||||
*/
|
||||
@@ -311,14 +323,20 @@ public class SignHandler {
|
||||
}, delay);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void updateSkulls(Location loc1, Location loc2) {
|
||||
for (Block block : MiscUtils.getInstance().getRegionBlocks(location.getWorld(), loc1, loc2)) {
|
||||
if (block.getState() instanceof Skull) {
|
||||
Skull skull = (Skull) block.getState();
|
||||
skull.setOwner(playerName);
|
||||
skull.update();
|
||||
BlockState state = getLocation().getBlock().getState();
|
||||
if (state instanceof Sign) {
|
||||
org.bukkit.material.Sign s = (org.bukkit.material.Sign) state.getData();
|
||||
Block b = location.getBlock().getRelative(s.getAttachedFace());
|
||||
Block above = b.getRelative(BlockFace.UP);
|
||||
if (checkSkull(above)) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (Block block : MiscUtils.getInstance().getRegionBlocks(location.getWorld(), loc1, loc2)) {
|
||||
checkSkull(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -250,6 +250,12 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clearOfflineRewards() {
|
||||
setOfflineVotes(new ArrayList<String>());
|
||||
setOfflineRewards(new ArrayList<String>());
|
||||
setOfflineOtherRewards(new ArrayList<String>());
|
||||
}
|
||||
|
||||
public void clearTotals() {
|
||||
setAllTimeTotal(0);
|
||||
resetDailyTotalVotes();
|
||||
@@ -306,6 +312,10 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return getData().getInt("HighestWeeklyTotal");
|
||||
}
|
||||
|
||||
public int getLastMonthTotal() {
|
||||
return getData().getInt("LastMonthTotal");
|
||||
}
|
||||
|
||||
public HashMap<VoteSite, Long> getLastVotes() {
|
||||
HashMap<VoteSite, Long> lastVotes = new HashMap<VoteSite, Long>();
|
||||
ArrayList<String> LastVotesList = getUserData().getStringList("LastVotes");
|
||||
@@ -353,10 +363,6 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return getData().getInt("MonthTotal");
|
||||
}
|
||||
|
||||
public int getLastMonthTotal() {
|
||||
return getData().getInt("LastMonthTotal");
|
||||
}
|
||||
|
||||
public int getMonthVoteStreak() {
|
||||
return getData().getInt("MonthVoteStreak");
|
||||
}
|
||||
@@ -405,25 +411,13 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return getData().getInt("WeekVoteStreak");
|
||||
}
|
||||
|
||||
/**
|
||||
* Give daily top voter award.
|
||||
*
|
||||
* @param place
|
||||
* the place
|
||||
*/
|
||||
public void giveDailyTopVoterAward(int place) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getDailyAwardRewardsPath(place))
|
||||
public void giveDailyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getDailyAwardRewardsPath(path))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Daily").send(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give monthly top voter award.
|
||||
*
|
||||
* @param place
|
||||
* the place
|
||||
*/
|
||||
public void giveMonthlyTopVoterAward(int place) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getMonthlyAwardRewardsPath(place))
|
||||
public void giveMonthlyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getMonthlyAwardRewardsPath(path))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Monthly").send(this);
|
||||
}
|
||||
|
||||
@@ -456,36 +450,6 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("MonthlyTopVoter")) {
|
||||
String st = str.substring("MontlyTopVoter".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int place = Integer.parseInt(st);
|
||||
if (place > 0) {
|
||||
if (Config.getInstance().getMonthlyAwardsEnabled()) {
|
||||
giveMonthlyTopVoterAward(place);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("WeeklyTopVoter")) {
|
||||
String st = str.substring("WeeklyTopVoter".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int place = Integer.parseInt(st);
|
||||
if (place > 0) {
|
||||
if (Config.getInstance().getWeeklyAwardsEnabled()) {
|
||||
giveWeeklyTopVoterAward(place);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("DailyTopVoter")) {
|
||||
String st = str.substring("DailyTopVoter".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int place = Integer.parseInt(st);
|
||||
if (place > 0) {
|
||||
if (Config.getInstance().getDailyAwardsEnabled()) {
|
||||
giveDailyTopVoterAward(place);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("VoteStreak")) {
|
||||
String[] args = str.split("_");
|
||||
if (args.length > 2) {
|
||||
@@ -507,14 +471,8 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Give weekly top voter award.
|
||||
*
|
||||
* @param place
|
||||
* the place
|
||||
*/
|
||||
public void giveWeeklyTopVoterAward(int place) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getWeeklyAwardRewardsPath(place))
|
||||
public void giveWeeklyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getWeeklyAwardRewardsPath(path))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Weekly").send(this);
|
||||
}
|
||||
|
||||
@@ -702,6 +660,10 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
getData().setInt("HighestWeeklyTotal", total);
|
||||
}
|
||||
|
||||
public void setLastMonthTotal(int total) {
|
||||
getData().setInt("LastMonthTotal", total);
|
||||
}
|
||||
|
||||
public void setLastVotes(HashMap<VoteSite, Long> lastVotes) {
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
for (Entry<VoteSite, Long> entry : lastVotes.entrySet()) {
|
||||
@@ -719,10 +681,6 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
getData().setInt("MonthTotal", total);
|
||||
}
|
||||
|
||||
public void setLastMonthTotal(int total) {
|
||||
getData().setInt("LastMonthTotal", total);
|
||||
}
|
||||
|
||||
public void setMonthVoteStreak(int streak) {
|
||||
getData().setInt("MonthVoteStreak", streak);
|
||||
if (getBestMonthVoteStreak() < streak) {
|
||||
@@ -791,10 +749,4 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clearOfflineRewards() {
|
||||
setOfflineVotes(new ArrayList<String>());
|
||||
setOfflineRewards(new ArrayList<String>());
|
||||
setOfflineOtherRewards(new ArrayList<String>());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -170,10 +170,6 @@ public class VoteSite {
|
||||
.withPlaceHolder("VoteDelay", "" + getVoteDelay()).withPlaceHolder("VoteURL", getVoteURL()).send(user);
|
||||
}
|
||||
|
||||
public boolean hasRewards() {
|
||||
return RewardHandler.getInstance().hasRewards(configVoteSites.getData(), configVoteSites.getRewardsPath(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Give site reward.
|
||||
*
|
||||
@@ -186,6 +182,10 @@ public class VoteSite {
|
||||
giveRewards(user, online);
|
||||
}
|
||||
|
||||
public boolean hasRewards() {
|
||||
return RewardHandler.getInstance().hasRewards(configVoteSites.getData(), configVoteSites.getRewardsPath(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the.
|
||||
*/
|
||||
|
||||
@@ -284,5 +284,4 @@ public class OtherVoteReward {
|
||||
.setOnline(online).withPlaceHolder("Type", type).withPlaceHolder("Streak", "" + votes).send(user);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -82,12 +82,6 @@ public class TopVoterHandler implements Listener {
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPreDateChanged(PreDateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
|
||||
@@ -111,7 +105,7 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
if (Config.getInstance().getDailyAwardsEnabled()) {
|
||||
Set<String> places = Config.getInstance().getDailyPossibleRewardPlaces();
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getDailyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterDaily.keySet()) {
|
||||
@@ -123,8 +117,8 @@ public class TopVoterHandler implements Listener {
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.giveDailyTopVoterAward(i);
|
||||
if (places.containsKey(i)) {
|
||||
user.giveDailyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getDailyTotal();
|
||||
@@ -156,7 +150,7 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
if (Config.getInstance().getMonthlyAwardsEnabled()) {
|
||||
Set<String> places = Config.getInstance().getMonthlyPossibleRewardPlaces();
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getMonthlyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterMonthly.keySet()) {
|
||||
@@ -169,8 +163,8 @@ public class TopVoterHandler implements Listener {
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.giveMonthlyTopVoterAward(i);
|
||||
if (places.containsKey(i)) {
|
||||
user.giveMonthlyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getMonthTotal();
|
||||
@@ -186,7 +180,32 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<Integer, String> handlePlaces(Set<String> places) {
|
||||
HashMap<Integer, String> place = new HashMap<Integer, String>();
|
||||
for (String p : places) {
|
||||
String[] data = p.split("-");
|
||||
try {
|
||||
if (data.length > 1) {
|
||||
for (int i = Integer.parseInt(data[0]); i < Integer.parseInt(data[1]); i++) {
|
||||
place.put(i, p);
|
||||
}
|
||||
} else {
|
||||
place.put(Integer.parseInt(data[0]), p);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return place;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPreDateChanged(PreDateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@@ -211,7 +230,7 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
if (Config.getInstance().getWeeklyAwardsEnabled()) {
|
||||
Set<String> places = Config.getInstance().getWeeklyPossibleRewardPlaces();
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getWeeklyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterWeekly.keySet()) {
|
||||
@@ -223,8 +242,8 @@ public class TopVoterHandler implements Listener {
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.giveWeeklyTopVoterAward(i);
|
||||
if (places.containsKey(i)) {
|
||||
user.giveWeeklyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getWeeklyTotal();
|
||||
|
||||
@@ -32,6 +32,10 @@ public class UserManager {
|
||||
return com.Ben12345rocks.AdvancedCore.UserManager.UserManager.getInstance().getAllUUIDs();
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(java.util.UUID uuid) {
|
||||
return getVotingPluginUser(new UUID(uuid.toString()));
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(OfflinePlayer player) {
|
||||
return getVotingPluginUser(player.getName());
|
||||
}
|
||||
@@ -49,8 +53,4 @@ public class UserManager {
|
||||
public User getVotingPluginUser(UUID uuid) {
|
||||
return new User(uuid);
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(java.util.UUID uuid) {
|
||||
return getVotingPluginUser(new UUID(uuid.toString()));
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
@@ -110,7 +109,7 @@ public class PlaceHolders {
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesCurrent")) {
|
||||
return Integer.toString(VoteParty.getInstance().getTotalVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesRequired")) {
|
||||
return Integer.toString(Config.getInstance().getVotePartyVotesRequired());
|
||||
return Integer.toString(VoteParty.getInstance().getVotesRequired());
|
||||
}
|
||||
|
||||
// %VotingPlugin_canvote% - Whether or not a player can vote on all
|
||||
|
||||
@@ -86,8 +86,8 @@ public class VoteParty implements Listener {
|
||||
* Check.
|
||||
*/
|
||||
public void check() {
|
||||
if (getTotalVotes() >= Config.getInstance().getVotePartyVotesRequired()) {
|
||||
setTotalVotes(getTotalVotes() - Config.getInstance().getVotePartyVotesRequired());
|
||||
if (getTotalVotes() >= getVotesRequired()) {
|
||||
setTotalVotes(getTotalVotes() - getVotesRequired());
|
||||
|
||||
VotePartyEvent event = new VotePartyEvent();
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
@@ -96,6 +96,11 @@ public class VoteParty implements Listener {
|
||||
}
|
||||
giveRewards();
|
||||
MiscUtils.getInstance().broadcast(Config.getInstance().getVotePartyBroadcast());
|
||||
|
||||
if (Config.getInstance().getVotePartyIncreaseVotesRquired() > 0) {
|
||||
ServerData.getInstance().setVotePartyExtraRequired(ServerData.getInstance().getVotePartyExtraRequired()
|
||||
+ Config.getInstance().getVotePartyIncreaseVotesRquired());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -123,13 +128,17 @@ public class VoteParty implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public int getVotesRequired() {
|
||||
return Config.getInstance().getVotePartyVotesRequired() + ServerData.getInstance().getVotePartyExtraRequired();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the needed votes.
|
||||
*
|
||||
* @return the needed votes
|
||||
*/
|
||||
public int getNeededVotes() {
|
||||
int votesRequired = Config.getInstance().getVotePartyVotesRequired();
|
||||
int votesRequired = getVotesRequired();
|
||||
int votes = getTotalVotes();
|
||||
int neededVotes = votesRequired - votes;
|
||||
return neededVotes;
|
||||
@@ -226,6 +235,7 @@ public class VoteParty implements Listener {
|
||||
|
||||
public void reset() {
|
||||
setVotedUsers(new ArrayList<String>());
|
||||
setTotalVotes(0);
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getVotePartyVotes() != 0) {
|
||||
|
||||
Reference in new issue
Block a user