Compare commits

...
40 Commits
Author SHA1 Message Date
BenCodez e59b171aae Fix deploying profiles 2023-06-17 20:19:31 -04:00
BenCodez 36cfe6c9c6 Update version to 6.13.1 2023-06-17 20:14:32 -04:00
BenCodez 45a413c3a6 Fix minor issue 2023-06-16 16:45:06 -04:00
Ben a640582278 Merge pull request #1275 from akdukaan/patch-2
check milestones in /av user all addmilestonecount
2023-06-16 16:44:07 -04:00
akdukaan 94122a1c80 check milestones in /av user all addmilestonecount 2023-06-15 22:35:28 -05:00
BenCodez 0448278ba1 Fix issue with messages on commands 2023-06-15 17:18:09 -04:00
BenCodez 097bff23a2 Small api change 2023-06-15 16:56:31 -04:00
BenCodez be76d8f4af Support all players on addmilestonecount command 2023-06-15 16:45:58 -04:00
BenCodez 6122805c0d Update cache of onlines players with cleargottenmilestones on all users 2023-06-14 21:44:47 -04:00
BenCodez 392d5cb17a Remove command alias 2023-06-14 21:40:06 -04:00
BenCodez ec1352d52b Add support for clearing all gotten milestones for all players 2023-06-14 21:38:35 -04:00
BenCodez c3a4db1ac8 Update spigot 1.20.1 2023-06-12 17:27:05 -04:00
BenCodez 442eb35a4f Add debug log message if loading vote top last month 2023-06-09 17:06:21 -04:00
BenCodez d0851a9365 Update to 1.20 2023-06-07 19:45:35 -04:00
BenCodez 5273745be5 Remove suppress warnings 2023-06-04 21:00:31 -04:00
BenCodez ca937f6879 edit dependency 2023-06-04 20:48:23 -04:00
BenCodez a4c4fa5556 Fix issue 2023-06-04 20:45:20 -04:00
BenCodez 480c303f2f Add maven profile for folia 2023-06-04 20:44:06 -04:00
BenCodez 347640f346 Fix an issue 2023-06-04 20:23:47 -04:00
BenCodez 1d8314c0eb Test change for java 8 support 2023-06-04 17:24:53 -04:00
BenCodez 20d95baea9 Chnages to placeholder handling 2023-06-04 15:24:49 -04:00
BenCodez 510f400c1b Update placeholders every minute 2023-06-03 15:11:41 -04:00
BenCodez c49d0b3ede Add extra log messages for top voter rewards 2023-06-01 21:32:04 -04:00
BenCodez ff197cb6b6 Add folia support, upgrade to java 17, credits to LOOHP 2023-05-31 20:12:08 -04:00
Ben 9e4605258b Delete stale.yml 2023-05-30 20:26:39 -04:00
Ben c54e8bc8bd Merge pull request #1273 from BenCodez/BenCodez-patch-1
Create stale.yml
2023-05-30 20:25:57 -04:00
Ben fe937b8f8d Create stale.yml 2023-05-30 20:25:45 -04:00
BenCodez d262b3689a Apply voteshop option to voteshop command 2023-05-28 20:06:43 -04:00
BenCodez aac5226fce Change handling of givepoints command 2023-05-28 12:34:29 -04:00
BenCodez 1d1b9722ac Add comments to config option 2023-05-26 19:52:12 -04:00
BenCodez 94193501ba Add new config options for give points command 2023-05-26 19:50:10 -04:00
BenCodez 2b142316dc Add method for adding points async if needed 2023-05-22 17:42:20 -04:00
BenCodez a06124e49c Set points async on vote shop purchase 2023-05-22 17:41:01 -04:00
BenCodez c1bd04f117 Minor user data handling change 2023-05-21 20:19:10 -04:00
BenCodez 4272d15a8b Add config option for tracking vote shop purchases 2023-05-20 18:51:02 -04:00
BenCodez 0537dad68e Track number of purchases with voteshop 2023-05-20 07:59:39 -04:00
BenCodez c1f09a6bd9 Edit config comments 2023-05-16 21:31:04 -04:00
BenCodez 69ea7c71b3 Minor change 2023-05-16 21:30:29 -04:00
BenCodez 3052f28b2c Add option for voteshop check on purchase 2023-05-16 21:28:56 -04:00
BenCodez 892d23e0d0 Add gui option to reopen shop gui on purchase 2023-05-14 19:39:51 -04:00
41 changed files with 581 additions and 293 deletions

No files matched your search

