mirror of
https://github.com/BenCodez/VotingPlugin.git
synced 2026-11-04 17:10:03 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b4d93197c | ||
|
|
d1d159ba90 | ||
|
|
8501c351dd | ||
|
|
a61d8bbd04 | ||
|
|
ccd39ebc89 | ||
|
|
da04ddad7d | ||
|
|
498210d709 | ||
|
|
c128bec2af | ||
|
|
84ce9275f0 | ||
|
|
66bdd9b5c7 | ||
|
|
b02ab916cd | ||
|
|
a2068da36b | ||
|
|
83c43331a9 | ||
|
|
afe68ef229 | ||
|
|
7eec56ee2a | ||
|
|
2ed462b61c | ||
|
|
dd142d20fe | ||
|
|
8a340dc292 | ||
|
|
e77201613e | ||
|
|
710ad17f47 | ||
|
|
a617625b87 | ||
|
|
e8a5319544 | ||
|
|
86e737892a | ||
|
|
3fd7a40421 | ||
|
|
a70e5aa54c | ||
|
|
593aae1e67 | ||
|
|
e88849854b | ||
|
|
738fd5645e | ||
|
|
22ac364f8a | ||
|
|
5d78d3a734 | ||
|
|
e83b12a248 |
No files matched your search
@@ -28,10 +28,6 @@ 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
|
||||
@@ -41,11 +37,13 @@ Server: PleaseSet
|
||||
# -----------------------------
|
||||
|
||||
# Bungee communication, add bungee host/port here
|
||||
# For socket method
|
||||
BungeeServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1297
|
||||
|
||||
# Bungee communication, add this to bungee server
|
||||
# For socket method
|
||||
SpigotServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1298
|
||||
@@ -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'
|
||||
@@ -394,6 +397,9 @@ PreventRepeatMilestones: false
|
||||
# Mainly to be used for alts and such
|
||||
UsePrimaryAccountForPlaceholders: false
|
||||
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
AddCustomCommands: false
|
||||
|
||||
# Injects custom command to /vote
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -49,8 +49,12 @@ VoteParty:
|
||||
GiveAllPlayers: false
|
||||
# If true, the vote count will reset each day
|
||||
ResetEachDay: false
|
||||
# If true, the vote count will reset each week
|
||||
ResetWeekly: false
|
||||
# Reset at the end of the month
|
||||
ResetMonthly: false
|
||||
# If true, will give voteparty only once per day
|
||||
OnlyOncePerDay: false
|
||||
# Reset extra votes
|
||||
ResetExtraVotesMonthly: false
|
||||
# Count votes from /av vote?
|
||||
|
||||
@@ -47,14 +47,17 @@ AllowUnJoined: false
|
||||
# ----------------------------
|
||||
|
||||
# Tell servers to broadcast
|
||||
# For socket method
|
||||
Broadcast: true
|
||||
|
||||
# Bungee communication, Add this to each spigot server
|
||||
# For socket method
|
||||
BungeeServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1297
|
||||
|
||||
# Bungee communication, add each spigot server here
|
||||
# For socket method
|
||||
SpigotServers:
|
||||
lobby:
|
||||
Host: '127.0.0.1'
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>6.1</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>
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.bencodez.advancedcore.bungeeapi.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -59,11 +60,12 @@ public class BungeeHandler {
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
plugin.debug("pluginmessaging vote received from " + player + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
player);
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
|
||||
String text = args.get(6);
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
user.clearCache();
|
||||
|
||||
@@ -94,9 +96,10 @@ public class BungeeHandler {
|
||||
String uuid = args.get(1);
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
String text = args.get(6);
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
plugin.debug("pluginmessaging voteonline received from " + player + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
player);
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text);
|
||||
@@ -147,6 +150,15 @@ public class BungeeHandler {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String server = args.get(0);
|
||||
plugin.getPluginMessaging().sendPluginMessage("statusokay", server);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
|
||||
@@ -162,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;
|
||||
@@ -174,7 +186,7 @@ public class BungeeHandler {
|
||||
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVote(data[3]);
|
||||
user.bungeeVote(data[3], new BungeeMessageData(data[4]));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -183,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;
|
||||
@@ -195,7 +207,7 @@ public class BungeeHandler {
|
||||
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVoteOnline(data[3]);
|
||||
user.bungeeVoteOnline(data[3], new BungeeMessageData(data[4]));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -634,9 +634,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
// vote party
|
||||
voteParty = new VoteParty(this);
|
||||
if (specialRewardsConfig.getVotePartyEnabled()) {
|
||||
voteParty.check();
|
||||
}
|
||||
voteParty.register();
|
||||
|
||||
topVoterHandler.register();
|
||||
@@ -773,7 +770,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
if (!contains) {
|
||||
issues = false;
|
||||
plugin.getLogger().warning("No vote has been recieved from " + site.getServiceSite()
|
||||
+ ", may be an invalid service site. Vote on the site and look in console for a service site, if you get nothing then there is an issue with votifier");
|
||||
+ ", may be an invalid service site. Please read: https://github.com/BenCodez/VotingPlugin/wiki/Votifier-Troubleshooting");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -898,9 +895,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
pm.registerEvents(new BlockBreak(this), this);
|
||||
pm.registerEvents(new PlayerInteract(this), this);
|
||||
pm.registerEvents(new VotingPluginUpdateEvent(this), this);
|
||||
/*if (!NMSManager.getInstance().isVersion("1.12")) {
|
||||
pm.registerEvents(new PlayerCommandSendListener(this), this);
|
||||
}*/
|
||||
/*
|
||||
* if (!NMSManager.getInstance().isVersion("1.12")) { pm.registerEvents(new
|
||||
* PlayerCommandSendListener(this), this); }
|
||||
*/
|
||||
coolDownCheck = new CoolDownCheck(this);
|
||||
pm.registerEvents(coolDownCheck, this);
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class BungeeMessageData {
|
||||
|
||||
// Message string
|
||||
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount
|
||||
|
||||
@Getter
|
||||
private int allTimeTotal = 0;
|
||||
@Getter
|
||||
private int monthTotal = 0;
|
||||
@Getter
|
||||
private int weeklyTotal = 0;
|
||||
@Getter
|
||||
private int dailyTotal = 0;
|
||||
@Getter
|
||||
private int points = 0;
|
||||
@Getter
|
||||
private int milestoneCount = 0;
|
||||
|
||||
public BungeeMessageData(String str) {
|
||||
String[] data = str.split(Pattern.quote("//"));
|
||||
if (data.length >= 6) {
|
||||
allTimeTotal = Integer.parseInt(data[0]);
|
||||
monthTotal = Integer.parseInt(data[1]);
|
||||
weeklyTotal = Integer.parseInt(data[2]);
|
||||
dailyTotal = Integer.parseInt(data[3]);
|
||||
points = Integer.parseInt(data[4]);
|
||||
milestoneCount = Integer.parseInt(data[5]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return allTimeTotal + "//" + monthTotal + "//" + weeklyTotal + "//" + dailyTotal + "//" + points + "//"
|
||||
+ milestoneCount;
|
||||
}
|
||||
|
||||
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
|
||||
int milestoneCount) {
|
||||
this.allTimeTotal = allTimeTotal;
|
||||
this.monthTotal = monthTotal;
|
||||
this.weeklyTotal = weeklyTotal;
|
||||
this.dailyTotal = dailyTotal;
|
||||
this.points = points;
|
||||
this.milestoneCount = milestoneCount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,9 +36,11 @@ import lombok.Getter;
|
||||
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.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;
|
||||
@@ -86,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());
|
||||
@@ -245,9 +248,14 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
|
||||
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
|
||||
|
||||
method = BungeeMethod.getByName(config.getBungeeMethod());
|
||||
if (method == null) {
|
||||
method = BungeeMethod.PLUGINMESSAGING;
|
||||
}
|
||||
|
||||
this.getProxy().registerChannel("vp:vp");
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
this.getProxy().registerChannel("vp:vp");
|
||||
// this.getProxy().registerChannel("vp:vp");
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
voteCacheFile = new VoteCache(this);
|
||||
@@ -297,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() {
|
||||
|
||||
@@ -312,8 +320,6 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
|
||||
}
|
||||
}
|
||||
}, 1l, 60l, TimeUnit.MINUTES);
|
||||
|
||||
this.getProxy().registerChannel("vp:vp");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
|
||||
|
||||
@@ -376,6 +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 {
|
||||
@@ -383,14 +395,23 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
|
||||
DataOutputStream out = new DataOutputStream(outstream);
|
||||
String subchannel = in.readUTF();
|
||||
int size = in.readInt();
|
||||
out.writeUTF(subchannel);
|
||||
out.writeInt(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
out.writeUTF(in.readUTF());
|
||||
}
|
||||
for (String send : getProxy().getServers().keySet()) {
|
||||
if (getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||
getProxy().getServers().get(send).sendData("vp:vp".toLowerCase(), outstream.toByteArray());
|
||||
|
||||
// check for status message returns
|
||||
if (subchannel.equalsIgnoreCase("statusokay")) {
|
||||
String server = in.readUTF();
|
||||
getLogger().info("Status okay for " + server);
|
||||
return;
|
||||
} else {
|
||||
// reforward message
|
||||
out.writeUTF(subchannel);
|
||||
out.writeInt(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
out.writeUTF(in.readUTF());
|
||||
}
|
||||
for (String send : getProxy().getServers().keySet()) {
|
||||
if (getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||
getProxy().getServers().get(send).sendData("vp:vp".toLowerCase(), outstream.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -414,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);
|
||||
@@ -484,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);
|
||||
}
|
||||
@@ -506,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);
|
||||
}
|
||||
@@ -516,7 +552,24 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
|
||||
}
|
||||
|
||||
public void status(CommandSender sender) {
|
||||
sendServerMessage("status");
|
||||
if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage("status");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
if (!config.getBlockedServers().contains(s)) {
|
||||
ServerInfo info = getProxy().getServerInfo(s);
|
||||
if (info.getPlayers().isEmpty()) {
|
||||
getLogger().info("No players on server " + s + " to send test status message");
|
||||
} else {
|
||||
// send
|
||||
getLogger().info("Sending request for status message on " + s);
|
||||
sendPluginMessageServer(s, "Status", s);
|
||||
}
|
||||
} else {
|
||||
getLogger().info("Ignoring blocked server " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void vote(String player, String service, boolean realVote) {
|
||||
@@ -524,44 +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));
|
||||
|
||||
String text = mysqlUpdate(data, uuid, "AllTimeTotal", 1) + "//" + mysqlUpdate(data, uuid, "MonthTotal", 1)
|
||||
+ "//" + mysqlUpdate(data, uuid, "WeeklyTotal", 1) + "//" + mysqlUpdate(data, uuid, "DailyTotal", 1)
|
||||
+ "//" + mysqlUpdate(data, uuid, "Points", 1) + "//" + mysqlUpdate(data, uuid, "MilestoneCount", 1);
|
||||
BungeeMessageData text = new BungeeMessageData(mysqlUpdate(data, uuid, "AllTimeTotal", 1),
|
||||
mysqlUpdate(data, uuid, "MonthTotal", 1), mysqlUpdate(data, uuid, "WeeklyTotal", 1),
|
||||
mysqlUpdate(data, uuid, "DailyTotal", 1), mysqlUpdate(data, uuid, "Points", 1),
|
||||
mysqlUpdate(data, uuid, "MilestoneCount", 1));
|
||||
|
||||
long time = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
/*
|
||||
* 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();
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
|
||||
if (config.getSendVotesToAllServers()) {
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
@@ -573,7 +635,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
|
||||
cachedVotes.put(s, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
ArrayList<OfflineBungeeVote> list = cachedVotes.get(s);
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text));
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
|
||||
cachedVotes.put(s, list);
|
||||
|
||||
debug("Caching vote for " + player + " on " + service + " for " + s);
|
||||
@@ -581,7 +643,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
|
||||
} else {
|
||||
// send
|
||||
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text);
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -590,7 +652,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
|
||||
if (p != null && p.isConnected()
|
||||
&& !config.getBlockedServers().contains(p.getServer().getInfo().getName())) {
|
||||
sendPluginMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
|
||||
"" + time, Boolean.TRUE.toString(), "" + realVote, text);
|
||||
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString());
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
@@ -599,13 +661,15 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
|
||||
if (list == null) {
|
||||
list = new ArrayList<OfflineBungeeVote>();
|
||||
}
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text));
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
|
||||
cachedOnlineVotes.put(uuid, list);
|
||||
debug("Caching online vote for " + player + " on " + service);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendSocketVote(player, service, text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,10 +31,14 @@ public class VotingPluginBungeeCommand extends Command {
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
if (bungee.getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
"Checking status, waiting for response, check console, only for socket method"));
|
||||
"Checking status, waiting for response, check console, method: sockets"));
|
||||
bungee.status(sender);
|
||||
} else if (bungee.getMethod().equals(BungeeMethod.PLUGINMESSAGING)){
|
||||
sender.sendMessage(new TextComponent(
|
||||
"Checking status, waiting for response, check console, method: plugin messaging"));
|
||||
bungee.status(sender);
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("Not using socket method, command unavailable"));
|
||||
sender.sendMessage(new TextComponent("Not using socket/pluginmessage method, command unavailable"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
|
||||
@@ -450,15 +450,16 @@ public class CommandLoader {
|
||||
});
|
||||
|
||||
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") {
|
||||
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)));
|
||||
}
|
||||
});
|
||||
@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" },
|
||||
@@ -1231,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.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]);
|
||||
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);
|
||||
@@ -1265,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.devDebug("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.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]);
|
||||
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);
|
||||
@@ -1320,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.devDebug("Failed to set permission for /vote");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1657,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) {
|
||||
|
||||
@@ -1667,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") {
|
||||
@@ -1776,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) {
|
||||
|
||||
@@ -1800,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
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @return the vote delay
|
||||
*/
|
||||
public int getVoteDelay(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelay");
|
||||
return getData(siteName).getInt("VoteDelay", 24);
|
||||
}
|
||||
|
||||
public int getVoteDelayMin(String siteName) {
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -43,6 +43,10 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesMonthly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetCount")
|
||||
@Getter
|
||||
private boolean votePartyResetCount = true;
|
||||
|
||||
@Getter
|
||||
private String votePartyRewardsPath = "VoteParty.Rewards";
|
||||
|
||||
@@ -229,9 +233,17 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
return getData().getBoolean("VoteParty.ResetEachDay");
|
||||
}
|
||||
|
||||
public boolean getVotePartyOnlyOncePerDay() {
|
||||
return getData().getBoolean("VoteParty.OnlyOncePerDay");
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetMontly() {
|
||||
return getData().getBoolean("VoteParty.ResetMonthly");
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetWeekly() {
|
||||
return getData().getBoolean("VoteParty.ResetWeekly");
|
||||
}
|
||||
|
||||
public int getVotePartyUserVotesRequired() {
|
||||
return getData().getInt("VoteParty.UserVotesRequired");
|
||||
|
||||
@@ -239,4 +239,17 @@ public class ServerData {
|
||||
public void updateValues() {
|
||||
setVersion();
|
||||
}
|
||||
|
||||
public boolean isLastVotePartySameDay() {
|
||||
int num = getData().getInt("LastVoteParty", 0);
|
||||
if (num != plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateLastVoteParty() {
|
||||
getData().set("LastVoteParty", plugin.getTimeChecker().getTime().getDayOfYear());
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.events;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class PlayerVoteEvent extends Event {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String bungeeTextTotals;
|
||||
private BungeeMessageData bungeeTextTotals;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -66,7 +67,7 @@ public class PlayerVoteEvent extends Event {
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser votingPluginUser;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -147,9 +147,9 @@ public class VoteSite {
|
||||
*/
|
||||
public ItemBuilder getItem() {
|
||||
if (item == null) {
|
||||
plugin.getLogger().warning("Invalid item section in site: " + key);
|
||||
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid item for site: " + key)
|
||||
.setLore("&cInvalid item for site: " + key);
|
||||
plugin.getLogger().warning("Invalid display item section in site: " + key);
|
||||
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid display item for site: " + key)
|
||||
.setLore("&cInvalid display item for site: " + key);
|
||||
} else {
|
||||
return new ItemBuilder(item);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.events.PlayerSpecialRewardEvent;
|
||||
import com.bencodez.votingplugin.events.SpecialRewardType;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
@@ -41,7 +42,7 @@ public class SpecialRewards {
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
public boolean checkCumualativeVotes(VotingPluginUser user, String bungeeTextTotals) {
|
||||
public boolean checkCumualativeVotes(VotingPluginUser user, BungeeMessageData bungeeMessageData) {
|
||||
boolean gotCumulativeAny = false;
|
||||
Set<String> votes = plugin.getSpecialRewardsConfig().getCumulativeVotes();
|
||||
for (String vote : votes) {
|
||||
@@ -53,35 +54,30 @@ public class SpecialRewards {
|
||||
plugin.getSpecialRewardsConfig().getCumulativeRewardsPath(votesRequired))) {
|
||||
boolean gotCumulative = false;
|
||||
int total = 0;
|
||||
boolean useBungeeTotalNum = false;
|
||||
String[] data = new String[] { "0", "0", "0", "0" };
|
||||
if (bungeeTextTotals != null) {
|
||||
data = bungeeTextTotals.split("//");
|
||||
useBungeeTotalNum = true;
|
||||
}
|
||||
boolean useBungeeTotalNum = bungeeMessageData != null;
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameDay(votesRequired)) {
|
||||
if (!useBungeeTotalNum) {
|
||||
total = user.getTotal(TopVoter.Daily);
|
||||
} else {
|
||||
total = Integer.parseInt(data[3]);
|
||||
total = bungeeMessageData.getDailyTotal();
|
||||
}
|
||||
} else if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameWeek(votesRequired)) {
|
||||
if (!useBungeeTotalNum) {
|
||||
total = user.getTotal(TopVoter.Weekly);
|
||||
} else {
|
||||
total = Integer.parseInt(data[2]);
|
||||
total = bungeeMessageData.getWeeklyTotal();
|
||||
}
|
||||
} else if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameMonth(votesRequired)) {
|
||||
if (!useBungeeTotalNum) {
|
||||
total = user.getTotal(TopVoter.Monthly);
|
||||
} else {
|
||||
total = Integer.parseInt(data[1]);
|
||||
total = bungeeMessageData.getMonthTotal();
|
||||
}
|
||||
} else {
|
||||
if (!useBungeeTotalNum) {
|
||||
total = user.getTotal(TopVoter.AllTime);
|
||||
} else {
|
||||
total = Integer.parseInt(data[0]);
|
||||
total = bungeeMessageData.getAllTimeTotal();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,17 +121,14 @@ public class SpecialRewards {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkMilestone(VotingPluginUser user, String bungeeTextTotals) {
|
||||
public boolean checkMilestone(VotingPluginUser user, BungeeMessageData bungeeMessageData) {
|
||||
int milestoneCount = user.getMilestoneCount();
|
||||
if (bungeeTextTotals != null) {
|
||||
String[] data = bungeeTextTotals.split("//");
|
||||
if (data.length > 4) {
|
||||
try {
|
||||
milestoneCount = Integer.parseInt(data[5]);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
milestoneCount = user.getMilestoneCount();
|
||||
}
|
||||
if (bungeeMessageData != null) {
|
||||
try {
|
||||
milestoneCount = bungeeMessageData.getMilestoneCount();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
milestoneCount = user.getMilestoneCount();
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigFile().isPreventRepeatMilestones()) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.time.events.DateChangedEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.DayChangeEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
|
||||
@@ -105,7 +106,9 @@ public class TopVoterHandler implements Listener {
|
||||
public void onDateChanged(DateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
loadLastMonth();
|
||||
if (event.getTimeType().equals(TimeType.MONTH)) {
|
||||
loadLastMonth();
|
||||
}
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCache();
|
||||
}
|
||||
@@ -171,7 +174,7 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
resetTotals(TopVoter.Daily);
|
||||
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCache();
|
||||
}
|
||||
@@ -259,7 +262,7 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCache();
|
||||
}
|
||||
@@ -337,7 +340,7 @@ public class TopVoterHandler implements Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
resetTotals(TopVoter.Weekly);
|
||||
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCache();
|
||||
}
|
||||
@@ -402,17 +405,19 @@ public class TopVoterHandler implements Listener {
|
||||
} else if (top.equals(TopVoter.Weekly)) {
|
||||
fileName += "_" + week;
|
||||
}
|
||||
fileName += ".yml";
|
||||
fileName += "_" + System.currentTimeMillis() + ".yml";
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.UUID;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.events.PlayerReceivePointsEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
@@ -156,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);
|
||||
|
||||
@@ -164,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
|
||||
@@ -174,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
|
||||
@@ -192,7 +199,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
}
|
||||
|
||||
public void bungeeVotePluginMessaging(String service, long time, String bungeeTextTotals) {
|
||||
public void bungeeVotePluginMessaging(String service, long time, BungeeMessageData text) {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
VotingPluginMain.plugin.debug("Pluginmessaging vote for " + getPlayerName() + " on " + service);
|
||||
|
||||
@@ -203,7 +210,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
voteEvent.setForceBungee(true);
|
||||
voteEvent.setTime(time);
|
||||
voteEvent.setAddTotals(false);
|
||||
voteEvent.setBungeeTextTotals(bungeeTextTotals);
|
||||
voteEvent.setBungeeTextTotals(text);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.time.events.DayChangeEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
|
||||
import com.bencodez.advancedcore.api.user.UUID;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.VotePartyEvent;
|
||||
@@ -59,8 +60,12 @@ public class VoteParty implements Listener {
|
||||
* Check.
|
||||
*/
|
||||
public void check() {
|
||||
if (getTotalVotes() >= getVotesRequired()) {
|
||||
setTotalVotes(getTotalVotes() - getVotesRequired());
|
||||
if (getTotalVotes() >= getVotesRequired() && ((plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()
|
||||
&& plugin.getServerData().isLastVotePartySameDay())
|
||||
|| !plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay())) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetCount()) {
|
||||
setTotalVotes(getTotalVotes() - getVotesRequired());
|
||||
}
|
||||
|
||||
VotePartyEvent event = new VotePartyEvent();
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
@@ -74,6 +79,10 @@ public class VoteParty implements Listener {
|
||||
plugin.getServerData().setVotePartyExtraRequired(plugin.getServerData().getVotePartyExtraRequired()
|
||||
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired());
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
|
||||
plugin.getServerData().updateLastVoteParty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -190,20 +199,27 @@ public class VoteParty implements Listener {
|
||||
giveReward(user);
|
||||
}
|
||||
}
|
||||
reset();
|
||||
reset(false);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyResetEachDay()) {
|
||||
reset();
|
||||
reset(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWeekChange(WeekChangeEvent event) {
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyResetWeekly()) {
|
||||
reset(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMonthChange(MonthChangeEvent event) {
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyResetMontly()) {
|
||||
reset();
|
||||
reset(true);
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetExtraVotesMonthly()) {
|
||||
@@ -215,9 +231,11 @@ public class VoteParty implements Listener {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
public void reset(boolean override) {
|
||||
if (override) {
|
||||
setTotalVotes(0);
|
||||
}
|
||||
setVotedUsers(new ArrayList<String>());
|
||||
setTotalVotes(0);
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getVotePartyVotes() != 0) {
|
||||
|
||||
Reference in new issue
Block a user