Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ee3706190 | ||
|
|
9f7fc3dafd | ||
|
|
d8ce4a9578 | ||
|
|
574e8d4a54 | ||
|
|
19a7a6a733 | ||
|
|
1e131e57c3 | ||
|
|
57795bdb23 | ||
|
|
52bbb76aad | ||
|
|
1257ac4600 | ||
|
|
64ffc38405 | ||
|
|
f8009b05bc | ||
|
|
114f217046 | ||
|
|
2de309cccc | ||
|
|
7f827857bc | ||
|
|
75e244f678 | ||
|
|
a346f28df1 | ||
|
|
afa57566da | ||
|
|
6f46469ff6 | ||
|
|
7edf33a448 | ||
|
|
4d7b30eb20 | ||
|
|
ed8d92e4a4 | ||
|
|
f7e62f5790 | ||
|
|
84146236b1 | ||
|
|
97c4ee3564 | ||
|
|
f8547c5d86 | ||
|
|
c97acf7a29 | ||
|
|
fbbb11a4b0 | ||
|
|
e517bb43b8 | ||
|
|
e43ef1ea3e |
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%'
|
||||
@@ -166,7 +169,11 @@ Format:
|
||||
Title: '&3&l%player% Last Vote Times:'
|
||||
# Lines for each vote site
|
||||
# %time% = time, using timeformat below
|
||||
Line: '&3%SiteName%: &6%time%'
|
||||
# %timesince% = time since vote
|
||||
Line: '&3%SiteName%: &6%timeSince% ago'
|
||||
# Spelling of TimeType can be changed under Format.Commands.TimeFormats
|
||||
TimeFormat: '%amount% %TimeType%'
|
||||
NeverVoted: 'Never voted'
|
||||
|
||||
# Format for /vote total
|
||||
Total:
|
||||
@@ -230,6 +237,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
|
||||
@@ -239,6 +250,16 @@ Format:
|
||||
# See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
|
||||
TimeFormat: 'EEE, d MMM yyyy HH:mm'
|
||||
|
||||
TimeFomrats:
|
||||
Day: 'Day'
|
||||
Days: 'Days'
|
||||
Hour: 'Hour'
|
||||
Hours: 'Hours'
|
||||
Minute: 'Minute'
|
||||
Minutes: 'Minutes'
|
||||
Second: 'Second'
|
||||
Seconds: 'Seconds'
|
||||
|
||||
# Format for signs
|
||||
# SiteName may be all, depending on sign
|
||||
# %position% = position of player, set by sign
|
||||
@@ -310,7 +331,7 @@ GUI:
|
||||
Slot: 1
|
||||
Last:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Last'
|
||||
@@ -436,25 +457,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 +483,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 +504,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
|
||||
|
||||
@@ -32,7 +32,7 @@ VoteSites:
|
||||
VoteDelayDaily: false
|
||||
|
||||
# If true, rewards can be executed offline (requires ForceOffline to be true in the reward)
|
||||
# Setting this to true will execute the reward offline, NOT WHEN THE PLAYER IS OFFLINE
|
||||
# Setting this to true will execute the reward offline while the player is offline
|
||||
# This basiclly disables offline voting if set to true, don't misinterpret this option
|
||||
ForceOffline: false
|
||||
|
||||
|
||||
@@ -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.13.3</version>
|
||||
<version>5.14.2</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);
|
||||
|
||||
@@ -595,6 +590,7 @@ public class Commands {
|
||||
* the vote site
|
||||
* @return the string
|
||||
*/
|
||||
@Deprecated
|
||||
public String voteCommandLastDate(User user, VoteSite voteSite) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time > 0) {
|
||||
@@ -607,9 +603,89 @@ public class Commands {
|
||||
|
||||
public String voteCommandLastLine(User user, VoteSite voteSite) {
|
||||
String timeString = voteCommandLastDate(user, voteSite);
|
||||
String timeSince = voteCommandLastDuration(user, voteSite);
|
||||
|
||||
return config.getFormatCommandsVoteLastLine().replace("%Month% %Day%, %Year% %Hour%:%Minute% %ampm%", "%time%")
|
||||
.replace("%time%", timeString).replace("%SiteName%", voteSite.getDisplayName());
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("time", timeString);
|
||||
placeholders.put("SiteName", voteSite.getDisplayName());
|
||||
placeholders.put("timesince", timeSince);
|
||||
|
||||
return StringUtils.getInstance().replacePlaceHolder(Config.getInstance().formatCommandsVoteLastLine,
|
||||
placeholders);
|
||||
}
|
||||
|
||||
public String voteCommandLastDuration(User user, VoteSite voteSite) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time > 0) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
|
||||
|
||||
Duration dur = Duration.between(lastVote, now);
|
||||
|
||||
long diffSecond = dur.getSeconds();
|
||||
int diffDays = (int) (diffSecond / 60 / 60 / 24);
|
||||
int diffHours = (int) (diffSecond / 60 / 60 - diffDays * 24);
|
||||
int diffMinutes = (int) (diffSecond / 60 - diffHours * 60 - diffDays * 24 * 60);
|
||||
int diffSeconds = (int) (diffSecond - diffMinutes * 60 - diffHours * 60 * 60 - diffDays * 24 * 60 * 60);
|
||||
|
||||
String info = "";
|
||||
if (diffDays == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsDay), "amount", "" + diffDays);
|
||||
info += " ";
|
||||
} else if (diffDays > 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsDays), "amount", "" + diffDays);
|
||||
info += " ";
|
||||
}
|
||||
|
||||
if (diffHours == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsHour), "amount", "" + diffHours);
|
||||
info += " ";
|
||||
} else if (diffHours > 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsHours), "amount", "" + diffHours);
|
||||
info += " ";
|
||||
}
|
||||
|
||||
if (diffMinutes == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsMinute), "amount", "" + diffMinutes);
|
||||
info += " ";
|
||||
} else if (diffMinutes > 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsMinutes), "amount", "" + diffMinutes);
|
||||
info += " ";
|
||||
}
|
||||
|
||||
if (diffSeconds == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsSecond), "amount", "" + diffSeconds);
|
||||
} else {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsSeconds), "amount", "" + diffSeconds);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
return Config.getInstance().formatCommandsVoteLastNeverVoted;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,48 @@ 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;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.TimeFormat", defaultValue = "%amount% %TimeType%")
|
||||
public String formatCommandsVoteLastTimeFormat;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.Line", defaultValue = "&3%SiteName%: &6%timeSince% ago")
|
||||
public String formatCommandsVoteLastLine;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.NeverVoted", defaultValue = "Never voted")
|
||||
public String formatCommandsVoteLastNeverVoted;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Days", defaultValue = "Days")
|
||||
public String formatTimeFormatsDays;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Day", defaultValue = "Day")
|
||||
public String formatTimeFormatsDay;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Hours", defaultValue = "Hours")
|
||||
public String formatTimeFormatsHours;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Hour", defaultValue = "Hour")
|
||||
public String formatTimeFormatsHour;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Minutes", defaultValue = "Minutes")
|
||||
public String formatTimeFormatsMinutes;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Minute", defaultValue = "Minute")
|
||||
public String formatTimeFormatsMinute;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Seconds", defaultValue = "Seconds")
|
||||
public String formatTimeFormatsSeconds;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Second", defaultValue = "Second")
|
||||
public String formatTimeFormatsSecond;
|
||||
|
||||
/**
|
||||
* Allow un joined.
|
||||
*
|
||||
@@ -159,7 +208,7 @@ public class Config extends YMLFile {
|
||||
}
|
||||
|
||||
public int getConvertDelay() {
|
||||
return getData().getInt("ConvertDelay", 10000);
|
||||
return getData().getInt("ConvertDelay", 30000);
|
||||
}
|
||||
|
||||
public boolean getCountFakeVotes() {
|
||||
@@ -360,15 +409,6 @@ public class Config extends YMLFile {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote last line.
|
||||
*
|
||||
* @return the commands vote last line
|
||||
*/
|
||||
public String getFormatCommandsVoteLastLine() {
|
||||
return getData().getString("Format.Commands.Vote.Last.Line", "&3%SiteName%: &6%time%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote last title.
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
@@ -138,22 +139,26 @@ public class Main extends JavaPlugin {
|
||||
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() != null) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
}
|
||||
|
||||
ArrayList<String> converted = new ArrayList<String>();
|
||||
int i = 0;
|
||||
while (i < 500 && i < uuids.size()) {
|
||||
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()) {
|
||||
values.put(key, user.getData().getString(key));
|
||||
String value = user.getData().getValue(key);
|
||||
if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
|
||||
values.put(key, value);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
converted.add(uuid);
|
||||
@@ -169,7 +174,6 @@ public class Main extends JavaPlugin {
|
||||
try {
|
||||
wait(Config.getInstance().getConvertDelay());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
uuids.removeAll(converted);
|
||||
@@ -179,9 +183,7 @@ public class Main extends JavaPlugin {
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() != null)
|
||||
|
||||
{
|
||||
&& AdvancedCoreHook.getInstance().getMysql() != null) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
}
|
||||
|
||||
@@ -774,7 +776,26 @@ public class Main extends JavaPlugin {
|
||||
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("DailyTotal", "VARCHAR(10)");
|
||||
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'");
|
||||
|
||||
}
|
||||
|
||||
@@ -877,6 +898,7 @@ public class Main extends JavaPlugin {
|
||||
public void reload() {
|
||||
setUpdate(true);
|
||||
config.reloadData();
|
||||
config.loadValues();
|
||||
configVoteSites.reloadData();
|
||||
updateAdvancedCoreHook();
|
||||
plugin.loadVoteSites();
|
||||
@@ -897,6 +919,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() {
|
||||
@@ -991,10 +1014,22 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
|
||||
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()) {
|
||||
entry.getKey().getData().setString(values.getKey(), values.getValue());
|
||||
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();
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class PlaceHolders {
|
||||
PlaceHolders.plugin = plugin;
|
||||
}
|
||||
|
||||
public synchronized String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
|
||||
// %VotingPlugin_VotePartyVotesNeeded - Number of votes needed until
|
||||
@@ -241,7 +241,7 @@ public class PlaceHolders {
|
||||
}
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(siteName);
|
||||
return Commands.getInstance().voteCommandLastDate(user, voteSite);
|
||||
return Commands.getInstance().voteCommandLastDuration(user, voteSite);
|
||||
}
|
||||
|
||||
public String playerNextVote(User user, String siteName) {
|
||||
|
||||
Reference in new issue
Block a user