Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f50998519 | ||
|
|
1768d4490f | ||
|
|
2a3635b805 | ||
|
|
a5be973fd4 | ||
|
|
c8a76f38f9 | ||
|
|
273edaf101 | ||
|
|
d1a90676fc | ||
|
|
ff6119050d | ||
|
|
0a0b95097d | ||
|
|
ace42a5a1f | ||
|
|
1a23648b91 | ||
|
|
65b5a46525 | ||
|
|
462d99c0e5 | ||
|
|
04636dd5af | ||
|
|
d5b5b6cec0 | ||
|
|
921fdac8bb | ||
|
|
6b9bc60785 | ||
|
|
ff01c73193 | ||
|
|
a6cb4c3a8c | ||
|
|
43d33277ba | ||
|
|
9badb50075 | ||
|
|
ad6a09ba85 | ||
|
|
1791ec5e46 | ||
|
|
46457a9e61 | ||
|
|
38ab221fd8 | ||
|
|
fc2317655e | ||
|
|
fb183b9f1f |
No files matched your search
@@ -28,6 +28,10 @@ BungeeDebug: false
|
||||
# If false you need to enable
|
||||
BungeeBroadcast: false
|
||||
|
||||
# If true & AllowUnJoined is false (Config.yml) it will remove any invalid players
|
||||
# Not fully tested, could cause some trouble in some cases
|
||||
RemoveInvalidUsers: false
|
||||
|
||||
# What server this is in bungee (must match)
|
||||
# Also can be applied to rewards
|
||||
Server: PleaseSet
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# GUI Methods:
|
||||
# - BOOK
|
||||
# - GUI
|
||||
# - CHEST
|
||||
# - CHAT (Disables GUI)
|
||||
GUIMethod:
|
||||
Today: CHEST #BOOK not available (future update?)
|
||||
|
||||
@@ -101,6 +101,12 @@ VoteSites:
|
||||
Fallback:
|
||||
Messages:
|
||||
Player: 'You got unlucky'
|
||||
|
||||
# Give 1 diamond
|
||||
Items:
|
||||
item1:
|
||||
Material: DIAMOND
|
||||
Amount: 1
|
||||
|
||||
Messages:
|
||||
Player: 'You voted'
|
||||
|
||||
@@ -40,6 +40,8 @@ BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
FallBackServer: factions
|
||||
|
||||
AllowUnJoined: false
|
||||
|
||||
# ----------------------------
|
||||
# SOCKET METHOD Settings
|
||||
# ----------------------------
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>6.0.3</version>
|
||||
<version>6.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>
|
||||
|
||||
@@ -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;
|
||||
@@ -899,9 +898,9 @@ 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")) {
|
||||
/*if (!NMSManager.getInstance().isVersion("1.12")) {
|
||||
pm.registerEvents(new PlayerCommandSendListener(this), this);
|
||||
}
|
||||
}*/
|
||||
coolDownCheck = new CoolDownCheck(this);
|
||||
pm.registerEvents(coolDownCheck, this);
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,12 +247,15 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
|
||||
method = BungeeMethod.getByName(config.getBungeeMethod());
|
||||
|
||||
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 +302,18 @@ 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);
|
||||
|
||||
this.getProxy().registerChannel("vp:vp");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
|
||||
|
||||
@@ -369,8 +390,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
|
||||
}
|
||||
for (String send : getProxy().getServers().keySet()) {
|
||||
if (getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||
getProxy().getServers().get(send).sendData("vp:vp".toLowerCase(),
|
||||
outstream.toByteArray());
|
||||
getProxy().getServers().get(send).sendData("vp:vp".toLowerCase(), outstream.toByteArray());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -378,6 +398,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 +461,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) {
|
||||
@@ -503,17 +529,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);
|
||||
|
||||
@@ -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,29 @@ 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 +541,7 @@ public class CommandLoader {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
sendMessage(sender,
|
||||
"Using AdvancedCore " + plugin.getVersion() + "' built on '" + plugin.getBuildTime());
|
||||
}
|
||||
@@ -1200,11 +1235,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.devDebug("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 +1266,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.devDebug("Failed to set permission for /vote");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1221,11 +1288,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.devDebug("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 +1320,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.devDebug("Failed to set permission for /vote");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1385,6 +1483,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 +1824,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 +1863,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 +2036,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);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -65,6 +66,10 @@ public class PlayerVoteEvent extends Event {
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser votingPluginUser;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername, String serviceSite, boolean realVote) {
|
||||
super(true);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -59,6 +59,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);
|
||||
@@ -193,6 +199,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
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);
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in new issue
Block a user