Compare commits

...
16 Commits
15 changed files with 48 additions and 24 deletions

No files matched your search

+2 -2
View File
@@ -9,7 +9,7 @@ UseBungeecord: false
# What type of bungee setup
# Requires restart and set on all servers
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecoord-Setups
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups
# Available:
# SOCKETS
# PLUGINMESSAGING
@@ -66,4 +66,4 @@ BungeeVotePartyRewards: {}
# For socket setup below only
# -----------------------------
# Options available here:
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
+2 -1
View File
@@ -444,7 +444,8 @@ UsePrimaryAccountForPlaceholders: false
AlwaysWaitForCachePlaceholders: false
# Enable auto caching placeholders
AutoCachePlaceholders: true
# Generally this works well, but if you need to cache placeholders manually set them below
AutoCachePlaceholders: false
# Set which placeholders to cache at all times
# Use for placeholders to are pulled constantly or on the main thread
+1 -1
View File
@@ -4,7 +4,7 @@ main: com.bencodez.votingplugin.VotingPluginMain
description: Highly Customizable Voting Listener!
website: https://www.spigotmc.org/resources/votingplugin.15358/
author: BenCodez
softdepend: [MVdWPlaceholders, Votifier, VotifierPlus, NuVotifier, CMI, Vault, PlaceholderAPI, ProtocolLib, MVdWPlaceholderAPI, AuthMe]
softdepend: [MVdWPlaceholders, Votifier, VotifierPlus, NuVotifier, CMI, Vault, PlaceholderAPI, ProtocolLib, MVdWPlaceholderAPI, AuthMe, SuperVanish, PremiumVanish]
loadbefore: [MCPerks]
api-version: 1.13
libraries:
+1 -1
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId>
<version>6.8.1</version>
<version>6.8.2</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -344,11 +344,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
return siteName;
}
}
}
for (String siteName : sites) {
if (siteName.equalsIgnoreCase(url)) {
return siteName;
}
}
}
return url;
@@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
@@ -87,6 +88,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
@Getter
private TimeHandle timeHandle;
private ConcurrentHashMap<UUID, String> uuidPlayerNameCache = new ConcurrentHashMap<UUID, String>();
public synchronized void checkCachedVotes(String server) {
if (getProxy().getServerInfo(server) != null) {
if (!getProxy().getServerInfo(server).getPlayers().isEmpty()) {
@@ -153,6 +156,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
public UUID fetchUUID(String playerName) throws Exception {
if (playerName == null || playerName.equalsIgnoreCase("null")) {
return null;
}
// Get response from Mojang API
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + playerName);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
@@ -188,6 +194,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
if (p != null && p.isConnected()) {
return p.getUniqueId().toString();
}
for (Entry<UUID, String> entry : uuidPlayerNameCache.entrySet()) {
if (entry.getValue().equalsIgnoreCase(playerName)) {
return entry.getKey().toString();
}
}
if (mysql != null) {
String str = mysql.getUUID(playerName);
if (str != null) {
@@ -379,6 +392,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
this.getProxy().registerChannel("vp:vp");
if (mysqlLoaded) {
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
voteCacheFile = new VoteCache(this);
voteCacheFile.load();
@@ -806,6 +821,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
return;
}
// one time query to insert player
if (!mysql.getUuids().contains(uuid)) {
mysql.update(uuid, "PlayerName", new DataValueString(player));
}
@@ -27,6 +27,7 @@ import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
@@ -113,6 +114,8 @@ public class VotingPluginVelocity {
@Getter
private TimeHandle timeHandle;
private ConcurrentHashMap<UUID, String> uuidPlayerNameCache = new ConcurrentHashMap<UUID, String>();
@Inject
public VotingPluginVelocity(ProxyServer server, Logger logger, Metrics.Factory metricsFactory,
@DataDirectory Path dataDirectory) {
@@ -229,6 +232,11 @@ public class VotingPluginVelocity {
return p.getUniqueId().toString();
}
}
for (Entry<UUID, String> entry : uuidPlayerNameCache.entrySet()) {
if (entry.getValue().equalsIgnoreCase(playerName)) {
return entry.getKey().toString();
}
}
if (mysql != null) {
String str = mysql.getUUID(playerName);
if (str != null) {
@@ -445,6 +453,8 @@ public class VotingPluginVelocity {
server.getCommandManager().register(meta, new VotingPluginVelocityCommand(this));
if (mysqlLoaded) {
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.yml"));
nonVotedPlayersCache = new NonVotedPlayersCache(
new File(dataDirectory.toFile(), "nonvotedplayerscache.yml"), this);
@@ -18,7 +18,7 @@ import com.bencodez.votingplugin.signs.SignHandler;
public class BlockBreak implements Listener {
/** The plugin. */
private static VotingPluginMain plugin;
private VotingPluginMain plugin;
/**
* Instantiates a new block break.
@@ -26,7 +26,7 @@ public class BlockBreak implements Listener {
* @param plugin the plugin
*/
public BlockBreak(VotingPluginMain plugin) {
BlockBreak.plugin = plugin;
this.plugin = plugin;
}
/**
@@ -21,7 +21,7 @@ import com.bencodez.votingplugin.user.UserManager;
public class PlayerInteract implements Listener {
/** The plugin. */
private static VotingPluginMain plugin;
private VotingPluginMain plugin;
/**
* Instantiates a new player interact.
@@ -29,7 +29,7 @@ public class PlayerInteract implements Listener {
* @param plugin the plugin
*/
public PlayerInteract(VotingPluginMain plugin) {
PlayerInteract.plugin = plugin;
this.plugin = plugin;
}
/**
@@ -21,7 +21,7 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
public class PlayerJoinEvent implements Listener {
/** The plugin. */
private static VotingPluginMain plugin;
private VotingPluginMain plugin;
/**
* Instantiates a new player join event.
@@ -29,7 +29,7 @@ public class PlayerJoinEvent implements Listener {
* @param plugin the plugin
*/
public PlayerJoinEvent(VotingPluginMain plugin) {
PlayerJoinEvent.plugin = plugin;
this.plugin = plugin;
}
private void login(Player player) {
@@ -150,8 +150,7 @@ public class PlayerVoteListener implements Listener {
// try logging to file
if (plugin.getConfigFile().isLogVotesToFile()) {
try {
VotingPluginMain.plugin.logVote(
LocalDateTime.now().atZone(ZoneId.systemDefault()).toLocalDateTime(), playerName,
plugin.logVote(LocalDateTime.now().atZone(ZoneId.systemDefault()).toLocalDateTime(), playerName,
voteSite.getKey());
} catch (Exception e) {
e.printStackTrace();
@@ -167,9 +166,8 @@ public class PlayerVoteListener implements Listener {
}
// check if player has voted on all sites in one day
if (((user.isOnline() || voteSite.isGiveOffline())
&& VotingPluginMain.plugin.getOptions().isProcessRewards()) || event.isBungee()) {
if (((user.isOnline() || voteSite.isGiveOffline()) && plugin.getOptions().isProcessRewards())
|| event.isBungee()) {
boolean online = true;
if (event.isBungee()) {
online = event.isWasOnline();
@@ -16,7 +16,7 @@ import com.bencodez.votingplugin.VotingPluginMain;
public class SignChange implements Listener {
/** The plugin. */
private static VotingPluginMain plugin;
private VotingPluginMain plugin;
/**
* Instantiates a new sign change.
@@ -24,7 +24,7 @@ public class SignChange implements Listener {
* @param plugin the plugin
*/
public SignChange(VotingPluginMain plugin) {
SignChange.plugin = plugin;
this.plugin = plugin;
}
/**
@@ -82,7 +82,7 @@ public class VotiferEvent implements Listener {
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames(false);
boolean createSite = false;
if (sites != null) {
if (!sites.contains(voteSiteNameStr)) {
if (!ArrayUtils.getInstance().containsIgnoreCase(sites, voteSiteNameStr)) {
createSite = true;
}
} else {
@@ -14,7 +14,7 @@ import com.bencodez.votingplugin.VotingPluginMain;
public class VotingPluginUpdateEvent implements Listener {
/** The plugin. */
private static VotingPluginMain plugin;
private VotingPluginMain plugin;
/**
* Instantiates a new advanced core update event.
@@ -22,7 +22,7 @@ public class VotingPluginUpdateEvent implements Listener {
* @param plugin the plugin
*/
public VotingPluginUpdateEvent(VotingPluginMain plugin) {
VotingPluginUpdateEvent.plugin = plugin;
this.plugin = plugin;
}
/**
@@ -335,7 +335,7 @@ public class TopVoterHandler implements Listener {
int lastTotal = -1;
@SuppressWarnings("unchecked")
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
.getTopVoter(TopVoter.Monthly).clone();
.getTopVoter(TopVoter.Weekly).clone();
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
VotingPluginUser user = entry.getKey().getUser();
user.dontCache();