Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57795bdb23 | ||
|
|
52bbb76aad | ||
|
|
1257ac4600 | ||
|
|
64ffc38405 | ||
|
|
f8009b05bc | ||
|
|
114f217046 | ||
|
|
2de309cccc | ||
|
|
7f827857bc | ||
|
|
75e244f678 | ||
|
|
a346f28df1 | ||
|
|
afa57566da | ||
|
|
6f46469ff6 | ||
|
|
7edf33a448 | ||
|
|
4d7b30eb20 | ||
|
|
ed8d92e4a4 | ||
|
|
f7e62f5790 | ||
|
|
84146236b1 | ||
|
|
97c4ee3564 | ||
|
|
f8547c5d86 | ||
|
|
c97acf7a29 | ||
|
|
fbbb11a4b0 | ||
|
|
e517bb43b8 | ||
|
|
e43ef1ea3e | ||
|
|
7ab78f30d5 | ||
|
|
668bc34157 | ||
|
|
5f89b30628 | ||
|
|
2145c9bc40 | ||
|
|
fdb3bca7f8 | ||
|
|
c96610d137 | ||
|
|
be6414602d | ||
|
|
a7b2d8010c | ||
|
|
4ccc5def2b | ||
|
|
5378d4e372 | ||
|
|
8d37d39b1c | ||
|
|
473a83604c | ||
|
|
4f72fbab78 | ||
|
|
1f62d68aed | ||
|
|
7c063bbe68 | ||
|
|
4c11df4b37 | ||
|
|
f859caf1ee | ||
|
|
566d688b57 | ||
|
|
e4209b15c3 | ||
|
|
bd5b26805a | ||
|
|
27c43b8e8e | ||
|
|
5b719141fe | ||
|
|
f8ee0bba17 | ||
|
|
d5ea3c60a9 | ||
|
|
3be9eaf47a | ||
|
|
f385927958 |
No files matched your search
@@ -85,18 +85,6 @@ VoteReminding:
|
||||
FadeIn: 10
|
||||
ShowTime: 50
|
||||
FadeOut: 10
|
||||
|
||||
Commands:
|
||||
# Wether or not the following commands will open GUIs rather than display text
|
||||
UseGUI:
|
||||
Today: true
|
||||
TopVoter: true
|
||||
Last: true
|
||||
Next: true
|
||||
Total: true
|
||||
Vote: true
|
||||
Best: true
|
||||
Streak: true
|
||||
|
||||
# ------------------------------------------------
|
||||
# Format
|
||||
@@ -110,6 +98,21 @@ Commands:
|
||||
#
|
||||
# Set Message to '' (2 ') to disable message
|
||||
|
||||
Commands:
|
||||
# Wether or not the following commands will open GUIs rather than display text
|
||||
UseGUI:
|
||||
Today: true
|
||||
TopVoter: true
|
||||
Last: true
|
||||
Next: true
|
||||
Total: true
|
||||
Vote: true
|
||||
Best: true
|
||||
Streak: true
|
||||
# If true, you can right click a votesite from /vote (gui version) and open the vote reward gui for that site
|
||||
# Can be used to display rewards for that site
|
||||
VoteRewardFromVoteURL: false
|
||||
|
||||
Format:
|
||||
# CommandHandler help message
|
||||
HelpLine: '&3&l%Command% - &3%HelpMessage%'
|
||||
@@ -230,6 +233,10 @@ Format:
|
||||
|
||||
# %Points% = player points
|
||||
Points: '&a%Player% currently has &a&l%Points%&a Points!'
|
||||
|
||||
ToggleBroadcast:
|
||||
Enabled: '&cYou will now see vote broadcasts'
|
||||
Disabled: '&cYou will no longer see vote broadcasts'
|
||||
|
||||
# Msg on top voter award, will only send message if that place has a reward set
|
||||
# %place% = place - 1,2,3,etc
|
||||
@@ -310,7 +317,7 @@ GUI:
|
||||
Slot: 1
|
||||
Last:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Last'
|
||||
@@ -436,25 +443,25 @@ GUI:
|
||||
BackButton: true
|
||||
DayTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cDaily Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
WeekTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cWeekly Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
MonthTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cMonthly Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
AllTimeTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cAllTime Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
@@ -462,19 +469,19 @@ GUI:
|
||||
Name: 'VoteBest: %player%'
|
||||
DayBest:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cDaily Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
WeekBest:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cWeekly Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
MonthBest:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cMonthly Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
@@ -483,37 +490,37 @@ GUI:
|
||||
BackButton: false
|
||||
CurrentDayStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Daily Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
CurrentWeekStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Weekly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
CurrentMonthStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Monthly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestDayStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Daily Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestWeekStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Weekly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestMonthStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Monthly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
@@ -530,6 +537,7 @@ BackButton:
|
||||
Name: '&8Back to VoteGUI'
|
||||
|
||||
VoteShopBackButton: true
|
||||
VoteShopEnabled: true
|
||||
Shop:
|
||||
# Identifier
|
||||
# Used in placeholders for formats
|
||||
@@ -546,6 +554,8 @@ Shop:
|
||||
- '&c&lCost: &c3 Voting Points'
|
||||
# Number of voting points this cost
|
||||
Cost: 3
|
||||
# Permission required, leave blank for no permission
|
||||
Permission: ''
|
||||
# Rewards to run if player buys succesfully
|
||||
Rewards:
|
||||
Items:
|
||||
@@ -597,6 +607,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
|
||||
@@ -710,6 +722,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:
|
||||
@@ -836,4 +849,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: false
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get saved)
|
||||
CreateBackups: true
|
||||
@@ -5,6 +5,7 @@ description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
author: Ben12345rocks
|
||||
softdepend: [AdvancedCore]
|
||||
api-version: 1.13
|
||||
commands:
|
||||
vote:
|
||||
description: Vote command
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>5.12.7</version>
|
||||
<version>5.14</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -165,7 +165,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -1146,6 +1146,23 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "ToggleBroadcast" },
|
||||
"VotingPlugin.Commands.Vote.ToggleBroadcast|" + playerPerm,
|
||||
"Toggle whether or not you will recieve vote broadcasts", false) {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser((Player) sender);
|
||||
boolean value = !user.getDisableBroadcast();
|
||||
user.setDisableBroadcast(value);
|
||||
if (!value) {
|
||||
sendMessage(sender, Config.getInstance().formatCommandsVoteToggleBroadcastEnabled);
|
||||
} else {
|
||||
sendMessage(sender, Config.getInstance().formatCommandsVoteToggleBroadcastDisabled);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Next", "(player)" },
|
||||
"VotingPlugin.Commands.Vote.Next.Other|" + modPerm, "See other players next votes") {
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ public class Commands {
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterAllTimeScoreBoard(Player player, int page) {
|
||||
public void sendTopVoterAllTimeScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterAllTime.keySet());
|
||||
@@ -346,8 +346,7 @@ public class Commands {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}, 90);
|
||||
}
|
||||
@@ -361,7 +360,7 @@ public class Commands {
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterDailyScoreBoard(Player player, int page) {
|
||||
public void sendTopVoterDailyScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterDaily.keySet());
|
||||
@@ -387,8 +386,7 @@ public class Commands {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}, 90);
|
||||
}
|
||||
@@ -402,7 +400,7 @@ public class Commands {
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterMonthlyScoreBoard(Player player, int page) {
|
||||
public void sendTopVoterMonthlyScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterMonthly.keySet());
|
||||
@@ -428,8 +426,7 @@ public class Commands {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}, 90);
|
||||
}
|
||||
@@ -443,7 +440,7 @@ public class Commands {
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterWeeklyScoreBoard(Player player, int page) {
|
||||
public void sendTopVoterWeeklyScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterWeekly.keySet());
|
||||
@@ -469,8 +466,7 @@ public class Commands {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}, 90);
|
||||
|
||||
@@ -485,7 +481,7 @@ public class Commands {
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendVoteTodayScoreBoard(Player player, int page) {
|
||||
public void sendVoteTodayScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
|
||||
@@ -508,8 +504,7 @@ public class Commands {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}, 90);
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ public class PlayerGUIs {
|
||||
count++;
|
||||
}
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteURLAlreadyVotedItemSection());
|
||||
if (user.canVoteSite(voteSite)) {
|
||||
builder = new ItemBuilder(Config.getInstance().getVoteURLCanVoteItemSection());
|
||||
@@ -541,14 +541,18 @@ public class PlayerGUIs {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(
|
||||
StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getGUIVoteURLURLText(), "voteurl",
|
||||
voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
if (Config.getInstance().commandsVoteRewardFromVoteURL
|
||||
&& event.getClick().equals(ClickType.RIGHT)) {
|
||||
voteReward(player, voteSite.getKey());
|
||||
} else {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getGUIVoteURLURLText(), "voteurl",
|
||||
voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -596,7 +600,7 @@ public class PlayerGUIs {
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.WATCH).setName("&4Last Vote")
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.CLOCK).setName("&4Last Vote")
|
||||
.addLoreLine(Commands.getInstance().voteCommandLastLine(user, site))) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,9 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Annotation.AnnotationHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Annotation.ConfigDataBoolean;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Annotation.ConfigDataString;
|
||||
import com.Ben12345rocks.AdvancedCore.YML.YMLFile;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
@@ -31,6 +34,10 @@ public class Config extends YMLFile {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new config.
|
||||
*/
|
||||
@@ -38,6 +45,15 @@ public class Config extends YMLFile {
|
||||
super(new File(Main.plugin.getDataFolder(), "Config.yml"));
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Enabled", defaultValue = "&cYou will now see vote broadcasts")
|
||||
public String formatCommandsVoteToggleBroadcastEnabled;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Disabled", defaultValue = "&cYou will no longer see vote broadcasts")
|
||||
public String formatCommandsVoteToggleBroadcastDisabled;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.VoteRewardFromVoteURL", defaultValue = false)
|
||||
public boolean commandsVoteRewardFromVoteURL;
|
||||
|
||||
/**
|
||||
* Allow un joined.
|
||||
*
|
||||
@@ -158,6 +174,10 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("Commands.UseGUI.Vote", true);
|
||||
}
|
||||
|
||||
public int getConvertDelay() {
|
||||
return getData().getInt("ConvertDelay", 30000);
|
||||
}
|
||||
|
||||
public boolean getCountFakeVotes() {
|
||||
return getData().getBoolean("CountFakeVotes", true);
|
||||
}
|
||||
@@ -216,15 +236,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";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -946,15 +959,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";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1149,6 +1155,10 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("VoteParty.GiveAllPlayers");
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRquired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRquired", 0);
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetEachDay() {
|
||||
return getData().getBoolean("VoteParty.ResetEachDay");
|
||||
}
|
||||
@@ -1224,10 +1234,18 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("VoteShopBackButton", true);
|
||||
}
|
||||
|
||||
public boolean getVoteShopEnabled() {
|
||||
return getData().getBoolean("VoteShopEnabled", true);
|
||||
}
|
||||
|
||||
public String getVoteShopName() {
|
||||
return getData().getString("GUI.VoteShopName", "VoteShop");
|
||||
}
|
||||
|
||||
public String getVoteShopPermission(String ident) {
|
||||
return getData().getString("Shop." + ident + ".Permission", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site items.
|
||||
*
|
||||
@@ -1357,15 +1375,8 @@ public class Config extends YMLFile {
|
||||
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";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -151,6 +151,10 @@ public class ServerData {
|
||||
}
|
||||
}
|
||||
|
||||
public int getVotePartyExtraRequired() {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Next sign number.
|
||||
*
|
||||
@@ -238,6 +242,11 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVotePartyExtraRequired(int value) {
|
||||
getData().set("VotePartyExtraRequired", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.Ben12345rocks.AdvancedCore.Util.Javascript.JavascriptPlaceholderReque
|
||||
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.Misc.StringUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Updater.Updater;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.CommandLoader;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
@@ -129,41 +130,66 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
UserStorage cur = AdvancedCoreHook.getInstance().getStorageType();
|
||||
AdvancedCoreHook.getInstance().setStorageType(from);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
HashMap<User, HashMap<String, String>> data = new HashMap<User, HashMap<String, String>>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
try {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() != null) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
}
|
||||
ArrayList<String> uuids = new ArrayList<String>(UserManager.getInstance().getAllUUIDs());
|
||||
|
||||
HashMap<String, String> values = new HashMap<String, String>();
|
||||
for (String key : user.getData().getKeys()) {
|
||||
values.put(key, user.getData().getString(key));
|
||||
}
|
||||
data.put(user, values);
|
||||
debug("[Convert] Added " + uuid);
|
||||
} catch (Exception e) {
|
||||
AdvancedCoreHook.getInstance().debug(e);
|
||||
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
|
||||
+ ", turn debug on to see full stack traces");
|
||||
while (uuids.size() > 0) {
|
||||
HashMap<User, HashMap<String, String>> data = new HashMap<User, HashMap<String, String>>();
|
||||
AdvancedCoreHook.getInstance().setStorageType(from);
|
||||
//AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() != null) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
}
|
||||
|
||||
ArrayList<String> converted = new ArrayList<String>();
|
||||
int i = 0;
|
||||
while (i < 250 && i < uuids.size()) {
|
||||
String uuid = uuids.get(i);
|
||||
try {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
|
||||
HashMap<String, String> values = new HashMap<String, String>();
|
||||
for (String key : user.getData().getKeys()) {
|
||||
String value = user.getData().getValue(key);
|
||||
if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
|
||||
values.put(key, value);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
converted.add(uuid);
|
||||
data.put(user, values);
|
||||
debug("[Convert] Added " + uuid);
|
||||
} catch (Exception e) {
|
||||
AdvancedCoreHook.getInstance().debug(e);
|
||||
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
|
||||
+ ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
wait(Config.getInstance().getConvertDelay());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
uuids.removeAll(converted);
|
||||
|
||||
plugin.getLogger()
|
||||
.info("Finished getting data from " + from.toString() + " Converting " + data.size() + " users");
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() != null) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
}
|
||||
|
||||
writeConvertData(data);
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Finished getting data from " + from.toString());
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
|
||||
for (Entry<User, HashMap<String, String>> entry : data.entrySet()) {
|
||||
try {
|
||||
for (Entry<String, String> values : entry.getValue().entrySet()) {
|
||||
entry.getKey().getData().setString(values.getKey(), values.getValue());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().warning("Exception occoured for '" + entry.getKey().getUUID() + "': "
|
||||
+ e.getMessage() + ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
AdvancedCoreHook.getInstance().setStorageType(cur);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
|
||||
@@ -692,6 +718,7 @@ public class Main extends JavaPlugin {
|
||||
|
||||
setupFiles();
|
||||
loadVoteSites();
|
||||
AdvancedCoreHook.getInstance().setJenkinsSite("ben12345rocks.com");
|
||||
updateAdvancedCoreHook();
|
||||
AdvancedCoreHook.getInstance().loadHook(this);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
@@ -744,6 +771,34 @@ public class Main extends JavaPlugin {
|
||||
|
||||
loadTimer();
|
||||
|
||||
// set columns
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("CheckWorld", "VARCHAR(5)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("Reminded", "VARCHAR(5)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("DisableBroadcast", "VARCHAR(5)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("LastOnline", "VARCHAR(20)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("PlayerName", "VARCHAR(20)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("DailyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("WeeklyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("DayVoteStreak", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("BestDayVoteStreak", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("WeekVoteStreak", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("BestWeekVoteStreak", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("VotePartyVotes", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("MonthVoteStreak", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("Points", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("HighestDailyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("MileStoneTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("AllTimeTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("HighestMonthlyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("MilestoneCount", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("MonthTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("HighestWeeklyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("LastMonthTotal", "INT DEFAULT '0'");
|
||||
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
|
||||
|
||||
boolean hasRewards = RewardHandler.getInstance().hasRewards(ConfigVoteSites.getInstance().getData(),
|
||||
@@ -776,8 +831,8 @@ public class Main extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger()
|
||||
.warning("Detected an issue with voting sites, check the plugin startup log for more details");
|
||||
plugin.getLogger().warning(
|
||||
"Detected an issue with voting sites, check the plugin startup log for more details");
|
||||
}
|
||||
}, 30l);
|
||||
}
|
||||
@@ -863,6 +918,7 @@ public class Main extends JavaPlugin {
|
||||
try {
|
||||
config = Config.getInstance();
|
||||
config.setup();
|
||||
config.loadValues();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@@ -956,4 +1012,30 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().setConfigData(Config.getInstance().getData());
|
||||
}
|
||||
|
||||
private void writeConvertData(HashMap<User, HashMap<String, String>> data) {
|
||||
boolean checkInt = AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL);
|
||||
for (Entry<User, HashMap<String, String>> entry : data.entrySet()) {
|
||||
try {
|
||||
for (Entry<String, String> values : entry.getValue().entrySet()) {
|
||||
String value = values.getValue();
|
||||
if (value != null && !value.equalsIgnoreCase("null")) {
|
||||
if (checkInt) {
|
||||
if (StringUtils.getInstance().isInt(value)) {
|
||||
entry.getKey().getData().setInt(values.getKey(), Integer.parseInt(value));
|
||||
} else {
|
||||
entry.getKey().getData().setString(values.getKey(), value);
|
||||
}
|
||||
} else {
|
||||
entry.getKey().getData().setString(values.getKey(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().warning("Exception occoured for '" + entry.getKey().getUUID() + "': "
|
||||
+ e.getMessage() + ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,19 +51,28 @@ public enum TopVoter {
|
||||
}
|
||||
|
||||
public TopVoter prev() {
|
||||
switch (this) {
|
||||
case AllTime:
|
||||
return Daily;
|
||||
case Daily:
|
||||
return Weekly;
|
||||
case Monthly:
|
||||
return AllTime;
|
||||
case Weekly:
|
||||
return Monthly;
|
||||
default:
|
||||
return AllTime;
|
||||
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
|
||||
if (Config.getInstance().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
for (int i = list.size()-1; i >= 0; i--) {
|
||||
if (list.get(i).equals(this)) {
|
||||
int prev = i - 1;
|
||||
if (prev < 0) {
|
||||
prev = list.size()-1;
|
||||
}
|
||||
return TopVoter.values()[prev];
|
||||
}
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
}
|
||||
@@ -176,6 +176,14 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean getDisableBroadcast() {
|
||||
return getUserData().getBoolean("DisableBroadcast");
|
||||
}
|
||||
|
||||
public void setDisableBroadcast(boolean value) {
|
||||
getUserData().setBoolean("DisableBroadcast", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can vote site.
|
||||
*
|
||||
@@ -204,7 +212,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
|
||||
return now.isAfter(nextvote);
|
||||
} else {
|
||||
if (now.getDayOfYear() != lastVote.getDayOfYear() && now.getYear() != lastVote.getYear()) {
|
||||
if (now.getDayOfYear() != lastVote.getDayOfYear() || now.getYear() != lastVote.getYear()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -411,25 +419,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);
|
||||
}
|
||||
|
||||
@@ -462,36 +458,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) {
|
||||
@@ -513,14 +479,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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
@@ -11,8 +16,8 @@ import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteSite.
|
||||
*/
|
||||
@@ -84,8 +89,20 @@ public class VoteSite {
|
||||
if (!user.isVanished()) {
|
||||
String playerName = user.getPlayerName();
|
||||
String bc = StringUtils.getInstance().colorize(config.getFormatBroadCastMsg());
|
||||
bc = bc.replace("%player%", playerName).replace("%SiteName%", getDisplayName());
|
||||
MiscUtils.getInstance().broadcast(bc);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("player", playerName);
|
||||
placeholders.put("nickname",
|
||||
(user.getPlayer() != null) ? user.getPlayer().getDisplayName() : user.getPlayerName());
|
||||
placeholders.put("sitename", getDisplayName());
|
||||
bc = StringUtils.getInstance().replacePlaceHolder(bc, placeholders);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
MiscUtils.getInstance().broadcast(bc, players);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,26 @@ public class TopVoterHandler implements Listener {
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
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 onDateChanged(DateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
@@ -105,7 +125,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()) {
|
||||
@@ -117,8 +137,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();
|
||||
@@ -150,7 +170,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()) {
|
||||
@@ -163,8 +183,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();
|
||||
@@ -180,7 +200,6 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, 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();
|
||||
|
||||
+17
-12
@@ -2,12 +2,12 @@ package com.Ben12345rocks.VotingPlugin.Util.PlaceHolders;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
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;
|
||||
@@ -51,9 +51,19 @@ public class PlaceHolders {
|
||||
PlaceHolders.plugin = plugin;
|
||||
}
|
||||
|
||||
public synchronized String getPlaceHolder(Player p, String identifier) {
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
|
||||
// %VotingPlugin_VotePartyVotesNeeded - Number of votes needed until
|
||||
// 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());
|
||||
}
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
|
||||
// %VotingPlugin_total% - Total votes of all vote sites
|
||||
@@ -103,16 +113,6 @@ public class PlaceHolders {
|
||||
return Integer.toString(user.getPoints());
|
||||
}
|
||||
|
||||
// %VotingPlugin_VotePartyVotesNeeded - Number of votes needed until
|
||||
// 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(Config.getInstance().getVotePartyVotesRequired());
|
||||
}
|
||||
|
||||
// %VotingPlugin_canvote% - Whether or not a player can vote on all
|
||||
// sites
|
||||
if (identifier.equalsIgnoreCase("canvote")) {
|
||||
@@ -230,6 +230,11 @@ public class PlaceHolders {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public String getPlaceHolder(Player p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier);
|
||||
}
|
||||
|
||||
public String playerLastVote(User user, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames().contains(siteName)) {
|
||||
return "";
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -129,7 +134,7 @@ public class VoteParty implements Listener {
|
||||
* @return the needed votes
|
||||
*/
|
||||
public int getNeededVotes() {
|
||||
int votesRequired = Config.getInstance().getVotePartyVotesRequired();
|
||||
int votesRequired = getVotesRequired();
|
||||
int votes = getTotalVotes();
|
||||
int neededVotes = votesRequired - votes;
|
||||
return neededVotes;
|
||||
@@ -158,6 +163,15 @@ public class VoteParty implements Listener {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
public int getVotesRequired() {
|
||||
int required = Config.getInstance().getVotePartyVotesRequired();
|
||||
int extra = ServerData.getInstance().getVotePartyExtraRequired();
|
||||
if (extra > 0) {
|
||||
return required + extra;
|
||||
}
|
||||
return required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give reward.
|
||||
*
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
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.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.GUI.PlayerGUIs;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
@@ -30,35 +31,49 @@ public class VoteShop {
|
||||
}
|
||||
|
||||
public void voteShop(Player player) {
|
||||
if (!Config.getInstance().getVoteShopEnabled()) {
|
||||
player.sendMessage(StringUtils.getInstance().colorize("&cVote shop disabled"));
|
||||
return;
|
||||
}
|
||||
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
|
||||
|
||||
for (String identifier : Config.getInstance().getIdentifiers()) {
|
||||
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
String perm = Config.getInstance().getVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
|
||||
inv.addButton(Config.getInstance().getIdentifierSlot(identifier), new BInventoryButton(builder) {
|
||||
if (hasPerm) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
inv.addButton(Config.getInstance().getIdentifierSlot(identifier), new BInventoryButton(builder) {
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
String identifier = Config.getInstance().getIdentifierFromSlot(event.getSlot());
|
||||
if (identifier != null) {
|
||||
if (user.removePoints(points)) {
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier));
|
||||
user.sendMessage(Config.getInstance().getFormatShopPurchaseMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
} else {
|
||||
user.sendMessage(Config.getInstance().getFormatShopFailedMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
String identifier = Config.getInstance().getIdentifierFromSlot(event.getSlot());
|
||||
if (identifier != null) {
|
||||
if (user.removePoints(points)) {
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier));
|
||||
user.sendMessage(Config.getInstance().getFormatShopPurchaseMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
} else {
|
||||
user.sendMessage(Config.getInstance().getFormatShopFailedMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVoteShopBackButton()) {
|
||||
|
||||
Reference in new issue
Block a user