Compare commits

..
42 Commits
Author SHA1 Message Date
BenCodez 88c5dc7c86 Update version number to 6.9.2 2022-06-07 16:01:30 -04:00
BenCodez b2b2c710c5 Open gui on votesite creation 2022-06-07 14:09:50 -04:00
BenCodez 4175e2d36a Update 1.19 2022-06-07 13:29:33 -04:00
BenCodez a84adb367d Modify delay to login event 2022-06-02 17:10:46 -04:00
BenCodez 7368158707 Add command /av voteexact 2022-06-02 17:01:36 -04:00
BenCodez 5d3c1cb553 Use exact player name in /av user for forcing a vote 2022-05-29 13:04:58 -04:00
BenCodez cb1206db0b Updates to pluginmessaging and sockets 2022-05-18 20:12:45 -04:00
BenCodez 03396e447f Fix color codes on bungee commands 2022-05-17 20:56:58 -04:00
BenCodez 6dec0826af Update version number to 6.9.1 2022-05-15 15:33:12 -04:00
BenCodez f443f77dfe Add option to set cumulative as recurring 2022-05-13 17:04:04 -04:00
BenCodez 5c4636d8c2 Fixed issues with settings points to quickly, causing lost points 2022-05-12 20:55:22 -04:00
BenCodez 51c6c4066b Add cumulative blacklist 2022-05-12 19:27:02 -04:00
BenCodez 161fc6da95 Improve config comment on bungee 2022-05-08 12:11:10 -04:00
BenCodez aba23f355e Fix some issues with points within rewards 2022-05-07 19:37:59 -04:00
BenCodez ac78b4d350 Fix error on bungee 2022-04-27 17:30:41 -04:00
BenCodez 0c01f8d3c1 Update version number to 6.9 2022-04-24 15:15:57 -04:00
BenCodez 77dc7d51f5 Fix alternate broadcast broadcasting 0 votes on each login 2022-04-24 14:48:27 -04:00
BenCodez ee5c4db0c9 Fix playerjoinevent not working 2022-04-24 14:46:06 -04:00
BenCodez f9b47c5c63 Fix vote point adding in rewards 2022-04-18 16:59:56 -04:00
BenCodez d7dc82b1a7 Add extra checks 2022-04-18 16:57:57 -04:00
BenCodez c5041edd8a Add exr 2022-04-18 16:57:20 -04:00
BenCodez d52b7f85b3 use new method to get reward handler 2022-04-15 20:15:58 -04:00
BenCodez 3e4564578a CHange points reward handling 2022-04-15 14:35:07 -04:00
BenCodez 65312cd2a1 Add config option to only broadcast once for offline votes 2022-04-14 20:36:19 -04:00
BenCodez b2db9675ca Add ability to check if player doesn't have permission for vote shop 2022-04-13 16:47:09 -04:00
BenCodez 0a66c2dd7e Synchronize points adding 2022-04-06 17:36:20 -04:00
BenCodez 7c02cb91f4 Update version number to 6.8.4 2022-03-26 21:16:18 -04:00
BenCodez 3a390659cd Reenable config option 2022-03-26 20:16:11 -04:00
BenCodez 99bd32c8f5 Improve placeholder cache 2022-03-24 19:59:00 -04:00
BenCodez de894a98b2 Disable auto cache placeholders when no config option present 2022-03-24 17:35:00 -04:00
BenCodez 8c668289ce Add config options for mysql 2022-03-20 14:14:04 -04:00
BenCodez 95e850cb84 Add blacklist for rewards broadcasts 2022-03-20 12:48:03 -04:00
BenCodez d2134abc45 Fix broadcast blacklist not working on bungee setups 2022-03-19 17:10:47 -04:00
BenCodez 3316662889 Add default top voter material item 2022-03-05 21:57:15 -05:00
BenCodez 5b3ced6ca9 Attempt to fix /vote help for 1.12 2022-03-05 18:54:37 -05:00
BenCodez 50a5169543 Add extra check for background task for shutdowns 2022-03-03 16:52:23 -05:00
BenCodez c8d5e2f4b5 Have placeholders return error message rather than dots 2022-03-02 17:33:05 -05:00
BenCodez 3dcd78e4f5 change vote processing to java timers (hopes to reduce thread usage) 2022-02-22 16:51:18 -05:00
BenCodez de570574c9 Fix potential NPE on velocity shutdown 2022-02-20 16:52:32 -05:00
BenCodez 116eda2866 Update version number to 6.8.3 2022-02-20 13:44:33 -05:00
BuildTools 30f1576510 Fix creating milestones in GUI not working correctly 2022-02-19 17:00:05 -05:00
BuildTools 64e897615a use java timer for login/logout event 2022-02-18 19:16:18 -05:00
34 changed files with 663 additions and 447 deletions

No files matched your search

