use of com.Ben12345rocks.VotingPlugin.Objects.User in project VotingPlugin by Ben12345rocks.
the class TopVoterHandler method onDayChange.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDayChange(DayChangeEvent event) {
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
if (user.getDailyTotal() == 0 && user.getDayVoteStreak() != 0) {
user.setDayVoteStreak(0);
} else {
user.addDayVoteStreak();
}
OtherVoteReward.getInstance().checkVoteStreak(user, "Day");
if (user.getHighestDailyTotal() < user.getDailyTotal()) {
user.setHighestDailyTotal(user.getDailyTotal());
}
}
if (Config.getInstance().getStoreTopVotersDaily()) {
plugin.debug("Storing TopVoters Daily");
storeDailyTopVoters();
}
if (Config.getInstance().getDailyAwardsEnabled()) {
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getDailyPossibleRewardPlaces());
int i = 0;
int lastTotal = -1;
for (User user : plugin.topVoterDaily.keySet()) {
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
if (Config.getInstance().getTopVoterAwardsTies()) {
if (user.getDailyTotal() != lastTotal) {
i++;
}
} else {
i++;
}
if (places.containsKey(i)) {
user.giveDailyTopVoterAward(i, places.get(i));
}
}
lastTotal = user.getDailyTotal();
}
}
resetDailyTotals();
}
use of com.Ben12345rocks.VotingPlugin.Objects.User in project VotingPlugin by Ben12345rocks.
the class TopVoterHandler method onMonthChange.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMonthChange(MonthChangeEvent event) {
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
if (user.getMonthTotal() == 0 && user.getMonthVoteStreak() != 0) {
user.setMonthVoteStreak(0);
} else {
user.addMonthVoteStreak();
OtherVoteReward.getInstance().checkVoteStreak(user, "Month");
}
if (user.getHighestMonthlyTotal() < user.getMonthTotal()) {
user.setHighestMonthlyTotal(user.getMonthTotal());
}
}
if (Config.getInstance().getStoreTopVotersMonthly()) {
plugin.debug("Storing TopVoters Monthly");
storeMonthlyTopVoters();
}
if (Config.getInstance().getMonthlyAwardsEnabled()) {
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getMonthlyPossibleRewardPlaces());
int i = 0;
int lastTotal = -1;
for (User user : plugin.topVoterMonthly.keySet()) {
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
if (Config.getInstance().getTopVoterAwardsTies()) {
if (user.getMonthTotal() != lastTotal) {
i++;
}
} else {
i++;
}
if (places.containsKey(i)) {
user.giveMonthlyTopVoterAward(i, places.get(i));
}
}
lastTotal = user.getMonthTotal();
}
}
resetMonthlyTotals();
if (Config.getInstance().getResetMilestonesMonthly()) {
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
user.setMilestoneCount(0);
user.setHasGottenMilestone(new HashMap<String, Boolean>());
}
}
}
use of com.Ben12345rocks.VotingPlugin.Objects.User in project VotingPlugin by Ben12345rocks.
the class TopVoterHandler method updateTopVoters.
public synchronized void updateTopVoters(ArrayList<User> users1) {
ArrayList<User> users = new ArrayList<User>();
ArrayList<String> blackList = getTopVoterBlackList();
for (User user : users1) {
if (!blackList.contains(user.getPlayerName())) {
if ((!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) && !user.isBanned()) {
users.add(user);
}
}
}
plugin.topVoterAllTime.clear();
if (Config.getInstance().getLoadTopVoterAllTime()) {
for (User user : users) {
int total = user.getAllTimeTotal();
if (total > 0) {
plugin.topVoterAllTime.put(user, total);
}
}
plugin.topVoterAllTime = sortByValues(plugin.topVoterAllTime, false);
plugin.debug("All Time TopVoter loaded");
}
plugin.topVoterMonthly.clear();
if (Config.getInstance().getLoadTopVoterMonthly()) {
for (User user : users) {
int total = user.getMonthTotal();
if (total > 0) {
plugin.topVoterMonthly.put(user, total);
}
}
plugin.topVoterMonthly = sortByValues(plugin.topVoterMonthly, false);
plugin.debug("Monthly TopVoter loaded");
}
plugin.topVoterWeekly.clear();
if (Config.getInstance().getLoadTopVoterWeekly()) {
for (User user : users) {
int total = user.getWeeklyTotal();
if (total > 0) {
plugin.topVoterWeekly.put(user, total);
}
}
plugin.topVoterWeekly = sortByValues(plugin.topVoterWeekly, false);
plugin.debug("Weekly TopVoter loaded");
}
plugin.topVoterDaily.clear();
if (Config.getInstance().getLoadTopVoterDaily()) {
for (User user : users) {
int total = user.getDailyTotal();
if (total > 0) {
plugin.topVoterDaily.put(user, total);
}
}
plugin.topVoterDaily = sortByValues(plugin.topVoterDaily, false);
plugin.debug("Daily TopVoter loaded");
}
plugin.debug("Updated TopVoter");
}
use of com.Ben12345rocks.VotingPlugin.Objects.User in project VotingPlugin by Ben12345rocks.
the class PlaceHolders method getPlaceHolder.
public synchronized String getPlaceHolder(Player p, String identifier) {
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
User user = UserManager.getInstance().getVotingPluginUser(p);
// %VotingPlugin_total% - Total votes of all vote sites
if (identifier.equalsIgnoreCase("total")) {
return Integer.toString(user.getMonthTotal());
} else if (identifier.equalsIgnoreCase("alltimetotal")) {
return Integer.toString(user.getAllTimeTotal());
} else if (identifier.equalsIgnoreCase("lastmonthtotal")) {
return Integer.toString(user.getLastMonthTotal());
}
String[] args = identifier.split("_");
if (args.length > 1 && args[0].equalsIgnoreCase("total")) {
if (args[1].equalsIgnoreCase("all")) {
return Integer.toString(user.getAllTimeTotal());
} else if (args[1].equalsIgnoreCase("month")) {
return Integer.toString(user.getMonthTotal());
} else if (args[1].equalsIgnoreCase("week")) {
return Integer.toString(user.getWeeklyTotal());
} else if (args[1].equalsIgnoreCase("daily")) {
return Integer.toString(user.getDailyTotal());
}
}
if (identifier.equalsIgnoreCase("BestDailyTotal")) {
return "" + user.getHighestDailyTotal();
} else if (identifier.equalsIgnoreCase("BestWeeklyTotal")) {
return "" + user.getHighestWeeklyTotal();
} else if (identifier.equalsIgnoreCase("BestMonthlyTotal")) {
return "" + user.getHighestMonthlyTotal();
} else if (identifier.equalsIgnoreCase("DailyVoteStreak")) {
return "" + user.getDayVoteStreak();
} else if (identifier.equalsIgnoreCase("WeeklyVoteStreak")) {
return "" + user.getWeekVoteStreak();
} else if (identifier.equalsIgnoreCase("MonthlyVoteStreak")) {
return "" + user.getMonthVoteStreak();
} else if (identifier.equalsIgnoreCase("BestDailyVoteStreak")) {
return "" + user.getBestDayVoteStreak();
} else if (identifier.equalsIgnoreCase("BestWeeklyVoteStreak")) {
return "" + user.getBestWeekVoteStreak();
} else if (identifier.equalsIgnoreCase("BestMonthlyVoteStreak")) {
return "" + user.getBestMonthVoteStreak();
}
// %VotingPlugin_points% - Total votes of all vote sites
if (identifier.equalsIgnoreCase("points")) {
return Integer.toString(user.getPoints());
}
// vote party rewards
if (identifier.equalsIgnoreCase("VotePartyVotesNeeded")) {
return Integer.toString(VoteParty.getInstance().getNeededVotes());
} else if (identifier.equalsIgnoreCase("VotePartyVotesCurrent")) {
return Integer.toString(VoteParty.getInstance().getTotalVotes());
} else if (identifier.equalsIgnoreCase("VotePartyVotesRequired")) {
return Integer.toString(VoteParty.getInstance().getVotesRequired());
}
// sites
if (identifier.equalsIgnoreCase("canvote")) {
return Boolean.toString(user.canVoteAll());
}
// %VotingPlugin_next_SITENAME% - Next time you can vote for voteSite
if (startsWithIgnoreCase(identifier, "next")) {
if (args.length > 1) {
String str = args[1];
for (int i = 2; i < args.length; i++) {
str += "_" + args[i];
}
return playerNextVote(user, str);
} else {
return "";
}
}
// %VotingPlugin_last_SITENAME% - Next time you can vote for voteSite
if (startsWithIgnoreCase(identifier, "last")) {
if (args.length > 1) {
String str = args[1];
for (int i = 2; i < args.length; i++) {
str += "_" + args[i];
}
return playerLastVote(user, str);
}
}
if (args.length > 2) {
if (args[0].equalsIgnoreCase("top")) {
if (StringUtils.getInstance().isInt(args[2])) {
int number = Integer.parseInt(args[2]);
int num = 1;
if (args[1].equalsIgnoreCase("all")) {
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
if (num == number) {
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
return "" + entry.getValue().intValue();
} else {
return entry.getKey().getPlayerName();
}
}
num++;
}
} else if (args[1].equalsIgnoreCase("month")) {
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
if (num == number) {
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
return "" + entry.getValue().intValue();
} else {
return entry.getKey().getPlayerName();
}
}
num++;
}
} else if (args[1].equalsIgnoreCase("week")) {
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
if (num == number) {
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
return "" + entry.getValue().intValue();
} else {
return entry.getKey().getPlayerName();
}
}
num++;
}
} else if (args[1].equalsIgnoreCase("daily")) {
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
if (num == number) {
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
return "" + entry.getValue().intValue();
} else {
return entry.getKey().getPlayerName();
}
}
num++;
}
}
} else if (args[2].equalsIgnoreCase("Position")) {
int num = 1;
if (args[1].equalsIgnoreCase("all")) {
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
return "" + num;
}
num++;
}
} else if (args[1].equalsIgnoreCase("month")) {
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
return "" + num;
}
num++;
}
} else if (args[1].equalsIgnoreCase("week")) {
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
return "" + num;
}
num++;
}
} else if (args[1].equalsIgnoreCase("daily")) {
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
return "" + num;
}
num++;
}
}
}
}
}
return identifier;
}
use of com.Ben12345rocks.VotingPlugin.Objects.User in project VotingPlugin by Ben12345rocks.
the class VoteParty method reset.
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) {
user.setVotePartyVotes(0);
}
}
}
Aggregations