Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23ffc18289 | ||
|
|
2152a6688f | ||
|
|
c3220392eb | ||
|
|
fec401485b | ||
|
|
2b2a6385b4 | ||
|
|
9937f3d9c0 | ||
|
|
b276d516a6 | ||
|
|
d6a336e9b9 | ||
|
|
b356cb1794 | ||
|
|
4b0a2ee384 | ||
|
|
8dab62124e | ||
|
|
a7df1a0150 | ||
|
|
f2d7e24400 | ||
|
|
fa74bdcb3c | ||
|
|
80a4cb8f78 | ||
|
|
f16aef16d4 | ||
|
|
e7a1a1241b | ||
|
|
0ee002e3fb | ||
|
|
69ab9df8b3 | ||
|
|
54ff1dd66b | ||
|
|
75732910e2 | ||
|
|
9c6614836a | ||
|
|
72148816e5 | ||
|
|
f969c91170 | ||
|
|
904d660919 | ||
|
|
fb5449effe | ||
|
|
46db998e17 | ||
|
|
2bcf096584 | ||
|
|
c2b7e2388e | ||
|
|
180ae04b24 | ||
|
|
73efcfb87f | ||
|
|
6ba2ff582a | ||
|
|
d622b5b684 | ||
|
|
2247134daa | ||
|
|
7de7150e41 | ||
|
|
be23989a20 | ||
|
|
8c4bdc8e20 | ||
|
|
f4d507d821 | ||
|
|
43fd338efd | ||
|
|
c51873e7b2 |
No files matched your search
@@ -108,12 +108,6 @@ Commands:
|
||||
# Set Message to '' (2 ') to disable message
|
||||
|
||||
Format:
|
||||
# Message when player tries to run command without required permissions
|
||||
NoPerms: '&cYou do not have enough permission!'
|
||||
|
||||
# Message when player types a command but does not input a number where needed
|
||||
NotNumber: '&cError on &6%arg%&c, number expected!'
|
||||
|
||||
# CommandHandler help message
|
||||
HelpLine: '&3&l%Command% - &3%HelpMessage%'
|
||||
|
||||
@@ -160,7 +154,7 @@ Format:
|
||||
# If there is an error finding out time until next vote
|
||||
Error: '&cCould not caculate time until next vote!'
|
||||
# For sites that have this, requires votedelaydaily to be set to true in the site
|
||||
VoteDelayDaily: 'Tomorrow'
|
||||
VoteDelayDaily: '%hours% Hours and %minutes% Minutes'
|
||||
|
||||
# Format for /vote last
|
||||
Last:
|
||||
@@ -524,6 +518,7 @@ BackButton:
|
||||
Amount: 1
|
||||
Name: '&8Back to VoteGUI'
|
||||
|
||||
VoteShopBackButton: true
|
||||
Shop:
|
||||
# Identifier
|
||||
# Used in placeholders for formats
|
||||
@@ -596,6 +591,8 @@ VoteParty:
|
||||
GiveAllPlayers: false
|
||||
# If true, the vote count will reset each day
|
||||
ResetEachDay: false
|
||||
# Count votes from /av vote?
|
||||
CountFakeVotes: true
|
||||
# Number of user votes that apply to vote party total the user needs to get rewards
|
||||
UserVotesRequired: 0
|
||||
# Broadcast when vote party reached
|
||||
@@ -778,6 +775,9 @@ LogVotesToFile: false
|
||||
# Longer times result in longer wait in stuff updating after a vote, like topvoter
|
||||
DelayBetweenUpdates: 3
|
||||
|
||||
# Clear cache on update, setting to true reduces performance
|
||||
ClearCacheOnUpdate: false
|
||||
|
||||
# Set to true to disable no service site message on voting
|
||||
# You should never have to touch this if everything is setup properly
|
||||
DisableNoServiceSiteMessage: false
|
||||
@@ -785,3 +785,6 @@ DisableNoServiceSiteMessage: false
|
||||
# Used in special cases
|
||||
# Much slower, but may work better
|
||||
AlternateUUIDLookup: false
|
||||
|
||||
# Shouldn't need to change this
|
||||
AutoKillInvs: true
|
||||
@@ -156,6 +156,30 @@ commands:
|
||||
adminvoteClearCache:
|
||||
description: Command Alias
|
||||
aliases: avClearCache
|
||||
adminvoteConvertFrom:
|
||||
description: Command Alias
|
||||
aliases: avConvertFrom
|
||||
adminvoteRemovePoints:
|
||||
description: Command Alias
|
||||
aliases: avRemovePoints
|
||||
adminvoteServiceSites:
|
||||
description: Command Alias
|
||||
aliases: avServiceSites
|
||||
adminvoteSetVotePartyCount:
|
||||
description: Command Alias
|
||||
aliases: avSetVotePartyCount
|
||||
adminvoteClearOfflineVotes:
|
||||
description: Command Alias
|
||||
aliases: avClearOfflineVotes
|
||||
adminvoteGiveAll:
|
||||
description: Command Alias
|
||||
aliases: avGiveAll
|
||||
adminvoteGiveAllOnline:
|
||||
description: Command Alias
|
||||
aliases: avGiveAllOnline
|
||||
adminvoteForceTimeChanged:
|
||||
description: Command Alias
|
||||
aliases: avForceTimeChanged
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>5.9.7</version>
|
||||
<version>5.10.2</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -161,7 +161,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.Ben12345rocks.VotingPlugin.Commands.GUI.PlayerGUIs;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.TabCompleter.AliasesTabCompleter;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotiferEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
@@ -253,6 +254,27 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "ServiceSites" },
|
||||
"VotingPlugin.Commands.AdminVote.ServiceSites|" + adminPerm,
|
||||
"See a list of all service sites the server got") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cEvery service site the server has gotten:");
|
||||
|
||||
for (String serviceSites : ServerData.getInstance().getServiceSites()) {
|
||||
boolean hasSite = plugin.hasVoteSite(serviceSites);
|
||||
if (hasSite) {
|
||||
String siteName = plugin.getVoteSiteName(serviceSites);
|
||||
sendMessage(sender, serviceSites + " : Current site = " + siteName);
|
||||
} else {
|
||||
sendMessage(sender, serviceSites + " : No site with this service site, did you do something wrong?");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "Help&?", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.Help|" + adminPerm, "See this page") {
|
||||
|
||||
@@ -448,7 +470,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotiferEvent.playerVote(args[1], args[2]);
|
||||
VotiferEvent.playerVote(args[1], args[2], false);
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2]),
|
||||
UserManager.getInstance().getVotingPluginUser(args[1]));
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
@@ -576,6 +598,16 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "SetVotePartyCount", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.SetVotePartyCount|" + adminPerm, "Set voteparty count") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
plugin.getVoteParty().setTotalVotes(Integer.parseInt(args[1]));
|
||||
sendMessage(sender, "&cSet vote party count to " + args[1]);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "ClearOfflineVotes" },
|
||||
"VotingPlugin.Commands.AdminVote.ClearOfflineVotes|" + adminPerm, "Clear all offline votes") {
|
||||
|
||||
@@ -673,7 +705,8 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
VotiferEvent.playerVote(
|
||||
UserGUI.getInstance().getCurrentPlayer(player), value);
|
||||
UserGUI.getInstance().getCurrentPlayer(player), value,
|
||||
false);
|
||||
|
||||
player.sendMessage("Forced vote for "
|
||||
+ UserGUI.getInstance().getCurrentPlayer(player)
|
||||
@@ -988,7 +1021,12 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
PlayerGUIs.getInstance().openVoteGUI(player, UserManager.getInstance().getVotingPluginUser(args[1]));
|
||||
if (com.Ben12345rocks.AdvancedCore.UserManager.UserManager.getInstance().userExist(args[1])) {
|
||||
PlayerGUIs.getInstance().openVoteGUI(player,
|
||||
UserManager.getInstance().getVotingPluginUser(args[1]));
|
||||
} else {
|
||||
sendMessage(sender, "&cUser does not exist: " + args[1]);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -467,9 +467,6 @@ public class Commands {
|
||||
return ArrayUtils.getInstance().convert(ArrayUtils.getInstance().colorize(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update vote today.
|
||||
*/
|
||||
public void updateVoteToday(ArrayList<User> users) {
|
||||
plugin.voteToday.clear();
|
||||
|
||||
@@ -615,7 +612,18 @@ public class Commands {
|
||||
}
|
||||
} else {
|
||||
if (lastVote.getDayOfYear() == now.getDayOfYear() && lastVote.getYear() == now.getYear()) {
|
||||
info = config.getFormatCommandsVoteNextInfoVoteDelayDaily();
|
||||
LocalDateTime midnight = LocalDateTime.now().plusDays(1).withHour(0).withMinute(0);
|
||||
Duration dur = Duration.between(now, midnight);
|
||||
|
||||
int diffHours = (int) (dur.getSeconds() / (60 * 60));
|
||||
long diffMinutes = dur.getSeconds() / 60 - diffHours*60;
|
||||
|
||||
String timeMsg = config.getFormatCommandsVoteNextInfoVoteDelayDaily();
|
||||
timeMsg = StringUtils.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
|
||||
timeMsg = StringUtils.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
|
||||
Long.toString(diffMinutes));
|
||||
info = timeMsg;
|
||||
|
||||
} else {
|
||||
info = config.getFormatCommandsVoteNextInfoCanVote();
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
@@ -98,7 +100,7 @@ public class PlayerGUIs {
|
||||
&& !player.hasPermission("VotingPlugin.Mod"))
|
||||
|| (!player.hasPermission("VotingPlugin.Commands.Vote.GUI")
|
||||
&& !player.hasPermission("VotingPlugin.Player"))) {
|
||||
player.sendMessage(AdvancedCoreHook.getInstance().getFormatNoPerms());
|
||||
player.sendMessage(StringUtils.getInstance().colorize(AdvancedCoreHook.getInstance().getFormatNoPerms()));
|
||||
return;
|
||||
}
|
||||
setSelectedPlayer(player, user);
|
||||
@@ -182,7 +184,7 @@ public class PlayerGUIs {
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteLastName(), "player", user.getPlayerName()));
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new BInventoryButton(new ItemBuilder(site.getItem()).setName(site.getDisplayName())
|
||||
new BInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(Commands.getInstance().voteCommandLastLine(user, site)).setAmountNone(1)) {
|
||||
|
||||
@Override
|
||||
@@ -212,7 +214,7 @@ public class PlayerGUIs {
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteNextName(), "player", user.getPlayerName()));
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new BInventoryButton(new ItemBuilder(site.getItem()).setName(site.getDisplayName())
|
||||
new BInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(Commands.getInstance().voteCommandNextInfo(user, site)).setAmountNone(1)) {
|
||||
|
||||
@Override
|
||||
@@ -310,6 +312,7 @@ public class PlayerGUIs {
|
||||
}
|
||||
|
||||
public void openVoteToday(Player player) {
|
||||
setSelectedPlayer(player, null);
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteTodayName());
|
||||
for (User user : plugin.voteToday.keySet()) {
|
||||
|
||||
@@ -374,12 +377,20 @@ public class PlayerGUIs {
|
||||
.addLoreLine(Config.getInstance().getGUIVoteTopItemLore())
|
||||
.addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
.addPlaceholder("votes", "" + entry.getValue())
|
||||
.addLoreLine("&3Name: " + entry.getKey().getPlayerName())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
User user = UserManager.getInstance()
|
||||
.getVotingPluginUser(clickEvent.getClickedItem().getItemMeta().getDisplayName());
|
||||
String name = "";
|
||||
ItemBuilder item = new ItemBuilder(clickEvent.getClickedItem());
|
||||
for (String lore : item.getLore()) {
|
||||
if (lore.contains("Name:")) {
|
||||
name = ChatColor.stripColor(item.getName()).split(":")[1].trim();
|
||||
plugin.debug(name);
|
||||
}
|
||||
}
|
||||
User user = UserManager.getInstance().getVotingPluginUser(name);
|
||||
openVoteGUI(player, user);
|
||||
}
|
||||
});
|
||||
@@ -391,12 +402,16 @@ public class PlayerGUIs {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
openVoteTop(player, cur.next());
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
openVoteTop(player, cur.next());
|
||||
} else {
|
||||
openVoteTop(player, cur.prev());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteTopBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
inv.getPageButtons().add(new BInventoryButton(getBackButton().setSlot(1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -465,6 +480,7 @@ public class PlayerGUIs {
|
||||
* the player
|
||||
*/
|
||||
public void openVoteURL(Player player) {
|
||||
setSelectedPlayer(player, null);
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteURLName());
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
@@ -608,7 +624,7 @@ public class PlayerGUIs {
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
try {
|
||||
ItemBuilder builder = new ItemBuilder(voteSite.getItem());
|
||||
ItemBuilder builder = voteSite.getItem();
|
||||
final VoteSite site = voteSite;
|
||||
|
||||
inv.addButton(count, new BInventoryButton(builder) {
|
||||
|
||||
@@ -383,7 +383,12 @@ public class Config extends YMLFile {
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteNextInfoVoteDelayDaily() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Info.VoteDelayDaily", "Tomorrow");
|
||||
return getData().getString("Format.Commands.Vote.Next.Info.VoteDelayDaily",
|
||||
"%hours% Hours and %minutes% Minutes");
|
||||
}
|
||||
|
||||
public boolean getVoteShopBackButton() {
|
||||
return getData().getBoolean("VoteShopBackButton", true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -867,11 +872,19 @@ public class Config extends YMLFile {
|
||||
public int getMysqlMaxSize() {
|
||||
return getData().getInt("MySQL.MaxSize", -1);
|
||||
}
|
||||
|
||||
|
||||
public ConfigurationSection getBackButton() {
|
||||
return getData().getConfigurationSection("BackButton");
|
||||
}
|
||||
|
||||
public boolean getAutoKillInvs() {
|
||||
return getData().getBoolean("AutoKillInvs", true);
|
||||
}
|
||||
|
||||
public boolean getVotePartyCountFakeVotes() {
|
||||
return getData().getBoolean("VoteParty.CountFakeVotes", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly awards enabled.
|
||||
*
|
||||
@@ -881,6 +894,10 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("EnableMonthlyAwards");
|
||||
}
|
||||
|
||||
public boolean getClearCacheOnUpdate() {
|
||||
return getData().getBoolean("ClearCacheOnUpdate");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly possible reward places.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -224,4 +225,20 @@ public class ServerData {
|
||||
public void updateValues() {
|
||||
setVersion();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getServiceSites() {
|
||||
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public void addServiceSite(String site) {
|
||||
ArrayList<String> l = getServiceSites();
|
||||
l.add(site);
|
||||
setServiceSites(l);
|
||||
}
|
||||
|
||||
public void setServiceSites(ArrayList<String> list) {
|
||||
getData().set("ServiceSites", list);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,11 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.OtherRewards.OtherVoteReward;
|
||||
@@ -34,25 +36,21 @@ public class VotiferEvent implements Listener {
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Player vote.
|
||||
*
|
||||
* @param playerName
|
||||
* the player name
|
||||
* @param voteSiteURL
|
||||
* the vote site URL
|
||||
*/
|
||||
public static void playerVote(final String playerName, final String voteSiteURL) {
|
||||
playerVote(playerName, voteSiteURL, true);
|
||||
}
|
||||
|
||||
public static void playerVote(final String playerName, final String voteSiteURL, final boolean realVote) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (configVoteSites) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
if (!user.hasLoggedOnBefore() && !config.allowUnJoined()) {
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName) && !config.allowUnJoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
return;
|
||||
}
|
||||
User user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(voteSiteURL);
|
||||
if (voteSite == null) {
|
||||
@@ -73,9 +71,11 @@ public class VotiferEvent implements Listener {
|
||||
|
||||
// vote party
|
||||
if (Config.getInstance().getVotePartyEnabled()) {
|
||||
VoteParty.getInstance().addTotal(user);
|
||||
VoteParty.getInstance().addVotePlayer(user);
|
||||
VoteParty.getInstance().check();
|
||||
if (Config.getInstance().getVotePartyCountFakeVotes() || realVote) {
|
||||
VoteParty.getInstance().addTotal(user);
|
||||
VoteParty.getInstance().addVotePlayer(user);
|
||||
VoteParty.getInstance().check();
|
||||
}
|
||||
}
|
||||
|
||||
// broadcast vote if enabled in config
|
||||
@@ -109,7 +109,9 @@ public class VotiferEvent implements Listener {
|
||||
user.closeInv();
|
||||
} else {
|
||||
user.addOfflineVote(voteSite.getKey());
|
||||
plugin.debug("Offline vote set for " + playerName + " on " + voteSite.getKey());
|
||||
// plugin.debug(ArrayUtils.getInstance().makeStringList(user.getOfflineVotes()));
|
||||
plugin.debug("Offline vote set for " + playerName + " (" + user.getUUID() + ") on "
|
||||
+ voteSite.getKey());
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
@@ -140,7 +142,8 @@ public class VotiferEvent implements Listener {
|
||||
|
||||
Vote vote = event.getVote();
|
||||
final String voteSite = vote.getServiceName();
|
||||
final String voteUsername = vote.getUsername();
|
||||
final String voteUsername = vote.getUsername().trim();
|
||||
ServerData.getInstance().addServiceSite(voteSite);
|
||||
|
||||
if (voteUsername.length() == 0) {
|
||||
plugin.getLogger().warning("No name from vote on " + voteSite);
|
||||
@@ -178,7 +181,7 @@ public class VotiferEvent implements Listener {
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
}
|
||||
|
||||
playerVote(voteUsername, voteSite);
|
||||
playerVote(voteUsername, voteSite, true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
@@ -16,6 +17,7 @@ import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -74,16 +76,16 @@ public class Main extends JavaPlugin {
|
||||
public static Main plugin;
|
||||
|
||||
/** The top voter monthly. */
|
||||
public HashMap<User, Integer> topVoterAllTime;
|
||||
public LinkedHashMap<User, Integer> topVoterAllTime;
|
||||
|
||||
/** The top voter monthly. */
|
||||
public HashMap<User, Integer> topVoterMonthly;
|
||||
public LinkedHashMap<User, Integer> topVoterMonthly;
|
||||
|
||||
/** The top voter weekly. */
|
||||
public HashMap<User, Integer> topVoterWeekly;
|
||||
public LinkedHashMap<User, Integer> topVoterWeekly;
|
||||
|
||||
/** The top voter daily. */
|
||||
public HashMap<User, Integer> topVoterDaily;
|
||||
public LinkedHashMap<User, Integer> topVoterDaily;
|
||||
|
||||
/** The updater. */
|
||||
public Updater updater;
|
||||
@@ -98,7 +100,7 @@ public class Main extends JavaPlugin {
|
||||
private List<VoteSite> voteSites;
|
||||
|
||||
/** The vote today. */
|
||||
public HashMap<User, HashMap<VoteSite, LocalDateTime>> voteToday;
|
||||
public LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> voteToday;
|
||||
|
||||
/** The signs. */
|
||||
public ArrayList<SignHandler> signs;
|
||||
@@ -108,6 +110,8 @@ public class Main extends JavaPlugin {
|
||||
|
||||
private boolean update = true;
|
||||
|
||||
private boolean updateStarted = false;
|
||||
|
||||
/**
|
||||
* Check votifier.
|
||||
*/
|
||||
@@ -646,6 +650,9 @@ public class Main extends JavaPlugin {
|
||||
loadVoteSites();
|
||||
updateAdvancedCoreHook();
|
||||
AdvancedCoreHook.getInstance().loadHook(this);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
debug("UseBatchUpdates: " + AdvancedCoreHook.getInstance().getMysql().isUseBatchUpdates());
|
||||
}
|
||||
registerCommands();
|
||||
registerEvents();
|
||||
checkVotifier();
|
||||
@@ -664,11 +671,11 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
});
|
||||
|
||||
topVoterMonthly = new HashMap<User, Integer>();
|
||||
topVoterWeekly = new HashMap<User, Integer>();
|
||||
topVoterDaily = new HashMap<User, Integer>();
|
||||
voteToday = new HashMap<User, HashMap<VoteSite, LocalDateTime>>();
|
||||
topVoterAllTime = new HashMap<User, Integer>();
|
||||
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"));
|
||||
|
||||
@@ -776,10 +783,34 @@ public class Main extends JavaPlugin {
|
||||
* Setup files.
|
||||
*/
|
||||
public void setupFiles() {
|
||||
config = Config.getInstance();
|
||||
configVoteSites = ConfigVoteSites.getInstance();
|
||||
config.setup();
|
||||
configVoteSites.setup();
|
||||
try {
|
||||
config = Config.getInstance();
|
||||
config.setup();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().severe("Failed to load Config.yml");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
try {
|
||||
configVoteSites = ConfigVoteSites.getInstance();
|
||||
configVoteSites.setup();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().severe("Failed to load VoteSites.yml");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
plugin.debug("Loaded Files");
|
||||
|
||||
@@ -789,7 +820,9 @@ public class Main extends JavaPlugin {
|
||||
* Update.
|
||||
*/
|
||||
public void update() {
|
||||
if (update && plugin != null) {
|
||||
if (update && plugin != null && !updateStarted) {
|
||||
updateStarted = true;
|
||||
update = false;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -799,12 +832,15 @@ public class Main extends JavaPlugin {
|
||||
if (AdvancedCoreHook.getInstance().getMysql() == null) {
|
||||
plugin.debug("MySQL not loaded yet");
|
||||
return;
|
||||
} else {
|
||||
} else if (Config.getInstance().getClearCacheOnUpdate()) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
} else {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCacheBasic();
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
|
||||
plugin.debug("Starting background task");
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
ArrayList<User> users = new ArrayList<User>();
|
||||
@@ -812,12 +848,20 @@ public class Main extends JavaPlugin {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
users.add(user);
|
||||
}
|
||||
plugin.debug("Finished loading player data");
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug(
|
||||
"Finished loading player data in " + time1 + " seconds, " + users.size() + " users");
|
||||
TopVoterHandler.getInstance().updateTopVoters(users);
|
||||
Commands.getInstance().updateVoteToday(users);
|
||||
ServerData.getInstance().updateValues();
|
||||
Signs.getInstance().updateSigns();
|
||||
plugin.debug("Background task ran");
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
UserManager.getInstance().getVotingPluginUser(player).offVote();
|
||||
}
|
||||
time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Background task finished in " + time1 + " seconds");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
plugin.getLogger().info("Looks like something went wrong.");
|
||||
@@ -826,9 +870,14 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
|
||||
});
|
||||
updateStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
public VoteParty getVoteParty() {
|
||||
return VoteParty.getInstance();
|
||||
}
|
||||
|
||||
public void updateAdvancedCoreHook() {
|
||||
AdvancedCoreHook.getInstance().setMaxMysqlSize(Config.getInstance().getMysqlMaxSize());
|
||||
AdvancedCoreHook.getInstance().setAutoDownload(Config.getInstance().getAutoDownload());
|
||||
@@ -849,6 +898,7 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().setLogDebugToFile(Config.getInstance().getLogDebugToFile());
|
||||
AdvancedCoreHook.getInstance().setSendScoreboards(Config.getInstance().getSendScoreboards());
|
||||
AdvancedCoreHook.getInstance().setAlternateUUIDLookUp(Config.getInstance().getAlternateUUIDLookup());
|
||||
AdvancedCoreHook.getInstance().setAutoKillInvs(Config.getInstance().getAutoKillInvs());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public enum TopVoter {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return AllTime;
|
||||
}
|
||||
|
||||
public TopVoter next() {
|
||||
@@ -49,4 +49,21 @@ public enum TopVoter {
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
|
||||
public TopVoter prev() {
|
||||
switch (this) {
|
||||
case AllTime:
|
||||
return Daily;
|
||||
case Daily:
|
||||
return Weekly;
|
||||
case Monthly:
|
||||
return AllTime;
|
||||
case Weekly:
|
||||
return Monthly;
|
||||
default:
|
||||
return AllTime;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,10 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
* Adds the points.
|
||||
*/
|
||||
public void addPoints() {
|
||||
addPoints(Config.getInstance().getPointsOnVote());
|
||||
int points = Config.getInstance().getPointsOnVote();
|
||||
if (points != 0) {
|
||||
addPoints(points);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,9 +133,9 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
*
|
||||
*/
|
||||
public void addTotal() {
|
||||
setMilestoneCount(getMilestoneCount() + 1);
|
||||
addMonthTotal();
|
||||
addAllTimeTotal();
|
||||
setMilestoneCount(getMilestoneCount()+1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -559,16 +562,22 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
if (player != null) {
|
||||
setTopVoterIgnore(player.hasPermission("VotingPlugin.TopVoter.Ignore"));
|
||||
ArrayList<String> offlineVotes = getOfflineVotes();
|
||||
// plugin.debug(ArrayUtils.getInstance().makeStringList(offlineVotes));
|
||||
if (offlineVotes.size() > 0) {
|
||||
sendVoteEffects(true);
|
||||
}
|
||||
|
||||
for (int i = 0; i < offlineVotes.size(); i++) {
|
||||
if (plugin.hasVoteSite(offlineVotes.get(i))) {
|
||||
plugin.debug("Giving offline site reward: " + offlineVotes.get(i));
|
||||
playerVote(plugin.getVoteSite(offlineVotes.get(i)), false, true);
|
||||
} else {
|
||||
plugin.debug("Site doesn't exist: " + offlineVotes.get(i));
|
||||
}
|
||||
}
|
||||
setOfflineVotes(new ArrayList<String>());
|
||||
if (!offlineVotes.isEmpty()) {
|
||||
setOfflineVotes(new ArrayList<String>());
|
||||
}
|
||||
|
||||
giveOfflineOtherRewards();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
@@ -96,8 +98,13 @@ public class VoteSite {
|
||||
/**
|
||||
* @return the item
|
||||
*/
|
||||
public ConfigurationSection getItem() {
|
||||
return item;
|
||||
public ItemBuilder getItem() {
|
||||
if (item == null) {
|
||||
plugin.getLogger().warning("Invalid item section in site: " + key);
|
||||
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid item for site: " + key);
|
||||
} else {
|
||||
return new ItemBuilder(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -248,9 +248,9 @@ public class TopVoterHandler implements Listener {
|
||||
* the order, false for high to low
|
||||
* @return the hash map
|
||||
*/
|
||||
public HashMap<User, Integer> sortByValues(HashMap<User, Integer> unsortMap, final boolean order) {
|
||||
public LinkedHashMap<User, Integer> sortByValues(LinkedHashMap<User, Integer> topVoterAllTime, final boolean order) {
|
||||
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(unsortMap.entrySet());
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(topVoterAllTime.entrySet());
|
||||
|
||||
// Sorting the list based on values
|
||||
Collections.sort(list, new Comparator<Entry<User, Integer>>() {
|
||||
@@ -266,11 +266,11 @@ public class TopVoterHandler implements Listener {
|
||||
});
|
||||
|
||||
// Maintaining insertion order with the help of LinkedList
|
||||
HashMap<User, Integer> sortedMap = new LinkedHashMap<User, Integer>();
|
||||
LinkedHashMap<User, Integer> sortedMap = new LinkedHashMap<User, Integer>();
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
sortedMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
|
||||
return sortedMap;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,16 +33,16 @@ public class UserManager {
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(OfflinePlayer player) {
|
||||
return getVotingPluginUser(new UUID(player.getUniqueId().toString()));
|
||||
return getVotingPluginUser(player.getName());
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(Player player) {
|
||||
return getVotingPluginUser(new UUID(player.getUniqueId().toString()));
|
||||
return getVotingPluginUser(player.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public User getVotingPluginUser(String playerName) {
|
||||
return new User(playerName);
|
||||
return new User(com.Ben12345rocks.AdvancedCore.UserManager.UserManager.getInstance().getProperName(playerName));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -116,6 +116,7 @@ public class VoteReminding {
|
||||
if (Config.getInstance().getVoteRemindingEnabled()
|
||||
&& (!UserManager.getInstance().getAllUUIDs().contains(user.getUUID()) || user.canVoteAll())) {
|
||||
giveReward(user);
|
||||
user.setReminded(true);
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.GUI.PlayerGUIs;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
@@ -60,6 +61,18 @@ public class VoteShop {
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVoteShopBackButton()) {
|
||||
inv.addButton(new BInventoryButton(PlayerGUIs.getInstance().getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
PlayerGUIs.getInstance().openVoteGUI(event.getPlayer(),
|
||||
UserManager.getInstance().getVotingPluginUser(player));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user