mirror of
https://github.com/BenCodez/VotingPlugin.git
synced 2026-11-04 09:02:00 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9e8ade60f | ||
|
|
2364fd7ac6 | ||
|
|
7135ed0f95 | ||
|
|
b5fbaaaf92 | ||
|
|
94c025886a | ||
|
|
0956466edb | ||
|
|
b2b23ab622 | ||
|
|
0e6529efbe | ||
|
|
f7ce51f63a | ||
|
|
68334ef1a2 | ||
|
|
404c1eeb4d | ||
|
|
347c1d975d | ||
|
|
3b022fc841 | ||
|
|
88afb70fad | ||
|
|
62e21d9f93 | ||
|
|
20289a5d7b | ||
|
|
02b0103fbd |
No files matched your search
@@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=Cp1252
|
||||
encoding/Resources=Cp1252
|
||||
encoding/src=Cp1252
|
||||
@@ -10,6 +10,7 @@
|
||||
DataStorage: SQLITE
|
||||
|
||||
# Information for mysql
|
||||
# See the end of the config for cache options
|
||||
MySQL:
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
@@ -31,20 +32,6 @@ MySQL:
|
||||
# Recommend: False (Will prevent creating random user data)
|
||||
AllowUnjoined: false
|
||||
|
||||
# If true, plugin will send scoreboards on some commands
|
||||
SendScoreboards: true
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being created randomly
|
||||
# Most cases this will work all the time
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Automaticly download the latest version
|
||||
# Will require a restart to actually update
|
||||
# Note: It takes 30-40 minutes before being able to download the latest build
|
||||
# You can also use /av download
|
||||
AutoDownload: false
|
||||
|
||||
# ------------------------------------------------
|
||||
# VoteReminding
|
||||
# ------------------------------------------------
|
||||
@@ -648,7 +635,7 @@ VoteParty:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
|
||||
# Reset milestons at end of the month
|
||||
# Reset milestones at end of the month
|
||||
ResetMilestonesMonthly: false
|
||||
|
||||
MileStones:
|
||||
@@ -711,6 +698,7 @@ AnySiteRewards: []
|
||||
# ------------------------------------------------
|
||||
|
||||
# Top voter blacklist
|
||||
# Hide these names from top voter lists
|
||||
BlackList:
|
||||
- 'Notch'
|
||||
|
||||
@@ -783,7 +771,7 @@ DailyAwards:
|
||||
|
||||
# ------------------------------------------------
|
||||
# Advanced
|
||||
# Most of these values can be left untouched
|
||||
# Most of these values can be left untouched for most setups
|
||||
# ------------------------------------------------
|
||||
|
||||
# Number of points to give on vote
|
||||
@@ -825,19 +813,17 @@ RequestAPI:
|
||||
# Not recommended though
|
||||
LogVotesToFile: false
|
||||
|
||||
# Only update the background when needed when set to false
|
||||
AlwaysUpdate: false
|
||||
|
||||
# Update in the background only if players are online
|
||||
UpdateWithPlayersOnlineOnly: false
|
||||
|
||||
# Delay between background updates like signs and more
|
||||
# Default: 3 Minutes
|
||||
# Longer times result in longer wait in stuff updating after a vote, like topvoter
|
||||
DelayBetweenUpdates: 3
|
||||
|
||||
# Clear cache on update, setting to true reduces performance
|
||||
ClearCacheOnUpdate: false
|
||||
|
||||
# Clears cache for the player who voted only
|
||||
# Only effects if using mysql
|
||||
# Would recommend for some bungee setups
|
||||
ClearCacheOnVote: false
|
||||
|
||||
# Set to true to disable no service site message on voting
|
||||
# You should never have to touch this if everything is setup properly
|
||||
# Will also disable a few other warnings about vote sites
|
||||
@@ -861,6 +847,40 @@ PurgeMin: 90
|
||||
# Whether or not to create daily backups. (Only the most recent ones get kept)
|
||||
CreateBackups: true
|
||||
|
||||
# If true, plugin will send scoreboards on some commands
|
||||
SendScoreboards: true
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being created randomly
|
||||
# Most cases this will work all the time
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Automaticly download the latest version
|
||||
# Will require a restart to actually update
|
||||
# Note: It takes 30-40 minutes before being able to download the latest build
|
||||
# You can also use /av download
|
||||
AutoDownload: false
|
||||
|
||||
# Disable this on a hub server for example
|
||||
# Still processes rewards for offline rewards (just won't give any)
|
||||
ProcessRewards: true
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Mysql cache options
|
||||
# Clearing cache forces the plugin to pull from database
|
||||
# ---------------------------------------------------------
|
||||
|
||||
# Clear cache on update, setting to true reduces update speed
|
||||
ClearCacheOnUpdate: false
|
||||
|
||||
# Clear mysql on player join always
|
||||
ClearCacheOnJoin: false
|
||||
|
||||
# Clears cache for the player who voted only
|
||||
# Only effects if using mysql
|
||||
# Would recommend for some bungee setups
|
||||
ClearCacheOnVote: false
|
||||
|
||||
# ###############################################################
|
||||
# Deprecated options, don't recommend using any of these
|
||||
|
||||
|
||||
+59
-3
@@ -4,13 +4,14 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>5.16</version>
|
||||
<version>5.16.1</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
@@ -34,6 +35,34 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<versionRange>[1,)</versionRange>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -45,6 +74,25 @@
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>delombok</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<addOutputDirectory>false</addOutputDirectory>
|
||||
<outputDirectory>${project.basedir}/target/delombok</outputDirectory>
|
||||
<sourceDirectory>${project.basedir}/src</sourceDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
@@ -93,7 +141,6 @@
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@@ -109,6 +156,9 @@
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
@@ -191,7 +241,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -215,5 +265,11 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/VoteRoulette.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -120,7 +120,7 @@ public class Commands {
|
||||
|
||||
boolean requirePerms = Config.getInstance().getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.adminVoteCommand) {
|
||||
for (CommandHandler cmdHandle : plugin.getAdminVoteCommand()) {
|
||||
if (sender.hasPermission(cmdHandle.getPerm()) && requirePerms) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
} else {
|
||||
@@ -192,7 +192,7 @@ public class Commands {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&c&lCommand : Permissions (seperated by |)");
|
||||
|
||||
for (CommandHandler handle : plugin.voteCommand) {
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (sender instanceof Player) {
|
||||
if (handle.hasPerm(sender)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : true");
|
||||
@@ -205,7 +205,7 @@ public class Commands {
|
||||
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.adminVoteCommand) {
|
||||
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
|
||||
if (sender instanceof Player) {
|
||||
if (handle.hasPerm(sender)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : true");
|
||||
@@ -241,7 +241,7 @@ public class Commands {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> text = new ArrayList<String>();
|
||||
|
||||
for (CommandHandler handle : plugin.voteCommand) {
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (handle.hasPerm(p)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : true");
|
||||
} else {
|
||||
@@ -250,7 +250,7 @@ public class Commands {
|
||||
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.adminVoteCommand) {
|
||||
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
|
||||
if (handle.hasPerm(p)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : true");
|
||||
} else {
|
||||
@@ -536,7 +536,7 @@ public class Commands {
|
||||
}
|
||||
|
||||
public void updateVoteToday(ArrayList<User> users) {
|
||||
plugin.voteToday.clear();
|
||||
plugin.getVoteToday().clear();
|
||||
|
||||
for (User user : users) {
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
@@ -551,7 +551,7 @@ public class Commands {
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
plugin.voteToday.put(user, times);
|
||||
plugin.getVoteToday().put(user, times);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -620,60 +620,58 @@ public class Commands {
|
||||
if (diffDays == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsDay), "amount", "" + diffDays);
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsDay()), "amount", "" + diffDays);
|
||||
info += " ";
|
||||
} else if (diffDays > 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsDays), "amount", "" + diffDays);
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsDays()), "amount", "" + diffDays);
|
||||
info += " ";
|
||||
}
|
||||
|
||||
if (diffHours == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsHour), "amount", "" + diffHours);
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsHour()), "amount", "" + diffHours);
|
||||
info += " ";
|
||||
} else if (diffHours > 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsHours), "amount", "" + diffHours);
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsHours()), "amount", "" + diffHours);
|
||||
info += " ";
|
||||
}
|
||||
|
||||
if (diffMinutes == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsMinute), "amount", "" + diffMinutes);
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsMinute()), "amount", "" + diffMinutes);
|
||||
info += " ";
|
||||
} else if (diffMinutes > 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsMinutes), "amount", "" + diffMinutes);
|
||||
info += StringUtils.getInstance().replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsMinutes()), "amount", "" + diffMinutes);
|
||||
info += " ";
|
||||
}
|
||||
|
||||
if (diffSeconds == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsSecond), "amount", "" + diffSeconds);
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsSecond()), "amount", "" + diffSeconds);
|
||||
} else {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().formatCommandsVoteLastTimeFormat, "TimeType",
|
||||
Config.getInstance().formatTimeFormatsSeconds), "amount", "" + diffSeconds);
|
||||
info += StringUtils.getInstance().replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsSeconds()), "amount", "" + diffSeconds);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
return Config.getInstance().formatCommandsVoteLastNeverVoted;
|
||||
return Config.getInstance().getFormatCommandsVoteLastNeverVoted();
|
||||
}
|
||||
|
||||
public String voteCommandLastLine(User user, VoteSite voteSite) {
|
||||
@@ -685,7 +683,7 @@ public class Commands {
|
||||
placeholders.put("SiteName", voteSite.getDisplayName());
|
||||
placeholders.put("timesince", timeSince);
|
||||
|
||||
return StringUtils.getInstance().replacePlaceHolder(Config.getInstance().formatCommandsVoteLastLine,
|
||||
return StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getFormatCommandsVoteLastLine(),
|
||||
placeholders);
|
||||
}
|
||||
|
||||
@@ -858,7 +856,7 @@ public class Commands {
|
||||
|
||||
boolean requirePerms = config.getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.voteCommand) {
|
||||
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
|
||||
if (cmdHandle.hasPerm(sender)) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"), cmdHandle.getHelpLine("/vote"));
|
||||
} else if (!requirePerms) {
|
||||
@@ -882,11 +880,11 @@ public class Commands {
|
||||
*/
|
||||
public String[] voteToday() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
for (User user : plugin.voteToday.keySet()) {
|
||||
for (User user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.voteToday.get(user).keySet()) {
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Config.getInstance().getFormatTimeFormat());
|
||||
String timeString = plugin.voteToday.get(user).get(voteSite).format(formatter);
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " + timeString);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -55,14 +55,13 @@ public class CommandAdminVote implements CommandExecutor {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (CommandHandler commandHandler : plugin.adminVoteCommand) {
|
||||
for (CommandHandler commandHandler : plugin.getAdminVoteCommand()) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+2
-3
@@ -32,7 +32,6 @@ public class CommandAliases implements CommandExecutor {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
@@ -50,9 +49,9 @@ public class CommandAliases implements CommandExecutor {
|
||||
|
||||
ArrayList<CommandHandler> handles = new ArrayList<CommandHandler>();
|
||||
if (adminCommand) {
|
||||
handles.addAll(plugin.adminVoteCommand);
|
||||
handles.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
handles.addAll(plugin.voteCommand);
|
||||
handles.addAll(plugin.getVoteCommand());
|
||||
}
|
||||
|
||||
for (CommandHandler cmdHandle : handles) {
|
||||
|
||||
@@ -47,7 +47,6 @@ public class CommandVote implements CommandExecutor {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
@@ -55,7 +54,7 @@ public class CommandVote implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
for (CommandHandler commandHandler : plugin.voteCommand) {
|
||||
for (CommandHandler commandHandler : plugin.getVoteCommand()) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -64,90 +64,6 @@ public class PlayerGUIs {
|
||||
return str;
|
||||
}
|
||||
|
||||
public void openVoteShop(Player player) {
|
||||
if (!Config.getInstance().getVoteShopEnabled()) {
|
||||
player.sendMessage(StringUtils.getInstance().colorize("&cVote shop disabled"));
|
||||
return;
|
||||
}
|
||||
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
|
||||
|
||||
for (final String identifier : Config.getInstance().getIdentifiers()) {
|
||||
|
||||
String perm = Config.getInstance().getVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
|
||||
int limit = Config.getInstance().getIdentifierLimit(identifier);
|
||||
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPerm && limitPass) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("identifier", identifier);
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatShopPurchaseMsg(), placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier,
|
||||
user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}.addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVoteShopBackButton()) {
|
||||
inv.addButton(new BInventoryButton(PlayerGUIs.getInstance().getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
PlayerGUIs.getInstance().openVoteGUI(event.getPlayer(),
|
||||
UserManager.getInstance().getVotingPluginUser(player));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteBest(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
@@ -334,6 +250,103 @@ public class PlayerGUIs {
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteShop(Player player) {
|
||||
if (!Config.getInstance().getVoteShopEnabled()) {
|
||||
player.sendMessage(StringUtils.getInstance().colorize("&cVote shop disabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
|
||||
|
||||
for (final String identifier : Config.getInstance().getIdentifiers()) {
|
||||
|
||||
String perm = Config.getInstance().getVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
|
||||
int limit = Config.getInstance().getIdentifierLimit(identifier);
|
||||
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPerm && limitPass) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.clearCache();
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
|
||||
// limit fail-safe, should never be needed, except in rare cases
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (limitPass) {
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("identifier", identifier);
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatShopPurchaseMsg(), placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier,
|
||||
user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}.addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVoteShopBackButton()) {
|
||||
inv.addButton(new BInventoryButton(PlayerGUIs.getInstance().getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
PlayerGUIs.getInstance().openVoteGUI(event.getPlayer(),
|
||||
UserManager.getInstance().getVotingPluginUser(player));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteStreak(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
@@ -411,11 +424,11 @@ public class PlayerGUIs {
|
||||
public void openVoteToday(Player player) {
|
||||
setSelectedPlayer(player, null);
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteTodayName());
|
||||
for (User user : plugin.voteToday.keySet()) {
|
||||
for (User user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.voteToday.get(user).keySet()) {
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Config.getInstance().getFormatTimeFormat());
|
||||
String timeString = plugin.voteToday.get(user).get(voteSite).format(formatter);
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
String msg = "&6" + voteSite.getDisplayName() + " : " + timeString;
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(user.getPlayerName(), new String[] { msg },
|
||||
MiscUtils.getInstance().setSkullOwner(user.getOfflinePlayer())) {
|
||||
@@ -600,7 +613,7 @@ public class PlayerGUIs {
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
|
||||
if (Config.getInstance().commandsVoteRewardFromVoteURL
|
||||
if (Config.getInstance().isCommandsVoteRewardFromVoteURL()
|
||||
&& event.getClick().equals(ClickType.RIGHT)) {
|
||||
voteReward(player, voteSite.getKey());
|
||||
} else {
|
||||
|
||||
+1
-2
@@ -24,7 +24,6 @@ public class AdminVoteTabCompleter implements TabCompleter {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
@@ -36,7 +35,7 @@ public class AdminVoteTabCompleter implements TabCompleter {
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.adminVoteCommand, sender, args,
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getAdminVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
|
||||
+2
-3
@@ -32,7 +32,6 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
@@ -54,9 +53,9 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
|
||||
|
||||
if (adminCommand) {
|
||||
cmdHandlers.addAll(plugin.adminVoteCommand);
|
||||
cmdHandlers.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
cmdHandlers.addAll(plugin.voteCommand);
|
||||
cmdHandlers.addAll(plugin.getVoteCommand());
|
||||
}
|
||||
ConcurrentHashMap<String, ArrayList<String>> tabCompletes = TabCompleteHandler.getInstance()
|
||||
.getTabCompleteOptions();
|
||||
|
||||
+1
-2
@@ -25,7 +25,6 @@ public class VoteTabCompleter implements TabCompleter {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
@@ -37,7 +36,7 @@ public class VoteTabCompleter implements TabCompleter {
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.voteCommand, sender, args,
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
|
||||
@@ -9,11 +9,14 @@ 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.ConfigDataInt;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Annotation.ConfigDataString;
|
||||
import com.Ben12345rocks.AdvancedCore.YML.YMLFile;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Config.
|
||||
@@ -35,50 +38,182 @@ public class Config extends YMLFile {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Enabled", defaultValue = "&cYou will now see vote broadcasts")
|
||||
public String formatCommandsVoteToggleBroadcastEnabled;
|
||||
@ConfigDataString(
|
||||
path = "Format.Commands.Vote.ToggleBroadcasts.Enabled", defaultValue = "&cYou will now see vote broadcasts"
|
||||
)
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleBroadcastEnabled;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Disabled", defaultValue = "&cYou will no longer see vote broadcasts")
|
||||
public String formatCommandsVoteToggleBroadcastDisabled;
|
||||
@ConfigDataString(
|
||||
path = "Format.Commands.Vote.ToggleBroadcasts.Disabled",
|
||||
defaultValue = "&cYou will no longer see vote broadcasts"
|
||||
)
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleBroadcastDisabled;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.VoteRewardFromVoteURL", defaultValue = false)
|
||||
public boolean commandsVoteRewardFromVoteURL;
|
||||
@ConfigDataBoolean(path = "Commands.VoteRewardFromVoteURL")
|
||||
@Getter
|
||||
private boolean commandsVoteRewardFromVoteURL = false;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.TimeFormat", defaultValue = "%amount% %TimeType%")
|
||||
public String formatCommandsVoteLastTimeFormat;
|
||||
@Getter
|
||||
private String formatCommandsVoteLastTimeFormat;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.Line", defaultValue = "&3%SiteName%: &6%timeSince% ago")
|
||||
public String formatCommandsVoteLastLine;
|
||||
@Getter
|
||||
private String formatCommandsVoteLastLine;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.NeverVoted", defaultValue = "Never voted")
|
||||
public String formatCommandsVoteLastNeverVoted;
|
||||
@Getter
|
||||
private String formatCommandsVoteLastNeverVoted;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Days", defaultValue = "Days")
|
||||
public String formatTimeFormatsDays;
|
||||
@Getter
|
||||
private String formatTimeFormatsDays;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Day", defaultValue = "Day")
|
||||
public String formatTimeFormatsDay;
|
||||
@Getter
|
||||
private String formatTimeFormatsDay;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Hours", defaultValue = "Hours")
|
||||
public String formatTimeFormatsHours;
|
||||
@Getter
|
||||
private String formatTimeFormatsHours;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Hour", defaultValue = "Hour")
|
||||
public String formatTimeFormatsHour;
|
||||
@Getter
|
||||
private String formatTimeFormatsHour;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Minutes", defaultValue = "Minutes")
|
||||
public String formatTimeFormatsMinutes;
|
||||
@Getter
|
||||
private String formatTimeFormatsMinutes;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Minute", defaultValue = "Minute")
|
||||
public String formatTimeFormatsMinute;
|
||||
@Getter
|
||||
private String formatTimeFormatsMinute;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Seconds", defaultValue = "Seconds")
|
||||
public String formatTimeFormatsSeconds;
|
||||
@Getter
|
||||
private String formatTimeFormatsSeconds;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Second", defaultValue = "Second")
|
||||
public String formatTimeFormatsSecond;
|
||||
@Getter
|
||||
private String formatTimeFormatsSecond;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.DisableVoteRewardGUIs", defaultValue = false)
|
||||
public boolean commandsDisableVoteRewardGUIs;
|
||||
@ConfigDataBoolean(path = "Commands.DisableVoteRewardGUIs")
|
||||
@Getter
|
||||
private boolean commandsDisableVoteRewardGUIs;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysUpdate")
|
||||
@Getter
|
||||
private boolean alwaysUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UpdateWithPlayersOnlineOnly")
|
||||
@Getter
|
||||
private boolean updateWithPlayersOnlineOnly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnjoined")
|
||||
@Getter
|
||||
private boolean allowUnjoined = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AddTotals")
|
||||
@Getter
|
||||
private boolean addTotals = true;
|
||||
|
||||
@Getter
|
||||
private String allSitesRewardPath = "AllSites";
|
||||
|
||||
@ConfigDataBoolean(path = "AlternateUUIDLookup")
|
||||
@Getter
|
||||
private boolean alternateUUIDLookup = false;
|
||||
|
||||
@Getter
|
||||
private String anySiteRewardsPath = "AnySiteRewards";
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCreateVoteSites")
|
||||
@Getter
|
||||
private boolean autoCreateVoteSites = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.BroadcastVote")
|
||||
@Getter
|
||||
private boolean broadcastVotesEnabled = true;
|
||||
|
||||
@ConfigDataBoolean(path = "clearCacheOnUpdate")
|
||||
@Getter
|
||||
private boolean clearCacheOnUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ClearCacheOnVote")
|
||||
@Getter
|
||||
private boolean clearCacheOnVote = false;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Best")
|
||||
@Getter
|
||||
private boolean commandsUseGUIBest = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Last")
|
||||
@Getter
|
||||
private boolean commandsUseGUILast = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Next")
|
||||
@Getter
|
||||
private boolean commandsUseGUINext = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Streak")
|
||||
@Getter
|
||||
private boolean commandsUseGUIStreak = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Today")
|
||||
@Getter
|
||||
private boolean commandsUseGUIToday = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.TopVoter")
|
||||
@Getter
|
||||
private boolean commandsUseGUITopVoter = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Total")
|
||||
@Getter
|
||||
private boolean commandsUseGUITotal = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Vote")
|
||||
@Getter
|
||||
private boolean commandsUseGUIVote = true;
|
||||
|
||||
@ConfigDataBoolean(path = "CountFakeVotes")
|
||||
@Getter
|
||||
private boolean countFakeVotes = true;
|
||||
|
||||
@ConfigDataInt(path = "ConvertDelay", defaultValue = 30000)
|
||||
@Getter
|
||||
private int convertDelay;
|
||||
|
||||
@ConfigDataBoolean(path = "EnableDailyRewards")
|
||||
@Getter
|
||||
private boolean enableDailyRewards = false;
|
||||
|
||||
@ConfigDataInt(path = "DelayBetweenUpdates")
|
||||
@Getter
|
||||
private int delayBetweenUpdates = 3;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableNoServiceSiteMessage")
|
||||
@Getter
|
||||
private boolean disableNoServiceSiteMessage = false;
|
||||
|
||||
@Getter
|
||||
private String firstVoteRewardsPath = "FirstVote";
|
||||
|
||||
@ConfigDataBoolean(path = "LogVotesToFile")
|
||||
@Getter
|
||||
private boolean logVotesToFile = false;
|
||||
|
||||
@ConfigDataBoolean(path = "EnableMonthlyAwards")
|
||||
@Getter
|
||||
private boolean enableMonthlyAwards = false;
|
||||
|
||||
@Getter
|
||||
private String votePartyRewardsPath = "VoteParty.Rewards";
|
||||
|
||||
@ConfigDataBoolean(path = "EnableWeeklyAwards")
|
||||
@Getter
|
||||
private boolean enableWeeklyAwards = false;
|
||||
|
||||
/**
|
||||
* Instantiates a new config.
|
||||
@@ -87,59 +222,6 @@ public class Config extends YMLFile {
|
||||
super(new File(Main.plugin.getDataFolder(), "Config.yml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow un joined.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean allowUnJoined() {
|
||||
return getData().getBoolean("AllowUnjoined");
|
||||
}
|
||||
|
||||
public boolean getAddTotals() {
|
||||
return getData().getBoolean("AddTotals", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all sites reward.
|
||||
*
|
||||
* @return the all sites reward
|
||||
*/
|
||||
public String getAllSitesRewardPath() {
|
||||
return "AllSites";
|
||||
}
|
||||
|
||||
public boolean getAlternateUUIDLookup() {
|
||||
return getData().getBoolean("AlternateUUIDLookup");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards.
|
||||
*
|
||||
* @return the rewards
|
||||
*/
|
||||
public String getAnySiteRewardsPath() {
|
||||
return "AnySiteRewards";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the auto create vote sites.
|
||||
*
|
||||
* @return the auto create vote sites
|
||||
*/
|
||||
public boolean getAutoCreateVoteSites() {
|
||||
return getData().getBoolean("AutoCreateVoteSites");
|
||||
}
|
||||
|
||||
public boolean getAutoDownload() {
|
||||
return getData().getBoolean("AutoDownload");
|
||||
}
|
||||
|
||||
public boolean getAutoKillInvs() {
|
||||
return getData().getBoolean("AutoKillInvs", true);
|
||||
}
|
||||
|
||||
public ConfigurationSection getBackButton() {
|
||||
return getData().getConfigurationSection("BackButton");
|
||||
}
|
||||
@@ -154,67 +236,6 @@ public class Config extends YMLFile {
|
||||
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<String>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the broad cast votes enabled.
|
||||
*
|
||||
* @return the broad cast votes enabled
|
||||
*/
|
||||
public boolean getBroadCastVotesEnabled() {
|
||||
return getData().getBoolean("BroadcastVote", true);
|
||||
}
|
||||
|
||||
public boolean getCheckNameMojang() {
|
||||
return getData().getBoolean("CheckNameMojang", false);
|
||||
}
|
||||
|
||||
public boolean getClearCacheOnUpdate() {
|
||||
return getData().getBoolean("ClearCacheOnUpdate");
|
||||
}
|
||||
|
||||
public boolean getClearCacheOnVote() {
|
||||
return getData().getBoolean("ClearCacheOnVote");
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUIBest() {
|
||||
return getData().getBoolean("Commands.UseGUI.Best");
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUILast() {
|
||||
return getData().getBoolean("Commands.UseGUI.Last", true);
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUINext() {
|
||||
return getData().getBoolean("Commands.UseGUI.Next", true);
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUIStreak() {
|
||||
return getData().getBoolean("Commands.UseGUI.Streak");
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUIToday() {
|
||||
return getData().getBoolean("Commands.UseGUI.Today", true);
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUITopVoter() {
|
||||
return getData().getBoolean("Commands.UseGUI.TopVoter", true);
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUITotal() {
|
||||
return getData().getBoolean("Commands.UseGUI.Total", true);
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUIVote() {
|
||||
return getData().getBoolean("Commands.UseGUI.Vote", true);
|
||||
}
|
||||
|
||||
public int getConvertDelay() {
|
||||
return getData().getInt("ConvertDelay", 30000);
|
||||
}
|
||||
|
||||
public boolean getCountFakeVotes() {
|
||||
return getData().getBoolean("CountFakeVotes", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cumulative reward enabled.
|
||||
*
|
||||
@@ -273,15 +294,6 @@ public class Config extends YMLFile {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the daily awards enabled.
|
||||
*
|
||||
* @return the daily awards enabled
|
||||
*/
|
||||
public boolean getDailyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableDailyAwards");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the daily possible reward places.
|
||||
*
|
||||
@@ -296,53 +308,6 @@ public class Config extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
public String getDataStorage() {
|
||||
return getData().getString("DataStorage", "FLAT");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the debug enabled.
|
||||
*
|
||||
* @return the debug enabled
|
||||
*/
|
||||
public boolean getDebugEnabled() {
|
||||
return getData().getBoolean("Debug");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the debug info ingame.
|
||||
*
|
||||
* @return the debug info ingame
|
||||
*/
|
||||
public boolean getDebugInfoIngame() {
|
||||
return getData().getBoolean("DebugInfoIngame");
|
||||
}
|
||||
|
||||
public int getDelayBetweenUpdates() {
|
||||
return getData().getInt("DelayBetweenUpdates", 3);
|
||||
}
|
||||
|
||||
public boolean getDisableCheckOnWorldChange() {
|
||||
return getData().getBoolean("DisableCheckOnWorldChange");
|
||||
}
|
||||
|
||||
public boolean getDisableNoServiceSiteMessage() {
|
||||
return getData().getBoolean("DisableNoServiceSiteMessage");
|
||||
}
|
||||
|
||||
public boolean getExtraDebug() {
|
||||
return getData().getBoolean("ExtraDebug");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first vote rewards.
|
||||
*
|
||||
* @return the first vote rewards
|
||||
*/
|
||||
public String getFirstVoteRewardsPath() {
|
||||
return "FirstVote";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the broad cast msg.
|
||||
*
|
||||
@@ -597,15 +562,9 @@ public class Config extends YMLFile {
|
||||
public String getFormatNotNumber() {
|
||||
return getData().getString("Format.NotNumber", "&cError on &6%arg%&c, number expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the page size.
|
||||
*
|
||||
* @return the page size
|
||||
*/
|
||||
public int getFormatPageSize() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private int formatPageSize = 10;
|
||||
|
||||
public String getFormatPrevPage() {
|
||||
return getData().getString("Format.PrevPage", "&aPrevious Page");
|
||||
@@ -836,22 +795,6 @@ public class Config extends YMLFile {
|
||||
return getData().getConfigurationSection("GUI.VoteTotal.AllTimeTotal.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getGUIVoteTotalItem(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getGUIVoteTotalAllTimeTotalItem();
|
||||
case Daily:
|
||||
return getGUIVoteTotalDayTotalItem();
|
||||
case Monthly:
|
||||
return getGUIVoteTotalMonthTotalItem();
|
||||
case Weekly:
|
||||
return getGUIVoteTotalWeekTotalItem();
|
||||
default:
|
||||
return getGUIVoteTotalAllTimeTotalItem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getGUIVoteTotalBackButton() {
|
||||
return getData().getBoolean("GUI.VoteTotal.BackButton");
|
||||
}
|
||||
@@ -860,6 +803,22 @@ public class Config extends YMLFile {
|
||||
return getData().getConfigurationSection("GUI.VoteTotal.DayTotal.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getGUIVoteTotalItem(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getGUIVoteTotalAllTimeTotalItem();
|
||||
case Daily:
|
||||
return getGUIVoteTotalDayTotalItem();
|
||||
case Monthly:
|
||||
return getGUIVoteTotalMonthTotalItem();
|
||||
case Weekly:
|
||||
return getGUIVoteTotalWeekTotalItem();
|
||||
default:
|
||||
return getGUIVoteTotalAllTimeTotalItem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getGUIVoteTotalMonthTotalItem() {
|
||||
return getData().getConfigurationSection("GUI.VoteTotal.MonthTotal.Item");
|
||||
}
|
||||
@@ -913,6 +872,21 @@ public class Config extends YMLFile {
|
||||
return getData().getConfigurationSection("Shop." + identifier);
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoter(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getLoadTopVoterAllTime();
|
||||
case Daily:
|
||||
return getLoadTopVoterDaily();
|
||||
case Monthly:
|
||||
return getLoadTopVoterMonthly();
|
||||
case Weekly:
|
||||
return getLoadTopVoterWeekly();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoterAllTime() {
|
||||
return getData().getBoolean("LoadTopVoter.AllTime", true);
|
||||
}
|
||||
@@ -929,24 +903,6 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("LoadTopVoter.Weekly");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log debug to file.
|
||||
*
|
||||
* @return the log debug to file
|
||||
*/
|
||||
public boolean getLogDebugToFile() {
|
||||
return getData().getBoolean("LogDebugToFile", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log votes to file.
|
||||
*
|
||||
* @return the log votes to file
|
||||
*/
|
||||
public boolean getLogVotesToFile() {
|
||||
return getData().getBoolean("LogVotesToFile");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone reward enabled.
|
||||
*
|
||||
@@ -990,15 +946,6 @@ public class Config extends YMLFile {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly awards enabled.
|
||||
*
|
||||
* @return the monthly awards enabled
|
||||
*/
|
||||
public boolean getMonthlyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableMonthlyAwards");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly possible reward places.
|
||||
*
|
||||
@@ -1012,10 +959,6 @@ public class Config extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getMySql() {
|
||||
return getData().getConfigurationSection("MySQL");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
@@ -1051,15 +994,6 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("ResetMilestonesMonthly");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the send scoreboards.
|
||||
*
|
||||
* @return the send scoreboards
|
||||
*/
|
||||
public boolean getSendScoreboards() {
|
||||
return getData().getBoolean("SendScoreboards");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the store top voters daily.
|
||||
*
|
||||
@@ -1194,15 +1128,6 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("VoteParty.ResetMonthly");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote party rewards.
|
||||
*
|
||||
* @return the vote party rewards
|
||||
*/
|
||||
public String getVotePartyRewardsPath() {
|
||||
return "VoteParty.Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote party votes required.
|
||||
*
|
||||
@@ -1406,15 +1331,6 @@ public class Config extends YMLFile {
|
||||
return "WeeklyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weekly awards enabled.
|
||||
*
|
||||
* @return the weekly awards enabled
|
||||
*/
|
||||
public boolean getWeeklyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableWeeklyAwards");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weekly possible reward places.
|
||||
*
|
||||
@@ -1437,110 +1353,4 @@ public class Config extends YMLFile {
|
||||
plugin.saveResource("Config.yml", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the allow un joined.
|
||||
*
|
||||
* @param value
|
||||
* the new allow un joined
|
||||
*/
|
||||
public void setAllowUnJoined(boolean value) {
|
||||
getData().set("AllowUnjoined", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rewards.
|
||||
*
|
||||
* @param rewards
|
||||
* the new rewards
|
||||
*/
|
||||
public void setAnySiteRewards(ArrayList<String> rewards) {
|
||||
getData().set("AnySiteRewards", rewards);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the broadcast vote enabled.
|
||||
*
|
||||
* @param value
|
||||
* the new broadcast vote enabled
|
||||
*/
|
||||
public void setBroadcastVoteEnabled(boolean value) {
|
||||
getData().set("BroadcastVote", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debug enabled.
|
||||
*
|
||||
* @param value
|
||||
* the new debug enabled
|
||||
*/
|
||||
public void setDebugEnabled(boolean value) {
|
||||
getData().set("Debug", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debug info ingame.
|
||||
*
|
||||
* @param value
|
||||
* the new debug info ingame
|
||||
*/
|
||||
public void setDebugInfoIngame(boolean value) {
|
||||
getData().set("DebugInfoIngame", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the top voter awards enabled.
|
||||
*
|
||||
* @param value
|
||||
* the new top voter awards enabled
|
||||
*/
|
||||
public void setTopVoterAwardsEnabled(boolean value) {
|
||||
getData().set("TopVoterAwards", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteRemindingEnabled(boolean value) {
|
||||
getData().set("VoteReminding.Enabled", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteRemindingRemindDelay(int value) {
|
||||
getData().set("VoteReminding.RemindDelay", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteRemindingRemindOnLogin(boolean value) {
|
||||
getData().set("VoteReminding.RemindOnLogin", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteRemindingRemindOnlyOnce(boolean value) {
|
||||
getData().set("VoteReminding.RemindOnlyOnce", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteRemindingRewards(ArrayList<String> value) {
|
||||
getData().set("VoteReminding.Rewards", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoter(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getLoadTopVoterAllTime();
|
||||
case Daily:
|
||||
return getLoadTopVoterDaily();
|
||||
case Monthly:
|
||||
return getLoadTopVoterMonthly();
|
||||
case Weekly:
|
||||
return getLoadTopVoterWeekly();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* the site name
|
||||
*/
|
||||
public void generateVoteSite(String siteName) {
|
||||
if (Config.getInstance().getAutoCreateVoteSites()) {
|
||||
if (Config.getInstance().isAutoCreateVoteSites()) {
|
||||
String org = siteName;
|
||||
siteName = siteName.replace(".", "_");
|
||||
plugin.getLogger().warning("VoteSite " + siteName
|
||||
@@ -353,6 +353,11 @@ public class ConfigVoteSites extends YMLFile {
|
||||
set(siteName, "Enabled", disabled);
|
||||
}
|
||||
|
||||
public void setForceOffline(String siteName, boolean value) {
|
||||
set(siteName, "ForceOffline", value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the priority.
|
||||
*
|
||||
@@ -401,6 +406,10 @@ public class ConfigVoteSites extends YMLFile {
|
||||
set(siteName, "VoteDelay", voteDelay);
|
||||
}
|
||||
|
||||
public void setVoteDelayDaily(String siteName, boolean value) {
|
||||
set(siteName, "VoteDelayDaily", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote URL.
|
||||
*
|
||||
@@ -432,13 +441,4 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return pass;
|
||||
}
|
||||
|
||||
public void setForceOffline(String siteName, boolean value) {
|
||||
set(siteName, "ForceOffline", value);
|
||||
|
||||
}
|
||||
|
||||
public void setVoteDelayDaily(String siteName, boolean value) {
|
||||
set(siteName, "VoteDelayDaily", value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class ServerData {
|
||||
getData().set("Signs." + count + ".Data", data);
|
||||
getData().set("Signs." + count + ".Position", position);
|
||||
saveData();
|
||||
plugin.signs.add(new SignHandler("" + count, getSignLocation("" + count), getSignData("" + count),
|
||||
plugin.getSigns().add(new SignHandler("" + count, getSignLocation("" + count), getSignData("" + count),
|
||||
getSignPosition("" + count)));
|
||||
}
|
||||
|
||||
|
||||
+10
-51
@@ -5,6 +5,9 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
@@ -23,25 +26,16 @@ public class PlayerSpecialRewardEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private User user;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private SpecialRewardType type;
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public SpecialRewardType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(SpecialRewardType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/** The cancelled. */
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerSpecialRewardEvent(User user, SpecialRewardType type) {
|
||||
@@ -52,7 +46,6 @@ public class PlayerSpecialRewardEvent extends Event {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
@@ -60,38 +53,4 @@ public class PlayerSpecialRewardEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user
|
||||
*/
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* the user to set
|
||||
*/
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
@@ -23,15 +26,26 @@ public class PlayerVoteEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/** The player. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String player;
|
||||
|
||||
/** The vote site. */
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
/** The cancelled. */
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean realVote = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite = "";
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername, String serviceSite, boolean realVote) {
|
||||
super(true);
|
||||
setPlayer(voteUsername);
|
||||
@@ -42,7 +56,6 @@ public class PlayerVoteEvent extends Event {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
@@ -50,81 +63,4 @@ public class PlayerVoteEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site.
|
||||
*
|
||||
* @return the vote site
|
||||
*/
|
||||
public VoteSite getVoteSite() {
|
||||
return voteSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
public void setPlayer(String voteUsername) {
|
||||
this.player = voteUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote site.
|
||||
*
|
||||
* @param voteSite
|
||||
* the new vote site
|
||||
*/
|
||||
public void setVoteSite(VoteSite voteSite) {
|
||||
this.voteSite = voteSite;
|
||||
}
|
||||
|
||||
private boolean realVote = true;
|
||||
|
||||
public void setRealVote(boolean b) {
|
||||
realVote = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the realVote
|
||||
*/
|
||||
public boolean isRealVote() {
|
||||
return realVote;
|
||||
}
|
||||
|
||||
private String serviceSite = "";
|
||||
|
||||
public void setServiceSite(String value) {
|
||||
serviceSite = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the serviceSite
|
||||
*/
|
||||
public String getServiceSite() {
|
||||
return serviceSite;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,20 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public enum SpecialRewardType {
|
||||
ALLSITE, CUMMULATIVE, MILESTONE, VOTESTREAK, FIRSTVOTE;
|
||||
|
||||
@Getter
|
||||
|
||||
private int amount = -1;
|
||||
@Getter
|
||||
|
||||
private String type = "";
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
public SpecialRewardType setAmount(int num) {
|
||||
amount = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpecialRewardType setType(String type) {
|
||||
@@ -18,16 +22,4 @@ public enum SpecialRewardType {
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpecialRewardType setAmount(int num) {
|
||||
amount = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount
|
||||
*/
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package com.Ben12345rocks.VotingPlugin.Events;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
@@ -21,7 +24,8 @@ public class VotePartyEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/** The cancelled. */
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public VotePartyEvent() {
|
||||
@@ -30,7 +34,6 @@ public class VotePartyEvent extends Event {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
@@ -38,23 +41,4 @@ public class VotePartyEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class BlockBreak implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
for (SignHandler sign : plugin.getSigns()) {
|
||||
if (sign.getLocation().equals(loc)) {
|
||||
sign.removeSign();
|
||||
sign.setValid(false);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PlayerInteract implements Listener {
|
||||
// plugin.debug("Checking for sign click");
|
||||
if (event.getClickedBlock().getState() instanceof Sign) {
|
||||
// plugin.debug(player.getName() + " right clicked a sign");
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
for (SignHandler sign : plugin.getSigns()) {
|
||||
if (sign.isLocationSame(event.getClickedBlock().getLocation())) {
|
||||
// plugin.debug(player.getName() +
|
||||
// " right clicked a top voter sign, sending message");
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UserStorage;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
@@ -57,7 +56,7 @@ public class PlayerVoteListener implements Listener {
|
||||
public void onplayerVote(PlayerVoteEvent event) {
|
||||
String playerName = event.getPlayer();
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName)) {
|
||||
if (!config.allowUnJoined()) {
|
||||
if (!config.isAllowUnjoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
return;
|
||||
@@ -68,7 +67,7 @@ public class PlayerVoteListener implements Listener {
|
||||
|
||||
// check valid service sites
|
||||
if (voteSite == null) {
|
||||
if (!Config.getInstance().getDisableNoServiceSiteMessage()) {
|
||||
if (!Config.getInstance().isDisableNoServiceSiteMessage()) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + event.getServiceSite() + "'");
|
||||
plugin.getLogger().warning(
|
||||
"Please read here on how to fix it: https://github.com/Ben12345rocks/VotingPlugin/wiki/Common-Problems");
|
||||
@@ -85,13 +84,17 @@ public class PlayerVoteListener implements Listener {
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
|
||||
if (Config.getInstance().isClearCacheOnVote()) {
|
||||
user.clearCache();
|
||||
}
|
||||
|
||||
synchronized (object) {
|
||||
|
||||
// vote party
|
||||
VoteParty.getInstance().vote(user, event.isRealVote());
|
||||
|
||||
// broadcast vote if enabled in config
|
||||
if (config.getBroadCastVotesEnabled()) {
|
||||
if (config.isBroadcastVotesEnabled()) {
|
||||
if (!Config.getInstance().getFormatBroadcastWhenOnline() || user.isOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
}
|
||||
@@ -109,7 +112,8 @@ public class PlayerVoteListener implements Listener {
|
||||
|
||||
// check if player has voted on all sites in one day
|
||||
|
||||
if (user.isOnline() || voteSite.isGiveOffline()) {
|
||||
if ((user.isOnline() || voteSite.isGiveOffline())
|
||||
&& AdvancedCoreHook.getInstance().getOptions().isProcessRewards()) {
|
||||
user.playerVote(voteSite, true, false);
|
||||
user.closeInv();
|
||||
} else {
|
||||
@@ -119,8 +123,8 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
|
||||
// add to total votes
|
||||
if (Config.getInstance().getCountFakeVotes() || event.isRealVote()) {
|
||||
if (Config.getInstance().getAddTotals()) {
|
||||
if (Config.getInstance().isCountFakeVotes() || event.isRealVote()) {
|
||||
if (Config.getInstance().isAddTotals()) {
|
||||
user.addTotal();
|
||||
user.addTotalDaily();
|
||||
user.addTotalWeekly();
|
||||
@@ -132,12 +136,6 @@ public class PlayerVoteListener implements Listener {
|
||||
SpecialRewards.getInstance().checkAllSites(user);
|
||||
SpecialRewards.getInstance().checkCumualativeVotes(user);
|
||||
SpecialRewards.getInstance().checkMilestone(user);
|
||||
|
||||
if (Config.getInstance().getClearCacheOnVote()) {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
AdvancedCoreHook.getInstance().getMysql().removePlayer(user.getUUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
|
||||
@@ -78,12 +78,12 @@ public class VotiferEvent implements Listener {
|
||||
|
||||
ArrayList<String> sites = configVoteSites.getVoteSitesNames();
|
||||
if (sites != null) {
|
||||
if (!sites.contains(voteSiteName) && Config.getInstance().getAutoCreateVoteSites()) {
|
||||
if (!sites.contains(voteSiteName) && Config.getInstance().isAutoCreateVoteSites()) {
|
||||
plugin.getLogger()
|
||||
.warning("VoteSite " + voteSiteName + " doe not exist, generaterating one...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
}
|
||||
} else if (Config.getInstance().getAutoCreateVoteSites()) {
|
||||
} else if (Config.getInstance().isAutoCreateVoteSites()) {
|
||||
plugin.getLogger().warning("VoteSite " + voteSiteName + " doe not exist, generaterating one...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,9 @@ import com.Ben12345rocks.VotingPlugin.Util.PlaceHolders.PlaceHolders;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteReminding.VoteReminding;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* The Class Main.
|
||||
*/
|
||||
@@ -79,42 +82,39 @@ public class Main extends JavaPlugin {
|
||||
/** The plugin. */
|
||||
public static Main plugin;
|
||||
|
||||
@Getter
|
||||
private LinkedHashMap<TopVoter, LinkedHashMap<User, Integer>> topVoter;
|
||||
|
||||
/**
|
||||
* @return the topVoter
|
||||
*/
|
||||
public LinkedHashMap<TopVoter, LinkedHashMap<User, Integer>> getTopVoter() {
|
||||
return topVoter;
|
||||
}
|
||||
@Getter
|
||||
@Setter
|
||||
private Updater updater;
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoter(TopVoter top) {
|
||||
return topVoter.get(top);
|
||||
}
|
||||
@Getter
|
||||
@Setter
|
||||
private ArrayList<CommandHandler> voteCommand;
|
||||
|
||||
/** The updater. */
|
||||
public Updater updater;
|
||||
@Getter
|
||||
@Setter
|
||||
private ArrayList<CommandHandler> adminVoteCommand;
|
||||
|
||||
/** The vote command. */
|
||||
public ArrayList<CommandHandler> voteCommand;
|
||||
|
||||
/** The admin vote command. */
|
||||
public ArrayList<CommandHandler> adminVoteCommand;
|
||||
|
||||
/** The vote sites. */
|
||||
@Getter
|
||||
private List<VoteSite> voteSites;
|
||||
|
||||
/** The vote today. */
|
||||
public LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> voteToday;
|
||||
@Getter
|
||||
private LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> voteToday;
|
||||
|
||||
/** The signs. */
|
||||
public ArrayList<SignHandler> signs;
|
||||
@Getter
|
||||
@Setter
|
||||
private ArrayList<SignHandler> signs;
|
||||
|
||||
/** The vote log. */
|
||||
public Logger voteLog;
|
||||
@Getter
|
||||
private Logger voteLog;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean update = true;
|
||||
|
||||
@Getter
|
||||
private boolean updateStarted = false;
|
||||
|
||||
/**
|
||||
@@ -215,30 +215,8 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().debug(plugin, message);
|
||||
}
|
||||
|
||||
public ArrayList<CommandHandler> getAdminVoteCommand() {
|
||||
return adminVoteCommand;
|
||||
}
|
||||
|
||||
public ArrayList<SignHandler> getSigns() {
|
||||
return signs;
|
||||
}
|
||||
|
||||
/*
|
||||
* public LinkedHashMap<User, Integer> getTopVoterAllTime() { return
|
||||
* topVoterAllTime; }
|
||||
*
|
||||
* public LinkedHashMap<User, Integer> getTopVoterDaily() { return
|
||||
* topVoterDaily; }
|
||||
*
|
||||
* public LinkedHashMap<User, Integer> getTopVoterMonthly() { return
|
||||
* topVoterMonthly; }
|
||||
*
|
||||
* public LinkedHashMap<User, Integer> getTopVoterWeekly() { return
|
||||
* topVoterWeekly; }
|
||||
*/
|
||||
|
||||
public Updater getUpdater() {
|
||||
return updater;
|
||||
public LinkedHashMap<User, Integer> getTopVoter(TopVoter top) {
|
||||
return topVoter.get(top);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,14 +234,6 @@ public class Main extends JavaPlugin {
|
||||
return UserManager.getInstance();
|
||||
}
|
||||
|
||||
public ArrayList<CommandHandler> getVoteCommand() {
|
||||
return voteCommand;
|
||||
}
|
||||
|
||||
public Logger getVoteLog() {
|
||||
return voteLog;
|
||||
}
|
||||
|
||||
public VoteParty getVoteParty() {
|
||||
return VoteParty.getInstance();
|
||||
}
|
||||
@@ -282,7 +252,7 @@ public class Main extends JavaPlugin {
|
||||
return voteSite;
|
||||
}
|
||||
}
|
||||
if (Config.getInstance().getAutoCreateVoteSites() && !configVoteSites.getVoteSitesNames().contains(siteName)) {
|
||||
if (Config.getInstance().isAutoCreateVoteSites() && !configVoteSites.getVoteSitesNames().contains(siteName)) {
|
||||
configVoteSites.generateVoteSite(siteName);
|
||||
return new VoteSite(siteName.replace(".", "_"));
|
||||
}
|
||||
@@ -343,14 +313,6 @@ public class Main extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
public List<VoteSite> getVoteSites() {
|
||||
return voteSites;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> getVoteToday() {
|
||||
return voteToday;
|
||||
}
|
||||
|
||||
public boolean hasVoteSite(String site) {
|
||||
String siteName = getVoteSiteName(site);
|
||||
for (VoteSite voteSite : getVoteSites()) {
|
||||
@@ -361,14 +323,6 @@ public class Main extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isUpdate() {
|
||||
return update;
|
||||
}
|
||||
|
||||
public boolean isUpdateStarted() {
|
||||
return updateStarted;
|
||||
}
|
||||
|
||||
private void loadTimer() {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@@ -413,7 +367,7 @@ public class Main extends JavaPlugin {
|
||||
* the vote site
|
||||
*/
|
||||
public void logVote(Date date, String playerName, String voteSite) {
|
||||
if (Config.getInstance().getLogVotesToFile()) {
|
||||
if (Config.getInstance().isLogVotesToFile()) {
|
||||
String str = new SimpleDateFormat("EEE, d MMM yyyy HH:mm").format(date);
|
||||
voteLog.logToFile(str + ": " + playerName + " voted on " + voteSite);
|
||||
}
|
||||
@@ -592,14 +546,14 @@ public class Main extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getAutoCreateVoteSites();
|
||||
return "" + Config.getInstance().isAutoCreateVoteSites();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("sendscoreboards") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getSendScoreboards();
|
||||
return "" + AdvancedCoreHook.getInstance().getOptions().isSendScoreboards();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofuser") {
|
||||
@@ -618,14 +572,14 @@ public class Main extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return Config.getInstance().getDataStorage().toUpperCase();
|
||||
return AdvancedCoreHook.getInstance().getOptions().getStorageType().toString();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("DisableCheckOnWorldChange") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getDisableCheckOnWorldChange();
|
||||
return "" + AdvancedCoreHook.getInstance().getOptions().isDisableCheckOnWorldChange();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votereminding_enabled") {
|
||||
@@ -639,56 +593,56 @@ public class Main extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIToday();
|
||||
return "" + Config.getInstance().isCommandsUseGUIToday();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_TopVoter") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUITopVoter();
|
||||
return "" + Config.getInstance().isCommandsUseGUITopVoter();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Last") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUILast();
|
||||
return "" + Config.getInstance().isCommandsUseGUILast();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Next") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUINext();
|
||||
return "" + Config.getInstance().isCommandsUseGUINext();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Total") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUITotal();
|
||||
return "" + Config.getInstance().isCommandsUseGUITotal();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Vote") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIVote();
|
||||
return "" + Config.getInstance().isCommandsUseGUIVote();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Best") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIBest();
|
||||
return "" + Config.getInstance().isCommandsUseGUIBest();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Streak") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIStreak();
|
||||
return "" + Config.getInstance().isCommandsUseGUIStreak();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Monthly") {
|
||||
@@ -716,7 +670,6 @@ public class Main extends JavaPlugin {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onDisable()
|
||||
*/
|
||||
@Override
|
||||
@@ -734,7 +687,6 @@ public class Main extends JavaPlugin {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
@@ -757,7 +709,7 @@ public class Main extends JavaPlugin {
|
||||
plugin.signs = new ArrayList<SignHandler>();
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Signs.getInstance().loadSigns();
|
||||
@@ -862,7 +814,7 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (NMSManager.getInstance().isVersion("1.7", "1.8", "1.9", "1.10", "1.11", "1.12")) {
|
||||
plugin.getLogger().warning("Detected running " + NMSManager.getInstance().getVersion()
|
||||
plugin.getLogger().severe("Detected running " + NMSManager.getInstance().getVersion()
|
||||
+ ", this version is not supported on this build");
|
||||
}
|
||||
}
|
||||
@@ -938,10 +890,6 @@ public class Main extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
public void setUpdate(boolean update) {
|
||||
this.update = update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup files.
|
||||
*/
|
||||
@@ -985,55 +933,60 @@ public class Main extends JavaPlugin {
|
||||
* Update.
|
||||
*/
|
||||
public void update() {
|
||||
if (update && plugin != null && !updateStarted) {
|
||||
updateStarted = true;
|
||||
update = false;
|
||||
if (update || Config.getInstance().isAlwaysUpdate()) {
|
||||
if (!updateStarted && plugin != null) {
|
||||
if (!Config.getInstance().isUpdateWithPlayersOnlineOnly() || Bukkit.getOnlinePlayers().size() != 0) {
|
||||
updateStarted = true;
|
||||
update = false;
|
||||
|
||||
synchronized (plugin) {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
if (AdvancedCoreHook.getInstance().getMysql() == null) {
|
||||
plugin.debug("MySQL not loaded yet");
|
||||
return;
|
||||
} else if (Config.getInstance().getClearCacheOnUpdate()) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
} else {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCacheBasic();
|
||||
}
|
||||
}
|
||||
synchronized (plugin) {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
if (AdvancedCoreHook.getInstance().getMysql() == null) {
|
||||
plugin.debug("MySQL not loaded yet");
|
||||
return;
|
||||
} else if (Config.getInstance().isClearCacheOnUpdate()) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
} else {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCacheBasic();
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug("Starting background task");
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
ArrayList<User> users = new ArrayList<User>();
|
||||
for (String uuid : uuids) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
users.add(user);
|
||||
// AdvancedCoreHook.getInstance().extraDebug("Loading " + uuid);
|
||||
// java.lang.Thread.sleep(5000);
|
||||
plugin.debug("Starting background task");
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
ArrayList<User> users = new ArrayList<User>();
|
||||
for (String uuid : uuids) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
users.add(user);
|
||||
// AdvancedCoreHook.getInstance().extraDebug("Loading " + uuid);
|
||||
// java.lang.Thread.sleep(5000);
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + users.size()
|
||||
+ " users");
|
||||
TopVoterHandler.getInstance().updateTopVoters(users);
|
||||
Commands.getInstance().updateVoteToday(users);
|
||||
ServerData.getInstance().updateValues();
|
||||
Signs.getInstance().updateSigns();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
UserManager.getInstance().getVotingPluginUser(player).offVote();
|
||||
}
|
||||
time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Background task finished in " + time1 + " seconds");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
plugin.getLogger().info("Looks like something went wrong.");
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + users.size() + " users");
|
||||
TopVoterHandler.getInstance().updateTopVoters(users);
|
||||
Commands.getInstance().updateVoteToday(users);
|
||||
ServerData.getInstance().updateValues();
|
||||
Signs.getInstance().updateSigns();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
UserManager.getInstance().getVotingPluginUser(player).offVote();
|
||||
}
|
||||
time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Background task finished in " + time1 + " seconds");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
plugin.getLogger().info("Looks like something went wrong.");
|
||||
updateStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
updateStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -371,14 +371,6 @@ public class User extends com.Ben12345rocks.AdvancedCore.UserManager.User {
|
||||
return getData().getInt("MonthTotal");
|
||||
}
|
||||
|
||||
public int getVoteShopIdentifierLimit(String identifier) {
|
||||
return getData().getInt("VoteShopLimit" + identifier);
|
||||
}
|
||||
|
||||
public void setVoteShopIdentifierLimit(String identifier, int value) {
|
||||
getData().setInt("VoteShopLimit" + identifier, value);
|
||||
}
|
||||
|
||||
public int getMonthVoteStreak() {
|
||||
return getData().getInt("MonthVoteStreak");
|
||||
}
|
||||
@@ -415,10 +407,28 @@ public class User extends com.Ben12345rocks.AdvancedCore.UserManager.User {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getTotal(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getUserData().getInt("AllTimeTotal");
|
||||
case Daily:
|
||||
return getUserData().getInt("DailyTotal");
|
||||
case Monthly:
|
||||
return getData().getInt("MonthTotal");
|
||||
case Weekly:
|
||||
return getUserData().getInt("WeeklyTotal");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getVotePartyVotes() {
|
||||
return getUserData().getInt("VotePartyVotes");
|
||||
}
|
||||
|
||||
public int getVoteShopIdentifierLimit(String identifier) {
|
||||
return getData().getInt("VoteShopLimit" + identifier);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getWeeklyTotal() {
|
||||
return getUserData().getInt("WeeklyTotal");
|
||||
@@ -499,7 +509,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.UserManager.User {
|
||||
* @return true if user got the first vote reward
|
||||
*/
|
||||
public boolean hasGottenFirstVote() {
|
||||
return getAllTimeTotal() != 0;
|
||||
return getTotal(TopVoter.AllTime) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -518,11 +528,11 @@ public class User extends com.Ben12345rocks.AdvancedCore.UserManager.User {
|
||||
}
|
||||
|
||||
public boolean isReminded() {
|
||||
return Boolean.valueOf(getUserData().getString("Reminded"));
|
||||
return getUserData().getBoolean("Reminded");
|
||||
}
|
||||
|
||||
public boolean isTopVoterIgnore() {
|
||||
return Boolean.valueOf(getUserData().getString("TopVoterIgnore"));
|
||||
return getUserData().getBoolean("TopVoterIgnore");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -538,6 +548,10 @@ public class User extends com.Ben12345rocks.AdvancedCore.UserManager.User {
|
||||
* Off vote.
|
||||
*/
|
||||
public void offVote() {
|
||||
if (!AdvancedCoreHook.getInstance().getOptions().isProcessRewards()) {
|
||||
AdvancedCoreHook.getInstance().debug("Processing rewards is disabled");
|
||||
return;
|
||||
}
|
||||
AdvancedCoreHook.getInstance().extraDebug("Checking offline vote site votes");
|
||||
Player player = getPlayer();
|
||||
if (player != null) {
|
||||
@@ -577,54 +591,13 @@ public class User extends com.Ben12345rocks.AdvancedCore.UserManager.User {
|
||||
* the broadcast
|
||||
*/
|
||||
public void playerVote(VoteSite voteSite, boolean online, boolean broadcast) {
|
||||
if (Config.getInstance().getFormatBroadcastWhenOnline() && Config.getInstance().getBroadCastVotesEnabled()
|
||||
if (Config.getInstance().getFormatBroadcastWhenOnline() && Config.getInstance().isBroadcastVotesEnabled()
|
||||
&& broadcast) {
|
||||
voteSite.broadcastVote(this);
|
||||
}
|
||||
voteSite.giveRewards(this, online);
|
||||
}
|
||||
|
||||
public int getTotal(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getUserData().getInt("AllTimeTotal");
|
||||
case Daily:
|
||||
return getUserData().getInt("DailyTotal");
|
||||
case Monthly:
|
||||
return getData().getInt("MonthTotal");
|
||||
case Weekly:
|
||||
return getUserData().getInt("WeeklyTotal");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setTotal(TopVoter top, int value) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
getUserData().setInt("AllTimeTotal", value);
|
||||
break;
|
||||
case Daily:
|
||||
getUserData().setInt("DailyTotal", value);
|
||||
break;
|
||||
case Monthly:
|
||||
getData().setInt("MonthTotal", value);
|
||||
break;
|
||||
case Weekly:
|
||||
getUserData().setInt("WeeklyTotal", value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void resetTotals(TopVoter topVoter) {
|
||||
if (topVoter.equals(TopVoter.Monthly)) {
|
||||
setLastMonthTotal(getTotal(TopVoter.Monthly));
|
||||
}
|
||||
setTotal(topVoter, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the points.
|
||||
*
|
||||
@@ -640,6 +613,13 @@ public class User extends com.Ben12345rocks.AdvancedCore.UserManager.User {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetTotals(TopVoter topVoter) {
|
||||
if (topVoter.equals(TopVoter.Monthly)) {
|
||||
setLastMonthTotal(getTotal(TopVoter.Monthly));
|
||||
}
|
||||
setTotal(topVoter, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send vote effects.
|
||||
*
|
||||
@@ -776,10 +756,34 @@ public class User extends com.Ben12345rocks.AdvancedCore.UserManager.User {
|
||||
getUserData().setString("TopVoterIgnore", "" + topVoterIgnore);
|
||||
}
|
||||
|
||||
public void setTotal(TopVoter top, int value) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
getUserData().setInt("AllTimeTotal", value);
|
||||
break;
|
||||
case Daily:
|
||||
getUserData().setInt("DailyTotal", value);
|
||||
break;
|
||||
case Monthly:
|
||||
getData().setInt("MonthTotal", value);
|
||||
break;
|
||||
case Weekly:
|
||||
getUserData().setInt("WeeklyTotal", value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void setVotePartyVotes(int value) {
|
||||
getUserData().setInt("VotePartyVotes", value);
|
||||
}
|
||||
|
||||
public void setVoteShopIdentifierLimit(String identifier, int value) {
|
||||
getData().setInt("VoteShopLimit" + identifier, value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setWeeklyTotal(int total) {
|
||||
getUserData().setInt("WeeklyTotal", total);
|
||||
|
||||
@@ -20,6 +20,9 @@ import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* The Class VoteSite.
|
||||
*/
|
||||
@@ -34,30 +37,43 @@ public class VoteSite {
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/** The vote URL. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String voteURL;
|
||||
|
||||
/** The service site. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite;
|
||||
|
||||
/** The site name. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String key;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String displayName;
|
||||
|
||||
/** The vote delay. */
|
||||
@Getter
|
||||
@Setter
|
||||
private double voteDelay;
|
||||
|
||||
/** The enabled. */
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean enabled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean voteDelayDaily;
|
||||
|
||||
/** The priority. */
|
||||
@Getter
|
||||
@Setter
|
||||
private int priority;
|
||||
|
||||
@Setter
|
||||
private ConfigurationSection item;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean giveOffline;
|
||||
|
||||
/**
|
||||
@@ -109,13 +125,6 @@ public class VoteSite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the displayName
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item
|
||||
*/
|
||||
@@ -129,49 +138,6 @@ public class VoteSite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the priority.
|
||||
*
|
||||
* @return the priority
|
||||
*/
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service site.
|
||||
*
|
||||
* @return the service site
|
||||
*/
|
||||
public String getServiceSite() {
|
||||
return serviceSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote delay.
|
||||
*
|
||||
* @return the vote delay
|
||||
*/
|
||||
public double getVoteDelay() {
|
||||
return voteDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL.
|
||||
*
|
||||
* @return the vote URL
|
||||
*/
|
||||
public String getVoteURL() {
|
||||
return voteURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give rewards.
|
||||
*
|
||||
@@ -193,10 +159,6 @@ public class VoteSite {
|
||||
public boolean hasRewards() {
|
||||
return RewardHandler.getInstance().hasRewards(configVoteSites.getData(), configVoteSites.getRewardsPath(key));
|
||||
}
|
||||
|
||||
public boolean isVaidServiceSite() {
|
||||
return ArrayUtils.getInstance().containsIgnoreCase(ServerData.getInstance().getServiceSites(), getServiceSite());
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the.
|
||||
@@ -216,117 +178,9 @@ public class VoteSite {
|
||||
giveOffline = configVoteSites.getVoteSiteGiveOffline(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is enabled.
|
||||
*
|
||||
* @return true, if is enabled
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the giveOffline
|
||||
*/
|
||||
public boolean isGiveOffline() {
|
||||
return giveOffline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the voteDelayDaily
|
||||
*/
|
||||
public boolean isVoteDelayDaily() {
|
||||
return voteDelayDaily;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayName
|
||||
* the displayName to set
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled.
|
||||
*
|
||||
* @param enabled
|
||||
* the new enabled
|
||||
*/
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param giveOffline
|
||||
* the giveOffline to set
|
||||
*/
|
||||
public void setGiveOffline(boolean giveOffline) {
|
||||
this.giveOffline = giveOffline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* the item to set
|
||||
*/
|
||||
public void setItem(ConfigurationSection item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* the key to set
|
||||
*/
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the priority.
|
||||
*
|
||||
* @param priority
|
||||
* the new priority
|
||||
*/
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the service site.
|
||||
*
|
||||
* @param serviceSite
|
||||
* the new service site
|
||||
*/
|
||||
public void setServiceSite(String serviceSite) {
|
||||
this.serviceSite = serviceSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote delay.
|
||||
*
|
||||
* @param voteDelay
|
||||
* the new vote delay
|
||||
*/
|
||||
public void setVoteDelay(double voteDelay) {
|
||||
this.voteDelay = voteDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param voteDelayDaily
|
||||
* the voteDelayDaily to set
|
||||
*/
|
||||
public void setVoteDelayDaily(boolean voteDelayDaily) {
|
||||
this.voteDelayDaily = voteDelayDaily;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote URL.
|
||||
*
|
||||
* @param voteURL
|
||||
* the new vote URL
|
||||
*/
|
||||
public void setVoteURL(String voteURL) {
|
||||
this.voteURL = voteURL;
|
||||
public boolean isVaidServiceSite() {
|
||||
return ArrayUtils.getInstance().containsIgnoreCase(ServerData.getInstance().getServiceSites(),
|
||||
getServiceSite());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,19 +19,25 @@ import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class SignHandler.
|
||||
*/
|
||||
public class SignHandler {
|
||||
|
||||
/** The sign. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String sign;
|
||||
|
||||
/** The location. */
|
||||
@Getter
|
||||
@Setter
|
||||
private Location location;
|
||||
|
||||
/** The data. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String data;
|
||||
|
||||
/** The lines. */
|
||||
@@ -49,8 +55,9 @@ public class SignHandler {
|
||||
/** The votes. */
|
||||
private int votes;
|
||||
|
||||
/** The is valid. */
|
||||
private boolean isValid;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean valid;
|
||||
|
||||
/**
|
||||
* Instantiates a new sign handler.
|
||||
@@ -117,24 +124,6 @@ public class SignHandler {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location.
|
||||
*
|
||||
* @return the location
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the right click message.
|
||||
*
|
||||
@@ -149,15 +138,6 @@ public class SignHandler {
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign.
|
||||
*
|
||||
* @return the sign
|
||||
*/
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is location same.
|
||||
*
|
||||
@@ -169,15 +149,6 @@ public class SignHandler {
|
||||
return loc.equals(getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is valid.
|
||||
*
|
||||
* @return true, if is valid
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the sign.
|
||||
*/
|
||||
@@ -185,46 +156,6 @@ public class SignHandler {
|
||||
ServerData.getInstance().removeSign(sign);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data.
|
||||
*
|
||||
* @param data
|
||||
* the new data
|
||||
*/
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location.
|
||||
*
|
||||
* @param location
|
||||
* the new location
|
||||
*/
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sign.
|
||||
*
|
||||
* @param sign
|
||||
* the new sign
|
||||
*/
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the valid.
|
||||
*
|
||||
* @param isValid
|
||||
* the new valid
|
||||
*/
|
||||
public void setValid(boolean isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store sign.
|
||||
*/
|
||||
|
||||
@@ -65,10 +65,10 @@ public class Signs {
|
||||
* Load signs.
|
||||
*/
|
||||
public void loadSigns() {
|
||||
plugin.signs = new ArrayList<SignHandler>();
|
||||
plugin.setSigns(new ArrayList<SignHandler>());
|
||||
for (String sign : ServerData.getInstance().getSigns()) {
|
||||
// plugin.getLogger().info("Loading sign " + sign);
|
||||
plugin.signs.add(new SignHandler(sign, ServerData.getInstance().getSignLocation(sign),
|
||||
plugin.getSigns().add(new SignHandler(sign, ServerData.getInstance().getSignLocation(sign),
|
||||
ServerData.getInstance().getSignData(sign), ServerData.getInstance().getSignPosition(sign)));
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class Signs {
|
||||
* Store signs.
|
||||
*/
|
||||
public void storeSigns() {
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
for (SignHandler sign : plugin.getSigns()) {
|
||||
sign.storeSign();
|
||||
}
|
||||
}
|
||||
@@ -87,14 +87,14 @@ public class Signs {
|
||||
*/
|
||||
public void updateSigns() {
|
||||
int time = 0;
|
||||
for (int i = plugin.signs.size() - 1; i >= 0; i--) {
|
||||
if (!plugin.signs.get(i).isValid()) {
|
||||
for (int i = plugin.getSigns().size() - 1; i >= 0; i--) {
|
||||
if (!plugin.getSigns().get(i).isValid()) {
|
||||
plugin.debug("Sign " + i + " invalid, removing from data.");
|
||||
plugin.signs.get(i).removeSign();
|
||||
plugin.signs.remove(i);
|
||||
plugin.getSigns().get(i).removeSign();
|
||||
plugin.getSigns().remove(i);
|
||||
} else {
|
||||
plugin.signs.get(i).updateLines();
|
||||
plugin.signs.get(i).updateSign(time);
|
||||
plugin.getSigns().get(i).updateLines();
|
||||
plugin.getSigns().get(i).updateSign(time);
|
||||
time += 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,13 @@ import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
public class VoteTester {
|
||||
|
||||
private static VoteTester instance = new VoteTester();
|
||||
private Main plugin = Main.plugin;
|
||||
|
||||
public static VoteTester getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Main plugin = Main.plugin;
|
||||
|
||||
public void testVotes(int amount, String name, String site) {
|
||||
long time1 = System.currentTimeMillis();
|
||||
ArrayList<Long> timesPerVote = new ArrayList<Long>();
|
||||
|
||||
@@ -24,6 +24,18 @@ public enum TopVoter {
|
||||
return AllTime;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (this.equals(TopVoter.Monthly)) {
|
||||
return Config.getInstance().getFormatTopVoterMonthly();
|
||||
} else if (this.equals(TopVoter.Weekly)) {
|
||||
return Config.getInstance().getFormatTopVoterWeekly();
|
||||
} else if (this.equals(TopVoter.Daily)) {
|
||||
return Config.getInstance().getFormatTopVoterDaily();
|
||||
} else {
|
||||
return Config.getInstance().getFormatTopVoterAllTime();
|
||||
}
|
||||
}
|
||||
|
||||
public TopVoter next() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
@@ -75,16 +87,4 @@ public enum TopVoter {
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (this.equals(TopVoter.Monthly)) {
|
||||
return Config.getInstance().getFormatTopVoterMonthly();
|
||||
} else if (this.equals(TopVoter.Weekly)) {
|
||||
return Config.getInstance().getFormatTopVoterWeekly();
|
||||
} else if (this.equals(TopVoter.Daily)) {
|
||||
return Config.getInstance().getFormatTopVoterDaily();
|
||||
} else {
|
||||
return Config.getInstance().getFormatTopVoterAllTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class TopVoterHandler implements Listener {
|
||||
storeTopVoters(TopVoter.Daily);
|
||||
}
|
||||
|
||||
if (Config.getInstance().getDailyAwardsEnabled()) {
|
||||
if (Config.getInstance().isEnableDailyRewards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getDailyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
@@ -168,7 +168,7 @@ public class TopVoterHandler implements Listener {
|
||||
storeTopVoters(TopVoter.Monthly);
|
||||
}
|
||||
|
||||
if (Config.getInstance().getMonthlyAwardsEnabled()) {
|
||||
if (Config.getInstance().isEnableMonthlyAwards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getMonthlyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
@@ -228,7 +228,7 @@ public class TopVoterHandler implements Listener {
|
||||
storeTopVoters(TopVoter.Weekly);
|
||||
}
|
||||
|
||||
if (Config.getInstance().getWeeklyAwardsEnabled()) {
|
||||
if (Config.getInstance().isEnableWeeklyAwards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getWeeklyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
|
||||
@@ -49,44 +49,45 @@ public class CheckUpdate {
|
||||
* Check update.
|
||||
*/
|
||||
public void checkUpdate() {
|
||||
plugin.updater = new Updater(plugin, 15358, false);
|
||||
final Updater.UpdateResult result = plugin.updater.getResult();
|
||||
plugin.setUpdater(new Updater(plugin, 15358, false));
|
||||
final Updater.UpdateResult result = plugin.getUpdater().getResult();
|
||||
switch (result) {
|
||||
case FAIL_SPIGOT: {
|
||||
plugin.getLogger().info("Failed to check for update for " + plugin.getName() + "!");
|
||||
break;
|
||||
}
|
||||
case NO_UPDATE: {
|
||||
plugin.getLogger().info(plugin.getName() + " is up to date! Version: " + plugin.updater.getVersion());
|
||||
break;
|
||||
}
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.updater.getVersion()
|
||||
+ " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
case FAIL_SPIGOT: {
|
||||
plugin.getLogger().info("Failed to check for update for " + plugin.getName() + "!");
|
||||
break;
|
||||
}
|
||||
case NO_UPDATE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " is up to date! Version: " + plugin.getUpdater().getVersion());
|
||||
break;
|
||||
}
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: "
|
||||
+ plugin.getUpdater().getVersion() + " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkUpdateBasic() {
|
||||
plugin.updater = new Updater(plugin, 15358, false);
|
||||
final Updater.UpdateResult result = plugin.updater.getResult();
|
||||
plugin.setUpdater(new Updater(plugin, 15358, false));
|
||||
final Updater.UpdateResult result = plugin.getUpdater().getResult();
|
||||
switch (result) {
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.updater.getVersion()
|
||||
+ " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: "
|
||||
+ plugin.getUpdater().getVersion() + " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-21
@@ -5,16 +5,13 @@ import org.bukkit.OfflinePlayer;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public abstract class PlaceHolder {
|
||||
private String identifier;
|
||||
private boolean useStartsWith = false;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @return the identifier
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
public abstract class PlaceHolder {
|
||||
@Getter
|
||||
private String identifier;
|
||||
@Getter
|
||||
private boolean useStartsWith = false;
|
||||
|
||||
public PlaceHolder(String identifier) {
|
||||
this.identifier = identifier;
|
||||
@@ -25,11 +22,6 @@ public abstract class PlaceHolder {
|
||||
this.useStartsWith = useStartsWith;
|
||||
}
|
||||
|
||||
public PlaceHolder useStartsWith() {
|
||||
useStartsWith = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean matches(String identifier) {
|
||||
if (isUseStartsWith()) {
|
||||
if (StringUtils.getInstance().startsWithIgnoreCase(identifier, getIdentifier())) {
|
||||
@@ -43,13 +35,11 @@ public abstract class PlaceHolder {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the useStartsWith
|
||||
*/
|
||||
public boolean isUseStartsWith() {
|
||||
return useStartsWith;
|
||||
}
|
||||
|
||||
public abstract String placeholderRequest(OfflinePlayer p, User user, String identifier);
|
||||
|
||||
public PlaceHolder useStartsWith() {
|
||||
useStartsWith = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
+29
-44
@@ -15,6 +15,8 @@ import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlaceHolders.
|
||||
@@ -36,6 +38,12 @@ public class PlaceHolders {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private ArrayList<PlaceHolder> placeholders = new ArrayList<PlaceHolder>();
|
||||
|
||||
@Getter
|
||||
private ArrayList<PlaceHolder> nonPlayerPlaceholders = new ArrayList<PlaceHolder>();
|
||||
|
||||
/**
|
||||
* Instantiates a new place holders.
|
||||
*/
|
||||
@@ -52,21 +60,29 @@ public class PlaceHolders {
|
||||
PlaceHolders.plugin = plugin;
|
||||
}
|
||||
|
||||
private ArrayList<PlaceHolder> placeholders = new ArrayList<PlaceHolder>();
|
||||
private ArrayList<PlaceHolder> nonPlayerPlaceholders = new ArrayList<PlaceHolder>();
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
|
||||
/**
|
||||
* @return the nonPlayerPlaceholders
|
||||
*/
|
||||
public ArrayList<PlaceHolder> getNonPlayerPlaceholders() {
|
||||
return nonPlayerPlaceholders;
|
||||
for (PlaceHolder placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
return placeholder.placeholderRequest(p, null, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
|
||||
for (PlaceHolder placeholder : placeholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
return placeholder.placeholderRequest(p, user, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
return identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the placeholders
|
||||
*/
|
||||
public ArrayList<PlaceHolder> getPlaceholders() {
|
||||
return placeholders;
|
||||
public String getPlaceHolder(Player p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
@@ -206,9 +222,6 @@ public class PlaceHolders {
|
||||
return Commands.getInstance().voteCommandNextInfo(user, voteSite);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
placeholders.add(new PlaceHolder("Last_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
@@ -342,11 +355,8 @@ public class PlaceHolders {
|
||||
}
|
||||
}.useStartsWith());
|
||||
|
||||
|
||||
|
||||
|
||||
// non players
|
||||
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder("VotePartyVotesCurrent") {
|
||||
|
||||
@Override
|
||||
@@ -371,29 +381,4 @@ public class PlaceHolders {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
|
||||
for (PlaceHolder placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
return placeholder.placeholderRequest(p, null, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
|
||||
for (PlaceHolder placeholder : placeholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
return placeholder.placeholderRequest(p, user, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public String getPlaceHolder(Player p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user