Compare commits

...
12 Commits
11 changed files with 205 additions and 166 deletions

No files matched your search

+3
View File
@@ -241,6 +241,9 @@ Format:
# See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
TimeFormat: 'EEE, d MMM yyyy HH:mm'
# Reward time format for %date% placeholder (Time of giving reward)
RewardTimeFormat: 'EEE, d MMM yyyy HH:mm'
TimeFormats:
Day: 'Day'
Days: 'Days'
+17 -10
View File
@@ -24,12 +24,13 @@ LastMonthGUI: false
CHEST:
# GUI for /vote gui, /vgui, /votegui
VoteGUI:
# Items will be orders as it is below
# Items will be ordered as listed here
# You can add items following this format, even set slots
# See extra item below. GUI will auto resize to what is needed
URL:
# Standard item format, lore is automaticly applied
Item:
Material: 'BOW'
Data: 0
Amount: 1
Name: '&4URL'
Lore:
@@ -40,41 +41,45 @@ CHEST:
Next:
Item:
Material: 'COMPASS'
Data: 0
Amount: 1
Name: '&4Next'
Last:
Item:
Material: 'CLOCK'
Data: 0
Amount: 1
Name: '&4Last'
Total:
Item:
Material: 'CHEST'
Data: 0
Amount: 1
Name: '&4Total'
Top:
Item:
Material: 'OAK_SIGN'
Data: 0
Amount: 1
Name: '&4Top'
Today:
Item:
Material: 'BOOK'
Data: 0
Amount: 1
Name: '&4Today'
Shop:
Item:
Material: 'DIAMOND'
Data: 0
Amount: 1
Name: '&4Vote Shop'
Lore:
- '&aYou currently have %points% points'
# 'ExtraName' below is an identifier, can be whatever
# ExtraItem:
# Item:
# Material: 'DIRT'
# Amount: 1
# Name: 'Extra item'
## Works on most GUI items
# Slot: 10
## Send rewards on click, run commands, check conditions, etc
# Rewards: []
# GUI for /vote url, /vote
VoteURL:
@@ -139,9 +144,10 @@ CHEST:
Material: 'OAK_SIGN'
Amount: 1
# 8 Slots over from the bottom left
# Bottom of GUI
Slot: 7
# Number of topvoters to display on page +9
# 9 Slots on the botton are used for page buttons
# Number of topvoters to display on each GUI page
# 9 Slots on the botton are used for page buttons (added on top)
Size: 27
# If true, /vote top will show player heads
UseSkull: true
@@ -258,6 +264,7 @@ CHEST:
# Identifier
# Used in placeholders for formats
# Do not have spaces in the identifier
# Change the identifier for each shop item
Diamond:
Identifier_Name: 'Diamond'
# Item
+2 -2
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>VotingPlugin</artifactId>
<version>6.1.2</version>
<version>6.1.3</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -256,7 +256,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -149,7 +149,7 @@ public class BungeeHandler {
}
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
@@ -174,7 +174,7 @@ public class BungeeHandler {
@Override
public void onReceive(String[] data) {
if (data.length > 3) {
if (data.length > 4) {
plugin.extraDebug("BungeeVote from " + data[2] + ", processing");
String uuid = data[1];
VotingPluginUser user = null;
@@ -186,7 +186,7 @@ public class BungeeHandler {
user.clearCache();
user.bungeeVote(data[3]);
user.bungeeVote(data[3], new BungeeMessageData(data[4]));
}
}
});
@@ -195,7 +195,7 @@ public class BungeeHandler {
@Override
public void onReceive(String[] data) {
if (data.length > 3) {
if (data.length > 4) {
plugin.extraDebug("BungeeVoteOnline from " + data[2] + ", processing");
String uuid = data[1];
VotingPluginUser user = null;
@@ -207,7 +207,7 @@ public class BungeeHandler {
user.clearCache();
user.bungeeVoteOnline(data[3]);
user.bungeeVoteOnline(data[3], new BungeeMessageData(data[4]));
}
}
});
@@ -40,6 +40,7 @@ import net.md_5.bungee.api.connection.Server;
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.event.ServerSwitchEvent;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.event.EventHandler;
@@ -87,14 +88,15 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
}
}
public void checkOnlineVotes(ProxiedPlayer player, String uuid) {
public void checkOnlineVotes(ProxiedPlayer player, String uuid, String server) {
if (player != null && player.isConnected() && cachedOnlineVotes.containsKey(uuid)) {
ArrayList<OfflineBungeeVote> c = cachedOnlineVotes.get(uuid);
if (!c.isEmpty()) {
String server = getProxy().getPlayer(UUID.fromString(uuid)).getServer().getInfo().getName();
if (server == null) {
server = getProxy().getPlayer(UUID.fromString(uuid)).getServer().getInfo().getName();
}
if (!config.getBlockedServers().contains(server)) {
for (OfflineBungeeVote cache : c) {
sendPluginMessageServer(server, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
"" + cache.isRealVote(), cache.getText());
@@ -303,10 +305,10 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
}
for (String player : cachedOnlineVotes.keySet()) {
checkOnlineVotes(getProxy().getPlayer(UUID.fromString(player)), player);
checkOnlineVotes(getProxy().getPlayer(UUID.fromString(player)), player, null);
}
}
}, 15l, TimeUnit.SECONDS);
}, 15l, 30l, TimeUnit.SECONDS);
getProxy().getScheduler().schedule(this, new Runnable() {
@@ -380,12 +382,12 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
if (!ev.getTag().equals("vp:vp".toLowerCase())) {
return;
}
ev.setCancelled(true);
if (!(ev.getSender() instanceof Server))
return;
ByteArrayInputStream instream = new ByteArrayInputStream(ev.getData());
DataInputStream in = new DataInputStream(instream);
try {
@@ -433,7 +435,22 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
@Override
public void run() {
checkCachedVotes(server);
checkOnlineVotes(event.getPlayer(), uuid);
checkOnlineVotes(event.getPlayer(), uuid, server);
}
}, 2, TimeUnit.SECONDS);
}
@EventHandler
public void onServerConnected(ServerSwitchEvent event) {
final String server = event.getPlayer().getServer().getInfo().getName();
final String uuid = event.getPlayer().getUniqueId().toString();
getProxy().getScheduler().schedule(this, new Runnable() {
@Override
public void run() {
checkCachedVotes(server);
checkOnlineVotes(event.getPlayer(), uuid, server);
}
}, 2, TimeUnit.SECONDS);
@@ -503,11 +520,11 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
}
}
public void sendSocketVote(String name, String service) {
public void sendSocketVote(String name, String service, BungeeMessageData text) {
String uuid = getUUID(name);
if (config.getSendVotesToAllServers()) {
sendServerMessage("bungeevote", uuid, name, service);
sendServerMessage("bungeevote", uuid, name, service, text.toString());
if (config.getBroadcast()) {
sendServerMessage("BungeeBroadcast", service, uuid, name);
}
@@ -525,7 +542,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
server = config.getFallBack();
}
sendServerMessageServer(server, "bungeevoteonline", uuid, name, service);
sendServerMessageServer(server, "bungeevoteonline", uuid, name, service, text.toString());
if (config.getBroadcast()) {
sendServerMessage("BungeeBroadcast", service, uuid, name);
}
@@ -548,6 +565,8 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
getLogger().info("Sending request for status message on " + s);
sendPluginMessageServer(s, "Status", s);
}
} else {
getLogger().info("Ignoring blocked server " + s);
}
}
}
@@ -558,53 +577,53 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
getLogger().info("No name from vote on " + service);
return;
}
if (method.equals(BungeeMethod.SOCKETS)) {
sendSocketVote(player, service);
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
String uuid = getUUID(player);
if (uuid.isEmpty()) {
if (config.getAllowUnJoined()) {
UUID u = null;
try {
u = fetchUUID(player);
} catch (Exception e) {
if (getConfig().getDebug()) {
e.printStackTrace();
}
String uuid = getUUID(player);
if (uuid.isEmpty()) {
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);
}
if (u == null) {
debug("Failed to get uuid for " + player);
return;
}
uuid = u.toString();
} else {
getLogger().info("Ignoring vote from " + player);
return;
}
}
player = getProperName(uuid, player);
player = getProperName(uuid, player);
if (!mysql.getUuids().contains(uuid)) {
mysql.update(uuid, "PlayerName", player, DataType.STRING);
}
if (!mysql.getUuids().contains(uuid)) {
mysql.update(uuid, "PlayerName", player, DataType.STRING);
}
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", uuid, DataType.STRING));
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", uuid, DataType.STRING));
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));
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);
*/
/*
* 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();
long time = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
if (config.getSendVotesToAllServers()) {
for (String s : getProxy().getServers().keySet()) {
@@ -647,8 +666,10 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
debug("Caching online vote for " + player + " on " + service);
}
}
} else if (method.equals(BungeeMethod.SOCKETS)) {
sendSocketVote(player, service, text);
}
}
}
@@ -1232,32 +1232,39 @@ public class CommandLoader {
return;
}
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
if (cmdHandle.getArgs().length > 0) {
int argLength = cmdHandle.getArgs().length;
String arg0 = "";
if (argLength > 0) {
arg0 = cmdHandle.getArgs()[0];
}
String[] perms = cmdHandle.getPerm().split(Pattern.quote("|"));
try {
if (perms.length > 1) {
// has another perm
plugin.devDebug("Adding child perm " + perms[0] + " to " + perms[1] + " from /vote" + arg0);
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" + arg0);
}
if (argLength > 0) {
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]);
String currentPerm = plugin.getCommand("vote" + arg).getPermission();
if (currentPerm == null || currentPerm.length() > perms[0].length()) {
plugin.getCommand("vote" + arg).setPermission(perms[0]);
}
for (String str : plugin.getCommand("vote" + arg).getAliases()) {
commands.put(str, cmdHandle);
@@ -1266,50 +1273,43 @@ public class CommandLoader {
plugin.devDebug("Failed to load command and tab completer for /vote" + arg);
}
}
} 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");
}
}
}
for (CommandHandler cmdHandle : plugin.getAdminVoteCommand()) {
if (cmdHandle.getArgs().length > 0) {
int argLength = cmdHandle.getArgs().length;
String arg0 = "";
if (argLength > 0) {
arg0 = cmdHandle.getArgs()[0];
}
String[] perms = cmdHandle.getPerm().split(Pattern.quote("|"));
try {
if (perms.length > 1) {
// has another perm
plugin.devDebug("Adding child perm " + perms[0] + " to " + perms[1] + " from /adminvote" + arg0);
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" + arg0);
}
if (argLength > 0) {
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]);
String currentPerm = plugin.getCommand("adminvote" + arg).getPermission();
if (currentPerm == null || currentPerm.length() > perms[0].length()) {
plugin.getCommand("adminvote" + arg).setPermission(perms[0]);
}
for (String str : plugin.getCommand("adminvote" + arg).getAliases()) {
commands.put(str, cmdHandle);
@@ -1321,20 +1321,6 @@ 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");
}
}
}
}
@@ -1658,6 +1644,16 @@ public class CommandLoader {
});
}
plugin.getVoteCommand().add(new CommandHandler(new String[] { "URL", "(SiteName)" },
"VotingPlugin.Commands.Vote.URL.VoteSite", "Open VoteURL GUI for VoteSite", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteURLVoteSite(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender),
args[1]).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "URL" },
"VotingPlugin.Commands.Vote.URL|" + playerPerm, "Open VoteURL GUI", false) {
@@ -1668,15 +1664,6 @@ public class CommandLoader {
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "URL", "(SiteName)" },
"VotingPlugin.Commands.Vote.URL.VoteSite", "Open VoteURL GUI for VoteSite", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteURLVoteSite(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender),
args[1]).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Last", "(player)" },
"VotingPlugin.Commands.Vote.Last.Other|" + modPerm, "See other players last votes") {
@@ -1777,15 +1764,6 @@ public class CommandLoader {
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "GUI" },
"VotingPlugin.Commands.Vote.GUI|" + playerPerm, "Open VoteGUI", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteGUI(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "GUI", "(player)" },
"VotingPlugin.Commands.Vote.GUI.Other|" + modPerm, "Open VoteGUI", false) {
@@ -1801,6 +1779,15 @@ public class CommandLoader {
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "GUI" },
"VotingPlugin.Commands.Vote.GUI|" + playerPerm, "Open VoteGUI", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteGUI(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
}
});
if (plugin.getGui().isLastMonthGUI()) {
plugin.getVoteCommand()
.add(new CommandHandler(new String[] { "LastMonthTop" },
@@ -11,8 +11,9 @@ import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
import com.bencodez.votingplugin.user.UserManager;
@@ -122,15 +123,6 @@ public class VoteGUI extends GUIHandler {
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"))
|| (!player.hasPermission("VotingPlugin.Commands.Vote.GUI")
&& !player.hasPermission("VotingPlugin.Player"))) {
player.sendMessage(
StringParser.getInstance().colorize(VotingPluginMain.plugin.getOptions().getFormatNoPerms()));
return;
}
BInventory inv = new BInventory(plugin.getGui().getChestVoteGUIName());
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
inv.dontClose();
@@ -181,6 +173,13 @@ public class VoteGUI extends GUIHandler {
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
}
}
if (RewardHandler.getInstance().hasRewards(plugin.getGui().getData(),
plugin.getGui().getChestVoteGUISlotRewardsPath(slot))) {
RewardHandler.getInstance().giveReward(UserManager.getInstance().getVotingPluginUser(player),
plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot),
new RewardOptions().addPlaceholder("identifier", slot));
}
}
@Override
@@ -143,9 +143,10 @@ public class GUI extends YMLFile {
private boolean lastMonthGUI = false;
private VotingPluginMain plugin;
public String getCHESTVoteShopPurchase(String identifier) {
return getData().getString("CHEST.Shop." + identifier +".PurchaseMessage", plugin.getConfigFile().getFormatShopPurchaseMsg());
return getData().getString("CHEST.Shop." + identifier + ".PurchaseMessage",
plugin.getConfigFile().getFormatShopPurchaseMsg());
}
public GUI(VotingPluginMain plugin) {
@@ -217,6 +218,10 @@ public class GUI extends YMLFile {
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
}
public String getChestVoteGUISlotRewardsPath(String slot) {
return "CHEST.VoteGUI." + slot + ".Rewards";
}
/**
* Gets the vote GUI slot lore.
*
@@ -9,6 +9,7 @@ import org.bukkit.event.Listener;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
import com.bencodez.votingplugin.objects.VoteSite;
import com.vexsoftware.votifier.model.Vote;
@@ -68,6 +69,14 @@ public class VotiferEvent implements Listener {
@Override
public void run() {
if (plugin.getBungeeSettings().isUseBungeecoord()
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS))) {
plugin.getLogger()
.severe("Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled");
return;
}
String voteSiteName = plugin.getVoteSiteName(voteSite);
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames();
@@ -409,13 +409,15 @@ public class TopVoterHandler implements Listener {
YMLFileHandler file = new YMLFileHandler(plugin, new File(plugin.getDataFolder(), fileName));
file.setup();
ArrayList<String> topVoters = new ArrayList<String>();
int count = 1;
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(top).entrySet()) {
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
count++;
for (TopVoter cTop : TopVoter.values()) {
ArrayList<String> topVoters = new ArrayList<String>();
int count = 1;
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(cTop).entrySet()) {
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
count++;
}
file.getData().set(cTop.toString(), topVoters);
}
file.getData().set(top.toString(), topVoters);
file.saveData();
}
@@ -157,7 +157,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
setWeekVoteStreak(getWeekVoteStreak() + 1);
}
public void bungeeVote(String service) {
public void bungeeVote(String service, BungeeMessageData text) {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
VotingPluginMain.plugin.debug("Bungee vote for " + getPlayerName() + " on " + service);
@@ -165,6 +165,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
true);
voteEvent.setBungee(true);
voteEvent.setForceBungee(true);
voteEvent.setAddTotals(false);
voteEvent.setBungeeTextTotals(text);
voteEvent.setVotingPluginUser(this);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
@@ -175,14 +178,17 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
}
public void bungeeVoteOnline(String service) {
public void bungeeVoteOnline(String service, BungeeMessageData text) {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
VotingPluginMain.plugin.debug("Bungee online vote for " + getPlayerName() + " on " + service);
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service), getPlayerName(), service,
true);
voteEvent.setBungee(true);
voteEvent.setForceBungee(false);
voteEvent.setForceBungee(true);
voteEvent.setAddTotals(false);
voteEvent.setBungeeTextTotals(text);
voteEvent.setVotingPluginUser(this);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override