Compare commits

...
41 Commits
Author SHA1 Message Date
BenCodez 710ad17f47 Update version number 2021-01-30 20:06:58 -05:00
BenCodez a617625b87 Improve status command for pluginmessaging 2021-01-30 18:06:50 -05:00
BenCodez e8a5319544 Changes to bungee messaging, weekly voteparty reset 2021-01-30 17:34:24 -05:00
BenCodez 86e737892a Little fix for vote party reset count 2021-01-28 16:43:40 -05:00
BenCodez 3fd7a40421 Remove unneeded check 2021-01-27 17:05:20 -05:00
BenCodez a70e5aa54c Add option to not reset vote party total 2021-01-26 16:56:13 -05:00
BenCodez 593aae1e67 Fix issue with no player names 2021-01-26 16:52:38 -05:00
BenCodez e88849854b Bug fix 2021-01-26 16:47:52 -05:00
BenCodez 738fd5645e Change warning messages for votesite display item & service site issue 2021-01-24 20:36:10 -05:00
BenCodez 22ac364f8a Add option 2021-01-24 14:15:46 -05:00
BenCodez 5d78d3a734 Change debug values 2021-01-24 14:11:26 -05:00
BenCodez e83b12a248 Add ability for vote party once a day only 2021-01-23 20:45:08 -05:00
BenCodez 0f50998519 Update version number to 6.1 2021-01-23 18:01:37 -05:00
BenCodez 1768d4490f Command changes 2021-01-23 17:42:21 -05:00
BenCodez 2a3635b805 Add option to main vote gui run on /vote 2021-01-23 16:41:59 -05:00
BenCodez a5be973fd4 Fix back to main GUI button 2021-01-22 21:04:02 -05:00
BenCodez c8a76f38f9 Votetoday back button to votegui bug fix 2021-01-22 20:30:20 -05:00
BenCodez 273edaf101 Little bug fix 2021-01-22 19:12:54 -05:00
BenCodez d1a90676fc Changes to /av perms 2021-01-19 19:40:43 -05:00
BenCodez ff6119050d Add nonvotedplayerscache, allows allowunjoined option on bungee 2021-01-18 17:44:00 -05:00
BenCodez 0a0b95097d Changes to month/week/day changes to reduce impact of server restarts 2021-01-17 16:21:13 -05:00
BenCodez ace42a5a1f Little fixes 2021-01-13 17:11:25 -05:00
BenCodez 1a23648b91 Add package relocation to prevent conflicts 2021-01-09 14:50:00 -05:00
BenCodez 65b5a46525 Changes to permission handling, advanced tab is disabled 2021-01-08 17:34:54 -05:00
BenCodez 462d99c0e5 Little change 2021-01-04 18:57:23 -05:00
BenCodez 04636dd5af Little change 2021-01-03 12:29:38 -05:00
BenCodez d5b5b6cec0 Command changes 2021-01-02 16:47:08 -05:00
BenCodez 921fdac8bb Little change 2020-12-27 17:09:34 -05:00
BenCodez 6b9bc60785 Bug fix 2020-12-27 16:51:25 -05:00
BenCodez ff01c73193 Little changes 2020-12-26 09:14:59 -05:00
BenCodez a6cb4c3a8c Bug fix 2020-12-25 12:43:32 -05:00
BenCodez 43d33277ba Little fix 2020-12-25 11:41:12 -05:00
BenCodez 9badb50075 Little change 2020-12-22 19:44:29 -05:00
BenCodez ad6a09ba85 Bug fix 2020-12-22 16:58:55 -05:00
BenCodez 1791ec5e46 Merge branch 'master' of https://github.com/BenCodez/VotingPlugin 2020-12-22 16:57:24 -05:00
BenCodez 46457a9e61 Update version number 2020-12-22 16:56:23 -05:00
Ben 38ab221fd8 Little bug fix 2020-12-22 05:39:59 -05:00
BenCodez fc2317655e Change default option 2020-12-21 20:12:52 -05:00
BenCodez fb183b9f1f Add option 2020-12-21 18:40:49 -05:00
BenCodez 64057723b6 Update version number 2020-12-19 17:51:20 -05:00
BenCodez 703662c0c0 Bug fix 2020-12-19 17:51:01 -05:00
34 changed files with 839 additions and 205 deletions

No files matched your search

