Compare commits

...
13 Commits
12 changed files with 72 additions and 23 deletions

No files matched your search

+6
View File
@@ -30,6 +30,8 @@ MySQL:
#MaxLifeTime: -1
#Additional info on connection string
#Line: ''
#Attempt to use mariadb driver
#UseMariaDB: false
# --------------------
# AllowUnJoined options
@@ -415,6 +417,10 @@ ClickSound:
# case sensitive
VotingBroadcastBlacklist: []
# Playernames to not be broadcasted when broadcast comes from reward file
# case sensitive
BroadcastBlacklist: []
# When enabled, javascript will be parsed on placeholders (from placeholderapi)
# allows more fancy placeholders with math for example
UseJavascriptPlaceholders: false
+2
View File
@@ -15,6 +15,8 @@ MaxConnections: 1
Prefix: ''
#UseSSL: true
#PublicKeyRetrieval: false
#Attempt to use mariadb driver
#UseMariaDB: false
Debug: false
# Have a reward on each server
+2 -2
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId>
<version>6.8.3</version>
<version>6.8.4</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -226,7 +226,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -16,6 +16,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.zip.ZipEntry;
@@ -207,6 +208,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Getter
private boolean ymlError = false;
@Getter
private Timer voteTimer = new Timer();
@Getter
private UserManager votingPluginUserManager;
@@ -1363,6 +1367,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
ArrayList<TopVoter> topVotersToCheck = new ArrayList<TopVoter>();
for (TopVoter top : TopVoter.values()) {
if (plugin == null) {
return;
}
if (plugin.getConfigFile().getLoadTopVoter(top)) {
topVotersToCheck.add(top);
tempTopVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
@@ -397,7 +397,9 @@ public class VotingPluginVelocity {
}
}
}
timeHandle.save();
if (timeHandle != null) {
timeHandle.save();
}
voteCacheFile.save();
nonVotedPlayersCache.save();
if (mysql != null) {
@@ -373,12 +373,13 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.clearCache();
user.cache();
int newTotal = 0;
synchronized (pointLock) {
user.addPoints(Integer.parseInt(args[3]));
newTotal = user.addPoints(Integer.parseInt(args[3]));
}
sender.sendMessage(StringParser.getInstance().colorize("&cGave " + args[1] + " " + args[3]
+ " points" + ", " + args[1] + " now has " + user.getPoints() + " points"));
+ " points" + ", " + args[1] + " now has " + newTotal + " points"));
}
});
@@ -389,7 +390,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.clearCache();
user.cache();
user.removePoints(Integer.parseInt(args[3]));
sender.sendMessage(StringParser.getInstance().colorize("&cRemoved " + args[3] + " points from "
+ args[1] + ", " + args[1] + " now has " + user.getPoints() + " points"));
@@ -439,7 +440,6 @@ public class CommandLoader {
int page = Integer.parseInt(args[1]);
new AdminVoteHelp(plugin, sender, page).open();
}
});
@@ -1828,7 +1828,7 @@ public class CommandLoader {
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
if (hasPerm) {
user.clearCache();
user.cache();
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
if (identifier != null) {
@@ -11,6 +11,7 @@ import com.bencodez.advancedcore.api.command.CommandHandler;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.votingplugin.VotingPluginMain;
import net.md_5.bungee.api.ChatColor;
@@ -63,6 +64,28 @@ public class VoteHelp extends GUIHandler {
return msg;
}
public ArrayList<TextComponent> helpTextLegacy(CommandSender sender) {
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
if (!requirePerms || cmdHandle.hasPerm(sender)) {
unsorted.put(cmdHandle.getHelpLineCommand("/vote"),
cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine()));
}
}
ArrayList<String> unsortedList = new ArrayList<String>();
unsortedList.addAll(unsorted.keySet());
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
for (String cmd : unsortedList) {
msg.add(unsorted.get(cmd));
}
return msg;
}
@Override
public void onBook(Player player) {
@@ -86,7 +109,12 @@ public class VoteHelp extends GUIHandler {
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
int pagesize = plugin.getConfigFile().getFormatPageSize();
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
ArrayList<TextComponent> text = helpText(sender);
ArrayList<TextComponent> text = new ArrayList<TextComponent>();
if (NMSManager.getInstance().isVersion("1.12")) {
text = helpTextLegacy(sender);
} else {
text = helpText(sender);
}
int maxPage = text.size() / pagesize;
if ((text.size() % pagesize) != 0) {
@@ -86,7 +86,7 @@ public class VoteTopVoter extends GUIHandler {
int pos = 1;
for (Entry<TopVoterPlayer, Integer> entry : users) {
ItemBuilder playerItem;
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
if (plugin.getGui().isChestVoteTopUseSkull()) {
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
@@ -1,8 +1,8 @@
package com.bencodez.votingplugin.listeners;
import java.util.ArrayList;
import java.util.TimerTask;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -65,7 +65,7 @@ public class VotiferEvent implements Listener {
plugin.debug("VoteSite: " + voteSite);
plugin.debug("IP: " + IP);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
plugin.getVoteTimer().schedule(new TimerTask() {
@Override
public void run() {
@@ -110,7 +110,7 @@ public class VotiferEvent implements Listener {
}
}
});
}, 0);
}
@@ -108,6 +108,11 @@ public class VoteSite {
return;
}
if (!user.isVanished()) {
String playerName = user.getPlayerName();
if (plugin.getConfigFile().getVotingBroadcastBlacklist().contains(playerName)) {
plugin.getLogger().info("Not broadcasting for " + playerName + ", in blacklist");
return;
}
if (checkBungee && plugin.getBungeeSettings().isBungeeBroadcast()
&& plugin.getBungeeSettings().isUseBungeecoord()) {
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS)) {
@@ -123,11 +128,6 @@ public class VoteSite {
}
} else {
String playerName = user.getPlayerName();
if (plugin.getConfigFile().getVotingBroadcastBlacklist().contains(playerName)) {
plugin.getLogger().info("Not broadcasting for " + playerName + ", in blacklist");
return;
}
String bc = StringParser.getInstance().colorize(plugin.getConfigFile().getFormatBroadCastMsg());
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("player", playerName);
@@ -111,7 +111,7 @@ public class PlaceHolders {
}
} catch (Exception e) {
plugin.debug(e);
return "...";
return "Error";
}
}
@@ -762,6 +762,7 @@ public class PlaceHolders {
for (String key : keys) {
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
user.dontCache();
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(),
placeholder.placeholderRequest(vpUser, ident));
@@ -114,15 +114,18 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
* Adds the points.
*
* @param value the value
* @return current total points
*/
public void addPoints(int value) {
public int addPoints(int value) {
PlayerReceivePointsEvent event = new PlayerReceivePointsEvent(this, value);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
return getPoints();
}
setPoints(getPoints() + event.getPoints());
int newTotal = getPoints() + event.getPoints();
setPoints(newTotal);
return newTotal;
}
/**