+11 -1
View File
@@ -30,6 +30,8 @@ MySQL:
#MaxLifeTime: -1
#Additional info on connection string
#Line: ''
#Attempt to use mariadb driver
#UseMariaDB: false
# --------------------
# AllowUnJoined options
@@ -107,7 +109,11 @@ Format:
# Broadcast vote message
# Set to an empty message to disable
# Use %NewLine% for a new line
BroadcastMsg: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%'
# If true uses broadcast setting below for offline votes
OnlyOneOfflineBroadcast: false
OfflineBroadcast: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %numberofvotes% times!'
# Broadcast only when player is online
BroadcastWhenOnline: false
@@ -377,7 +383,7 @@ DisableCoolDownCheck: false
DisableInteractEvent: false
# Delays login event, delays vote reminding and more
# In ticks
# In miliseconds, 1000 = 1 second
DelayLoginEvent: 0
# If false, votestreaks will be disabled
@@ -415,6 +421,10 @@ ClickSound:
# case sensitive
VotingBroadcastBlacklist: []
# Playernames to not be broadcasted when broadcast comes from reward file
# case sensitive
BroadcastBlacklist: []
# When enabled, javascript will be parsed on placeholders (from placeholderapi)
# allows more fancy placeholders with math for example
UseJavascriptPlaceholders: false
+6 -1
View File
@@ -33,7 +33,7 @@ Cumulative:
# Can have multiple listed here
'20':
Enabled: false
# Wether or not votes must be made in same day/week
# Whether or not votes must be made in same day/week
# Useful if you want to require a certain number of voting sites to be voted on
# for a daily/weekly reward instead of all of them
# Valid options
@@ -42,6 +42,11 @@ Cumulative:
# Weekly
# Daily
TotalToUse: AllTime
# Blacklist recurring votes
#BlackList:
#- 40
# Whether or not to gives cumulative reward for every x number of votes, default: true
#Recurring: true
Rewards:
Messages:
Player: '&aYou got %cumulative% cumulative votes!'
+3
View File
@@ -12,9 +12,12 @@ Password: ''
# Max number of connections
MaxConnections: 1
# Table name prefix, for use with mutliple servers
# Don't use with PLUGINMESSAGING bungee setup
Prefix: ''
#UseSSL: true
#PublicKeyRetrieval: false
#Attempt to use mariadb driver
#UseMariaDB: false
Debug: false
# Have a reward on each server
+271 -257
View File
@@ -1,257 +1,271 @@
name: ${project.name}
version: ${project.version}
main: com.bencodez.votingplugin.VotingPluginMain
description: Highly Customizable Voting Listener!
website: https://www.spigotmc.org/resources/votingplugin.15358/
author: BenCodez
softdepend: [MVdWPlaceholders, Votifier, VotifierPlus, NuVotifier, CMI, Vault, PlaceholderAPI, ProtocolLib, MVdWPlaceholderAPI, AuthMe, SuperVanish, PremiumVanish]
loadbefore: [MCPerks]
api-version: 1.13
libraries:
- org.openjdk.nashorn:nashorn-core:15.3
commands:
vote:
description: Vote command
adminvote:
description: Admin commands for VotingPlugin
av:
description: Admin commands for VotingPlugin
votehelp:
description: See access to a list of commands, Formated in Format.yml
aliases: vhelp
votetotal:
description: See totals of votes
aliases: vtotal
votelast:
description: See the last time you voted
aliases: vlast
votenext:
description: See when you can vote next
aliases: vnext
votetop:
description: See top voters
aliases: vtop
votetoday:
description: See who voted today
aliases: vtoday
votegui:
description: Open VoteGUI
aliases: vgui
voteurl:
description: Open VoteURL
aliases: vurl
votereward:
description: Open VoteReward GUI
aliases: vreward
vote?:
description: View Help
aliases: v?
voteparty:
description: A command
aliases: vparty
voteshop:
description: A command
aliases: vshop
votebest:
description: A command
aliases: vbest
votestreak:
description: A command
aliases: vstreak
votetogglebroadcast:
description: A command
aliases: vtogglebroadcast
votepoints:
description: A command
aliases: vpoints
votetogglereminders:
aliases: [vtogglereminder,vtoggle]
votelist:
description: A command
aliases: vlist
voteall:
description: A command
aliases: vall
votechoices:
description: A command
alaises: vchoices
votegivepoints:
description: A command
alaises: vgivepoints
adminvotehelp:
description: Open adminvote help
aliases: avhelp
adminvote?:
description: Open adminvote help
aliases: av?
adminvotereport:
description: Command Alias
aliases: avreport
adminvoteperms:
description: Command Alias
aliases: avperms
adminvotereload:
description: Command Alias
aliases: avreload
adminvotetestreward:
description: Command Alias
aliases: avtestreward
adminvoteversion:
description: Command Alias
aliases: avversion
adminvotesites:
description: Command Alias
aliases: avsites
adminvoterewards:
description: Command Alias
aliases: avrewards
adminvoteuuid:
description: Command Alias
aliases: avuuid
adminvotevotesite:
description: Command Alias
aliases: avvotesite
adminvoteconfig:
description: Command Alias
aliases: avconfig
adminvoteupdatecheck:
description: Command Alias
aliases: avupdatecheck
adminvotevote:
description: Command Alias
aliases: [avvote, fakevote]
adminvotegui:
description: Command Alias
aliases: avgui
adminvotegivereward:
description: Command Alias
aliases: avgivereward
adminvoteConvertFromData:
description: Command Alias
aliases: avConvertFromData
adminvoteConvertToData:
description: Command Alias
aliases: avConvertFromData
adminvoteClearTotal:
description: Command Alias
adminvoteBackgroundUpdate:
description: Command Alias
aliases: avBackgroundUpdate
adminvoteClearCache:
description: Command Alias
aliases: avClearCache
adminvoteServiceSites:
description: Command Alias
aliases: avServiceSites
adminvoteVoteParty:
description: Command Alias
aliases: avVoteParty
adminvoteChoices:
description: Command Alias
aliases: avChoices
adminvoteReloadAll:
description: Command Alias
aliases: avReloadAll
adminvotePermsPlayer:
description: Command Alias
aliases: avPermsPlayer
adminvoteResyncMilestonesAlreadyGiven:
description: Command Alias
aliases: avResyncMilestonesAlreadyGiven
voteSetPrimaryAccount:
description: Command Alias
adminvoteClearOfflineVotes:
description: Command Alias
aliases: avClearOfflineVotes
adminvoteGiveAll:
description: Command Alias
aliases: avGiveAll
adminvoteGiveAllOnline:
description: Command Alias
aliases: avGiveAllOnline
adminvoteForceTimeChanged:
description: Command Alias
aliases: avForceTimeChanged
adminvoteplayername:
description: Command Alias
aliases: avplayername
adminvoteResyncMilestones:
description: Command Alias
aliases: avResyncMilestones
adminvoteClearOfflineRewards:
description: Command Alias
aliases: avClearOfflineRewards
adminvoteUserRemove:
description: Command Alias
aliases: avUserRemove
adminvotePurge:
description: Command Alias
aliases: avPurge
adminvoteJavascript:
description: Command Alias
aliases: avJavascript
adminvoteStatus:
description: Command Alias
aliases: avStatus
adminvoteTest:
description: Command Alias
aliases: avTest
adminvotePlaceholders:
description: Command Alias
aliases: avPlaceholders
adminvoteDownloadJenkins:
description: Command Alias
aliases: avDownloadJenkins
adminvoteSetRequestMethod:
description: Command Alias
aliases: avSetRequestMethod
adminvoteUser:
description: Command Alias
aliases: avUser
adminvoteCurrentPluginTime:
description: Command Alias
aliases: avCurrentPluginTime
adminvoteResetPoints:
description: Command Alias
aliases: avResetPoints
adminvoteRunCMD:
description: Command Alias
aliases: avRunCMD
adminvoteuseruuidremove:
description: Command Alias
aliases: avuseruuidremove
adminvoteedit:
description: Command Alias
aliases: avedit
adminvoteResetMilestoneCount:
description: Command Alias
aliases: avResetMilestoneCount
permissions:
VotingPlugin.Player:
description: Allows basic access player commands
VotingPlugin.Mod:
description: Allows mod commands
VotingPlugin.Admin:
description: Allows admincommands
VotingPlugin.Login.RemindVotes:
description: Allows players to get remined on login if they can vote
default: true
VotingPlugin.Admin.Debug:
description: Permission to view debug info ingame
VotingPlugin.Signs.Create:
description: Allows access to create signs
VotingPlugin.TopVoter.Ignore:
description: Allows you to be exempt from top voter
VotingPlugin.NoRemind:
description: Ignore vote reminding
default: false
VotingPlugin.Sign.Create:
description: Permission to create sign
VotingPlugin.Admin.GenerateServiceSite:
description: Permission for generating votesite message
VotingPlugin.Login.RemindVotes:
description: Permission to allow timed reminders
VotingPlugin.Login.RemindVotes.All:
description: Remind if player can vote on all votesites, rather than any
default: false
name: ${project.name}
version: ${project.version}
main: com.bencodez.votingplugin.VotingPluginMain
description: Highly Customizable Voting Listener!
website: https://www.spigotmc.org/resources/votingplugin.15358/
author: BenCodez
softdepend:
- MVdWPlaceholders
- Votifier
- VotifierPlus
- NuVotifier
- CMI
- Vault
- PlaceholderAPI
- ProtocolLib
- MVdWPlaceholderAPI
- AuthMe
- SuperVanish
- PremiumVanishs
- DiscordSRV
loadbefore:
- MCPerks
api-version: 1.13
libraries:
- org.openjdk.nashorn:nashorn-core:15.3
commands:
vote:
description: Vote command
adminvote:
description: Admin commands for VotingPlugin
av:
description: Admin commands for VotingPlugin
votehelp:
description: See access to a list of commands, Formated in Format.yml
aliases: vhelp
votetotal:
description: See totals of votes
aliases: vtotal
votelast:
description: See the last time you voted
aliases: vlast
votenext:
description: See when you can vote next
aliases: vnext
votetop:
description: See top voters
aliases: vtop
votetoday:
description: See who voted today
aliases: vtoday
votegui:
description: Open VoteGUI
aliases: vgui
voteurl:
description: Open VoteURL
aliases: vurl
votereward:
description: Open VoteReward GUI
aliases: vreward
vote?:
description: View Help
aliases: v?
voteparty:
description: A command
aliases: vparty
voteshop:
description: A command
aliases: vshop
votebest:
description: A command
aliases: vbest
votestreak:
description: A command
aliases: vstreak
votetogglebroadcast:
description: A command
aliases: vtogglebroadcast
votepoints:
description: A command
aliases: vpoints
votetogglereminders:
aliases:
- vtogglereminder
- vtoggle
votelist:
description: A command
aliases: vlist
voteall:
description: A command
aliases: vall
votechoices:
description: A command
alaises: vchoices
votegivepoints:
description: A command
alaises: vgivepoints
adminvotehelp:
description: Open adminvote help
aliases: avhelp
adminvote?:
description: Open adminvote help
aliases: av?
adminvotereport:
description: Command Alias
aliases: avreport
adminvoteperms:
description: Command Alias
aliases: avperms
adminvotereload:
description: Command Alias
aliases: avreload
adminvotetestreward:
description: Command Alias
aliases: avtestreward
adminvoteversion:
description: Command Alias
aliases: avversion
adminvotesites:
description: Command Alias
aliases: avsites
adminvoterewards:
description: Command Alias
aliases: avrewards
adminvoteuuid:
description: Command Alias
aliases: avuuid
adminvotevotesite:
description: Command Alias
aliases: avvotesite
adminvoteconfig:
description: Command Alias
aliases: avconfig
adminvoteupdatecheck:
description: Command Alias
aliases: avupdatecheck
adminvotevote:
description: Command Alias
aliases:
- avvote
- fakevote
adminvotegui:
description: Command Alias
aliases: avgui
adminvotegivereward:
description: Command Alias
aliases: avgivereward
adminvoteConvertFromData:
description: Command Alias
aliases: avConvertFromData
adminvoteConvertToData:
description: Command Alias
aliases: avConvertFromData
adminvoteClearTotal:
description: Command Alias
adminvoteBackgroundUpdate:
description: Command Alias
aliases: avBackgroundUpdate
adminvoteClearCache:
description: Command Alias
aliases: avClearCache
adminvoteServiceSites:
description: Command Alias
aliases: avServiceSites
adminvoteVoteParty:
description: Command Alias
aliases: avVoteParty
adminvoteChoices:
description: Command Alias
aliases: avChoices
adminvoteReloadAll:
description: Command Alias
aliases: avReloadAll
adminvotePermsPlayer:
description: Command Alias
aliases: avPermsPlayer
adminvoteResyncMilestonesAlreadyGiven:
description: Command Alias
aliases: avResyncMilestonesAlreadyGiven
voteSetPrimaryAccount:
description: Command Alias
adminvoteClearOfflineVotes:
description: Command Alias
aliases: avClearOfflineVotes
adminvoteGiveAll:
description: Command Alias
aliases: avGiveAll
adminvoteGiveAllOnline:
description: Command Alias
aliases: avGiveAllOnline
adminvoteForceTimeChanged:
description: Command Alias
aliases: avForceTimeChanged
adminvoteplayername:
description: Command Alias
aliases: avplayername
adminvoteResyncMilestones:
description: Command Alias
aliases: avResyncMilestones
adminvoteClearOfflineRewards:
description: Command Alias
aliases: avClearOfflineRewards
adminvoteUserRemove:
description: Command Alias
aliases: avUserRemove
adminvotePurge:
description: Command Alias
aliases: avPurge
adminvoteJavascript:
description: Command Alias
aliases: avJavascript
adminvoteStatus:
description: Command Alias
aliases: avStatus
adminvoteTest:
description: Command Alias
aliases: avTest
adminvotePlaceholders:
description: Command Alias
aliases: avPlaceholders
adminvoteDownloadJenkins:
description: Command Alias
aliases: avDownloadJenkins
adminvoteSetRequestMethod:
description: Command Alias
aliases: avSetRequestMethod
adminvoteUser:
description: Command Alias
aliases: avUser
adminvoteCurrentPluginTime:
description: Command Alias
aliases: avCurrentPluginTime
adminvoteResetPoints:
description: Command Alias
aliases: avResetPoints
adminvoteRunCMD:
description: Command Alias
aliases: avRunCMD
adminvoteuseruuidremove:
description: Command Alias
aliases: avuseruuidremove
adminvoteedit:
description: Command Alias
aliases: avedit
adminvoteResetMilestoneCount:
description: Command Alias
aliases: avResetMilestoneCount
permissions:
VotingPlugin.Player:
description: Allows basic access player commands
VotingPlugin.Mod:
description: Allows mod commands
VotingPlugin.Admin:
description: Allows admincommands
VotingPlugin.Admin.Debug:
description: Permission to view debug info ingame
VotingPlugin.Signs.Create:
description: Allows access to create signs
VotingPlugin.TopVoter.Ignore:
description: Allows you to be exempt from top voter
VotingPlugin.NoRemind:
description: Ignore vote reminding
default: false
VotingPlugin.Sign.Create:
description: Permission to create sign
VotingPlugin.Admin.GenerateServiceSite:
description: Permission for generating votesite message
VotingPlugin.Login.RemindVotes:
description: Permission to allow timed reminders
VotingPlugin.Login.RemindVotes.All:
description: Remind if player can vote on all votesites, rather than any
default: false
+2 -2
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId>
<version>6.8.2</version>
<version>6.9.2</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -226,7 +226,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -260,6 +260,19 @@ public class BungeeHandler implements Listener {
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcastOffline") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
if (args.size() > 2) {
String uuid = args.get(0);
String votes = args.get(2);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
args.get(1));
user.offlineBroadcast(user, false, Integer.parseInt(votes));
}
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
@@ -295,7 +308,13 @@ public class BungeeHandler implements Listener {
socketHandler = new SocketHandler(plugin.getVersion(), plugin.getBungeeSettings().getSpigotServerHost(),
plugin.getBungeeSettings().getSpigotServerPort(), encryptionHandler,
plugin.getBungeeSettings().isBungeeDebug());
plugin.getBungeeSettings().isBungeeDebug()) {
@Override
public void log(String str) {
plugin.getLogger().info(str);
}
};
socketHandler.add(new SocketReceiver("bungeevote") {
@@ -347,6 +366,19 @@ public class BungeeHandler implements Listener {
}
});
socketHandler.add(new SocketReceiver("BroadcastOffline") {
@Override
public void onReceive(String[] data) {
if (data.length > 2) {
String votes = data[0];
String p = data[1];
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
user.offlineBroadcast(user, false, Integer.parseInt(votes));
}
}
});
socketHandler.add(new SocketReceiver("BungeeBroadcast") {
@Override
@@ -364,6 +396,23 @@ public class BungeeHandler implements Listener {
}
});
socketHandler.add(new SocketReceiver("Broadcast") {
@Override
public void onReceive(String[] data) {
if (data.length > 2) {
VoteSite site = plugin.getVoteSite(data[1], true);
String p = data[3];
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
if (site != null) {
site.broadcastVote(user, false);
} else {
plugin.getLogger().warning("No votesite for " + data[1]);
}
}
}
});
socketHandler.add(new SocketReceiver("Status") {
@Override
@@ -2,7 +2,6 @@ package com.bencodez.votingplugin;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
import com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInject;
import com.bencodez.votingplugin.user.UserManager;
@@ -16,11 +15,11 @@ public class VotingPluginHooks {
}
public void addCustomRequirement(RequirementInject inject) {
RewardHandler.getInstance().addInjectedRequirements(inject);
getMainClass().getRewardHandler().addInjectedRequirements(inject);
}
public void addCustomReward(RewardInject inject) {
RewardHandler.getInstance().addInjectedReward(inject);
getMainClass().getRewardHandler().addInjectedReward(inject);
}
public void backgroundUpdate(Player player) {
@@ -16,6 +16,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.zip.ZipEntry;
@@ -44,7 +45,6 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward;
import com.bencodez.advancedcore.api.rewards.Reward;
import com.bencodez.advancedcore.api.rewards.RewardEditData;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardPlaceholderHandle;
import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationSection;
@@ -208,11 +208,14 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Getter
private boolean ymlError = false;
@Getter
private Timer voteTimer = new Timer();
@Getter
private UserManager votingPluginUserManager;
private void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
RewardHandler.getInstance().addDirectlyDefined(directlyDefinedReward);
getRewardHandler().addDirectlyDefined(directlyDefinedReward);
}
public void basicBungeeUpdate() {
@@ -401,7 +404,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
public void loadDirectlyDefined() {
RewardHandler.getInstance().getDirectlyDefinedRewards().clear();
getRewardHandler().getDirectlyDefinedRewards().clear();
// AllSites reward
addDirectlyDefinedRewards(new DirectlyDefinedReward("AllSites") {
@@ -1040,15 +1043,17 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
// Add rewards
RewardHandler.getInstance().addInjectedReward(new RewardInjectInt("Points", 0) {
getRewardHandler().addInjectedReward(new RewardInjectInt("Points", 0) {
@Override
public String onRewardRequest(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user,
int num, HashMap<String, String> placeholders) {
UserManager.getInstance().getVotingPluginUser(user).addPoints(num);
return null;
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
String str = "" + vpUser.addPoints(num);
debug("Setting points to " + str);
return str;
}
}.synchronize().addEditButton(
}.synchronize().asPlaceholder("newpoints").addEditButton(
new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueNumber("Points", null) {
@Override
@@ -1066,7 +1071,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
}));
RewardHandler.getInstance().addInjectedReward(new RewardInjectConfigurationSection("VoteBossBar") {
getRewardHandler().addInjectedReward(new RewardInjectConfigurationSection("VoteBossBar") {
@Override
public String onRewardRequested(Reward arg0, com.bencodez.advancedcore.api.user.AdvancedCoreUser user,
@@ -1085,7 +1090,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
});
for (final TopVoter top : TopVoter.values()) {
RewardHandler.getInstance().addPlaceholder(new RewardPlaceholderHandle("Total_" + top.toString()) {
getRewardHandler().addPlaceholder(new RewardPlaceholderHandle("Total_" + top.toString()) {
@Override
public String getValue(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user) {
@@ -1106,7 +1111,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
"Using dev build, this is not a stable build, use at your own risk. Build number: " + buildNumber);
}
boolean hasRewards = RewardHandler.getInstance().hasRewards(getConfigVoteSites().getData(),
boolean hasRewards = getRewardHandler().hasRewards(getConfigVoteSites().getData(),
getConfigVoteSites().getEverySiteRewardPath());
boolean issues = true;
@@ -1351,8 +1356,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
plugin.debug("Starting background task, current cached users: "
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
placeholders.onUpdate();
int dataLoadLimit = getConfigFile().getPlayerDataLoadLimit();
try {
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
@@ -1363,6 +1366,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
ArrayList<TopVoter> topVotersToCheck = new ArrayList<TopVoter>();
for (TopVoter top : TopVoter.values()) {
if (plugin == null) {
return;
}
if (plugin.getConfigFile().getLoadTopVoter(top)) {
topVotersToCheck.add(top);
tempTopVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
@@ -1437,6 +1443,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
time1 = System.currentTimeMillis();
topVoterHandler.updateTopVoters(tempTopVoter);
placeholders.onUpdate();
setVoteToday(voteToday);
serverData.updateValues();
getSigns().updateSigns();
@@ -3,7 +3,6 @@ package com.bencodez.votingplugin;
import java.util.concurrent.Callable;
import com.bencodez.advancedcore.api.metrics.BStatsMetrics;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.votingplugin.user.UserManager;
public class VotingPluginMetrics {
@@ -15,7 +14,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
return "True";
} else {
@@ -27,7 +26,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
if (RewardHandler.getInstance().hasRewards(plugin.getConfigVoteSites().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getConfigVoteSites().getData(),
plugin.getConfigVoteSites().getEverySiteRewardPath())) {
return "True";
} else {
@@ -39,7 +38,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getAllSitesRewardPath())) {
return "True";
} else {
@@ -94,7 +93,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath())) {
return "True";
} else {
@@ -109,7 +108,7 @@ public class VotingPluginMetrics {
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Day")) {
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Day", s)
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Day", s))) {
return "True";
}
@@ -126,7 +125,7 @@ public class VotingPluginMetrics {
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Week")) {
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Week", s)
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Week", s))) {
return "True";
}
@@ -143,7 +142,7 @@ public class VotingPluginMetrics {
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Month")) {
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Month", s)
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Month", s))) {
return "True";
}
@@ -163,7 +162,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
return "" + RewardHandler.getInstance().getRewards().size();
return "" + plugin.getRewardHandler().getRewards().size();
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("autocreatevotesites", new Callable<String>() {
@@ -201,14 +200,15 @@ public class VotingPluginMetrics {
}));
}
if (users > 10000) {
metrics.addCustomChart(new BStatsMetrics.SimplePie("number_of_users_in_thousands_plus_10", new Callable<String>() {
metrics.addCustomChart(
new BStatsMetrics.SimplePie("number_of_users_in_thousands_plus_10", new Callable<String>() {
@Override
public String call() throws Exception {
int total = UserManager.getInstance().getAllUUIDs().size() / 1000;
return "" + total;
}
}));
@Override
public String call() throws Exception {
int total = UserManager.getInstance().getAllUUIDs().size() / 1000;
return "" + total;
}
}));
}
metrics.addCustomChart(new BStatsMetrics.SimplePie("data_storage", new Callable<String>() {
@@ -330,7 +330,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
return "" + (!plugin.getConfigFile().isDisableCoolDownCheck() && RewardHandler.getInstance()
return "" + (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward"));
}
}));
@@ -473,7 +473,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
socketHandler = new SocketHandler(getDescription().getVersion(), config.getBungeeHost(),
config.getBungeePort(), encryptionHandler, config.getDebug());
config.getBungeePort(), encryptionHandler, config.getDebug()) {
@Override
public void log(String str) {
getLogger().info(str);
}
};
socketHandler.add(new SocketReceiver() {
@@ -514,12 +520,11 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
}
}
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
+ voteCacheFile.getVotePartyInreaseVotesRequired();
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
}
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
+ voteCacheFile.getVotePartyInreaseVotesRequired();
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
BStatsMetricsBungee metrics = new BStatsMetricsBungee(this, 9453);
metrics.addCustomChart(
@@ -863,6 +868,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
forceCache = true;
debug("Forcing vote to cache");
}
if (config.getBroadcast()) {
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
}
if (info.getPlayers().isEmpty() || forceCache) {
// cache
if (!cachedVotes.containsKey(s)) {
@@ -881,9 +889,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
"" + getConfig().getBungeeManageTotals(),
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
}
if (config.getBroadcast()) {
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
}
}
}
} else {
@@ -906,11 +912,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
debug("Caching online vote for " + player + " on " + service);
}
for (String s : getProxy().getServers().keySet()) {
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
"" + currentVotePartyVotesRequired);
if (config.getBroadcast()) {
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
}
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
"" + currentVotePartyVotesRequired);
}
}
} else if (method.equals(BungeeMethod.SOCKETS)) {
@@ -18,11 +18,11 @@ public class VotingPluginBungeeCommand extends Command {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("reload")) {
bungee.reload(false);
sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee"));
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee"));
}
if (args[0].equalsIgnoreCase("reloadmysql")) {
bungee.reload(true);
sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee with MySQL"));
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee with MySQL"));
}
if (args[0].equalsIgnoreCase("vote")) {
if (args.length >= 2) {
@@ -397,7 +397,9 @@ public class VotingPluginVelocity {
}
}
}
timeHandle.save();
if (timeHandle != null) {
timeHandle.save();
}
voteCacheFile.save();
nonVotedPlayersCache.save();
if (mysql != null) {
@@ -529,7 +531,13 @@ public class VotingPluginVelocity {
socketHandler = new SocketHandler(
server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get(),
config.getBungeeHost(), config.getBungeePort(), encryptionHandler, config.getDebug());
config.getBungeeHost(), config.getBungeePort(), encryptionHandler, config.getDebug()) {
@Override
public void log(String str) {
getLogger().info(str);
}
};
socketHandler.add(new SocketReceiver() {
@@ -28,7 +28,6 @@ import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.api.updater.Updater;
import com.bencodez.advancedcore.api.user.userstorage.DataType;
@@ -373,12 +372,13 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.clearCache();
user.cache();
int newTotal = 0;
synchronized (pointLock) {
user.addPoints(Integer.parseInt(args[3]));
newTotal = user.addPoints(Integer.parseInt(args[3]));
}
sender.sendMessage(StringParser.getInstance().colorize("&cGave " + args[1] + " " + args[3]
+ " points" + ", " + args[1] + " now has " + user.getPoints() + " points"));
+ " points" + ", " + args[1] + " now has " + newTotal + " points"));
}
});
@@ -389,7 +389,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.clearCache();
user.cache();
user.removePoints(Integer.parseInt(args[3]));
sender.sendMessage(StringParser.getInstance().colorize("&cRemoved " + args[3] + " points from "
+ args[1] + ", " + args[1] + " now has " + user.getPoints() + " points"));
@@ -439,7 +439,6 @@ public class CommandLoader {
int page = Integer.parseInt(args[1]);
new AdminVoteHelp(plugin, sender, page).open();
}
});
@@ -910,6 +909,32 @@ public class CommandLoader {
}
});
plugin.getAdminVoteCommand()
.add(new CommandHandler(new String[] { "VoteExact", "(PlayerExact)", "(Sitename)" },
"VotingPlugin.Commands.AdminVote.VoteExact|" + adminPerm,
"Trigger manual vote with exact player name") {
@Override
public void execute(CommandSender sender, String[] args) {
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2], true), args[1],
args[2], false);
sendMessage(sender, "&cTriggering vote...");
if (voteEvent.getVoteSite() != null) {
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
sendMessage(sender,
"&cPossible issue with service site, has the server gotten the vote from "
+ voteEvent.getServiceSite() + "?");
}
}
plugin.getServer().getPluginManager().callEvent(voteEvent);
if (plugin.isYmlError()) {
sendMessage(sender, "&3Detected yml error, please check server log for details");
}
}
});
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote", "(player)", },
"VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote via GUI", false) {
@@ -1267,7 +1292,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
RewardHandler.getInstance().giveReward(user, plugin.getConfigFile().getData(),
plugin.getRewardHandler().giveReward(user, plugin.getConfigFile().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(args[3]), new RewardOptions());
sendMessage(sender, "&cVoteShop " + args[3] + " forced");
}
@@ -1828,7 +1853,7 @@ public class CommandLoader {
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
if (hasPerm) {
user.clearCache();
user.cache();
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
if (identifier != null) {
@@ -1839,7 +1864,7 @@ public class CommandLoader {
placeholders.put("limit", "" + limit);
if (user.removePoints(points)) {
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
new RewardOptions().setPlaceholders(placeholders));
@@ -2011,7 +2036,7 @@ public class CommandLoader {
}
});
if (plugin.getGui().isLastMonthGUI()) {
if (plugin.getGui().isLastMonthGUI() || plugin.getOptions().getDebug().equals(DebugLevel.DEV)) {
plugin.getVoteCommand()
.add(new CommandHandler(new String[] { "LastMonthTop" },
"VotingPlugin.Commands.Vote.LastMonthTop|" + playerPerm,
@@ -21,7 +21,6 @@ import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueSt
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.valuerequest.InputMethod;
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
@@ -66,6 +65,7 @@ public class AdminGUI {
plugin.getConfigVoteSites().generateVoteSite(value);
player.sendMessage("Generated site");
plugin.reload();
openAdminGUIVoteSiteSite(player, plugin.getVoteSite(value, true));
}
});
} else {
@@ -110,7 +110,7 @@ public class AdminGUI {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("FirstVote"));
plugin.getRewardHandler().getDirectlyDefined("FirstVote"));
}
});
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit FirstVoteToday reward")) {
@@ -118,7 +118,7 @@ public class AdminGUI {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("FirstVoteToday"));
plugin.getRewardHandler().getDirectlyDefined("FirstVoteToday"));
}
});
@@ -127,7 +127,7 @@ public class AdminGUI {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("AllSites"));
plugin.getRewardHandler().getDirectlyDefined("AllSites"));
}
});
@@ -136,7 +136,7 @@ public class AdminGUI {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("AnySiteRewards"));
plugin.getRewardHandler().getDirectlyDefined("AnySiteRewards"));
}
});
@@ -145,7 +145,7 @@ public class AdminGUI {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("EverySiteReward"));
plugin.getRewardHandler().getDirectlyDefined("EverySiteReward"));
}
});
@@ -154,7 +154,7 @@ public class AdminGUI {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("BungeeVotePartyRewards"));
plugin.getRewardHandler().getDirectlyDefined("BungeeVotePartyRewards"));
}
});
@@ -364,7 +364,7 @@ public class AdminGUI {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), RewardHandler.getInstance()
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler()
.getDirectlyDefined("VoteSites." + voteSite.getKey() + ".Rewards"));
}
});
@@ -17,7 +17,6 @@ import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueLi
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
import com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener;
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
@@ -212,7 +211,7 @@ public class AdminVoteVoteParty extends GUIHandler {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("VoteParty.Rewards"));
plugin.getRewardHandler().getDirectlyDefined("VoteParty.Rewards"));
}
});
@@ -13,7 +13,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.valuerequest.InputMethod;
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
@@ -68,7 +67,7 @@ public class AdminVoteCumulative extends GUIHandler {
@Override
public void onInput(Player player, Number value) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance()
plugin.getRewardHandler()
.getDirectlyDefined("Cumulative." + value.intValue() + ".Rewards"));
}
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
@@ -13,7 +13,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.valuerequest.InputMethod;
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
@@ -68,7 +67,7 @@ public class AdminVoteMilestones extends GUIHandler {
@Override
public void onInput(Player player, Number value) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance()
plugin.getRewardHandler()
.getDirectlyDefined("MileStones." + value.intValue() + ".Rewards"));
}
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
@@ -17,7 +17,6 @@ import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueLi
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
import com.bencodez.votingplugin.VotingPluginMain;
@@ -115,7 +114,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("CHEST.Shop." + identifier + ".Rewards"));
plugin.getRewardHandler().getDirectlyDefined("CHEST.Shop." + identifier + ".Rewards"));
}
});
@@ -12,7 +12,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -184,9 +183,9 @@ public class VoteGUI extends GUIHandler {
}
}
if (RewardHandler.getInstance().hasRewards(plugin.getGui().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(),
plugin.getGui().getChestVoteGUISlotRewardsPath(slot))) {
RewardHandler.getInstance().giveReward(UserManager.getInstance().getVotingPluginUser(player),
plugin.getRewardHandler().giveReward(UserManager.getInstance().getVotingPluginUser(player),
plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot),
new RewardOptions().addPlaceholder("identifier", slot));
}
@@ -11,6 +11,7 @@ import com.bencodez.advancedcore.api.command.CommandHandler;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.votingplugin.VotingPluginMain;
import net.md_5.bungee.api.ChatColor;
@@ -63,6 +64,28 @@ public class VoteHelp extends GUIHandler {
return msg;
}
public ArrayList<TextComponent> helpTextLegacy(CommandSender sender) {
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
if (!requirePerms || cmdHandle.hasPerm(sender)) {
unsorted.put(cmdHandle.getHelpLineCommand("/vote"),
cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine()));
}
}
ArrayList<String> unsortedList = new ArrayList<String>();
unsortedList.addAll(unsorted.keySet());
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
for (String cmd : unsortedList) {
msg.add(unsorted.get(cmd));
}
return msg;
}
@Override
public void onBook(Player player) {
@@ -86,7 +109,12 @@ public class VoteHelp extends GUIHandler {
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
int pagesize = plugin.getConfigFile().getFormatPageSize();
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
ArrayList<TextComponent> text = helpText(sender);
ArrayList<TextComponent> text = new ArrayList<TextComponent>();
if (NMSManager.getInstance().isVersion("1.12")) {
text = helpTextLegacy(sender);
} else {
text = helpText(sender);
}
int maxPage = text.size() / pagesize;
if ((text.size() % pagesize) != 0) {
@@ -13,7 +13,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.UserManager;
@@ -65,7 +64,11 @@ public class VoteShop extends GUIHandler {
if (perm.isEmpty()) {
hasPerm = true;
} else {
hasPerm = player.hasPermission(perm);
if (perm.startsWith("!")) {
hasPerm = !player.hasPermission(perm.substring(1));
} else {
hasPerm = player.hasPermission(perm);
}
}
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
@@ -117,7 +120,7 @@ public class VoteShop extends GUIHandler {
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/"
+ user.getUUID() + " bought " + identifier + " for " + points);
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
new RewardOptions().setPlaceholders(placeholders));
@@ -14,7 +14,6 @@ import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -65,7 +64,7 @@ public class VoteShopConfirm extends GUIHandler {
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/" + user.getUUID() + " bought "
+ identifier + " for " + points);
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
new RewardOptions().setPlaceholders(placeholders));
@@ -86,7 +86,7 @@ public class VoteTopVoter extends GUIHandler {
int pos = 1;
for (Entry<TopVoterPlayer, Integer> entry : users) {
ItemBuilder playerItem;
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
if (plugin.getGui().isChestVoteTopUseSkull()) {
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
@@ -89,10 +89,6 @@ public class Config extends YMLFile {
@Getter
private int delayBetweenUpdates = 3;
@ConfigDataInt(path = "DelayLoginEvent")
@Getter
private int delayLoginEvent = 0;
@ConfigDataBoolean(path = "DisableAdvancedTab")
@Getter
private boolean disableAdvancedTab = false;
@@ -149,6 +145,14 @@ public class Config extends YMLFile {
@Getter
private boolean formatAlternateBroadcastEnabled = false;
@ConfigDataBoolean(path = "Format.OnlyOneOfflineBroadcast")
@Getter
private boolean formatOnlyOneOfflineBroadcast = false;
@ConfigDataString(path = "Format.OfflineBroadcast")
@Getter
private String formatOfflineBroadcast = "&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %numberofvotes% times!";
@ConfigDataBoolean(path = "Format.Commands.Vote.ForceLinks")
@Getter
private boolean formatCommandsVoteForceLinks = true;
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.config;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.bencodez.advancedcore.api.yml.YMLFile;
@@ -91,6 +92,14 @@ public class SpecialRewardsConfig extends YMLFile {
return "Cumulative." + cumulative + ".Rewards";
}
public List<Integer> getCumulativeBlackList(int cumulative) {
return getData().getIntegerList("Cumulative." + cumulative + ".BlackList");
}
public boolean getCumulativeRecurring(int cumulative) {
return getData().getBoolean("Cumulative." + cumulative + ".Recurring", true);
}
/**
* Gets the cumulative votes.
*
@@ -353,8 +362,8 @@ public class SpecialRewardsConfig extends YMLFile {
}
public void setMilestone(int intValue) {
getData().set("Milestones." + intValue + ".Enabled", true);
getData().set("Milestones." + intValue + ".Rewards.Messages.Player", "&aYou got %milestone% milestone votes!");
getData().set("MileStones." + intValue + ".Enabled", true);
getData().set("MileStones." + intValue + ".Rewards.Messages.Player", "&aYou got %milestone% milestone votes!");
saveData();
}
}
@@ -10,7 +10,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
import com.bencodez.advancedcore.api.user.UserStartup;
@@ -34,7 +33,7 @@ public class CoolDownCheck implements Listener {
private boolean cooldownCheckEnabled = false;
public void checkEnabled() {
if (!plugin.getConfigFile().isDisableCoolDownCheck() && RewardHandler.getInstance()
if (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward")) {
cooldownCheckEnabled = true;
} else {
@@ -110,7 +109,7 @@ public class CoolDownCheck implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
RewardHandler.getInstance().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
plugin.getRewardHandler().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
"VoteCoolDownEndedReward", new RewardOptions());
}
}
@@ -1,13 +1,13 @@
package com.bencodez.votingplugin.listeners;
import org.bukkit.Bukkit;
import java.util.TimerTask;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import com.bencodez.advancedcore.api.user.UserStorage;
import com.bencodez.advancedcore.listeners.AdvancedCoreLoginEvent;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMethod;
@@ -62,43 +62,29 @@ public class PlayerJoinEvent implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerLogin(AdvancedCoreLoginEvent event) {
if (event.getPlayer() == null || (VotingPluginMain.plugin.getStorageType().equals(UserStorage.MYSQL)
&& VotingPluginMain.plugin.getMysql() == null)) {
if (event.getPlayer() == null || !plugin.isMySQLOkay()) {
return;
}
int delay = plugin.getConfigFile().getDelayLoginEvent();
if (delay <= 0) {
login(event.getPlayer());
} else {
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
login(event.getPlayer());
}
}, delay);
}
login(event.getPlayer());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerQuit(PlayerQuitEvent event) {
if (plugin.getConfigFile().isDisableAdvancedTab()) {
return;
if (plugin != null && plugin.isEnabled()) {
final java.util.UUID uuid = event.getPlayer().getUniqueId();
plugin.getLoginTimer().schedule(new TimerTask() {
@Override
public void run() {
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
user.dontCache();
user.logoutRewards();
}
}, 0);
}
final java.util.UUID uuid = event.getPlayer().getUniqueId();
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
user.dontCache();
user.logoutRewards();
}
});
}
}
@@ -3,6 +3,8 @@ package com.bencodez.votingplugin.listeners;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.TimerTask;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
@@ -200,9 +202,10 @@ public class PlayerVoteListener implements Listener {
plugin.getSpecialRewards().checkCumualativeVotes(user, event.getBungeeTextTotals(), event.isForceBungee());
plugin.getSpecialRewards().checkMilestone(user, event.getBungeeTextTotals(), event.isForceBungee());
final String uuid = user.getUUID();
if (plugin.getBungeeSettings().isUseBungeecoord()) {
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MYSQL)) {
final String uuid = user.getUUID();
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
@@ -214,14 +217,24 @@ public class PlayerVoteListener implements Listener {
}, 40);
}
}
if (!user.isOnline()) {
user.clearCache();
}
}
PlayerPostVoteEvent postVoteEvent = new PlayerPostVoteEvent(voteSite, user, event.isRealVote(),
event.isForceBungee());
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
PlayerPostVoteEvent postVoteEvent = new PlayerPostVoteEvent(voteSite, user, event.isRealVote(),
event.isForceBungee());
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
plugin.getTimer().schedule(new TimerTask() {
@Override
public void run() {
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid));
if (!user.isOnline()) {
user.clearCache();
}
}
}, 1000 * 5);
}
plugin.setUpdate(true);
}
@@ -1,8 +1,8 @@
package com.bencodez.votingplugin.listeners;
import java.util.ArrayList;
import java.util.TimerTask;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -65,7 +65,7 @@ public class VotiferEvent implements Listener {
plugin.debug("VoteSite: " + voteSite);
plugin.debug("IP: " + IP);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
plugin.getVoteTimer().schedule(new TimerTask() {
@Override
public void run() {
@@ -110,7 +110,7 @@ public class VotiferEvent implements Listener {
}
}
});
}, 0);
}
@@ -14,7 +14,6 @@ import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.user.UserManager;
@@ -108,6 +107,11 @@ public class VoteSite {
return;
}
if (!user.isVanished()) {
String playerName = user.getPlayerName();
if (plugin.getConfigFile().getVotingBroadcastBlacklist().contains(playerName)) {
plugin.getLogger().info("Not broadcasting for " + playerName + ", in blacklist");
return;
}
if (checkBungee && plugin.getBungeeSettings().isBungeeBroadcast()
&& plugin.getBungeeSettings().isUseBungeecoord()) {
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS)) {
@@ -123,11 +127,6 @@ public class VoteSite {
}
} else {
String playerName = user.getPlayerName();
if (plugin.getConfigFile().getVotingBroadcastBlacklist().contains(playerName)) {
plugin.getLogger().info("Not broadcasting for " + playerName + ", in blacklist");
return;
}
String bc = StringParser.getInstance().colorize(plugin.getConfigFile().getFormatBroadCastMsg());
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("player", playerName);
@@ -209,7 +208,7 @@ public class VoteSite {
}
public boolean hasRewards() {
return RewardHandler.getInstance().hasRewards(plugin.getConfigVoteSites().getData(),
return plugin.getRewardHandler().hasRewards(plugin.getConfigVoteSites().getData(),
plugin.getConfigVoteSites().getRewardsPath(key));
}
@@ -111,7 +111,7 @@ public class PlaceHolders {
}
} catch (Exception e) {
plugin.debug(e);
return "...";
return "Error";
}
}
@@ -762,10 +762,11 @@ public class PlaceHolders {
for (String key : keys) {
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
user.dontCache();
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(),
placeholder.placeholderRequest(vpUser, ident));
plugin.devDebug("Updated cache for " + vpUser.getUUID() + " on " + key);
plugin.devDebug("Updated placeholder cache for " + vpUser.getUUID() + " on " + key);
}
@@ -2,13 +2,13 @@ package com.bencodez.votingplugin.specialrewards;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.Bukkit;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
@@ -58,7 +58,7 @@ public class SpecialRewards {
int votesRequired = Integer.parseInt(vote);
if (votesRequired != 0) {
if (plugin.getSpecialRewardsConfig().getCumulativeRewardEnabled(votesRequired)
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getCumulativeRewardsPath(votesRequired))) {
boolean gotCumulative = false;
int total = 0;
@@ -87,8 +87,25 @@ public class SpecialRewards {
}
}
if (total != 0 && total >= votesRequired) {
if ((total % votesRequired) == 0) {
List<Integer> blackList = plugin.getSpecialRewardsConfig()
.getCumulativeBlackList(votesRequired);
boolean blackListed = false;
for (Integer num : blackList) {
if (num.intValue() == total) {
blackListed = true;
plugin.extraDebug("Not giving cumulative " + votesRequired + " to "
+ user.getPlayerName() + " due to blacklist");
}
}
if (plugin.getSpecialRewardsConfig().getCumulativeRecurring(votesRequired)) {
if (total != 0 && total >= votesRequired) {
if ((total % votesRequired) == 0 && !blackListed) {
gotCumulative = true;
}
}
} else {
if (total == votesRequired) {
gotCumulative = true;
}
}
@@ -116,7 +133,7 @@ public class SpecialRewards {
}
public boolean checkFirstVote(VotingPluginUser user, boolean forceBungee) {
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
if (!user.hasGottenFirstVote()) {
giveFirstVoteRewards(user, user.isOnline(), forceBungee);
@@ -128,7 +145,7 @@ public class SpecialRewards {
}
public boolean checkFirstVoteToday(VotingPluginUser user, boolean forceBungee) {
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
if (!user.hasGottenFirstVoteToday()) {
giveFirstVoteTodayRewards(user, user.isOnline(), forceBungee);
@@ -181,7 +198,7 @@ public class SpecialRewards {
int votesRequired = Integer.parseInt(vote);
if (votesRequired != 0) {
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(votesRequired)
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getMilestoneRewardsPath(votesRequired))) {
int userVotesTotal = milestoneCount;
@@ -217,7 +234,7 @@ public class SpecialRewards {
int streakRequired = Integer.parseInt(s);
if (streakRequired != 0) {
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled(type, streak)
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath(type, "" + streak))) {
int curStreak = 0;
if (type.equalsIgnoreCase("day")) {
@@ -261,7 +278,7 @@ public class SpecialRewards {
if (event.isCancelled()) {
return;
}
RewardHandler.getInstance().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getAllSitesRewardPath(),
new RewardOptions().setServer(forceBungee).setOnline(online));
}
@@ -287,7 +304,7 @@ public class SpecialRewards {
if (event.isCancelled()) {
return;
}
RewardHandler.getInstance().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath(),
new RewardOptions().setServer(forceBungee).setOnline(online));
}
@@ -299,7 +316,7 @@ public class SpecialRewards {
if (event.isCancelled()) {
return;
}
RewardHandler.getInstance().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getFirstVoteTodayRewardsPath(),
new RewardOptions().setServer(forceBungee).setOnline(online));
}
@@ -3,7 +3,6 @@ package com.bencodez.votingplugin.test;
import java.util.ArrayList;
import com.bencodez.advancedcore.api.rewards.Reward;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
@@ -24,13 +23,13 @@ public class VoteTester {
long time1 = System.currentTimeMillis();
ArrayList<Long> timesPerReward = new ArrayList<Long>();
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(name);
Reward reward = RewardHandler.getInstance().getReward(rewardName);
Reward reward = plugin.getRewardHandler().getReward(rewardName);
int rewardsGiven = 0;
for (int i = 0; i < amount; i++) {
long start1 = System.currentTimeMillis();
if (reward.canGiveReward(user, new RewardOptions())) {
rewardsGiven++;
RewardHandler.getInstance().giveReward(user, reward, new RewardOptions().setIgnoreRequirements(true));
plugin.getRewardHandler().giveReward(user, reward, new RewardOptions().setIgnoreRequirements(true));
}
long start2 = System.currentTimeMillis();
timesPerReward.add(start2 - start1);
@@ -22,7 +22,6 @@ import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
import com.bencodez.votingplugin.VotingPluginMain;
@@ -114,15 +113,18 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
* Adds the points.
*
* @param value the value
* @return current total points
*/
public void addPoints(int value) {
public synchronized int addPoints(int value) {
PlayerReceivePointsEvent event = new PlayerReceivePointsEvent(this, value);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
return getPoints();
}
setPoints(getPoints() + event.getPoints());
int newTotal = getPoints() + event.getPoints();
setPoints(newTotal);
return newTotal;
}
/**
@@ -168,13 +170,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
voteEvent.setAddTotals(setTotals);
voteEvent.setBungeeTextTotals(text);
voteEvent.setVotingPluginUser(this);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
plugin.getServer().getPluginManager().callEvent(voteEvent);
}
});
plugin.getServer().getPluginManager().callEvent(voteEvent);
}
}
@@ -189,13 +185,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
voteEvent.setAddTotals(setTotals);
voteEvent.setBungeeTextTotals(text);
voteEvent.setVotingPluginUser(this);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
plugin.getServer().getPluginManager().callEvent(voteEvent);
}
});
plugin.getServer().getPluginManager().callEvent(voteEvent);
}
}
@@ -214,13 +204,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
voteEvent.setBungeeTextTotals(text);
voteEvent.setWasOnline(wasOnline);
voteEvent.setBroadcast(broadcast);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
plugin.getServer().getPluginManager().callEvent(voteEvent);
}
});
plugin.getServer().getPluginManager().callEvent(voteEvent);
}
}
@@ -682,16 +666,23 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
setTopVoterIgnore(topVoterIngorePerm);
}
ArrayList<String> offlineVotes = getOfflineVotes();
// plugin.debug(ArrayUtils.getInstance().makeStringList(offlineVotes));
// plugin.debug("Offvotes: " +
// ArrayUtils.getInstance().makeStringList(offlineVotes));
if (offlineVotes.size() > 0) {
sendVoteEffects(false);
setOfflineVotes(new ArrayList<String>());
}
boolean offlineBroadcast = plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast();
if (offlineBroadcast && offlineVotes.size() > 0) {
offlineBroadcast(this, plugin.getBungeeSettings().isUseBungeecoord(), offlineVotes.size());
}
for (int i = 0; i < offlineVotes.size(); i++) {
if (plugin.hasVoteSite(offlineVotes.get(i))) {
plugin.debug("Giving offline site reward: " + offlineVotes.get(i));
playerVote(plugin.getVoteSite(offlineVotes.get(i), true), false, true, false);
playerVote(plugin.getVoteSite(offlineVotes.get(i), true), false, !offlineBroadcast, false);
} else {
plugin.debug("Site doesn't exist: " + offlineVotes.get(i));
}
@@ -699,6 +690,52 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
}
public void offlineBroadcast(VotingPluginUser user, boolean checkBungee, int numberOfVotes) {
if (plugin.getConfigFile().isFormatAlternateBroadcastEnabled()) {
return;
}
if (!user.isVanished()) {
String playerName = user.getPlayerName();
if (plugin.getConfigFile().getVotingBroadcastBlacklist().contains(playerName)) {
plugin.getLogger().info("Not broadcasting for " + playerName + ", in blacklist");
return;
}
if (checkBungee && plugin.getBungeeSettings().isBungeeBroadcast()
&& plugin.getBungeeSettings().isUseBungeecoord()) {
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS)) {
plugin.getBungeeHandler().sendData("BroadcastOffline", "" + numberOfVotes, user.getPlayerName());
} else if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MYSQL)
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
String uuid = user.getUUID();
if (Bukkit.getOnlinePlayers().size() > 0) {
plugin.getPluginMessaging().sendPluginMessage("VoteBroadcastOffline", uuid, "" + numberOfVotes);
}
}
} else {
String bc = StringParser.getInstance().colorize(plugin.getConfigFile().getFormatOfflineBroadcast());
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("player", playerName);
placeholders.put("nickname",
(user.getPlayer() != null) ? user.getPlayer().getDisplayName() : user.getPlayerName());
placeholders.put("numberofvotes", "" + numberOfVotes);
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
bc = StringParser.getInstance().replacePlaceHolders(user.getOfflinePlayer(), bc);
ArrayList<Player> players = new ArrayList<Player>();
for (Player p : Bukkit.getOnlinePlayers()) {
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
players.add(p);
}
}
MiscUtils.getInstance().broadcast(bc, players);
}
} else {
plugin.debug(user.getPlayerName() + " is vanished, not broadcasting");
}
}
public void playerVote(VoteSite voteSite, boolean online, boolean broadcast, boolean bungee) {
if (plugin.getConfigFile().getFormatBroadcastWhenOnline() && plugin.getConfigFile().isBroadcastVotesEnabled()
&& broadcast && !plugin.getBungeeSettings().isDisableBroadcast()) {
@@ -731,7 +768,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
* @param online the online
*/
public void sendVoteEffects(boolean online) {
RewardHandler.getInstance().giveReward(this, plugin.getSpecialRewardsConfig().getData(),
plugin.getRewardHandler().giveReward(this, plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath(), new RewardOptions().setOnline(online));
}
@@ -865,7 +902,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
* @param value the new points
*/
public void setPoints(int value) {
getUserData().setInt(getPointsPath(), value, !plugin.getBungeeSettings().isUseBungeecoord());
getUserData().setInt(getPointsPath(), value, false);
}
public void setPrimaryAccount(java.util.UUID uuid) {