@@ -37,11 +37,13 @@ Server: PleaseSet
# -----------------------------
# Bungee communication, add bungee host/port here
# For socket method
BungeeServer:
Host: '127.0.0.1'
Port: 1297
# Bungee communication, add this to bungee server
# For socket method
SpigotServer:
Host: '127.0.0.1'
Port: 1298
+15 -3
View File
@@ -343,6 +343,15 @@ StoreTopVoters:
# Most of these values can be left untouched for most setups
# ------------------------------------------------
# If false, votestreaks will be disabled
UseVoteStreaks: true
# If false, storing best totals will be disabled
UseHighestTotals: true
# If true, /vote will open /vote gui by default
UseVoteGUIMainCommand: false
# Number of points to give on vote
# Set to 0 to give no points
PointsOnVote: 1
@@ -366,9 +375,9 @@ ClickSound:
# case sensitive
VotingBroadcastBlacklist: []
# Set to false to prevent javascript
# parsing on placeholderapi placeholders
UseJavascriptPlaceholders: true
# When enabled, javascript will be parsed on placeholders (from placeholderapi)
# allows more fancy placeholders with math for example
UseJavascriptPlaceholders: false
# Limit monthly votes to number of days of a month multipled by the number of sites
LimitMonthlyVotes: false
@@ -385,6 +394,9 @@ PreventRepeatMilestones: false
# Mainly to be used for alts and such
UsePrimaryAccountForPlaceholders: false
# If true, permissions will be handled differently
MultiplePermissionsCheck: false
AddCustomCommands: false
# Injects custom command to /vote
+1 -1
View File
@@ -4,7 +4,7 @@
#
# GUI Methods:
# - BOOK
# - GUI
# - CHEST
# - CHAT (Disables GUI)
GUIMethod:
Today: CHEST #BOOK not available (future update?)
@@ -49,8 +49,12 @@ VoteParty:
GiveAllPlayers: false
# If true, the vote count will reset each day
ResetEachDay: false
# If true, the vote count will reset each week
ResetWeekly: false
# Reset at the end of the month
ResetMonthly: false
# If true, will give voteparty only once per day
OnlyOncePerDay: false
# Reset extra votes
ResetExtraVotesMonthly: false
# Count votes from /av vote?
+6
View File
@@ -101,6 +101,12 @@ VoteSites:
Fallback:
Messages:
Player: 'You got unlucky'
# Give 1 diamond
Items:
item1:
Material: DIAMOND
Amount: 1
Messages:
Player: 'You voted'
+5
View File
@@ -40,19 +40,24 @@ BungeeMethod: PLUGINMESSAGING
FallBackServer: factions
AllowUnJoined: false
# ----------------------------
# SOCKET METHOD Settings
# ----------------------------
# Tell servers to broadcast
# For socket method
Broadcast: true
# Bungee communication, Add this to each spigot server
# For socket method
BungeeServer:
Host: '127.0.0.1'
Port: 1297
# Bungee communication, add each spigot server here
# For socket method
SpigotServers:
lobby:
Host: '127.0.0.1'
+19 -8
View File
@@ -112,9 +112,6 @@ commands:
adminvoteconfig:
description: Command Alias
aliases: avconfig
adminvotesettotal:
description: Command Alias
aliases: avsettotal
adminvoteupdatecheck:
description: Command Alias
aliases: avupdatecheck
@@ -127,9 +124,6 @@ commands:
adminvotegivereward:
description: Command Alias
aliases: avgivereward
adminvoteusers:
description: Command Alias
aliases: avusers
adminvoteConvertFromData:
description: Command Alias
aliases: avConvertFromData
@@ -147,6 +141,20 @@ commands:
adminvoteSetVotePartyCount:
description: Command Alias
aliases: avSetVotePartyCount
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
@@ -215,9 +223,9 @@ permissions:
VotingPlugin.Player:
description: Allows basic access player commands
VotingPlugin.Mod:
description: Allows mod access player commands
description: Allows mod commands
VotingPlugin.Admin:
description: Allows admin access player commands
description: Allows admincommands
VotingPlugin.Login.RemindVotes:
description: Allows players to get remined on login if they can vote
default: true
@@ -234,4 +242,7 @@ permissions:
description: Permission to create sign
VotingPlugin.Admin.GenerateServiceSite:
description: Permission for generating votesite message
VotingPlugin.Login.RemindVotes.Any:
description: Remind if player can vote on any website, rather than all
default: false
+3 -3
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>VotingPlugin</artifactId>
<version>6.0.2</version>
<version>6.1.1</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -127,8 +127,8 @@
<shadedPattern>${project.groupId}.votingplugin.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j.slf4j-simple</pattern>
<shadedPattern>${project.groupId}.votingplugin.slf4j-simple</shadedPattern>
<pattern>xyz.upperlevel.spigot.book</pattern>
<shadedPattern>${project.groupId}.votingplugin.upperlevel.book</shadedPattern>
</relocation>
</relocations>
</configuration>
@@ -9,6 +9,7 @@ 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.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.UserManager;
@@ -47,9 +48,9 @@ public class BungeeHandler {
plugin.getLogger().info("Using BungeeMethod: " + method.toString());
if (method.equals(BungeeMethod.MYSQL)) {
plugin.registerBungeeChannels("VP:VP");
plugin.registerBungeeChannels("vp:vp");
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
plugin.registerBungeeChannels("VP:VP");
plugin.registerBungeeChannels("vp:vp");
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
@Override
@@ -59,11 +60,12 @@ public class BungeeHandler {
String service = args.get(2);
long time = Long.parseLong(args.get(3));
plugin.debug("pluginmessaging vote received from " + player + " on " + service);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
player);
boolean wasOnline = Boolean.valueOf(args.get(4));
String text = args.get(6);
BungeeMessageData text = new BungeeMessageData(args.get(6));
user.clearCache();
@@ -94,9 +96,10 @@ public class BungeeHandler {
String uuid = args.get(1);
String service = args.get(2);
long time = Long.parseLong(args.get(3));
String text = args.get(6);
BungeeMessageData text = new BungeeMessageData(args.get(6));
plugin.debug("pluginmessaging voteonline received from " + player + " on " + service);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
player);
user.clearCache();
user.bungeeVotePluginMessaging(service, time, text);
@@ -146,6 +149,15 @@ public class BungeeHandler {
}
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
String server = args.get(0);
plugin.getPluginMessaging().sendPluginMessage("statusokay", server);
}
});
} else if (method.equals(BungeeMethod.SOCKETS)) {
encryptionHandler = new EncryptionHandler(new File(plugin.getDataFolder(), "secretkey.key"));
@@ -66,7 +66,6 @@ import com.bencodez.votingplugin.config.SpecialRewardsConfig;
import com.bencodez.votingplugin.cooldown.CoolDownCheck;
import com.bencodez.votingplugin.data.ServerData;
import com.bencodez.votingplugin.listeners.BlockBreak;
import com.bencodez.votingplugin.listeners.PlayerCommandSendListener;
import com.bencodez.votingplugin.listeners.PlayerInteract;
import com.bencodez.votingplugin.listeners.PlayerJoinEvent;
import com.bencodez.votingplugin.listeners.PlayerVoteListener;
@@ -635,9 +634,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
// vote party
voteParty = new VoteParty(this);
if (specialRewardsConfig.getVotePartyEnabled()) {
voteParty.check();
}
voteParty.register();
topVoterHandler.register();
@@ -774,7 +770,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
if (!contains) {
issues = false;
plugin.getLogger().warning("No vote has been recieved from " + site.getServiceSite()
+ ", may be an invalid service site. Vote on the site and look in console for a service site, if you get nothing then there is an issue with votifier");
+ ", may be an invalid service site. Please read: https://github.com/BenCodez/VotingPlugin/wiki/Votifier-Troubleshooting");
}
}
@@ -899,9 +895,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
pm.registerEvents(new BlockBreak(this), this);
pm.registerEvents(new PlayerInteract(this), this);
pm.registerEvents(new VotingPluginUpdateEvent(this), this);
if (!NMSManager.getInstance().isVersion("1.12")) {
pm.registerEvents(new PlayerCommandSendListener(this), this);
}
/*
* if (!NMSManager.getInstance().isVersion("1.12")) { pm.registerEvents(new
* PlayerCommandSendListener(this), this); }
*/
coolDownCheck = new CoolDownCheck(this);
pm.registerEvents(coolDownCheck, this);
@@ -0,0 +1,53 @@
package com.bencodez.votingplugin.bungee;
import java.util.regex.Pattern;
import lombok.Getter;
public class BungeeMessageData {
// Message string
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount
@Getter
private int allTimeTotal = 0;
@Getter
private int monthTotal = 0;
@Getter
private int weeklyTotal = 0;
@Getter
private int dailyTotal = 0;
@Getter
private int points = 0;
@Getter
private int milestoneCount = 0;
public BungeeMessageData(String str) {
String[] data = str.split(Pattern.quote("//"));
if (data.length >= 6) {
allTimeTotal = Integer.parseInt(data[0]);
monthTotal = Integer.parseInt(data[1]);
weeklyTotal = Integer.parseInt(data[2]);
dailyTotal = Integer.parseInt(data[3]);
points = Integer.parseInt(data[4]);
milestoneCount = Integer.parseInt(data[5]);
}
}
@Override
public String toString() {
return allTimeTotal + "//" + monthTotal + "//" + weeklyTotal + "//" + dailyTotal + "//" + points + "//"
+ milestoneCount;
}
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
int milestoneCount) {
this.allTimeTotal = allTimeTotal;
this.monthTotal = monthTotal;
this.weeklyTotal = weeklyTotal;
this.dailyTotal = dailyTotal;
this.points = points;
this.milestoneCount = milestoneCount;
}
}
@@ -28,6 +28,10 @@ public class Config {
public boolean getBroadcast() {
return getData().getBoolean("Broadcast", false);
}
public boolean getAllowUnJoined() {
return getData().getBoolean("AllowUnJoined",false);
}
public String getBungeeHost() {
return getData().getString("BungeeServer.Host", "");
@@ -0,0 +1,94 @@
package com.bencodez.votingplugin.bungee;
import java.io.File;
import java.io.IOException;
import lombok.Getter;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
public class NonVotedPlayersCache {
private VotingPluginBungee bungee;
@Getter
private Configuration data;
public NonVotedPlayersCache(VotingPluginBungee bungee) {
this.bungee = bungee;
}
public void addPlayer(ProxiedPlayer proxiedPlayer) {
if (!bungee.getMysql().containsKeyQuery(proxiedPlayer.getUniqueId().toString())) {
addPlayer(proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
}
}
private void addPlayer(String uuid, String playerName) {
getData().set("NonVotedPlayers." + playerName + ".UUID", uuid);
getData().set("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis());
}
public String playerExists(String playerName) {
if (getData().getSection("NonVotedPlayers").getKeys().contains(playerName)) {
return getData().getString("NonVotedPlayers." + playerName + ".UUID", "");
}
return "";
}
private void remove(String player) {
bungee.debug("Removing nonvotedplayer: " + player);
getData().set("NonVotedPlayers." + player, null);
}
public void check() {
for (String player : getData().getSection("NonVotedPlayers").getKeys()) {
long time = getData().getLong("NonVotedPlayers." + player + ".LastTime", 0);
if ((System.currentTimeMillis() - time) > 1000 * 60 * 60 * 24 * 5) {
remove(player);
} else {
String uuid = getData().getString("NonVotedPlayers." + player + ".UUID", "");
if (!uuid.isEmpty()) {
if (bungee.getMysql().containsKeyQuery(uuid)) {
remove(player);
}
} else {
remove(player);
}
}
}
save();
}
public void load() {
if (!bungee.getDataFolder().exists()) {
bungee.getDataFolder().mkdir();
}
File file = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
} catch (IOException e) {
e.printStackTrace();
}
}
public void save() {
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -37,6 +37,7 @@ import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.event.ServerConnectedEvent;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
@@ -65,6 +66,8 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
private VoteCache voteCacheFile;
private NonVotedPlayersCache nonVotedPlayersCache;
public void checkCachedVotes(String server) {
if (getProxy().getServerInfo(server) != null) {
if (!getProxy().getServerInfo(server).getPlayers().isEmpty()) {
@@ -147,6 +150,9 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
if (str != null) {
return str;
}
if (nonVotedPlayersCache != null) {
return nonVotedPlayersCache.playerExists(playerName);
}
return "";
}
@@ -170,7 +176,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
return num;
}
}
return -1;
return 0;
}
private int mysqlUpdate(ArrayList<Column> cols, String uuid, String column, int toAdd) {
@@ -199,6 +205,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
num++;
}
}
nonVotedPlayersCache.save();
}
}
@@ -238,14 +245,22 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
method = BungeeMethod.getByName(config.getBungeeMethod());
if (method == null) {
method = BungeeMethod.PLUGINMESSAGING;
}
this.getProxy().registerChannel("vp:vp");
if (method.equals(BungeeMethod.MYSQL)) {
this.getProxy().registerChannel("VP:VP".toLowerCase());
// this.getProxy().registerChannel("vp:vp");
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
voteCacheFile = new VoteCache(this);
voteCacheFile.load();
nonVotedPlayersCache = new NonVotedPlayersCache(this);
nonVotedPlayersCache.load();
try {
for (String server : voteCacheFile.getServers()) {
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
@@ -292,7 +307,16 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
}
}, 15l, TimeUnit.SECONDS);
this.getProxy().registerChannel("VotingPlugin:VotingPlugin".toLowerCase());
getProxy().getScheduler().schedule(this, new Runnable() {
@Override
public void run() {
if (nonVotedPlayersCache != null) {
debug("Checking nonvotedplayers.yml...");
nonVotedPlayersCache.check();
}
}
}, 1l, 60l, TimeUnit.MINUTES);
} else if (method.equals(BungeeMethod.SOCKETS)) {
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
@@ -352,7 +376,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
@EventHandler
public void onPluginMessage(PluginMessageEvent ev) {
if (!ev.getTag().equals("VP:VP".toLowerCase())) {
if (!ev.getTag().equals("vp:vp".toLowerCase())) {
return;
}
ByteArrayInputStream instream = new ByteArrayInputStream(ev.getData());
@@ -362,15 +386,23 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
DataOutputStream out = new DataOutputStream(outstream);
String subchannel = in.readUTF();
int size = in.readInt();
out.writeUTF(subchannel);
out.writeInt(size);
for (int i = 0; i < size; i++) {
out.writeUTF(in.readUTF());
}
for (String send : getProxy().getServers().keySet()) {
if (getProxy().getServers().get(send).getPlayers().size() > 0) {
getProxy().getServers().get(send).sendData("VP:VP".toLowerCase(),
outstream.toByteArray());
// check for status message returns
if (subchannel.equalsIgnoreCase("statusokay")) {
String server = in.readUTF();
getLogger().info("Status okay for " + server);
return;
} else {
// reforward message
out.writeUTF(subchannel);
out.writeInt(size);
for (int i = 0; i < size; i++) {
out.writeUTF(in.readUTF());
}
for (String send : getProxy().getServers().keySet()) {
if (getProxy().getServers().get(send).getPlayers().size() > 0) {
getProxy().getServers().get(send).sendData("vp:vp".toLowerCase(), outstream.toByteArray());
}
}
}
} catch (Exception e) {
@@ -378,6 +410,13 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
}
}
@EventHandler
public void onLogin(PostLoginEvent event) {
if (nonVotedPlayersCache != null) {
nonVotedPlayersCache.addPlayer(event.getPlayer());
}
}
@EventHandler
public void onServerConnected(ServerConnectedEvent event) {
final String server = event.getServer().getInfo().getName();
@@ -434,8 +473,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
out.writeUTF(message);
}
if (getProxy().getServers().get(server).getPlayers().size() > 0) {
getProxy().getServers().get(server).sendData("VotingPlugin:VotingPlugin".toLowerCase(),
byteOutStream.toByteArray(), false);
getProxy().getServers().get(server).sendData("vp:vp".toLowerCase(), byteOutStream.toByteArray(), false);
}
out.close();
} catch (Exception e) {
@@ -490,7 +528,22 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
}
public void status(CommandSender sender) {
sendServerMessage("status");
if (method.equals(BungeeMethod.SOCKETS)) {
sendServerMessage("status");
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
for (String s : getProxy().getServers().keySet()) {
if (!config.getBlockedServers().contains(s)) {
ServerInfo info = getProxy().getServerInfo(s);
if (info.getPlayers().isEmpty()) {
getLogger().info("No players on server " + s + " to send test status message");
} else {
// send
getLogger().info("Sending request for status message on " + s);
sendPluginMessageServer(s, "Status", s);
}
}
}
}
}
public void vote(String player, String service, boolean realVote) {
@@ -503,17 +556,24 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
String uuid = getUUID(player);
if (uuid.isEmpty()) {
UUID u = null;
try {
u = fetchUUID(player);
} catch (Exception e) {
e.printStackTrace();
}
if (u == null) {
debug("Failed to get uuid for " + player);
if (config.getAllowUnJoined()) {
UUID u = null;
try {
u = fetchUUID(player);
} catch (Exception e) {
if (getConfig().getDebug()) {
e.printStackTrace();
}
}
if (u == null) {
debug("Failed to get uuid for " + player);
return;
}
uuid = u.toString();
} else {
getLogger().info("Ignoring vote from " + player);
return;
}
uuid = u.toString();
}
player = getProperName(uuid, player);
@@ -524,9 +584,18 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", uuid, DataType.STRING));
String text = mysqlUpdate(data, uuid, "AllTimeTotal", 1) + "//" + mysqlUpdate(data, uuid, "MonthTotal", 1)
+ "//" + mysqlUpdate(data, uuid, "WeeklyTotal", 1) + "//" + mysqlUpdate(data, uuid, "DailyTotal", 1)
+ "//" + mysqlUpdate(data, uuid, "Points", 1) + "//" + mysqlUpdate(data, uuid, "MilestoneCount", 1);
BungeeMessageData text = new BungeeMessageData(mysqlUpdate(data, uuid, "AllTimeTotal", 1),
mysqlUpdate(data, uuid, "MonthTotal", 1), mysqlUpdate(data, uuid, "WeeklyTotal", 1),
mysqlUpdate(data, uuid, "DailyTotal", 1), mysqlUpdate(data, uuid, "Points", 1),
mysqlUpdate(data, uuid, "MilestoneCount", 1));
/*
* String text = mysqlUpdate(data, uuid, "AllTimeTotal", 1) + "//" +
* mysqlUpdate(data, uuid, "MonthTotal", 1) + "//" + mysqlUpdate(data, uuid,
* "WeeklyTotal", 1) + "//" + mysqlUpdate(data, uuid, "DailyTotal", 1) + "//" +
* mysqlUpdate(data, uuid, "Points", 1) + "//" + mysqlUpdate(data, uuid,
* "MilestoneCount", 1);
*/
long time = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
@@ -540,7 +609,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
cachedVotes.put(s, new ArrayList<OfflineBungeeVote>());
}
ArrayList<OfflineBungeeVote> list = cachedVotes.get(s);
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text));
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
cachedVotes.put(s, list);
debug("Caching vote for " + player + " on " + service + " for " + s);
@@ -548,7 +617,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
} else {
// send
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
Boolean.TRUE.toString(), "" + realVote, text);
Boolean.TRUE.toString(), "" + realVote, text.toString());
}
}
}
@@ -557,7 +626,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
if (p != null && p.isConnected()
&& !config.getBlockedServers().contains(p.getServer().getInfo().getName())) {
sendPluginMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
"" + time, Boolean.TRUE.toString(), "" + realVote, text);
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString());
} else {
if (!cachedOnlineVotes.containsKey(uuid)) {
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
@@ -566,7 +635,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
if (list == null) {
list = new ArrayList<OfflineBungeeVote>();
}
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text));
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
cachedOnlineVotes.put(uuid, list);
debug("Caching online vote for " + player + " on " + service);
}
@@ -31,10 +31,14 @@ public class VotingPluginBungeeCommand extends Command {
if (args[0].equalsIgnoreCase("status")) {
if (bungee.getMethod().equals(BungeeMethod.SOCKETS)) {
sender.sendMessage(new TextComponent(
"Checking status, waiting for response, check console, only for socket method"));
"Checking status, waiting for response, check console, method: sockets"));
bungee.status(sender);
} else if (bungee.getMethod().equals(BungeeMethod.PLUGINMESSAGING)){
sender.sendMessage(new TextComponent(
"Checking status, waiting for response, check console, method: plugin messaging"));
bungee.status(sender);
} else {
sender.sendMessage(new TextComponent("Not using socket method, command unavailable"));
sender.sendMessage(new TextComponent("Not using socket/pluginmessage method, command unavailable"));
}
}
if (args[0].equalsIgnoreCase("help")) {
@@ -6,6 +6,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -14,6 +15,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.permissions.Permission;
import com.bencodez.advancedcore.DebugLevel;
import com.bencodez.advancedcore.api.command.CommandHandler;
@@ -401,12 +403,21 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
new AdminVotePerms(plugin, sender).open();
new AdminVotePerms(plugin, sender, 1).open();
}
});
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Perms", "(Number)" },
"VotingPlugin.Commands.AdminVote.Perms|" + adminPerm, "List permissions") {
@Override
public void execute(CommandSender sender, String[] args) {
new AdminVotePerms(plugin, sender, Integer.parseInt(args[1])).open();
}
});
plugin.getAdminVoteCommand()
.add(new CommandHandler(new String[] { "Perms", "(Player)" },
.add(new CommandHandler(new String[] { "PermsPlayer", "(Player)" },
"VotingPlugin.Commands.AdminVote.Perms.Other|" + adminPerm,
"List permissions from the plugin the player has") {
@@ -417,7 +428,7 @@ public class CommandLoader {
});
plugin.getAdminVoteCommand()
.add(new CommandHandler(new String[] { "Perms", "(Player)", "(Number)" },
.add(new CommandHandler(new String[] { "PermsPlayer", "(Player)", "(Number)" },
"VotingPlugin.Commands.AdminVote.Perms.Other|" + adminPerm,
"List permissions from the plugin the player has") {
@@ -427,6 +438,30 @@ public class CommandLoader {
}
});
plugin.getAdminVoteCommand()
.add(new CommandHandler(new String[] { "Perms", "(Number)", "(Player)" },
"VotingPlugin.Commands.AdminVote.Perms.Other|" + adminPerm,
"List permissions from the plugin the specificed player has") {
@Override
public void execute(CommandSender sender, String[] args) {
new AdminVotePerms(plugin, sender, Integer.parseInt(args[1]), args[2]).open();
}
});
if (plugin.getOptions().getDebug().equals(DebugLevel.DEV)) {
plugin.getAdminVoteCommand()
.add(new CommandHandler(new String[] { "PermsDebug" }, "VotingPlugin.Commands.AdminVote.PermsDebug",
"Dev permission list, generate this list, requires dev debug") {
@Override
public void execute(CommandSender sender, String[] args) {
sendMessage(sender, ArrayUtils.getInstance()
.convert(new AdminVotePerms(plugin, sender, 0).listPermsDev(sender)));
}
});
}
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Reload" },
"VotingPlugin.Commands.AdminVote.Reload|" + adminPerm, "Reload plugin, will not reload user storage") {
@@ -507,6 +542,7 @@ public class CommandLoader {
});
}
sendMessage(sender,
"Using AdvancedCore " + plugin.getVersion() + "' built on '" + plugin.getBuildTime());
}
@@ -1200,11 +1236,29 @@ public class CommandLoader {
String[] args = cmdHandle.getArgs()[0].split("&");
for (String arg : args) {
commands.put("vote" + arg, cmdHandle);
try {
String[] perms = cmdHandle.getPerm().split(Pattern.quote("|"));
if (perms.length > 1) {
// has another perm
plugin.devDebug("Adding child perm " + perms[0] + " to " + perms[1]);
Permission p = Bukkit.getPluginManager().getPermission(perms[1]);
p.getChildren().put(perms[0], true);
p.recalculatePermissibles();
}
} catch (Exception e) {
plugin.debug("Failed to set permission for /vote" + arg);
}
try {
plugin.getCommand("vote" + arg).setExecutor(new CommandAliases(cmdHandle, false));
plugin.getCommand("vote" + arg)
.setTabCompleter(new AliasesTabCompleter().setCMDHandle(cmdHandle, false));
plugin.getCommand("vote" + arg).setPermission(cmdHandle.getPerm().split(Pattern.quote("|"))[0]);
for (String str : plugin.getCommand("vote" + arg).getAliases()) {
commands.put(str, cmdHandle);
}
@@ -1213,6 +1267,20 @@ public class CommandLoader {
}
}
} else {
try {
String[] perms = cmdHandle.getPerm().split(Pattern.quote("|"));
if (perms.length > 1) {
// has another perm
plugin.devDebug("Adding child perm " + perms[0] + " to " + perms[1]);
Permission p = Bukkit.getPluginManager().getPermission(perms[1]);
p.getChildren().put(perms[0], true);
p.recalculatePermissibles();
}
} catch (Exception e) {
plugin.debug("Failed to set permission for /vote");
}
}
}
@@ -1221,11 +1289,28 @@ public class CommandLoader {
String[] args = cmdHandle.getArgs()[0].split("&");
for (String arg : args) {
commands.put("adminvote" + arg, cmdHandle);
try {
String[] perms = cmdHandle.getPerm().split(Pattern.quote("|"));
if (perms.length > 1) {
// has another perm
plugin.devDebug("Adding child perm " + perms[0] + " to " + perms[1]);
Permission p = Bukkit.getPluginManager().getPermission(perms[1]);
p.getChildren().put(perms[0], true);
p.recalculatePermissibles();
}
} catch (Exception e) {
plugin.debug("Failed to set permission for /adminvote" + arg);
}
try {
plugin.getCommand("adminvote" + arg).setExecutor(new CommandAliases(cmdHandle, true));
plugin.getCommand("adminvote" + arg)
.setTabCompleter(new AliasesTabCompleter().setCMDHandle(cmdHandle, true));
plugin.getCommand("adminvote" + arg)
.setPermission(cmdHandle.getPerm().split(Pattern.quote("|"))[0]);
for (String str : plugin.getCommand("adminvote" + arg).getAliases()) {
commands.put(str, cmdHandle);
}
@@ -1236,6 +1321,20 @@ public class CommandLoader {
}
}
} else {
try {
String[] perms = cmdHandle.getPerm().split(Pattern.quote("|"));
if (perms.length > 1) {
// has another perm
plugin.devDebug("Adding child perm " + perms[0] + " to " + perms[1]);
Permission p = Bukkit.getPluginManager().getPermission(perms[1]);
p.getChildren().put(perms[0], true);
p.recalculatePermissibles();
}
} catch (Exception e) {
plugin.debug("Failed to set permission for /vote");
}
}
}
}
@@ -1385,6 +1484,28 @@ public class CommandLoader {
}
});
ArrayList<String> topVoter = new ArrayList<String>();
for (TopVoter top : TopVoter.values()) {
topVoter.add(top.toString());
}
TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(topvoter)", topVoter) {
@Override
public void reload() {
ArrayList<String> topVoter = new ArrayList<String>();
for (TopVoter top : TopVoter.values()) {
topVoter.add(top.toString());
}
setReplace(topVoter);
}
@Override
public void updateReplacements() {
}
});
TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(VoteShop)", sites) {
@Override
@@ -1704,6 +1825,34 @@ public class CommandLoader {
}
});
for (final TopVoter top : TopVoter.values()) {
String argName = top.toString();
String perm = top.toString();
if (argName.equals(TopVoter.AllTime.toString())) {
argName = "All";
perm = "All";
}
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top", argName },
"VotingPlugin.Commands.Vote.Top." + perm + "|" + playerPerm, "Open page of Top Voters") {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteTopVoter(plugin, sender, null, top, 1).open(GUIMethod.CHAT);
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top", argName, "(number)" },
"VotingPlugin.Commands.Vote.Top." + perm + "|" + playerPerm, "Open page of Top Voters") {
@Override
public void execute(CommandSender sender, String[] args) {
int page = Integer.parseInt(args[2]);
new VoteTopVoter(plugin, sender, null, top, page).open(GUIMethod.CHAT);
}
});
}
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top", "(number)" },
"VotingPlugin.Commands.Vote.Top|" + playerPerm, "Open page of Top Voters") {
@@ -1715,47 +1864,6 @@ public class CommandLoader {
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top", "(number)", "Monthly" },
"VotingPlugin.Commands.Vote.Top.Monthly|" + playerPerm, "Open page of Top Voters") {
@Override
public void execute(CommandSender sender, String[] args) {
int page = Integer.parseInt(args[1]);
new VoteTopVoter(plugin, sender, null, TopVoter.Monthly, page).open(GUIMethod.CHAT);
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top", "(number)", "All" },
"VotingPlugin.Commands.Vote.Top.All|" + playerPerm, "Open page of Top Voters All Time") {
@Override
public void execute(CommandSender sender, String[] args) {
int page = Integer.parseInt(args[1]);
new VoteTopVoter(plugin, sender, null, TopVoter.AllTime, page).open(GUIMethod.CHAT);
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top", "(number)", "Weekly" },
"VotingPlugin.Commands.Vote.Top.Weekly|" + playerPerm, "Open page of Top Voters") {
@Override
public void execute(CommandSender sender, String[] args) {
int page = Integer.parseInt(args[1]);
new VoteTopVoter(plugin, sender, null, TopVoter.Weekly, page).open(GUIMethod.CHAT);
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top", "(number)", "Daily" },
"VotingPlugin.Commands.Vote.Top.Daily|" + playerPerm, "Open page of Top Voters") {
@Override
public void execute(CommandSender sender, String[] args) {
int page = Integer.parseInt(args[1]);
new VoteTopVoter(plugin, sender, null, TopVoter.Daily, page).open(GUIMethod.CHAT);
}
});
plugin.getVoteCommand()
.add(new CommandHandler(new String[] { "Party" }, "VotingPlugin.Commands.Vote.Party|" + playerPerm,
"View current amount of votes and how many more needed") {
@@ -1929,7 +2037,13 @@ public class CommandLoader {
if (sender instanceof Player) {
user = UserManager.getInstance().getVotingPluginUser((Player) sender);
}
new VoteURL(plugin, sender, user, true).open();
if (plugin.getConfigFile().isUseVoteGUIMainCommand() && sender instanceof Player) {
// vote gui command
new VoteGUI(plugin, sender, user).open();
} else {
new VoteURL(plugin, sender, user, true).open();
}
}
});
@@ -1,6 +1,8 @@
package com.bencodez.votingplugin.commands.gui.admin;
import java.util.ArrayList;
import java.util.Set;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@@ -19,9 +21,10 @@ public class AdminVotePerms extends GUIHandler {
private String playerName;
private VotingPluginMain plugin;
public AdminVotePerms(VotingPluginMain plugin, CommandSender player) {
public AdminVotePerms(VotingPluginMain plugin, CommandSender player, int page) {
super(player);
this.plugin = plugin;
this.page = page;
}
public AdminVotePerms(VotingPluginMain plugin, CommandSender player, int page, String playerName) {
@@ -38,17 +41,18 @@ public class AdminVotePerms extends GUIHandler {
public String[] listPerms(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
msg.add("&c&lCommand : Permissions (seperated by |)");
for (CommandHandler handle : plugin.getVoteCommand()) {
if (sender instanceof Player) {
if (handle.hasPerm(sender)) {
msg.add("&a" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : true");
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
} else {
msg.add("&c" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : false");
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
}
} else {
msg.add(handle.getHelpLineCommand("/vote") + " : " + handle.getPerm());
msg.add(handle.getHelpLineCommand("/vote") + " : " + handle.getPerm().split(Pattern.quote("|"))[0]);
}
}
@@ -56,30 +60,57 @@ public class AdminVotePerms extends GUIHandler {
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
if (sender instanceof Player) {
if (handle.hasPerm(sender)) {
msg.add("&a" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : true");
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
} else {
msg.add("&c" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : false");
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
}
} else {
msg.add(handle.getHelpLineCommand("/av") + " : " + handle.getPerm());
msg.add(handle.getHelpLineCommand("/av") + " : " + handle.getPerm().split(Pattern.quote("|"))[0]);
}
}
for (Permission perm : plugin.getDescription().getPermissions()) {
if (sender instanceof Player) {
if (sender.hasPermission(perm)) {
msg.add("&a" + perm.getName() + " : true");
Set<String> child = perm.getChildren().keySet();
if (child.size() > 0) {
if (sender.hasPermission(perm)) {
msg.add("&6" + perm.getName() + " : &atrue");
} else {
msg.add("&6" + perm.getName() + " : &cfalse");
}
} else {
msg.add("&c" + perm.getName() + " : false");
if (sender.hasPermission(perm)) {
msg.add("&6" + perm.getName() + " : &atrue");
} else {
msg.add("&6" + perm.getName() + " : &cfalse");
}
}
} else {
msg.add(perm.getName());
}
}
msg = ArrayUtils.getInstance().colorize(msg);
int pagesize = plugin.getConfigFile().getFormatPageSize();
return ArrayUtils.getInstance().convert(msg);
int maxPage = msg.size() / pagesize;
if ((msg.size() % pagesize) != 0) {
maxPage++;
}
ArrayList<String> text = new ArrayList<String>();
text.add("&c&lCommand : Permissions " + page + "/" + maxPage);
for (int i = pagesize * page - pagesize; i < msg.size() && i < pagesize * page; i++) {
text.add(msg.get(i));
}
text = ArrayUtils.getInstance().colorize(text);
return ArrayUtils.getInstance().convert(text);
}
public ArrayList<String> listPerms(CommandSender sender, String player, int page) {
@@ -91,26 +122,39 @@ public class AdminVotePerms extends GUIHandler {
for (CommandHandler handle : plugin.getVoteCommand()) {
if (handle.hasPerm(p)) {
msg.add("&a" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : true");
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
} else {
msg.add("&c" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : false");
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
}
}
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
if (handle.hasPerm(p)) {
msg.add("&a" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : true");
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
} else {
msg.add("&c" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : false");
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
}
}
for (Permission perm : plugin.getDescription().getPermissions()) {
if (p.hasPermission(perm)) {
msg.add("&a" + perm.getName() + " : true");
Set<String> child = perm.getChildren().keySet();
if (child.size() > 0) {
if (p.hasPermission(perm)) {
msg.add("&6" + perm.getName() + " : &atrue");
} else {
msg.add("&6" + perm.getName() + " : &cfalse");
}
} else {
msg.add("&c" + perm.getName() + " : false");
if (p.hasPermission(perm)) {
msg.add("&6" + perm.getName() + " : &atrue");
} else {
msg.add("&6" + perm.getName() + " : &cfalse");
}
}
}
@@ -123,7 +167,7 @@ public class AdminVotePerms extends GUIHandler {
maxPage++;
}
text.add("&c&lCommand : Permissions (seperated by |) " + page + "/" + maxPage);
text.add("&c&lCommand : Permissions for " + player + " " + page + "/" + maxPage);
for (int i = pagesize * page - pagesize; i < msg.size() && i < pagesize * page; i++) {
text.add(msg.get(i));
@@ -135,6 +179,34 @@ public class AdminVotePerms extends GUIHandler {
}
public String[] listPermsDev(CommandSender sender) {
ArrayList<String> msg = new ArrayList<String>();
msg.add("Command");
msg.add(" Permissions (seperated by |");
msg.add(" Help messasge");
msg.add(" ");
for (CommandHandler handle : plugin.getVoteCommand()) {
msg.add(handle.getHelpLineCommand("/vote"));
msg.add(" " + handle.getPerm());
msg.add(" " + handle.getHelpMessage());
}
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
msg.add(handle.getHelpLineCommand("/av"));
msg.add(" " + handle.getPerm());
msg.add(" " + handle.getHelpMessage());
}
for (Permission perm : plugin.getDescription().getPermissions()) {
msg.add(perm.getName() + " : " + perm.getDescription());
}
msg = ArrayUtils.getInstance().colorize(msg);
return ArrayUtils.getInstance().convert(msg);
}
@Override
public void onBook(Player player) {
}
@@ -62,7 +62,14 @@ public class VoteGUI extends GUIHandler {
lore = plugin.getTopVoterHandler().topVoterAllTime(1);
}
} else if (slot.equalsIgnoreCase("today")) {
lore = new VoteToday(plugin, player, user, 1).voteToday();
String[] today = new VoteToday(plugin, player, user, 1).voteTodayGUI();
ArrayList<String> list = new ArrayList<String>();
if (today.length > 0) {
for (int i = today.length - 1; i < today.length && list.size() < 10 && i >= 0; i--) {
list.add(today[i]);
}
}
lore = ArrayUtils.getInstance().convert(list);
} else if (slot.equalsIgnoreCase("help")) {
lore = new String[] { "Click to view help" };
}
@@ -112,6 +119,9 @@ public class VoteGUI extends GUIHandler {
@Override
public void onChest(Player player) {
if (this.user == null) {
user = UserManager.getInstance().getVotingPluginUser((Player) player);
}
if ((!player.getName().equals(user.getPlayerName())
&& !player.hasPermission("VotingPlugin.Commands.Vote.GUI.Other")
&& !player.hasPermission("VotingPlugin.Mod"))
@@ -1,8 +1,10 @@
package com.bencodez.votingplugin.commands.gui.player;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -15,6 +17,7 @@ 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.ArrayUtils;
import com.bencodez.advancedcore.api.user.UUID;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
@@ -94,12 +97,12 @@ public class VoteToday extends GUIHandler {
item.setName(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(),
"player", user.getPlayerName()));
item.setLore(msg);
final String uuid = user.getUUID();
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
@Override
public void onClick(ClickEvent clickEvent) {
VotingPluginUser user = UserManager.getInstance()
.getVotingPluginUser(clickEvent.getClickedItem().getItemMeta().getDisplayName());
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
new VoteGUI(plugin, player, user)
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
}
@@ -139,4 +142,31 @@ public class VoteToday extends GUIHandler {
return ArrayUtils.getInstance().convert(msg);
}
public String[] voteTodayGUI() {
ArrayList<String> msg = new ArrayList<String>();
for (VotingPluginUser user : plugin.getVoteToday().keySet()) {
LocalDateTime mostRecent = null;
VoteSite mostRecentSite = null;
for (Entry<VoteSite, LocalDateTime> entry : plugin.getVoteToday().get(user).entrySet()) {
if (mostRecent == null || entry.getValue().isAfter(mostRecent)) {
mostRecent = entry.getValue();
mostRecentSite = entry.getKey();
}
}
if (mostRecent != null) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
String timeString = mostRecent.format(formatter);
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("player", user.getPlayerName());
placeholders.put("votesite", mostRecentSite.getKey());
placeholders.put("time", timeString);
msg.add(StringParser.getInstance()
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
}
}
msg = ArrayUtils.getInstance().colorize(msg);
return ArrayUtils.getInstance().convert(msg);
}
}
@@ -37,6 +37,10 @@ public class BungeeSettings extends YMLFile {
@Getter
private int bungeeServerPort = 1297;
@ConfigDataBoolean(path = "RemoveInvalidUsers")
@Getter
private boolean removeInvalidUsers = false;
@ConfigDataString(path = "Server")
@Getter
private String server = "PleaseSet";
@@ -36,6 +36,10 @@ public class Config extends YMLFile {
@Getter
private boolean allowUnjoined = false;
@ConfigDataBoolean(path = "UseVoteGUIMainCommand")
@Getter
private boolean useVoteGUIMainCommand = false;
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
@Getter
private boolean allowUnJoinedCheckServer = true;
@@ -217,7 +221,7 @@ public class Config extends YMLFile {
@ConfigDataBoolean(path = "UseJavascriptPlaceholders")
@Getter
private boolean useJavascriptPlaceholders = true;
private boolean useJavascriptPlaceholders = false;
@ConfigDataBoolean(path = "UsePrimaryAccountForPlaceholders")
@Getter
@@ -639,6 +643,14 @@ public class Config extends YMLFile {
return getData().getBoolean("LoadTopVoter.AllTime", true);
}
@ConfigDataBoolean(path = "UseVoteStreaks")
@Getter
private boolean useVoteStreaks = true;
@ConfigDataBoolean(path = "UseHighestTotals")
@Getter
private boolean useHighestTotals = true;
public boolean getLoadTopVoterDaily() {
return getData().getBoolean("LoadTopVoter.Daily", false);
}
@@ -43,6 +43,10 @@ public class SpecialRewardsConfig extends YMLFile {
@Getter
private boolean votePartyResetExtraVotesMonthly = false;
@ConfigDataBoolean(path = "VoteParty.ResetCount")
@Getter
private boolean votePartyResetCount = true;
@Getter
private String votePartyRewardsPath = "VoteParty.Rewards";
@@ -229,9 +233,17 @@ public class SpecialRewardsConfig extends YMLFile {
return getData().getBoolean("VoteParty.ResetEachDay");
}
public boolean getVotePartyOnlyOncePerDay() {
return getData().getBoolean("VoteParty.OnlyOncePerDay");
}
public boolean getVotePartyResetMontly() {
return getData().getBoolean("VoteParty.ResetMonthly");
}
public boolean getVotePartyResetWeekly() {
return getData().getBoolean("VoteParty.ResetWeekly");
}
public int getVotePartyUserVotesRequired() {
return getData().getInt("VoteParty.UserVotesRequired");
@@ -239,4 +239,17 @@ public class ServerData {
public void updateValues() {
setVersion();
}
public boolean isLastVotePartySameDay() {
int num = getData().getInt("LastVoteParty", 0);
if (num != plugin.getTimeChecker().getTime().getDayOfYear()) {
return true;
}
return false;
}
public void updateLastVoteParty() {
getData().set("LastVoteParty", plugin.getTimeChecker().getTime().getDayOfYear());
saveData();
}
}
@@ -3,7 +3,9 @@ package com.bencodez.votingplugin.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.VotingPluginUser;
import lombok.Getter;
import lombok.Setter;
@@ -36,7 +38,7 @@ public class PlayerVoteEvent extends Event {
@Getter
@Setter
private String bungeeTextTotals;
private BungeeMessageData bungeeTextTotals;
@Getter
@Setter
@@ -66,6 +68,10 @@ public class PlayerVoteEvent extends Event {
@Setter
private VoteSite voteSite;
@Getter
@Setter
private VotingPluginUser votingPluginUser;
public PlayerVoteEvent(VoteSite voteSite, String voteUsername, String serviceSite, boolean realVote) {
super(true);
this.player = voteUsername;
@@ -13,6 +13,7 @@ import com.bencodez.votingplugin.VotingPluginMain;
/**
* The Class PlayerJoinEvent.
*/
@Deprecated
public class PlayerCommandSendListener implements Listener {
@SuppressWarnings("unused")
@@ -49,10 +49,18 @@ public class PlayerVoteListener implements Listener {
if (!plugin.getConfigFile().isAllowUnjoined()) {
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();
}
return;
}
}
if (playerName.isEmpty()) {
plugin.getLogger().warning("Empty player name for vote");
return;
}
if (event.isBungee()) {
plugin.debug("BungeePlayerVote forcebungee: " + event.isForceBungee() + ", bungeetotals: "
+ event.getBungeeTextTotals());
@@ -75,7 +83,12 @@ public class PlayerVoteListener implements Listener {
return;
}
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(playerName);
VotingPluginUser user = null;
if (event.getVotingPluginUser() != null) {
user = event.getVotingPluginUser();
} else {
user = UserManager.getInstance().getVotingPluginUser(playerName);
}
user.updateName(true);
if (plugin.getConfigFile().isClearCacheOnVote() || plugin.getBungeeSettings().isUseBungeecoord()) {
@@ -131,6 +144,7 @@ public class PlayerVoteListener implements Listener {
if (((user.isOnline() || voteSite.isGiveOffline())
&& VotingPluginMain.plugin.getOptions().isProcessRewards()) || event.isBungee()) {
user.playerVote(voteSite, true, false, event.isForceBungee());
user.sendVoteEffects(true);
user.closeInv();
} else {
user.addOfflineVote(voteSite.getKey());
@@ -147,9 +147,9 @@ public class VoteSite {
*/
public ItemBuilder getItem() {
if (item == null) {
plugin.getLogger().warning("Invalid item section in site: " + key);
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid item for site: " + key)
.setLore("&cInvalid item for site: " + key);
plugin.getLogger().warning("Invalid display item section in site: " + key);
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid display item for site: " + key)
.setLore("&cInvalid display item for site: " + key);
} else {
return new ItemBuilder(item);
}
@@ -10,6 +10,7 @@ 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;
import com.bencodez.votingplugin.events.PlayerSpecialRewardEvent;
import com.bencodez.votingplugin.events.SpecialRewardType;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -41,7 +42,7 @@ public class SpecialRewards {
return checkAllVotes;
}
public boolean checkCumualativeVotes(VotingPluginUser user, String bungeeTextTotals) {
public boolean checkCumualativeVotes(VotingPluginUser user, BungeeMessageData bungeeMessageData) {
boolean gotCumulativeAny = false;
Set<String> votes = plugin.getSpecialRewardsConfig().getCumulativeVotes();
for (String vote : votes) {
@@ -53,35 +54,30 @@ public class SpecialRewards {
plugin.getSpecialRewardsConfig().getCumulativeRewardsPath(votesRequired))) {
boolean gotCumulative = false;
int total = 0;
boolean useBungeeTotalNum = false;
String[] data = new String[] { "0", "0", "0", "0" };
if (bungeeTextTotals != null) {
data = bungeeTextTotals.split("//");
useBungeeTotalNum = true;
}
boolean useBungeeTotalNum = bungeeMessageData != null;
if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameDay(votesRequired)) {
if (!useBungeeTotalNum) {
total = user.getTotal(TopVoter.Daily);
} else {
total = Integer.parseInt(data[3]);
total = bungeeMessageData.getDailyTotal();
}
} else if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameWeek(votesRequired)) {
if (!useBungeeTotalNum) {
total = user.getTotal(TopVoter.Weekly);
} else {
total = Integer.parseInt(data[2]);
total = bungeeMessageData.getWeeklyTotal();
}
} else if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameMonth(votesRequired)) {
if (!useBungeeTotalNum) {
total = user.getTotal(TopVoter.Monthly);
} else {
total = Integer.parseInt(data[1]);
total = bungeeMessageData.getMonthTotal();
}
} else {
if (!useBungeeTotalNum) {
total = user.getTotal(TopVoter.AllTime);
} else {
total = Integer.parseInt(data[0]);
total = bungeeMessageData.getAllTimeTotal();
}
}
@@ -125,17 +121,14 @@ public class SpecialRewards {
return false;
}
public boolean checkMilestone(VotingPluginUser user, String bungeeTextTotals) {
public boolean checkMilestone(VotingPluginUser user, BungeeMessageData bungeeMessageData) {
int milestoneCount = user.getMilestoneCount();
if (bungeeTextTotals != null) {
String[] data = bungeeTextTotals.split("//");
if (data.length > 4) {
try {
milestoneCount = Integer.parseInt(data[5]);
} catch (Exception e) {
e.printStackTrace();
milestoneCount = user.getMilestoneCount();
}
if (bungeeMessageData != null) {
try {
milestoneCount = bungeeMessageData.getMilestoneCount();
} catch (Exception e) {
e.printStackTrace();
milestoneCount = user.getMilestoneCount();
}
}
if (plugin.getConfigFile().isPreventRepeatMilestones()) {
@@ -91,4 +91,20 @@ public enum TopVoter {
}
return TopVoter.AllTime;
}
public String getColumnName() {
switch (this) {
case AllTime:
return "AllTimeTotal";
case Daily:
return "DailyTotal";
case Monthly:
return "MonthTotal";
case Weekly:
return "WeeklyTotal";
default:
return null;
}
}
}
@@ -24,6 +24,7 @@ import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
import com.bencodez.advancedcore.api.time.events.PreDateChangedEvent;
import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
import com.bencodez.advancedcore.api.user.UUID;
import com.bencodez.advancedcore.api.user.UserStorage;
import com.bencodez.advancedcore.api.yml.YMLFileHandler;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.UserManager;
@@ -105,6 +106,9 @@ public class TopVoterHandler implements Listener {
plugin.setUpdate(true);
plugin.update();
loadLastMonth();
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
plugin.getMysql().clearCache();
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@@ -112,14 +116,18 @@ public class TopVoterHandler implements Listener {
synchronized (VotingPluginMain.plugin) {
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
if (!user.voteStreakUpdatedToday(LocalDateTime.now().minusDays(1))) {
if (user.getDayVoteStreak() != 0) {
user.setDayVoteStreak(0);
if (plugin.getConfigFile().isUseVoteStreaks()) {
if (!user.voteStreakUpdatedToday(LocalDateTime.now().minusDays(1))) {
if (user.getDayVoteStreak() != 0) {
user.setDayVoteStreak(0);
}
}
}
if (user.getHighestDailyTotal() < user.getTotal(TopVoter.Daily)) {
user.setHighestDailyTotal(user.getTotal(TopVoter.Daily));
if (plugin.getConfigFile().isUseHighestTotals()) {
if (user.getHighestDailyTotal() < user.getTotal(TopVoter.Daily)) {
user.setHighestDailyTotal(user.getTotal(TopVoter.Daily));
}
}
for (String shopIdent : plugin.getGui().getChestShopIdentifiers()) {
if (plugin.getGui().getChestVoteShopResetDaily(shopIdent)) {
@@ -163,6 +171,10 @@ public class TopVoterHandler implements Listener {
}
resetTotals(TopVoter.Daily);
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
plugin.getMysql().clearCache();
}
}
}
@@ -171,15 +183,17 @@ public class TopVoterHandler implements Listener {
synchronized (VotingPluginMain.plugin) {
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
user.setMonthVoteStreak(0);
} else {
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|| user.hasPercentageTotal(TopVoter.Monthly,
plugin.getSpecialRewardsConfig().getVoteStreakRequirementMonth(),
LocalDateTime.now().minusDays(1))) {
user.addMonthVoteStreak();
plugin.getSpecialRewards().checkVoteStreak(user, "Month");
if (plugin.getConfigFile().isUseVoteStreaks()) {
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
user.setMonthVoteStreak(0);
} else {
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|| user.hasPercentageTotal(TopVoter.Monthly,
plugin.getSpecialRewardsConfig().getVoteStreakRequirementMonth(),
LocalDateTime.now().minusDays(1))) {
user.addMonthVoteStreak();
plugin.getSpecialRewards().checkVoteStreak(user, "Month");
}
}
}
@@ -191,8 +205,10 @@ public class TopVoterHandler implements Listener {
user.setLastMonthTotal(user.getTotal(TopVoter.Monthly));
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly)) {
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
if (plugin.getConfigFile().isUseHighestTotals()) {
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly)) {
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
}
}
}
@@ -243,6 +259,10 @@ public class TopVoterHandler implements Listener {
}
}
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
plugin.getMysql().clearCache();
}
}
}
@@ -257,14 +277,16 @@ public class TopVoterHandler implements Listener {
synchronized (VotingPluginMain.plugin) {
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
if (user.getTotal(TopVoter.Weekly) == 0 && user.getWeekVoteStreak() != 0) {
user.setWeekVoteStreak(0);
} else {
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|| user.hasPercentageTotal(TopVoter.Weekly,
plugin.getSpecialRewardsConfig().getVoteStreakRequirementWeek(), null)) {
user.addWeekVoteStreak();
plugin.getSpecialRewards().checkVoteStreak(user, "Week");
if (plugin.getConfigFile().isUseVoteStreaks()) {
if (user.getTotal(TopVoter.Weekly) == 0 && user.getWeekVoteStreak() != 0) {
user.setWeekVoteStreak(0);
} else {
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|| user.hasPercentageTotal(TopVoter.Weekly,
plugin.getSpecialRewardsConfig().getVoteStreakRequirementWeek(), null)) {
user.addWeekVoteStreak();
plugin.getSpecialRewards().checkVoteStreak(user, "Week");
}
}
}
@@ -274,8 +296,10 @@ public class TopVoterHandler implements Listener {
}
}
if (user.getHighestWeeklyTotal() < user.getTotal(TopVoter.Weekly)) {
user.setHighestWeeklyTotal(user.getTotal(TopVoter.Weekly));
if (plugin.getConfigFile().isUseHighestTotals()) {
if (user.getHighestWeeklyTotal() < user.getTotal(TopVoter.Weekly)) {
user.setHighestWeeklyTotal(user.getTotal(TopVoter.Weekly));
}
}
}
@@ -313,6 +337,10 @@ public class TopVoterHandler implements Listener {
e.printStackTrace();
}
resetTotals(TopVoter.Weekly);
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
plugin.getMysql().clearCache();
}
}
}
@@ -321,11 +349,15 @@ public class TopVoterHandler implements Listener {
}
public void resetTotals(TopVoter topVoter) {
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
if (user.getTotal(topVoter) != 0) {
user.resetTotals(topVoter);
if (!plugin.getStorageType().equals(UserStorage.MYSQL)) {
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
if (user.getTotal(topVoter) != 0) {
user.resetTotals(topVoter);
}
}
} else {
plugin.getMysql().wipeColumnData(topVoter.getColumnName());
}
}
@@ -412,7 +444,7 @@ public class TopVoterHandler implements Listener {
String title = plugin.getConfigFile().getFormatCommandVoteTopTitle();
title = title.replace("%page%", "" + page);
title = title.replace("%maxpages%", "" + pageSize);
title = title.replace("%Top%", "All Time");
title = title.replace("%Top%", plugin.getConfigFile().getFormatTopVoterAllTime());
msg.add(StringParser.getInstance().colorize(title));
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
@@ -451,7 +483,7 @@ public class TopVoterHandler implements Listener {
String title = plugin.getConfigFile().getFormatCommandVoteTopTitle();
title = title.replace("%page%", "" + page);
title = title.replace("%maxpages%", "" + pageSize);
title = title.replace("%Top%", "Daily");
title = title.replace("%Top%", plugin.getConfigFile().getFormatTopVoterDaily());
msg.add(StringParser.getInstance().colorize(title));
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
@@ -490,7 +522,7 @@ public class TopVoterHandler implements Listener {
String title = plugin.getConfigFile().getFormatCommandVoteTopTitle();
title = title.replace("%page%", "" + page);
title = title.replace("%maxpages%", "" + pageSize);
title = title.replace("%Top%", "Monthly");
title = title.replace("%Top%", plugin.getConfigFile().getFormatTopVoterMonthly());
msg.add(StringParser.getInstance().colorize(title));
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
@@ -610,7 +642,7 @@ public class TopVoterHandler implements Listener {
String title = plugin.getConfigFile().getFormatCommandVoteTopTitle();
title = title.replace("%page%", "" + page);
title = title.replace("%maxpages%", "" + pageSize);
title = title.replace("%Top%", "Weekly");
title = title.replace("%Top%", plugin.getConfigFile().getFormatTopVoterWeekly());
msg.add(StringParser.getInstance().colorize(title));
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
@@ -26,7 +26,7 @@ public class UserManager {
public UserManager() {
super();
}
public ArrayList<String> getAllUUIDs() {
return com.bencodez.advancedcore.api.user.UserManager.getInstance().getAllUUIDs();
}
@@ -39,8 +39,13 @@ public class UserManager {
return getVotingPluginUser(new UUID(uuid.toString()));
}
@SuppressWarnings("deprecation")
public VotingPluginUser getVotingPluginUser(java.util.UUID uuid, String playerName) {
return new VotingPluginUser(plugin, new UUID(uuid.toString()), playerName);
}
public VotingPluginUser getVotingPluginUser(OfflinePlayer player) {
return getVotingPluginUser(player.getName());
return getVotingPluginUser(player.getUniqueId(), player.getName());
}
public VotingPluginUser getVotingPluginUser(Player player) {
@@ -25,6 +25,7 @@ import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.api.user.UUID;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.events.PlayerReceivePointsEvent;
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
@@ -59,6 +60,12 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
this.plugin = plugin;
}
@Deprecated
public VotingPluginUser(VotingPluginMain plugin, UUID uuid, String playerName) {
super(plugin, uuid, playerName);
this.plugin = plugin;
}
@Deprecated
public VotingPluginUser(VotingPluginMain plugin, UUID uuid, boolean loadName) {
super(plugin, uuid, loadName);
@@ -186,17 +193,18 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
}
public void bungeeVotePluginMessaging(String service, long time, String bungeeTextTotals) {
public void bungeeVotePluginMessaging(String service, long time, BungeeMessageData text) {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
VotingPluginMain.plugin.debug("Pluginmessaging vote for " + getPlayerName() + " on " + service);
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service), getPlayerName(), service,
true);
voteEvent.setBungee(true);
voteEvent.setVotingPluginUser(this);
voteEvent.setForceBungee(true);
voteEvent.setTime(time);
voteEvent.setAddTotals(false);
voteEvent.setBungeeTextTotals(bungeeTextTotals);
voteEvent.setBungeeTextTotals(text);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
@@ -15,6 +15,7 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
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.UUID;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.VotePartyEvent;
@@ -59,8 +60,12 @@ public class VoteParty implements Listener {
* Check.
*/
public void check() {
if (getTotalVotes() >= getVotesRequired()) {
setTotalVotes(getTotalVotes() - getVotesRequired());
if (getTotalVotes() >= getVotesRequired() && ((plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()
&& plugin.getServerData().isLastVotePartySameDay())
|| !plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay())) {
if (plugin.getSpecialRewardsConfig().isVotePartyResetCount()) {
setTotalVotes(getTotalVotes() - getVotesRequired());
}
VotePartyEvent event = new VotePartyEvent();
Bukkit.getPluginManager().callEvent(event);
@@ -74,6 +79,10 @@ public class VoteParty implements Listener {
plugin.getServerData().setVotePartyExtraRequired(plugin.getServerData().getVotePartyExtraRequired()
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired());
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
plugin.getServerData().updateLastVoteParty();
}
}
}
@@ -190,20 +199,27 @@ public class VoteParty implements Listener {
giveReward(user);
}
}
reset();
reset(false);
}
@EventHandler
public void onDayChange(DayChangeEvent event) {
if (plugin.getSpecialRewardsConfig().getVotePartyResetEachDay()) {
reset();
reset(true);
}
}
@EventHandler
public void onWeekChange(WeekChangeEvent event) {
if (plugin.getSpecialRewardsConfig().getVotePartyResetWeekly()) {
reset(true);
}
}
@EventHandler
public void onMonthChange(MonthChangeEvent event) {
if (plugin.getSpecialRewardsConfig().getVotePartyResetMontly()) {
reset();
reset(true);
}
if (plugin.getSpecialRewardsConfig().isVotePartyResetExtraVotesMonthly()) {
@@ -215,9 +231,11 @@ public class VoteParty implements Listener {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public void reset() {
public void reset(boolean override) {
if (override) {
setTotalVotes(0);
}
setVotedUsers(new ArrayList<String>());
setTotalVotes(0);
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
if (user.getVotePartyVotes() != 0) {
@@ -95,7 +95,8 @@ public class VoteReminding {
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
}
if ((!UserManager.getInstance().getAllUUIDs().contains(user.getUUID()) || user.canVoteAll())
if ((!UserManager.getInstance().getAllUUIDs().contains(user.getUUID()) || (user.canVoteAll()
|| (user.canVoteAny() && user.hasPermission("VotingPlugin.Login.RemindVotes.Any"))))
&& user.shouldBeReminded()) {
giveReward(user);
if (user.getData().hasData()) {