Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
beb1b70f50 | ||
|
|
f52edad583 | ||
|
|
0a1283de4b | ||
|
|
bed263aa87 | ||
|
|
55d8d20f88 | ||
|
|
3a59e2cdc2 | ||
|
|
57fb754bc0 | ||
|
|
052b48348b | ||
|
|
5d15747c4e | ||
|
|
ce09359445 | ||
|
|
c22792bd9b | ||
|
|
4ab36c355e | ||
|
|
0b3829c1b4 | ||
|
|
ae4883f099 | ||
|
|
2e3cf25e57 | ||
|
|
e65b831f35 | ||
|
|
b6dc426eed | ||
|
|
a4f7619ca3 |
No files matched your search
@@ -6,11 +6,9 @@ https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
## License
|
||||
### Creative Commons Arttribution 3.0 Unported
|
||||
https://github.com/Ben12345rocks/VotingPlugin/blob/master/VotingPlugin/LICENSE.txt
|
||||
https://github.com/Ben12345rocks/VotingPlugin/blob/master/VotingPlugin/Resources/LICENSE.txt
|
||||
|
||||
### Maven:
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@ MySQL:
|
||||
# Recommend: False (Will prevent creating random user data)
|
||||
AllowUnjoined: false
|
||||
|
||||
# Use server lookup for when allowunjoined is set to false
|
||||
# Recommend leaving enabled unless you face issues
|
||||
AllowUnJoinedCheckServer: true
|
||||
|
||||
# ------------------------------------------------
|
||||
# VoteReminding
|
||||
# ------------------------------------------------
|
||||
@@ -237,7 +241,7 @@ Format:
|
||||
# %Points% = player points
|
||||
Points: '&a%Player% currently has &a&l%Points%&a Points!'
|
||||
|
||||
ToggleBroadcast:
|
||||
ToggleBroadcasts:
|
||||
Enabled: '&cYou will now see vote broadcasts'
|
||||
Disabled: '&cYou will no longer see vote broadcasts'
|
||||
|
||||
@@ -847,11 +851,11 @@ DebugInGame: false
|
||||
|
||||
# Will log debug messages to VotingPlugin/Log/log.txt
|
||||
# Requires Debug to be on
|
||||
# Only needed for extra cases
|
||||
# Only needed for extreme cases
|
||||
#LogDebugToFile: false
|
||||
|
||||
# Options for request api
|
||||
# Current methods
|
||||
# Current methods:
|
||||
# ANVIL
|
||||
# BOOK
|
||||
# CHAT
|
||||
@@ -938,6 +942,10 @@ WaitUntilLoggedIn: true
|
||||
# If false, skulls will be cached as they are used
|
||||
PreloadSkulls: false
|
||||
|
||||
# Setting to false disables saving skulls in a cache to improve speeds
|
||||
# Will reduce ram usage if disabled
|
||||
LoadSkulls: true
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Mysql cache options
|
||||
# Clearing cache forces the plugin to pull from database
|
||||
|
||||
@@ -61,6 +61,12 @@ commands:
|
||||
votepoints:
|
||||
description: A command
|
||||
aliases: vpoints
|
||||
votelist:
|
||||
description: A command
|
||||
aliases: vlist
|
||||
voteall:
|
||||
description: A command
|
||||
aliases: vall
|
||||
votechoices:
|
||||
description: A command
|
||||
alaises: vchoices
|
||||
@@ -85,6 +91,9 @@ commands:
|
||||
adminvotereload:
|
||||
description: Command Alias
|
||||
aliases: avreload
|
||||
adminvotetestreward:
|
||||
description: Command Alias
|
||||
aliases: avtestreward
|
||||
adminvoteversion:
|
||||
description: Command Alias
|
||||
aliases: avversion
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>5.19.3</version>
|
||||
<version>5.20.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
|
||||
@@ -2049,6 +2049,20 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getVoteCommand().add(new CommandHandler(new String[] { "List&All" },
|
||||
"VotingPlugin.Commands.Vote.List|" + playerPerm, "See voting URLs") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (isPlayer(sender)) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser((Player) sender);
|
||||
user.sendMessage(Commands.getInstance().voteURLs(user));
|
||||
} else {
|
||||
sender.sendMessage(Commands.getInstance().voteURLs(null));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<CommandHandler> avCommands = com.Ben12345rocks.AdvancedCore.Commands.CommandLoader.getInstance()
|
||||
.getBasicCommands("VotingPlugin");
|
||||
for (CommandHandler cmd : avCommands) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.EditGUI;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.EditGUIButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueBoolean;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueList;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueNumber;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueString;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
@@ -250,6 +251,20 @@ public class AdminGUI {
|
||||
}
|
||||
}));
|
||||
|
||||
if (voteSite.getSiteData().isList("Rewards")) {
|
||||
|
||||
inv.addButton(
|
||||
new EditGUIButton(new EditGUIValueList("Rewards", voteSite.getSiteData().getStringList("Rewards")) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player p, ArrayList<String> rewards) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
ConfigVoteSites.getInstance().set(voteSite.getKey(), "Rewards", rewards);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
@@ -474,53 +474,6 @@ public class PlayerGUIs {
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteTopLastMonth(Player player) {
|
||||
Set<Entry<User, Integer>> users = null;
|
||||
|
||||
users = plugin.getLastMonthTopVoter().entrySet();
|
||||
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteTopName(), "topvoter", "Last Month"));
|
||||
if (!Config.getInstance().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<User, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (Config.getInstance().isGuiVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(Config.getInstance().getGuiVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(Config.getInstance().getGUIVoteTopItemName())
|
||||
.addLoreLine(Config.getInstance().getGUIVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
User user = (User) getData("User");
|
||||
openVoteGUI(player, user);
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(getBackButton().setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(Config.getInstance().getGUIVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
public void openVoteTop(Player player, TopVoter top) {
|
||||
if (top == null) {
|
||||
top = TopVoter.getDefault();
|
||||
@@ -586,6 +539,53 @@ public class PlayerGUIs {
|
||||
|
||||
}
|
||||
|
||||
public void openVoteTopLastMonth(Player player) {
|
||||
Set<Entry<User, Integer>> users = null;
|
||||
|
||||
users = plugin.getLastMonthTopVoter().entrySet();
|
||||
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteTopName(), "topvoter", "Last Month"));
|
||||
if (!Config.getInstance().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<User, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (Config.getInstance().isGuiVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(Config.getInstance().getGuiVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(Config.getInstance().getGUIVoteTopItemName())
|
||||
.addLoreLine(Config.getInstance().getGUIVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
User user = (User) getData("User");
|
||||
openVoteGUI(player, user);
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(getBackButton().setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(Config.getInstance().getGUIVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
public void openVoteTotal(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
|
||||
@@ -287,6 +287,18 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private String formatCommandsVoteTodayLine = "&6%player% : %VoteSite% : %Time%";
|
||||
|
||||
@ConfigDataBoolean(path = "OverrideVersionDisable")
|
||||
@Getter
|
||||
private boolean overrideVersionDisable = false;
|
||||
|
||||
@ConfigDataBoolean(path = "LastMonthGUI")
|
||||
@Getter
|
||||
private boolean lastMonthGUI = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
|
||||
@Getter
|
||||
private boolean allowUnJoinedCheckServer = true;
|
||||
|
||||
/**
|
||||
* Instantiates a new config.
|
||||
*/
|
||||
@@ -1263,18 +1275,14 @@ public class Config extends YMLFile {
|
||||
return getData().getString("GUI.VoteShopName", "VoteShop");
|
||||
}
|
||||
|
||||
public boolean getVoteShopNotBuyable(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".NotBuyable", false);
|
||||
}
|
||||
|
||||
public String getVoteShopPermission(String ident) {
|
||||
return getData().getString("Shop." + ident + ".Permission", "");
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "OverrideVersionDisable")
|
||||
@Getter
|
||||
private boolean overrideVersionDisable = false;
|
||||
|
||||
@ConfigDataBoolean(path = "LastMonthGUI")
|
||||
@Getter
|
||||
private boolean lastMonthGUI = false;
|
||||
|
||||
/**
|
||||
* Gets the vote site items.
|
||||
*
|
||||
@@ -1310,10 +1318,6 @@ public class Config extends YMLFile {
|
||||
return getData().getInt("GUI.VoteReward." + siteName + ".Items." + item + ".Slot");
|
||||
}
|
||||
|
||||
public boolean getVoteShopNotBuyable(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".NotBuyable", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the votes required.
|
||||
*
|
||||
|
||||
@@ -47,7 +47,7 @@ public class PlayerJoinEvent implements Listener {
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (player.isOp() && plugin.isYmlError()) {
|
||||
user.sendMessage("&cVotingPlugin: Detected yml error, please chceck console for details");
|
||||
user.sendMessage("&cVotingPlugin: Detected yml error, please check console for details");
|
||||
}
|
||||
|
||||
// run remind
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PlayerVoteListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onplayerVote(PlayerVoteEvent event) {
|
||||
String playerName = event.getPlayer();
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName)) {
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName, Config.getInstance().isAllowUnJoinedCheckServer())) {
|
||||
if (!config.isAllowUnjoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
|
||||
@@ -102,7 +102,6 @@ public class VotiferEvent implements Listener {
|
||||
}
|
||||
plugin.getLogger()
|
||||
.info("Current known service sites: " + ArrayUtils.getInstance().makeStringList(services));
|
||||
|
||||
}
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName), voteUsername,
|
||||
|
||||
@@ -133,6 +133,9 @@ public class Main extends AdvancedCorePlugin {
|
||||
@Getter
|
||||
private boolean updateStarted = false;
|
||||
|
||||
@Getter
|
||||
private boolean ymlError = false;
|
||||
|
||||
/**
|
||||
* Check votifier.
|
||||
*/
|
||||
@@ -157,6 +160,35 @@ public class Main extends AdvancedCorePlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkYMLError() {
|
||||
if (config.isFailedToRead() || configVoteSites.isFailedToRead()) {
|
||||
ymlError = true;
|
||||
} else if (!config.isFailedToRead() && !configVoteSites.isFailedToRead()) {
|
||||
ymlError = false;
|
||||
}
|
||||
|
||||
if (config.isFailedToRead()) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().severe("Failed to load Config.yml");
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
if (configVoteSites.isFailedToRead()) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().severe("Failed to load VoteSites.yml");
|
||||
}
|
||||
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
public void convertDataStorage(UserStorage from, UserStorage to) {
|
||||
if (from == null || to == null) {
|
||||
throw new RuntimeException("Invalid Storage Method");
|
||||
@@ -831,7 +863,7 @@ public class Main extends AdvancedCorePlugin {
|
||||
}
|
||||
}));
|
||||
|
||||
for (final TopVoter top : TopVoter.values())
|
||||
for (final TopVoter top : TopVoter.values()) {
|
||||
RewardHandler.getInstance().addPlaceholder(new RewardPlaceholderHandle("Total_" + top.toString()) {
|
||||
|
||||
@Override
|
||||
@@ -840,6 +872,7 @@ public class Main extends AdvancedCorePlugin {
|
||||
return "" + vUser.getTotal(top);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
|
||||
|
||||
@@ -990,35 +1023,6 @@ public class Main extends AdvancedCorePlugin {
|
||||
|
||||
}
|
||||
|
||||
private void checkYMLError() {
|
||||
if (config.isFailedToRead() || configVoteSites.isFailedToRead()) {
|
||||
ymlError = true;
|
||||
} else if (!config.isFailedToRead() && !configVoteSites.isFailedToRead()) {
|
||||
ymlError = false;
|
||||
}
|
||||
|
||||
if (config.isFailedToRead()) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().severe("Failed to load Config.yml");
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
if (configVoteSites.isFailedToRead()) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().severe("Failed to load VoteSites.yml");
|
||||
}
|
||||
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload.
|
||||
*/
|
||||
@@ -1046,9 +1050,6 @@ public class Main extends AdvancedCorePlugin {
|
||||
});
|
||||
}
|
||||
|
||||
@Getter
|
||||
private boolean ymlError = false;
|
||||
|
||||
private void setupFiles() {
|
||||
config = Config.getInstance();
|
||||
config.setup();
|
||||
|
||||
@@ -652,9 +652,10 @@ public class User extends com.Ben12345rocks.AdvancedCore.UserManager.User {
|
||||
// plugin.debug(ArrayUtils.getInstance().makeStringList(offlineVotes));
|
||||
if (offlineVotes.size() > 0) {
|
||||
sendVoteEffects(true);
|
||||
setOfflineVotes(new ArrayList<String>());
|
||||
}
|
||||
|
||||
setOfflineVotes(new ArrayList<String>());
|
||||
|
||||
for (int i = 0; i < offlineVotes.size(); i++) {
|
||||
if (plugin.hasVoteSite(offlineVotes.get(i))) {
|
||||
plugin.debug("Giving offline site reward: " + offlineVotes.get(i));
|
||||
|
||||
@@ -144,6 +144,10 @@ public class VoteSite {
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getSiteData() {
|
||||
return configVoteSites.getData(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give rewards.
|
||||
*
|
||||
|
||||
@@ -96,6 +96,26 @@ public class TopVoterHandler implements Listener {
|
||||
return place;
|
||||
}
|
||||
|
||||
public void loadLastMonth() {
|
||||
if (Config.getInstance().isLastMonthGUI()) {
|
||||
plugin.getLastMonthTopVoter().clear();
|
||||
|
||||
LinkedHashMap<User, Integer> totals = new LinkedHashMap<User, Integer>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
int total = user.getLastMonthTotal();
|
||||
if (total > 0) {
|
||||
totals.put(user, total);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getLastMonthTopVoter().putAll(sortByValues(totals, false));
|
||||
|
||||
plugin.debug("Loaded last month top voters");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onDateChanged(DateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
@@ -570,26 +590,6 @@ public class TopVoterHandler implements Listener {
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
public void loadLastMonth() {
|
||||
if (Config.getInstance().isLastMonthGUI()) {
|
||||
plugin.getLastMonthTopVoter().clear();
|
||||
|
||||
LinkedHashMap<User, Integer> totals = new LinkedHashMap<User, Integer>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
int total = user.getLastMonthTotal();
|
||||
if (total > 0) {
|
||||
totals.put(user, total);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getLastMonthTopVoter().putAll(sortByValues(totals, false));
|
||||
|
||||
plugin.debug("Loaded last month top voters");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public synchronized void updateTopVoters(ArrayList<User> users1) {
|
||||
ArrayList<User> users = new ArrayList<User>();
|
||||
ArrayList<String> blackList = getTopVoterBlackList();
|
||||
|
||||
Reference in new issue
Block a user