-17
View File
@@ -1,17 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 20
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 5
# Issues with these labels will never be considered stale
exemptLabels:
- Priority
- nonstale
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
+27
View File
@@ -0,0 +1,27 @@
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests
on:
schedule:
- cron: '19 16 * * *'
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
stale-pr-message: 'Stale pull request message'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
+19
View File
@@ -245,6 +245,16 @@ Format:
# %Points% = player points
Points: '&a%Player% currently has &a&l%Points%&a Points!'
# /vote givepoints command
# Transfer between players command
# Enable command below
GivePoints:
NotEnoughPoints: '&cNot enough points'
NotJoinedServer: '&c%player% has not joined the server'
NumberLowerThanZero: '&cNumber of points needs to be greater than 0'
TransferFrom: '&c%transfer% points given to %touser%'
TransferTo: '&cYou received %transfer% points from %fromuser%'
ToggleBroadcasts:
Enabled: '&cYou will now see vote broadcasts'
Disabled: '&cYou will no longer see vote broadcasts'
@@ -528,6 +538,11 @@ OnlineMode: true
# May improve performance
#DisableCheckOnWorldChange: false
# If true, number of vote shop purchases will be tracked
# Data will be tracked in serverdata.yml, may change in the future
# No commands to view data currently
TrackShopPurchases: false
###########################################
# Skull settings
###########################################
@@ -694,6 +709,10 @@ PurgeMin: 90
# Options below don't need to be touched
##########################################
# If enabled, data is repulled from storage on vote shop purchase
# This prevents possible exploits with vote shop
ExtraVoteShopCheck: true
# Options for request api
# Current methods:
# ANVIL
+2
View File
@@ -309,6 +309,8 @@ CHEST:
VoteShopLimitReached: '&aYou reached your limit'
VoteShopRequireConfirmation: false
VoteShopDisabled: '&cVote shop disabled'
# If true, shop gui will reopen, updating all placeholders
VoteShopReopenGUIOnPurchase: false
# VoteShop extra items for display only
#VoteShopExtraItems:
#Item:
+1 -3
View File
@@ -20,6 +20,7 @@ softdepend:
loadbefore:
- MCPerks
api-version: 1.13
folia-supported: true
libraries:
- org.openjdk.nashorn:nashorn-core:15.3
commands:
@@ -56,9 +57,6 @@ commands:
votereward:
description: Open VoteReward GUI
aliases: vreward
vote?:
description: View Help
aliases: v?
voteparty:
description: A command
aliases: vparty
+82 -16
View File
@@ -1,13 +1,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId>
<version>6.13</version>
<artifactId>${version.art}</artifactId>
<version>6.13.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>
<build.number>NOTSET</build.number>
@@ -90,7 +88,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<version>3.3.0</version>
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<minimizeJar>true</minimizeJar>
@@ -210,18 +208,22 @@
<id>bencodez repo</id>
<url>https://nexus.bencodez.com/repository/maven-public/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.2</version>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -245,7 +247,7 @@
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>1.1.5</version>
<version>3.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -254,17 +256,51 @@
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>normal</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<build.profile.id>normal</build.profile.id>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>normal-folia</id>
<properties>
<build.profile.id>normal</build.profile.id>
<version.art>votingplugin-folia</version.art>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore-folia</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>prod2</id>
<properties>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>prod2</build.profile.id>
</properties>
<distributionManagement>
@@ -274,10 +310,21 @@
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>deploy-snapshot</id>
<properties>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>deploy-snapshot</build.profile.id>
</properties>
<distributionManagement>
@@ -290,12 +337,20 @@
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<version>3.0.0</version>
<configuration>
<skip>true</skip>
</configuration>
@@ -303,7 +358,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.5.1</version>
<version>1.6.13</version>
<executions>
<execution>
<id>default-deploy</id>
@@ -325,8 +380,19 @@
<profile>
<id>deploy</id>
<properties>
<version.art>votingplugin</version.art>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<build.profile.id>deploy</build.profile.id>
</properties>
<dependencies>
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>nexus</id>
@@ -2,7 +2,7 @@ package com.Ben12345rocks.VotingPlugin.Objects;
import org.bukkit.entity.Player;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@Deprecated
@@ -10,7 +10,7 @@ public class User {
private VotingPluginUser user;
public User(Player p) {
user = UserManager.getInstance().getVotingPluginUser(p);
user = VotingPluginMain.plugin.getVotingPluginUserManager().getVotingPluginUser(p);
}
public void addPoints(int points) {
@@ -28,11 +28,11 @@ import com.bencodez.advancedcore.bungeeapi.pluginmessage.PluginMessageHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.bungee.BungeeVersion;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
@@ -287,7 +287,7 @@ public class BungeeHandler implements Listener {
String service = args.get(2);
long time = Long.parseLong(args.get(3));
plugin.debug("pluginmessaging vote received from " + player + "/" + uuid + " on " + service);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
player);
boolean wasOnline = Boolean.valueOf(args.get(4));
@@ -383,7 +383,7 @@ public class BungeeHandler implements Listener {
plugin.debug(
"pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
player);
user.cache();
@@ -456,7 +456,7 @@ public class BungeeHandler implements Listener {
public void onRecieve(String subChannel, ArrayList<String> args) {
String player = args.get(0);
plugin.debug("pluginmessaging voteupdate received for " + player);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(player));
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(player));
user.cache();
user.offVote();
@@ -485,7 +485,7 @@ public class BungeeHandler implements Listener {
if (args.size() > 2) {
String uuid = args.get(0);
String service = args.get(2);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
args.get(1));
VoteSite site = plugin.getVoteSite(service, true);
if (site != null) {
@@ -503,7 +503,7 @@ public class BungeeHandler implements Listener {
if (args.size() > 2) {
String uuid = args.get(0);
String votes = args.get(2);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
args.get(1));
user.offlineBroadcast(user, false, Integer.parseInt(votes));
}
@@ -523,7 +523,7 @@ public class BungeeHandler implements Listener {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
BukkitScheduler.runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -572,9 +572,9 @@ public class BungeeHandler implements Listener {
String uuid = data[1];
VotingPluginUser user = null;
if (!uuid.isEmpty()) {
user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
} else {
user = UserManager.getInstance().getVotingPluginUser(data[2]);
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
}
user.cache();
@@ -605,9 +605,9 @@ public class BungeeHandler implements Listener {
String uuid = data[1];
VotingPluginUser user = null;
if (!uuid.isEmpty()) {
user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
} else {
user = UserManager.getInstance().getVotingPluginUser(data[2]);
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
}
user.cache();
@@ -628,7 +628,7 @@ public class BungeeHandler implements Listener {
if (data.length > 2) {
String votes = data[0];
String p = data[1];
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
user.offlineBroadcast(user, false, Integer.parseInt(votes));
}
}
@@ -641,7 +641,7 @@ public class BungeeHandler implements Listener {
if (data.length > 2) {
VoteSite site = plugin.getVoteSite(data[1], true);
String p = data[3];
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
if (site != null) {
site.broadcastVote(user, false);
} else {
@@ -658,7 +658,7 @@ public class BungeeHandler implements Listener {
if (data.length > 2) {
VoteSite site = plugin.getVoteSite(data[1], true);
String p = data[2];
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
if (site != null) {
site.broadcastVote(user, false);
} else {
@@ -33,7 +33,7 @@ public class VotingPluginHooks {
}
public UserManager getUserManager() {
return UserManager.getInstance();
return getMainClass().getVotingPluginUserManager();
}
}
@@ -56,6 +56,7 @@ import com.bencodez.advancedcore.api.updater.Updater;
import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.advancedcore.logger.Logger;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
import com.bencodez.votingplugin.commands.CommandLoader;
import com.bencodez.votingplugin.commands.executers.CommandAdminVote;
@@ -146,7 +147,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Getter
private PlaceHolders placeholders;
@Getter
private VoteTester voteTester;
@@ -227,7 +228,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
public void basicBungeeUpdate() {
for (Player player : Bukkit.getOnlinePlayers()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
VotingPluginUser user = getVotingPluginUserManager().getVotingPluginUser(player);
user.cache();
user.offVote();
user.checkOfflineRewards();
@@ -260,7 +261,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
if (ymlError) {
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -294,7 +295,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
* @return the user
*/
public VotingPluginUser getUser(UUID uuid) {
return UserManager.getInstance().getVotingPluginUser(uuid);
return getVotingPluginUserManager().getVotingPluginUser(uuid);
}
private YamlConfiguration getVersionFile() {
@@ -930,7 +931,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
private void loadTimer() {
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1017,7 +1018,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
public void onPostLoad() {
loadVersionFile();
getOptions().setServer(bungeeSettings.getServer());
voteTester = new VoteTester(plugin);
loadVoteTimer();
@@ -1051,7 +1052,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
coolDownCheck.checkEnabled();
coolDownCheck.load();
Bukkit.getScheduler().runTask(plugin, new Runnable() {
BukkitScheduler.runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -1061,7 +1062,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
topVoterHandler = new TopVoterHandler(this);
lastMonthTopVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1084,7 +1085,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
topVoterHandler.register();
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1121,7 +1122,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Override
public String onRewardRequest(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user,
int num, HashMap<String, String> placeholders) {
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
VotingPluginUser vpUser = getVotingPluginUserManager().getVotingPluginUser(user);
String str = "" + vpUser.addPoints(num);
debug("Setting points to " + str);
return str;
@@ -1154,7 +1155,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
StringParser.getInstance().replacePlaceHolder(section.getString("Message", ""),
placeholders),
section.getString("Color", "BLUE"), section.getString("Style", "SOLID"),
(double) UserManager.getInstance().getVotingPluginUser(user).getSitesVotedOn()
(double) getVotingPluginUserManager().getVotingPluginUser(user).getSitesVotedOn()
/ plugin.getVoteSites().size(),
section.getInt("Delay", 30));
}
@@ -1167,7 +1168,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Override
public String getValue(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user) {
VotingPluginUser vUser = UserManager.getInstance().getVotingPluginUser(user);
VotingPluginUser vUser = getVotingPluginUserManager().getVotingPluginUser(user);
return "" + vUser.getTotal(top);
}
});
@@ -1210,7 +1211,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
if (!issues) {
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1248,7 +1249,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
loadVoteSites();
votingPluginUserManager = UserManager.getInstance();
votingPluginUserManager = new UserManager(this);
votingPluginUserManager.addCachingKeys();
setJenkinsSite("bencodez.com");
@@ -1464,7 +1465,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
.getTopVoterIgnorePermission();
ArrayList<String> blackList = plugin.getConfigFile().getBlackList();
// ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
// ArrayList<String> uuids = getVotingPluginUserManager().getAllUUIDs();
int currentDay = LocalDateTime.now().getDayOfMonth();
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
long time1 = ((System.currentTimeMillis() - startTime) / 1000);
@@ -1476,7 +1477,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
String uuid = playerData.getKey().toString();
if (plugin != null && plugin.isEnabled()) {
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = UserManager.getInstance()
VotingPluginUser user = getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
@@ -3,7 +3,6 @@ package com.bencodez.votingplugin;
import java.util.concurrent.Callable;
import com.bencodez.advancedcore.api.metrics.BStatsMetrics;
import com.bencodez.votingplugin.user.UserManager;
public class VotingPluginMetrics {
@@ -177,7 +176,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
int total = UserManager.getInstance().getAllUUIDs().size();
int total = plugin.getUserManager().getAllUUIDs().size();
if (total > 800000) {
return ">800000";
} else if (total > 700000) {
@@ -13,7 +13,6 @@ import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.UserManager;
public class BroadcastHandler {
private VotingPluginMain plugin;
@@ -46,7 +45,7 @@ public class BroadcastHandler {
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
ArrayList<Player> players = new ArrayList<Player>();
for (Player p : Bukkit.getOnlinePlayers()) {
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
players.add(p);
}
}
@@ -37,6 +37,7 @@ import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
import com.bencodez.advancedcore.api.valuerequest.listeners.BooleanListener;
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
import com.bencodez.advancedcore.command.gui.UserGUI;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.commands.executers.CommandAliases;
import com.bencodez.votingplugin.commands.gui.AdminGUI;
@@ -67,7 +68,6 @@ import com.bencodez.votingplugin.commands.tabcompleter.AliasesTabCompleter;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
// TODO: Auto-generated Javadoc
@@ -282,7 +282,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.setPoints(Integer.parseInt(args[3]));
sender.sendMessage(
StringParser.getInstance().colorize("&cSet " + args[1] + " points to " + args[3]));
@@ -338,7 +338,7 @@ public class CommandLoader {
String uuid = playerData.getKey().toString();
if (plugin != null && plugin.isEnabled()) {
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = UserManager.getInstance()
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid));
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
@@ -399,7 +399,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.setMilestoneCount(user.getTotal(TopVoter.AllTime));
sendMessage(sender, "&cResynced milestones for " + args[1]);
@@ -414,7 +414,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
synchronized (pointLock) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.cache();
int newTotal = 0;
newTotal = user.addPoints(Integer.parseInt(args[3]));
@@ -430,7 +430,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.cache();
user.removePoints(Integer.parseInt(args[3]));
sender.sendMessage(StringParser.getInstance().colorize("&cRemoved " + args[3] + " points from "
@@ -653,7 +653,7 @@ public class CommandLoader {
public void execute(CommandSender sender, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
Bukkit.getScheduler().runTask(plugin, new Runnable() {
BukkitScheduler.runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -662,7 +662,7 @@ public class CommandLoader {
});
} else {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
BukkitScheduler.runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -735,7 +735,7 @@ public class CommandLoader {
try {
sender.sendMessage(ChatColor.GREEN + "PlayerName of player " + ChatColor.DARK_GREEN + args[1]
+ ChatColor.GREEN + " is: " + PlayerUtils.getInstance().getPlayerName(
UserManager.getInstance().getVotingPluginUser(UUID.fromString(args[1])), args[1]));
plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(args[1])), args[1]));
} catch (IllegalArgumentException e) {
sendMessage(sender, "&cInvalid uuid");
}
@@ -786,7 +786,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
UserManager.getInstance().getVotingPluginUser(args[1])
plugin.getVotingPluginUserManager().getVotingPluginUser(args[1])
.setDayVoteStreak(Integer.parseInt(args[4]));
sender.sendMessage(StringParser.getInstance()
.colorize("&cSet votestreak day for '" + args[1] + "' to " + args[4]));
@@ -800,7 +800,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
UserManager.getInstance().getVotingPluginUser(args[1])
plugin.getVotingPluginUserManager().getVotingPluginUser(args[1])
.setWeekVoteStreak(Integer.parseInt(args[4]));
sender.sendMessage(StringParser.getInstance()
.colorize("&cSet votestreak week for '" + args[1] + "' to " + args[4]));
@@ -814,7 +814,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
UserManager.getInstance().getVotingPluginUser(args[1])
plugin.getVotingPluginUserManager().getVotingPluginUser(args[1])
.setMonthVoteStreak(Integer.parseInt(args[4]));
sender.sendMessage(StringParser.getInstance()
.colorize("&cSet votestreak month for '" + args[1] + "' to " + args[4]));
@@ -829,7 +829,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
UserManager.getInstance().getVotingPluginUser(args[1]).setTotal(top,
plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]).setTotal(top,
Integer.parseInt(args[4]));
sender.sendMessage(StringParser.getInstance().colorize(
"&cSet " + top.toString() + " total for '" + args[1] + "' to " + args[4]));
@@ -843,7 +843,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.setTotal(top, user.getTotal(top) + Integer.parseInt(args[4]));
sender.sendMessage(StringParser.getInstance()
.colorize("&cAdded " + top.toString() + " total for " + args[1]));
@@ -856,7 +856,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.clearTotals();
sender.sendMessage(StringParser.getInstance().colorize("&cCleared totals for '" + args[1] + "'"));
}
@@ -867,7 +867,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.resetLastVoted();
sender.sendMessage(StringParser.getInstance().colorize("&cVoted sites reset for '" + args[1] + "'"));
}
@@ -880,7 +880,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.resetLastVoted(plugin.getVoteSite(args[3], false));
sender.sendMessage(StringParser.getInstance()
.colorize("&cVoted site reset for '" + args[1] + "'" + " on " + args[3]));
@@ -893,11 +893,27 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.setMilestoneCount(user.getMilestoneCount() + Integer.parseInt(args[3]));
plugin.getSpecialRewards().checkMilestone(user, null, false);
sender.sendMessage(
StringParser.getInstance().colorize("&cAdded milestonecount for " + args[1]));
if (args[1].equalsIgnoreCase("all")) {
int toAdd = Integer.parseInt(args[3]);
sender.sendMessage(
StringParser.getInstance().colorize("&cAdding milestonecount for all players..."));
for (String uuidStr : plugin.getUserManager().getAllUUIDs()) {
UUID uuid = UUID.fromString(uuidStr);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
user.dontCache();
user.setMilestoneCount(user.getMilestoneCount() + toAdd);
plugin.getSpecialRewards().checkMilestone(user, null, plugin.getBungeeSettings().isUseBungeecoord());
}
sender.sendMessage(
StringParser.getInstance().colorize("&cFinished adding milestonecount for all players"));
} else {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.setMilestoneCount(user.getMilestoneCount() + Integer.parseInt(args[3]));
plugin.getSpecialRewards().checkMilestone(user, null, plugin.getBungeeSettings().isUseBungeecoord());
sender.sendMessage(
StringParser.getInstance().colorize("&cAdded milestonecount for " + args[1]));
}
}
});
@@ -907,7 +923,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.setMilestoneCount(Integer.parseInt(args[3]));
sender.sendMessage(StringParser.getInstance()
.colorize("&cSet milestonecount for " + args[1] + " to " + args[3]));
@@ -921,10 +937,26 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.setHasGottenMilestone(new HashMap<String, Boolean>());
sender.sendMessage(
StringParser.getInstance().colorize("&cClearing gotten milestones for " + args[1]));
if (args[1].equalsIgnoreCase("all")) {
String path = "GottenMileStones";
if (plugin.getBungeeSettings().isPerServerMilestones()) {
path = plugin.getBungeeSettings().getServerNameStorage() + "_" + "GottenMilestones";
}
sender.sendMessage(StringParser.getInstance()
.colorize("&cClearing gotten milestones for all players..."));
plugin.getUserManager().removeAllKeyValues(path, DataType.STRING);
for (Player p : Bukkit.getOnlinePlayers()) {
plugin.getUserManager().getDataManager().cacheUser(p.getUniqueId());
}
sender.sendMessage(StringParser.getInstance()
.colorize("&cFinished clearing gotten milestones for all players"));
} else {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
user.setHasGottenMilestone(new HashMap<String, Boolean>());
sender.sendMessage(
StringParser.getInstance().colorize("&cClearing gotten milestones for " + args[1]));
}
}
});
@@ -1093,7 +1125,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getRewardHandler().giveReward(user, plugin.getVoteSite(args[3], true).getSiteData(),
"CoolDownEndRewards", new RewardOptions());
sendMessage(sender, "&cCoolDownEndRewards forced on votesite " + args[3]);
@@ -1200,7 +1232,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1406,7 +1438,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getRewardHandler().giveReward(user, plugin.getConfigFile().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(args[3]), new RewardOptions());
sendMessage(sender, "&cVoteShop " + args[3] + " forced");
@@ -1419,7 +1451,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getSpecialRewards().giveMilestoneVoteReward(user, user.isOnline(), parseInt(args[3]),
plugin.getBungeeSettings().isUseBungeecoord());
sendMessage(sender, "&cMilestone " + args[3] + " forced");
@@ -1435,7 +1467,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
int place = parseInt(args[4]);
switch (top) {
case Daily:
@@ -1480,7 +1512,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getSpecialRewards().giveVoteStreakReward(user, user.isOnline(), str, args[4],
parseInt(args[4]), plugin.getBungeeSettings().isUseBungeecoord());
sendMessage(sender, "&cVoteStreak " + str + " " + args[4] + " forced");
@@ -1494,7 +1526,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getSpecialRewards().giveCumulativeVoteReward(user, user.isOnline(), parseInt(args[3]),
plugin.getBungeeSettings().isUseBungeecoord());
sendMessage(sender, "&cCumulative " + args[3] + " forced");
@@ -1506,7 +1538,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getSpecialRewards().giveAllSitesRewards(user, user.isOnline(),
plugin.getBungeeSettings().isUseBungeecoord());
sendMessage(sender, "&cAllSites forced");
@@ -1518,7 +1550,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getSpecialRewards().giveAlmostAllSitesRewards(user, user.isOnline(),
plugin.getBungeeSettings().isUseBungeecoord());
sendMessage(sender, "&cAlmostAllSites forced");
@@ -1530,7 +1562,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getSpecialRewards().giveFirstVoteRewards(user, user.isOnline(),
plugin.getBungeeSettings().isUseBungeecoord());
sendMessage(sender, "&cFirstVote forced");
@@ -1542,7 +1574,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getSpecialRewards().giveFirstVoteTodayRewards(user, user.isOnline(),
plugin.getBungeeSettings().isUseBungeecoord());
sendMessage(sender, "&cFirstVoteToday forced");
@@ -1557,7 +1589,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new AdminVotePlaceholdersPlayer(plugin, sender,
UserManager.getInstance().getVotingPluginUser(args[1])).open();
plugin.getVotingPluginUserManager().getVotingPluginUser(args[1])).open();
}
});
@@ -1687,7 +1719,7 @@ public class CommandLoader {
public void loadCommands() {
loadAdminVoteCommand();
loadVoteCommand();
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1752,7 +1784,7 @@ public class CommandLoader {
.getItemMeta().getDisplayName());
String playerName = (String) event.getMeta(player,
"Player");
VotingPluginUser user = UserManager.getInstance()
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(playerName);
new ValueRequest().requestBoolean(player,
"" + user.hasGottenMilestone(mileStone),
@@ -1763,8 +1795,7 @@ public class CommandLoader {
boolean value) {
String playerName = UserGUI.getInstance()
.getCurrentPlayer(player);
VotingPluginUser user = UserManager
.getInstance()
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(playerName);
user.setHasGotteMilestone(mileStone, value);
player.sendMessage(
@@ -1863,7 +1894,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(sender.getName());
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(sender.getName());
if (args[1].equals("none")) {
user.setPrimaryAccount(null);
sendMessage(sender, "&cRemoved primary account");
@@ -1924,7 +1955,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteShop(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
new VoteShop(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender)).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Shop", "(Text)" },
@@ -1956,7 +1987,7 @@ public class CommandLoader {
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(sender.getName());
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(sender.getName());
boolean limitPass = true;
if (limit > 0) {
@@ -1967,7 +1998,9 @@ public class CommandLoader {
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
if (hasPerm) {
user.cache();
if (plugin.getConfigFile().isExtraVoteShopCheck()) {
user.cache();
}
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
if (identifier != null) {
@@ -1976,7 +2009,7 @@ public class CommandLoader {
placeholders.put("identifier", identifier);
placeholders.put("points", "" + points);
placeholders.put("limit", "" + limit);
if (user.removePoints(points)) {
if (user.removePoints(points, true)) {
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
@@ -2011,7 +2044,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteURLVoteSite(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender),
new VoteURLVoteSite(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender),
args[1]).open();
}
});
@@ -2021,7 +2054,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteURL(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender), true)
new VoteURL(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender), true)
.open();
}
@@ -2033,7 +2066,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteLast(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
new VoteLast(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance()
.replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
@@ -2047,7 +2080,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteLast(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
new VoteLast(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender)).open();
}
});
@@ -2058,7 +2091,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser((Player) sender);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
boolean value = !user.getDisableBroadcast();
user.setDisableBroadcast(value);
if (!value) {
@@ -2075,7 +2108,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteNext(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
new VoteNext(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance()
.replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
@@ -2089,11 +2122,11 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
String msg = plugin.getConfigFile().getFormatCommandVotePoints()
.replace("%Player%", user.getPlayerName()).replace("%Points%", "" + user.getPoints());
if (sender instanceof Player) {
UserManager.getInstance().getVotingPluginUser((Player) sender).sendMessage(msg);
plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender).sendMessage(msg);
} else {
sender.sendMessage(StringParser.getInstance().colorize(msg));
}
@@ -2110,7 +2143,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser((Player) sender);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
String msg = plugin.getConfigFile().getFormatCommandVotePoints()
.replace("%Player%", user.getPlayerName()).replace("%Points%", "" + user.getPoints());
user.sendMessage(msg);
@@ -2122,7 +2155,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteNext(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
new VoteNext(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender)).open();
}
});
@@ -2132,7 +2165,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteGUI(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
new VoteGUI(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance()
.replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
@@ -2146,11 +2179,12 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteGUI(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
new VoteGUI(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender)).open();
}
});
if (plugin.getGui().isLastMonthGUI() || plugin.getOptions().getDebug().equals(DebugLevel.DEV)) {
plugin.debug("Loading last month top");
plugin.getVoteCommand()
.add(new CommandHandler(new String[] { "LastMonthTop" },
"VotingPlugin.Commands.Vote.LastMonthTop|" + playerPerm,
@@ -2159,7 +2193,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteTopVoterLastMonth(plugin, sender,
UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender)).open();
}
});
}
@@ -2302,7 +2336,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteTotal(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
new VoteTotal(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance()
.replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
@@ -2316,7 +2350,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteTotal(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
new VoteTotal(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender)).open();
}
});
@@ -2325,7 +2359,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteBest(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
new VoteBest(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender)).open();
}
});
@@ -2335,7 +2369,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteBest(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
new VoteBest(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance()
.replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
@@ -2348,7 +2382,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteStreak(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
new VoteStreak(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender)).open();
}
});
@@ -2358,7 +2392,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteStreak(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
new VoteStreak(plugin, sender, plugin.getVotingPluginUserManager().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance()
.replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
@@ -2373,29 +2407,44 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getConfigFile().isAllowVotePointTransfers()) {
VotingPluginUser cPlayer = UserManager.getInstance().getVotingPluginUser((Player) sender);
VotingPluginUser cPlayer = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
cPlayer.cache();
if (plugin.getUserManager().userExist(args[1])) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.dontCache();
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
if (!user.isOnline()) {
user.dontCache();
}
int pointsToGive = Integer.parseInt(args[2]);
if (pointsToGive > 0) {
if (cPlayer.getPoints() >= pointsToGive) {
user.addPoints(pointsToGive);
cPlayer.removePoints(pointsToGive);
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("transfer", "" + pointsToGive);
placeholders.put("touser", "" + user.getPlayerName());
placeholders.put("fromuser", "" + cPlayer.getPlayerName());
sendMessage(sender,
"&c" + pointsToGive + " points given to " + user.getPlayerName());
user.sendMessage("&cYou received " + pointsToGive + " points from "
+ cPlayer.getPlayerName());
StringParser.getInstance().replacePlaceHolder(
plugin.getConfigFile()
.getFormatCommandsVoteGivePointsTransferFrom(),
placeholders));
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteGivePointsTransferTo(),
placeholders));
} else {
sendMessage(sender, "&cNot enough points");
sendMessage(sender,
plugin.getConfigFile().getFormatCommandsVoteGivePointsNotEnoughPoints());
}
} else {
sendMessage(sender, "&cNumber of points needs to be greater than 0");
sendMessage(sender,
plugin.getConfigFile().getFormatCommandsVoteGivePointsNumberLowerThanZero());
}
} else {
sendMessage(sender, "&c" + args[1] + " has not joined the server");
sendMessage(sender,
StringParser.getInstance().replacePlaceHolder(
plugin.getConfigFile().getFormatCommandsVoteGivePointsNotJoinedServer(),
"player", args[1]));
}
}
}
@@ -2409,7 +2458,7 @@ public class CommandLoader {
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = null;
if (sender instanceof Player) {
user = UserManager.getInstance().getVotingPluginUser((Player) sender);
user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
}
if (plugin.getConfigFile().isUseVoteGUIMainCommand() && sender instanceof Player) {
// vote gui command
@@ -2444,7 +2493,7 @@ public class CommandLoader {
public void execute(CommandSender sender, String[] args) {
sendMessage(sender, section.getString("Message", ""));
for (String str : (ArrayList<String>) section.getList("Commands", new ArrayList<String>())) {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
BukkitScheduler.runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -14,7 +14,6 @@ import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
import xyz.upperlevel.spigot.book.BookUtil;
@@ -75,7 +74,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
msg.add("&cPlaceholders:");
VotingPluginUser placeholderUser = user;
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
placeholderUser = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
placeholderUser = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
}
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
String identifier = placeholder.getIdentifier().toLowerCase();
@@ -17,7 +17,6 @@ import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
public class VoteGUI extends GUIHandler {
@@ -122,7 +121,7 @@ public class VoteGUI extends GUIHandler {
@Override
public void onChest(Player player) {
if (this.user == null) {
user = UserManager.getInstance().getVotingPluginUser(player);
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
}
BInventory inv = new BInventory(plugin.getGui().getChestVoteGUIName());
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
@@ -166,7 +165,7 @@ public class VoteGUI extends GUIHandler {
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(), plugin.getGui()
.getChestVoteGUISlotRewardsPath(slot, event.getButton().getLastRewardsPath(player)))) {
plugin.getRewardHandler().giveReward(UserManager.getInstance().getVotingPluginUser(player),
plugin.getRewardHandler().giveReward(plugin.getVotingPluginUserManager().getVotingPluginUser(player),
plugin.getGui().getData(),
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
event.getButton().getLastRewardsPath(player)),
@@ -177,7 +176,7 @@ public class VoteGUI extends GUIHandler {
@Override
public ItemBuilder onUpdate(Player player) {
ItemBuilder item = getItemSlot(slot, player);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
item.addPlaceholder("points", "" + user.getPoints());
item.addPlaceholder("player", user.getPlayerName());
item.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
@@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
@@ -17,7 +17,6 @@ import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
public class VoteLast extends GUIHandler {
@@ -74,7 +73,7 @@ public class VoteLast extends GUIHandler {
if (plugin.getGui().isChestVoteLastClickableLinks()) {
Player player = event.getPlayer();
if (player != null) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
user.sendMessage(
StringParser.getInstance()
.replacePlaceHolder(
@@ -16,7 +16,6 @@ import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
public class VoteShop extends GUIHandler {
@@ -54,6 +53,10 @@ public class VoteShop extends GUIHandler {
if (this.user == null) {
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
}
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
/*
* if (!plugin.getConfigFile().isExtraVoteShopCheck()) { user.cacheAsync(); }
*/
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
inv.addPlaceholder("points", "" + user.getPoints());
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
@@ -92,8 +95,10 @@ public class VoteShop extends GUIHandler {
public void onClick(ClickEvent event) {
Player player = event.getWhoClicked();
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
user.cache();
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
if (plugin.getConfigFile().isExtraVoteShopCheck()) {
user.cache();
}
String identifier = (String) getData("identifier");
int limit = (int) getData("Limit");
@@ -118,9 +123,12 @@ public class VoteShop extends GUIHandler {
plugin.getGui().getChestShopIdentifierIdentifierName(identifier));
placeholders.put("points", "" + points);
placeholders.put("limit", "" + limit);
if (user.removePoints(points)) {
if (user.removePoints(points, true)) {
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/"
+ user.getUUID() + " bought " + identifier + " for " + points);
if (plugin.getConfigFile().isTrackShopPurchases()) {
plugin.getServerData().addVoteShopPurchase(identifier);
}
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
@@ -145,6 +153,9 @@ public class VoteShop extends GUIHandler {
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
}
plugin.getCommandLoader().processSlotClick(player, user, identifier);
if (plugin.getGui().getChestVoteShopReopenGUIOnPurchase()) {
plugin.getCommandLoader().processSlotClick(player, user, "shop");
}
}
}
@@ -60,9 +60,12 @@ public class VoteShopConfirm extends GUIHandler {
placeholders.put("identifier", identifier);
placeholders.put("points", "" + points);
placeholders.put("limit", "" + limit);
if (user.removePoints(points)) {
if (user.removePoints(points, true)) {
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/" + user.getUUID() + " bought "
+ identifier + " for " + points);
if (plugin.getConfigFile().isTrackShopPurchases()) {
plugin.getServerData().addVoteShopPurchase(identifier);
}
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
@@ -23,7 +23,6 @@ import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
public class VoteToday extends GUIHandler {
@@ -110,7 +109,7 @@ public class VoteToday extends GUIHandler {
@Override
public void onClick(ClickEvent clickEvent) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
new VoteGUI(plugin, player, user)
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
}
@@ -24,7 +24,6 @@ import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
import xyz.upperlevel.spigot.book.BookUtil;
@@ -41,11 +40,11 @@ public class VoteURL extends GUIHandler {
this.user = user;
this.json = json;
if (user == null && player instanceof Player) {
this.user = UserManager.getInstance().getVotingPluginUser((Player) player);
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) player);
}
if (player != null && user != null && player.getName().equals(user.getPlayerName())) {
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
}
}
}
@@ -169,7 +168,7 @@ public class VoteURL extends GUIHandler {
@Override
public void onClick(ClickEvent event) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(event.getPlayer());
json = true;
user.sendMessage(getChat(player));
}
@@ -196,7 +195,7 @@ public class VoteURL extends GUIHandler {
public void onClick(ClickEvent event) {
Player player = event.getPlayer();
if (player != null) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
user.sendMessage(StringParser.getInstance().replacePlaceHolder(StringParser.getInstance()
.replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
plugin.getGui().getChestVoteURLURLText(), "voteurl", voteSite.getVoteURL()),
@@ -66,6 +66,14 @@ public class Config extends YMLFile {
@Getter
private boolean alwaysCloseInventory = false;
@ConfigDataBoolean(path = "ExtraVoteShopCheck")
@Getter
private boolean extraVoteShopCheck = true;
@ConfigDataBoolean(path = "TrackShopPurchases")
@Getter
private boolean trackShopPurchases = false;
@ConfigDataBoolean(path = "AlwaysUpdate")
@Getter
private boolean alwaysUpdate = false;
@@ -158,6 +166,26 @@ public class Config extends YMLFile {
@Getter
private String formatCommandsVoteLastLastVoted = "%times% ago";
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.NotEnoughPoints")
@Getter
private String formatCommandsVoteGivePointsNotEnoughPoints = "&cNot enough points";
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.NotJoinedServer")
@Getter
private String formatCommandsVoteGivePointsNotJoinedServer = "&c%player% has not joined the server";
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.NumberLowerThanZero")
@Getter
private String formatCommandsVoteGivePointsNumberLowerThanZero = "&cNumber of points needs to be greater than 0";
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.TransferFrom")
@Getter
private String formatCommandsVoteGivePointsTransferFrom = "&c%transfer% points given to %touser%";
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.TransferTo")
@Getter
private String formatCommandsVoteGivePointsTransferTo = "&cYou received %transfer points from %fromuser%";
@ConfigDataString(path = "Format.Commands.Vote.Last.Line", defaultValue = "&3%SiteName%: &6%timeSince% ago")
@Getter
private String formatCommandsVoteLastLine;
@@ -317,6 +317,10 @@ public class GUI extends YMLFile {
public boolean getChestVoteShopBackButton() {
return getData().getBoolean("CHEST.VoteShopBackButton", true);
}
public boolean getChestVoteShopReopenGUIOnPurchase() {
return getData().getBoolean("CHEST.VoteShopReopenGUIOnPurchase", false);
}
public boolean getChestVoteShopCloseGUI(String shop) {
return getData().getBoolean("CHEST.Shop." + shop + ".CloseGUI", true);
@@ -50,6 +50,19 @@ public class ServerData {
}
}
public void addVoteShopPurchase(String ident) {
setVoteShopPurchases(ident, (getVoteShopPurchases(ident) + 1));
}
public void setVoteShopPurchases(String ident, int amount) {
getData().set("VoteShopPurchases." + ident, amount);
saveData();
}
public int getVoteShopPurchases(String ident) {
return getData().getInt("VoteShopPurchases." + ident);
}
public void setAutoCachedPlaceholder(List<String> placeholders) {
getData().set("AutoCachePlaceholders", placeholders);
saveData();
@@ -1,6 +1,5 @@
package com.bencodez.votingplugin.listeners;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Sign;
import org.bukkit.event.EventHandler;
@@ -8,6 +7,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.signs.SignHandler;
@@ -39,7 +39,7 @@ public class BlockBreak implements Listener {
if (event.getBlock().getState() instanceof Sign) {
Sign s = (Sign) event.getBlock().getState();
final Location loc = s.getLocation();
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1,7 +1,6 @@
package com.bencodez.votingplugin.listeners;
import org.bukkit.Bukkit;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
import com.vexsoftware.votifier.model.Vote;
@@ -10,7 +9,7 @@ import com.vexsoftware.votifier.model.VotifierEvent;
public class BungeeVotifierEvent {
public void send(VotingPluginMain plugin, PlayerVoteEvent event) {
plugin.debug("Triggering vote event");
Bukkit.getScheduler().runTask(plugin, new Runnable() {
BukkitScheduler.runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -12,7 +12,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.signs.SignHandler;
import com.bencodez.votingplugin.user.UserManager;
// TODO: Auto-generated Javadoc
/**
@@ -52,7 +51,7 @@ public class PlayerInteract implements Listener {
if (sign.isLocationSame(event.getClickedBlock().getLocation())) {
// plugin.debug(player.getName() +
// " right clicked a top voter sign, sending message");
UserManager.getInstance().getVotingPluginUser(player)
plugin.getVotingPluginUserManager().getVotingPluginUser(player)
.sendMessage(sign.getRightClickMessage());
if (!sign.isSkullSet()) {
@@ -9,7 +9,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import com.bencodez.advancedcore.listeners.AdvancedCoreLoginEvent;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
// TODO: Auto-generated Javadoc
@@ -31,7 +30,7 @@ public class PlayerJoinEvent implements Listener {
}
private void login(Player player) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
if (player.isOp() && plugin.isYmlError()) {
user.sendMessage("&cVotingPlugin: Detected yml error, please check console for details");
}
@@ -81,7 +80,7 @@ public class PlayerJoinEvent implements Listener {
public void run() {
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
user.dontCache();
user.logoutRewards();
}
@@ -12,12 +12,12 @@ import org.bukkit.event.Listener;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.events.PlayerPostVoteEvent;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
// TODO: Auto-generated Javadoc
@@ -55,7 +55,7 @@ public class PlayerVoteListener implements Listener {
plugin.getLogger().warning("Player " + playerName
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
if (event.isBungee() && plugin.getBungeeSettings().isRemoveInvalidUsers()) {
UserManager.getInstance().getVotingPluginUser(playerName).remove();
plugin.getVotingPluginUserManager().getVotingPluginUser(playerName).remove();
}
return;
}
@@ -108,9 +108,9 @@ public class PlayerVoteListener implements Listener {
Player p = Bukkit.getPlayerExact(playerName);
if (p != null) {
// player online
user = UserManager.getInstance().getVotingPluginUser(p);
user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
} else {
user = UserManager.getInstance().getVotingPluginUser(playerName);
user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerName);
}
}
@@ -208,7 +208,7 @@ public class PlayerVoteListener implements Listener {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MYSQL)) {
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -1,12 +1,12 @@
package com.bencodez.votingplugin.listeners;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.SignChangeEvent;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -47,7 +47,7 @@ public class SignChange implements Listener {
plugin.getServerData().addSign(event.getBlock().getLocation(), event.getLine(2),
Integer.parseInt(event.getLine(1)));
event.getPlayer().sendMessage(StringParser.getInstance().colorize("&aAdded sign!"));
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -16,7 +16,6 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
@@ -138,7 +137,7 @@ public class VoteSite {
bc = StringParser.getInstance().replacePlaceHolders(user.getOfflinePlayer(), bc);
ArrayList<Player> players = new ArrayList<Player>();
for (Player p : Bukkit.getOnlinePlayers()) {
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
players.add(p);
}
}
@@ -5,7 +5,6 @@ import org.bukkit.Bukkit;
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
import be.maximvdw.placeholderapi.PlaceholderAPI;
@@ -41,11 +40,11 @@ public class MVdWPlaceholders {
@Override
public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
VotingPluginUser user = UserManager.getInstance()
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(event.getOfflinePlayer());
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders()
&& user.hasPrimaryAccount()) {
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
}
return place.placeholderRequest(user,
event.getPlaceholder().substring("VotingPlugin_".length()));
@@ -18,6 +18,7 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.placeholder.CalculatingPlaceholder;
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
@@ -26,7 +27,6 @@ import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
@@ -55,7 +55,7 @@ public class PlaceHolders {
onUpdate();
if (!cacheLevel.equals(PlaceholderCacheLevel.NONE)) {
for (Player player : Bukkit.getOnlinePlayers()) {
onUpdate(UserManager.getInstance().getVotingPluginUser(player));
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(player));
}
}
}
@@ -127,7 +127,7 @@ public class PlaceHolders {
return "no player";
}
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
if (useCache) {
if (!cachedPlaceholders.contains(identifier)) {
// not cached placeholder
@@ -150,45 +150,85 @@ public class PlaceHolders {
}
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders()) {
if (user.hasPrimaryAccount()) {
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
}
}
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
try {
if (placeholder.matches(identifier)) {
if (useCache) {
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
if (cache.containsKey(p.getUniqueId())) {
return cache.get(p.getUniqueId());
} else if (!forceProcess) {
schedulePlaceholderCheck(user);
return "...";
if (placeholder instanceof CalculatingPlaceholder<?>) {
if (useCache) {
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
if (cache.containsKey(p.getUniqueId())) {
if (cPlaceholder.getCacheData().containsKey(user.getJavaUUID())) {
return cPlaceholder.placeholderRequest(user, identifier);
}
return cache.get(p.getUniqueId());
} else if (!forceProcess) {
schedulePlaceholderCheck(user);
return "...";
}
}
}
if (forceProcess) {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
if (forceProcess) {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return placeholder.placeholderRequest(user, identifier);
} else {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return ".";
}
return placeholder.placeholderRequest(user, identifier);
} else {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return ".";
return placeholder.placeholderRequest(user, identifier);
}
} else {
return placeholder.placeholderRequest(user, identifier);
if (useCache) {
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
if (cache.containsKey(p.getUniqueId())) {
return cache.get(p.getUniqueId());
} else if (!forceProcess) {
schedulePlaceholderCheck(user);
return "...";
}
}
if (forceProcess) {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return placeholder.placeholderRequest(user, identifier);
} else {
if (getCacheLevel().shouldCache()) {
if (!placeholdersToSetCacheOn.contains(identifier)
&& !cachedPlaceholders.contains(identifier)) {
placeholdersToSetCacheOn.add(identifier);
schedulePlaceholderCheck(user);
}
}
return ".";
}
} else {
return placeholder.placeholderRequest(user, identifier);
}
}
}
} catch (Exception e) {
@@ -452,12 +492,25 @@ public class PlaceHolders {
}.withDescription("How long until user can vote on anysite").updateDataKey("LastVotes"));
for (final VoteSite voteSite : plugin.getVoteSites()) {
placeholders.add(new PlaceHolder<VotingPluginUser>("Next_" + voteSite.getKey()) {
placeholders.add(new CalculatingPlaceholder<VotingPluginUser>("Next_" + voteSite.getKey()) {
@Override
public String placeholderRequest(VotingPluginUser user, String identifier) {
if (getCacheData().containsKey(user.getJavaUUID())) {
String data = getCacheData().get(user.getJavaUUID());
if (!data.isEmpty()) {
long time = Long.valueOf(data);
return user.voteCommandNextInfo(voteSite, time);
}
}
return user.voteCommandNextInfo(voteSite);
}
@Override
public String placeholderDataRequest(VotingPluginUser user, String identifier) {
long time = user.getTime(voteSite);
return "" + time;
}
}.withDescription("How long until user can vote on " + voteSite.getKey()).updateDataKey("LastVotes"));
placeholders.add(new PlaceHolder<VotingPluginUser>("Last_" + voteSite.getKey()) {
@@ -876,22 +929,40 @@ public class PlaceHolders {
@Override
public void onChange(AdvancedCoreUser user, String... keys) {
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
VotingPluginUser vpUser = plugin.getVotingPluginUserManager().getVotingPluginUser(user);
if (!vpUser.isCached()) {
vpUser.dontCache();
}
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder.isUsesCache()) {
for (String key : keys) {
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
for (String ident : placeholder.getCache().keySet()) {
String value = placeholder.placeholderRequest(vpUser, ident);
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(), value);
plugin.devDebug("Updated placeholder cache for " + vpUser.getUUID() + " on " + key
+ " with " + value);
if (placeholder instanceof CalculatingPlaceholder<?>) {
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
if (placeholder.isUsesCache()) {
for (String key : keys) {
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
for (String ident : placeholder.getCache().keySet()) {
String value = placeholder.placeholderRequest(vpUser, ident);
cPlaceholder.getCacheData().put(user.getJavaUUID(),
cPlaceholder.placeholderDataRequest(vpUser, ident));
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(), value);
plugin.devDebug("Updated calculating placeholder cache for " + vpUser.getUUID()
+ " on " + key + " with " + value);
}
}
}
}
} else {
if (placeholder.isUsesCache()) {
for (String key : keys) {
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
for (String ident : placeholder.getCache().keySet()) {
String value = placeholder.placeholderRequest(vpUser, ident);
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(), value);
plugin.devDebug("Updated placeholder cache for " + vpUser.getUUID() + " on "
+ key + " with " + value);
}
}
}
}
}
@@ -926,10 +997,24 @@ public class PlaceHolders {
public void onUpdate(VotingPluginUser user) {
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder.isUsesCache()) {
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
if (placeholder instanceof CalculatingPlaceholder<?>) {
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
if (placeholder.isUsesCache()) {
for (String ident : placeholder.getCache().keySet()) {
cPlaceholder.getCacheData().put(user.getJavaUUID(),
cPlaceholder.placeholderDataRequest(user, ident));
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
}
}
} else {
if (placeholder.isUsesCache()) {
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
}
}
}
}
@@ -2,7 +2,6 @@ package com.bencodez.votingplugin.signs;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -14,6 +13,7 @@ import org.bukkit.block.data.Directional;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
@@ -111,7 +111,7 @@ public class SignHandler {
* Check valid sign.
*/
public void checkValidSign() {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
BukkitScheduler.runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -121,7 +121,7 @@ public class SignHandler {
setValid(false);
}
}
});
}, getLocation());
}
@@ -240,8 +240,9 @@ public class SignHandler {
* @param delay the delay
*/
public void updateSign(int delay) {
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
BukkitScheduler.runTaskLater(plugin, new Runnable() {
@SuppressWarnings("deprecation")
@Override
public void run() {
try {
@@ -261,7 +262,7 @@ public class SignHandler {
VotingPluginMain.plugin.debug(ex);
}
}
}, delay);
}, delay, getLocation());
}
public void updateSkulls(Location loc1, Location loc2) {
@@ -4,14 +4,12 @@ import java.util.ArrayList;
import java.util.Random;
import java.util.UUID;
import org.bukkit.Bukkit;
import com.bencodez.advancedcore.api.rewards.Reward;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
public class VoteTester {
@@ -29,7 +27,7 @@ public class VoteTester {
public void run() {
long time1 = System.currentTimeMillis();
ArrayList<Long> timesPerReward = new ArrayList<Long>();
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(name);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(name);
Reward reward = plugin.getRewardHandler().getReward(rewardName);
int rewardsGiven = 0;
for (int i = 0; i < amount; i++) {
@@ -52,7 +50,7 @@ public class VoteTester {
VotingPluginMain.plugin.getLogger()
.info("Time to process rewards (" + amount + "): " + time + " ms, average per reward "
+ timePerRewardAvg + " ms. " + VotingPluginMain.plugin.getStorageType() + ", "
+ UserManager.getInstance().getAllUUIDs().size() + " users. " + rewardsGiven
+ plugin.getVotingPluginUserManager().getAllUUIDs().size() + " users. " + rewardsGiven
+ " rewards given");
}
@@ -126,7 +124,7 @@ public class VoteTester {
VotingPluginMain.plugin.getLogger()
.info("Time to process votes (" + amount + "): " + time + " ms, average per vote "
+ timePerVoteAvg + " ms. " + VotingPluginMain.plugin.getStorageType() + ", "
+ UserManager.getInstance().getAllUUIDs().size() + " users. "
+ plugin.getVotingPluginUserManager().getAllUUIDs().size() + " users. "
+ VotingPluginMain.plugin.getVoteSites().size() + " votesites");
}
@@ -136,7 +134,7 @@ public class VoteTester {
public void testSpam(int amount, String name, String site) {
for (int i = 0; i < amount; i++) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -30,7 +30,6 @@ import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.advancedcore.api.user.userstorage.DataType;
import com.bencodez.advancedcore.api.yml.YMLFileHandler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
public class TopVoterHandler implements Listener {
@@ -94,7 +93,7 @@ public class TopVoterHandler implements Listener {
String uuid = playerData.getKey().toString();
if (plugin != null && plugin.isEnabled()) {
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
@@ -141,7 +140,7 @@ public class TopVoterHandler implements Listener {
if (plugin.getConfigFile().isUseVoteStreaks() || plugin.getConfigFile().isUseHighestTotals()) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(playerData.getKey(), false);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
@@ -186,6 +185,8 @@ public class TopVoterHandler implements Listener {
user.dontCache();
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
user.giveDailyTopVoterAward(i, places.get(i));
plugin.getLogger().info("Giving daily top voter reward " + i + " to "
+ entry.getKey().getPlayerName());
}
}
lastTotal = entry.getValue().intValue();
@@ -236,7 +237,7 @@ public class TopVoterHandler implements Listener {
if (plugin.getConfigFile().isUseHighestTotals() || plugin.getConfigFile().isUseVoteStreaks()) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(playerData.getKey(), false);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
@@ -294,6 +295,8 @@ public class TopVoterHandler implements Listener {
user.dontCache();
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
user.giveMonthlyTopVoterAward(i, places.get(i));
plugin.getLogger().info("Giving Monthly top voter reward " + i + " to "
+ entry.getKey().getPlayerName());
}
}
lastTotal = entry.getValue().intValue();
@@ -356,7 +359,7 @@ public class TopVoterHandler implements Listener {
if (plugin.getConfigFile().isUseVoteStreaks() || plugin.getConfigFile().isUseHighestTotals()) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(playerData.getKey(), false);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
@@ -406,8 +409,9 @@ public class TopVoterHandler implements Listener {
VotingPluginUser user = entry.getKey().getUser();
user.dontCache();
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
user.giveWeeklyTopVoterAward(i, places.get(i));
plugin.getLogger().info("Giving weekly top voter reward " + i + " to "
+ entry.getKey().getPlayerName());
}
}
lastTotal = entry.getValue().intValue();
@@ -5,7 +5,7 @@ import java.util.UUID;
import org.bukkit.inventory.ItemStack;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
@@ -34,6 +34,6 @@ public class TopVoterPlayer {
}
public VotingPluginUser getUser() {
return UserManager.getInstance().getVotingPluginUser(getUuid(), getPlayerName());
return VotingPluginMain.plugin.getVotingPluginUserManager().getVotingPluginUser(getUuid(), getPlayerName());
}
}
@@ -3,9 +3,8 @@ package com.bencodez.votingplugin.updater;
import java.util.Timer;
import java.util.TimerTask;
import org.bukkit.Bukkit;
import com.bencodez.advancedcore.api.updater.Updater;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
// TODO: Auto-generated Javadoc
@@ -74,7 +73,7 @@ public class CheckUpdate {
if (plugin.getConfigFile().isDisableUpdateChecking()) {
return;
}
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
@@ -7,34 +7,25 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.user.usercache.UserDataManager;
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyBoolean;
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyInt;
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyString;
import com.bencodez.votingplugin.VotingPluginMain;
public class UserManager {
/** The instance. */
static UserManager instance = new UserManager();
/** The plugin. */
static VotingPluginMain plugin = VotingPluginMain.plugin;
private VotingPluginMain plugin;
/**
* Gets the single instance of UserManager.
*
* @return single instance of UserManager
*/
public static UserManager getInstance() {
return instance;
}
public UserManager() {
public UserManager(VotingPluginMain plugin) {
this.plugin = plugin;
}
public void addCachingKeys() {
UserDataManager manager = plugin.getUserManager().getDataManager();
manager.addKey(new UserDataKeyString("TopVoterIgnore").setColumnType("VARCHAR(5)"));
manager.addKey(new UserDataKeyBoolean("TopVoterIgnore"));
manager.addKey(new UserDataKeyInt("VotePartyVotes"));
manager.addKey(new UserDataKeyString("LastVotes"));
manager.addKey(new UserDataKeyString("CoolDownCheck").setColumnType("VARCHAR(5)"));
manager.addKey(new UserDataKeyBoolean("CoolDownCheck"));
manager.addKey(new UserDataKeyString("OfflineVotes").setColumnType("MEDIUMTEXT"));
manager.addKey(new UserDataKeyInt("MilestoneCount"));
manager.addKey(new UserDataKeyInt("MonthTotal"));
@@ -46,8 +37,8 @@ public class UserManager {
manager.addKey(new UserDataKeyInt("BestDayVoteStreak"));
manager.addKey(new UserDataKeyString("DayVoteStreakLastUpdate").setColumnType("MEDIUMTEXT"));
manager.addKey(new UserDataKeyString("GottenMileStones").setColumnType("LONGTEXT"));
manager.addKey(new UserDataKeyString("Reminded").setColumnType("VARCHAR(5)"));
manager.addKey(new UserDataKeyString("DisableBroadcast").setColumnType("VARCHAR(5)"));
manager.addKey(new UserDataKeyBoolean("Reminded"));
manager.addKey(new UserDataKeyBoolean("DisableBroadcast"));
manager.addKey(new UserDataKeyInt("WeekVoteStreak"));
manager.addKey(new UserDataKeyInt("BestWeekVoteStreak"));
manager.addKey(new UserDataKeyInt("MonthVoteStreak"));
@@ -116,7 +116,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
* @param value the value
* @return current total points
*/
public synchronized int addPoints(int value) {
public int addPoints(int value) {
return addPoints(value, false);
}
public synchronized int addPoints(int value, boolean async) {
PlayerReceivePointsEvent event = new PlayerReceivePointsEvent(this, value);
Bukkit.getPluginManager().callEvent(event);
@@ -124,7 +128,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
return getPoints();
}
int newTotal = getPoints() + event.getPoints();
setPoints(newTotal);
setPoints(newTotal, async);
return newTotal;
}
@@ -799,7 +803,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
bc = StringParser.getInstance().replacePlaceHolders(user.getOfflinePlayer(), bc);
ArrayList<Player> players = new ArrayList<Player>();
for (Player p : Bukkit.getOnlinePlayers()) {
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
players.add(p);
}
}
@@ -833,6 +837,14 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
return false;
}
public boolean removePoints(int points, boolean async) {
if (getPoints() >= points) {
setPoints(getPoints() - points, async);
return true;
}
return false;
}
public void resetTotals(TopVoter topVoter) {
setTotal(topVoter, 0);
}
@@ -1007,6 +1019,10 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
getUserData().setInt(getPointsPath(), value, false);
}
public void setPoints(int value, boolean async) {
getUserData().setInt(getPointsPath(), value, false, async);
}
public void setPrimaryAccount(java.util.UUID uuid) {
if (uuid != null) {
getData().setString("PrimaryAccount", uuid.toString());
@@ -1237,9 +1253,12 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
public String voteCommandNextInfo(VoteSite voteSite) {
return voteCommandNextInfo(voteSite, getTime(voteSite));
}
public String voteCommandNextInfo(VoteSite voteSite, long time) {
String info = new String();
long time = getTime(voteSite);
LocalDateTime now = plugin.getTimeChecker().getTime();
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault())
@@ -20,9 +20,9 @@ import com.bencodez.advancedcore.api.time.events.DayChangeEvent;
import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
import com.bencodez.advancedcore.api.user.userstorage.DataType;
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.VotePartyEvent;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
// TODO: Auto-generated Javadoc
@@ -204,7 +204,7 @@ public class VoteParty implements Listener {
String player = getRandomPlayerName();
for (final String cmd : plugin.getSpecialRewardsConfig().getVotePartyGlobalCommands()) {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
BukkitScheduler.runTask(plugin, new Runnable() {
@Override
public void run() {
@@ -223,7 +223,7 @@ public class VoteParty implements Listener {
if (orgUser != null && orgUser.getJavaUUID().equals(p.getUniqueId())) {
user = orgUser;
} else {
user = UserManager.getInstance().getVotingPluginUser(p);
user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
user.dontCache();
}
@@ -232,13 +232,13 @@ public class VoteParty implements Listener {
}
alreadyGotten.add(p.getUniqueId().toString());
}
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
for (String uuid : plugin.getVotingPluginUserManager().getAllUUIDs()) {
if (!alreadyGotten.contains(uuid)) {
VotingPluginUser user;
if (orgUser != null && orgUser.getJavaUUID().toString().equals(uuid)) {
user = orgUser;
} else {
user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
user.dontCache();
}
@@ -255,7 +255,7 @@ public class VoteParty implements Listener {
if (orgUser != null && orgUser.getJavaUUID().toString().equals(uuid)) {
user = orgUser;
} else {
user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
user.dontCache();
}
if (!plugin.getSpecialRewardsConfig().isVotePartyGiveOnlinePlayersOnly() || user.isOnline()) {
@@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
@@ -72,7 +71,7 @@ public class VoteReminding {
public void run() {
if (plugin != null && plugin.isEnabled()) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
if (!plugin.getOptions().isTreatVanishAsOffline() || !user.isVanished()) {
checkRemind(user);
}
@@ -93,7 +92,7 @@ public class VoteReminding {
public void runRemind(VotingPluginUser user) {
if (plugin.getConfigFile().getVoteRemindingEnabled()) {
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
}
giveReward(user);
if (user.getData().hasData() && plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
@@ -128,9 +127,9 @@ public class VoteReminding {
if (plugin.getConfigFile().getVoteRemindingEnabled()) {
if (user.hasPermission("VotingPlugin.Login.RemindVotes") || user.hasPermission("VotingPlugin.Player")) {
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
}
if ((!UserManager.getInstance().getAllUUIDs().contains(user.getUUID()) || shouldRemind(user))) {
if ((!plugin.getVotingPluginUserManager().getAllUUIDs().contains(user.getUUID()) || shouldRemind(user))) {
giveReward(user);
if (user.getData().hasData()) {
user.setReminded(true);