mirror of
https://github.com/BenCodez/VotingPlugin.git
synced 2026-11-06 09:42:38 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
caa7058363 | ||
|
|
b67f6a509c | ||
|
|
0edc09dc80 | ||
|
|
19e597e094 | ||
|
|
bfc838bfaa | ||
|
|
9cda17e89e | ||
|
|
54a573a445 | ||
|
|
5432b2a0d3 | ||
|
|
13d3a614ed | ||
|
|
f9641e158d | ||
|
|
a0c1f64aac | ||
|
|
1f88cb0261 | ||
|
|
47a42d2bc8 | ||
|
|
ac41787c1e | ||
|
|
ed4e3968da | ||
|
|
09da81cc4e | ||
|
|
fd35c43c16 | ||
|
|
8060f594c3 | ||
|
|
39aa7062a5 | ||
|
|
7ff7fbb7cb | ||
|
|
231817314b | ||
|
|
a20f10d978 | ||
|
|
997beaae28 | ||
|
|
9acc5861b7 | ||
|
|
f299847d46 | ||
|
|
87ff48366c | ||
|
|
3dde76dcde | ||
|
|
237713a799 | ||
|
|
23141d4ec1 | ||
|
|
2cfbaf4de8 | ||
|
|
c31b83fcd3 | ||
|
|
4cfd887c33 | ||
|
|
f04930e437 | ||
|
|
c45e8356bb | ||
|
|
2f78b7784a | ||
|
|
911642f57f | ||
|
|
5e63c04f6c | ||
|
|
e368f30dd9 | ||
|
|
5d5e8b0d55 | ||
|
|
16e52a4fd7 | ||
|
|
331c8fedf5 | ||
|
|
c085d6823e | ||
|
|
47680b2646 | ||
|
|
60ed0ce73d | ||
|
|
e5ae3184e0 | ||
|
|
dca9c6fe18 | ||
|
|
083e90706f | ||
|
|
fed96bcda1 | ||
|
|
5bad8c8f98 | ||
|
|
e31326395c | ||
|
|
f5b2d27b9e | ||
|
|
42626e3789 | ||
|
|
b35ff9454d | ||
|
|
9ee1547691 | ||
|
|
cb1599fe56 | ||
|
|
59a206617c | ||
|
|
699d74ca3f | ||
|
|
ad6d411e64 | ||
|
|
1b430dc4b8 | ||
|
|
526dcc830e | ||
|
|
75aaae7016 | ||
|
|
89d3372701 | ||
|
|
209f1dbc25 | ||
|
|
bb67de8d0e |
No files matched your search
+16
-8
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.18.3</version>
|
||||
<version>6.18.7</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -95,6 +95,14 @@
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
@@ -211,19 +219,19 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.21.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.7-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.36</version>
|
||||
<version>1.18.38</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.20-R0.3-SNAPSHOT</version>
|
||||
<version>1.21-R0.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -259,13 +267,13 @@
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>3.7.14</version>
|
||||
<version>3.7.18-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.12.0</version>
|
||||
<version>5.12.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -374,7 +382,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.3</version>
|
||||
<version>3.1.4</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
@@ -591,7 +599,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.3</version>
|
||||
<version>3.1.4</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
|
||||
@@ -13,30 +13,34 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigSpigot;
|
||||
import com.bencodez.advancedcore.bungeeapi.GlobalMessage.GlobalMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.GlobalMessage.GlobalMessageListener;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisListener;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
import com.bencodez.simpleapi.encryption.EncryptionHandler;
|
||||
import com.bencodez.simpleapi.servercomm.global.GlobalMessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.global.GlobalMessageListener;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttHandler;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttServerComm;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttHandler.MessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisListener;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.ClientHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketReceiver;
|
||||
import com.bencodez.simpleapi.sql.data.DataValue;
|
||||
import com.bencodez.simpleapi.sql.data.DataValueBoolean;
|
||||
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfigSpigot;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.BungeeVersion;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -202,6 +206,17 @@ public class BungeeHandler implements Listener {
|
||||
list.addAll(ArrayUtils.convert(messageData));
|
||||
redisHandler.sendMessage(plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin",
|
||||
ArrayUtils.convert(list));
|
||||
} else if (method.equals(BungeeMethod.MQTT)) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(subChannel);
|
||||
list.addAll(ArrayUtils.convert(messageData));
|
||||
try {
|
||||
mqttHandler.publish(plugin.getBungeeSettings().getMqttPrefix() + "votingplugin/servers/proxy",
|
||||
String.join(":", list));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -324,10 +339,6 @@ public class BungeeHandler implements Listener {
|
||||
.getVotingPluginUser(UUID.fromString(uuid), player);
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
@@ -547,7 +558,8 @@ public class BungeeHandler implements Listener {
|
||||
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
|
||||
|
||||
if (plugin.getBungeeSettings().isPluginMessageEncryption()) {
|
||||
encryptionHandler = new EncryptionHandler(new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
encryptionHandler = new EncryptionHandler(plugin.getName(),
|
||||
new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
plugin.getPluginMessaging().setEncryptionHandler(encryptionHandler);
|
||||
}
|
||||
|
||||
@@ -556,79 +568,17 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
plugin.getPluginMessaging().setDebug(plugin.getBungeeSettings().isBungeeDebug());
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler() {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("Vote", args);
|
||||
}
|
||||
});
|
||||
globalMessageHandler.onMessage(subChannel, args);
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteOnline") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VoteOnline", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteUpdate") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VoteUpdate", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("BungeeTimeChange") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("BungeeTimeChange", args);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VoteBroadcast", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcastOffline") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VoteBroadcastOffline", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("Status", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("ServerName") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("ServerName", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBungee") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VotePartyBungee", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VotePartyBroadcast", args);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
encryptionHandler = new EncryptionHandler(plugin.getName(),
|
||||
new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
|
||||
clientHandler = new ClientHandler(plugin.getBungeeSettings().getBungeeServerHost(),
|
||||
plugin.getBungeeSettings().getBungeeServerPort(), encryptionHandler,
|
||||
@@ -644,158 +594,52 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
};
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevote") {
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 5) {
|
||||
plugin.extraDebug("BungeeVote from " + data[2] + ", processing");
|
||||
String uuid = data[1];
|
||||
VotingPluginUser user = null;
|
||||
if (!uuid.isEmpty()) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
|
||||
} else {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
user.bungeeVote(data[3], new BungeeMessageData(data[4]), !Boolean.valueOf(data[5]));
|
||||
}
|
||||
globalMessageHandler.onMessage(data[0], ArrayUtils.convertAndRemoveFirst(data));
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeTimeChange") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
checkGlobalData();
|
||||
} else if (method.equals(BungeeMethod.MQTT)) {
|
||||
try {
|
||||
String id = plugin.getBungeeSettings().getMqttClientID();
|
||||
if (id.isEmpty()) {
|
||||
id = plugin.getOptions().getServer();
|
||||
}
|
||||
});
|
||||
mqttHandler = new MqttHandler(new MqttServerComm(plugin.getBungeeSettings().getMqttClientID(),
|
||||
plugin.getBungeeSettings().getMqttBrokerURL(), plugin.getBungeeSettings().getMqttUsername(),
|
||||
plugin.getBungeeSettings().getMqttPassword()), 2);
|
||||
mqttHandler.subscribe(plugin.getBungeeSettings().getMqttPrefix() + "votingplugin/servers/"
|
||||
+ plugin.getOptions().getServer(), new MessageHandler() {
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevoteonline") {
|
||||
@Override
|
||||
public void onMessage(String topic, String payload) {
|
||||
String[] message = payload.split(":");
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 5) {
|
||||
plugin.extraDebug("BungeeVoteOnline from " + data[2] + ", processing");
|
||||
String uuid = data[1];
|
||||
VotingPluginUser user = null;
|
||||
if (!uuid.isEmpty()) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
|
||||
} else {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
user.bungeeVoteOnline(data[3], new BungeeMessageData(data[4]), !Boolean.valueOf(data[5]));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BroadcastOffline") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
String votes = data[0];
|
||||
String p = data[1];
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
user.offlineBroadcast(user, false, Integer.parseInt(votes));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
VoteSite site = plugin.getVoteSite(data[1], true);
|
||||
String p = data[3];
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + data[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("Broadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
VoteSite site = plugin.getVoteSite(data[1], true);
|
||||
String p = data[2];
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + data[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("Status") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 0) {
|
||||
plugin.getLogger().info("Received status command, sending status back");
|
||||
sendData("StatusOkay", plugin.getOptions().getServer());
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeUpdate") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("VotePartyBungee") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("VotePartyBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
String broadcast = data[0];
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getOptions().getServer().equalsIgnoreCase("pleaseset")) {
|
||||
plugin.getLogger().warning("Server name for bungee voting is not set, please set it");
|
||||
if (message.length > 0) {
|
||||
globalMessageHandler.onMessage(message[0],
|
||||
ArrayUtils.convertAndRemoveFirst(message));
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (plugin.getOptions().getServer().equalsIgnoreCase("pleaseset")) {
|
||||
plugin.getLogger().warning("Server name for bungee voting is not set, please set it");
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
private MqttHandler mqttHandler;
|
||||
|
||||
public void loadGlobalMysql() {
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
if (timer != null) {
|
||||
@@ -832,12 +676,12 @@ public class BungeeHandler implements Listener {
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", plugin.getMysql().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
public void debugEx(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
public void debugLog(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
|
||||
@@ -847,7 +691,7 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
public void logSevere(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@@ -862,12 +706,12 @@ public class BungeeHandler implements Listener {
|
||||
plugin.getBungeeSettings().getData().getConfigurationSection("GlobalData"))) {
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
public void debugEx(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
public void debugLog(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
|
||||
@@ -877,7 +721,7 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
public void logSevere(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,11 +55,11 @@ import com.bencodez.advancedcore.api.rewards.injected.RewardInjectInt;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectValidator;
|
||||
import com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInjectConfigurationSection;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.logger.Logger;
|
||||
import com.bencodez.simpleapi.file.YMLConfig;
|
||||
import com.bencodez.simpleapi.nms.NMSManager;
|
||||
import com.bencodez.simpleapi.skull.SkullCache;
|
||||
import com.bencodez.simpleapi.sql.Column;
|
||||
import com.bencodez.simpleapi.updater.Updater;
|
||||
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
|
||||
import com.bencodez.votingplugin.commands.CommandLoader;
|
||||
@@ -339,6 +339,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
* @param uuid the uuid
|
||||
* @return the user
|
||||
*/
|
||||
@Deprecated
|
||||
public VotingPluginUser getUser(UUID uuid) {
|
||||
return getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
}
|
||||
@@ -1384,18 +1385,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
public void onPreLoad() {
|
||||
plugin = this;
|
||||
|
||||
// disable plugin for older versions below 1.12
|
||||
|
||||
if (NMSManager.getInstance().isVersion("1.7", "1.8", "1.9", "1.10", "1.11")) {
|
||||
plugin.getLogger().severe("Detected running " + Bukkit.getVersion()
|
||||
+ ", this version is not supported on this build, read the plugin page. Disabling...");
|
||||
if (!configFile.isOverrideVersionDisable()) {
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
plugin.getLogger().warning("Overriding version disable, beware of using this! This may cause issues!");
|
||||
}
|
||||
|
||||
setupFiles();
|
||||
|
||||
loadVoteSites();
|
||||
|
||||
@@ -31,8 +31,6 @@ import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerManager;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.BooleanListener;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
|
||||
@@ -43,6 +41,8 @@ import com.bencodez.simpleapi.command.TabCompleteHandle;
|
||||
import com.bencodez.simpleapi.command.TabCompleteHandler;
|
||||
import com.bencodez.simpleapi.debug.DebugLevel;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.sql.Column;
|
||||
import com.bencodez.simpleapi.sql.DataType;
|
||||
import com.bencodez.simpleapi.updater.Updater;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.executers.CommandAliases;
|
||||
@@ -1069,7 +1069,7 @@ public class CommandLoader {
|
||||
sender.sendMessage(MessageAPI.colorize("&cClearing gotten milestones for all players..."));
|
||||
plugin.getUserManager().removeAllKeyValues(path, DataType.STRING);
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
plugin.getUserManager().getDataManager().cacheUser(p.getUniqueId());
|
||||
plugin.getUserManager().getDataManager().cacheUser(p.getUniqueId(), p.getName());
|
||||
}
|
||||
sender.sendMessage(
|
||||
MessageAPI.colorize("&cFinished clearing gotten milestones for all players"));
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class AdminVoteTopPoints extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
@@ -58,6 +58,26 @@ public class BungeeSettings extends YMLFile {
|
||||
@ConfigDataInt(path = "Redis.Port")
|
||||
@Getter
|
||||
private int RedisPort = 6379;
|
||||
|
||||
@ConfigDataString(path = "MQTT.ClientID")
|
||||
@Getter
|
||||
private String mqttClientID = "";
|
||||
|
||||
@ConfigDataString(path = "MQTT.BrokerURL")
|
||||
@Getter
|
||||
private String mqttBrokerURL = "tcp://localhost:1883";
|
||||
|
||||
@ConfigDataString(path = "MQTT.Username")
|
||||
@Getter
|
||||
private String mqttUsername = "";
|
||||
|
||||
@ConfigDataString(path = "MQTT.Password")
|
||||
@Getter
|
||||
private String mqttPassword = "";
|
||||
|
||||
@ConfigDataString(path = "MQTT.Prefix")
|
||||
@Getter
|
||||
private String mqttPrefix = "";
|
||||
|
||||
@ConfigDataString(path = "BungeeServer.Host")
|
||||
@Getter
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
public void generateVoteSite(String siteName) {
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites()) {
|
||||
String org = siteName;
|
||||
siteName = siteName.replace(".", "_");
|
||||
siteName = siteName.replace(".", "_").replace(" ", "_");
|
||||
plugin.getLogger().warning("VoteSite " + siteName + " does not exist with the servicesite '" + org
|
||||
+ "', creating one, set AutoCreateVoteSites to false to prevent this");
|
||||
setEnabled(siteName, true);
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.bukkit.event.Listener;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserStartup;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.simpleapi.sql.Column;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteSiteCoolDownEndEvent;
|
||||
|
||||
+1
-1
@@ -3,8 +3,8 @@ 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.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -3,8 +3,8 @@ 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.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.bencodez.advancedcore.listeners.AdvancedCoreLoginEvent;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -50,9 +49,7 @@ public class PlayerJoinEvent implements Listener {
|
||||
|
||||
plugin.getPlaceholders().onUpdate(user, true);
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()
|
||||
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.REDIS))) {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
plugin.getBungeeHandler().getGlobalMessageHandler().sendMessage("Login", user.getPlayerName(),
|
||||
user.getUUID(), plugin.getBungeeSettings().getServer());
|
||||
}
|
||||
@@ -76,14 +73,14 @@ public class PlayerJoinEvent implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
final java.util.UUID uuid = event.getPlayer().getUniqueId();
|
||||
final Player player = event.getPlayer();
|
||||
plugin.getLoginTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(player.getUniqueId());
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
user.dontCache();
|
||||
user.logoutRewards();
|
||||
plugin.getPlaceholders().onLogout(user);
|
||||
|
||||
+19
-1
@@ -13,10 +13,10 @@ import org.bukkit.event.Listener;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerManager;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.events.PlayerPostVoteEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -50,7 +50,25 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
String playerName = event.getPlayer();
|
||||
plugin.debug("Processing PlayerVoteEvent: " + playerName + "/" + event.getServiceSite());
|
||||
|
||||
boolean notValid = false;
|
||||
if (!PlayerManager.getInstance().isValidUser(playerName, plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
|
||||
if (!playerName.startsWith(plugin.getOptions().getBedrockPlayerPrefix())
|
||||
&& !plugin.getOptions().getBedrockPlayerPrefix().isEmpty()) {
|
||||
if (!event.isBungee() && PlayerManager.getInstance().isValidUser(
|
||||
plugin.getOptions().getBedrockPlayerPrefix() + playerName,
|
||||
plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
|
||||
plugin.debug("Detected a bedrock user without bedrock prefix, adjusting");
|
||||
playerName = plugin.getOptions().getBedrockPlayerPrefix() + playerName;
|
||||
} else {
|
||||
notValid = true;
|
||||
}
|
||||
} else {
|
||||
notValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (notValid) {
|
||||
if (!plugin.getConfigFile().isAllowUnjoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
|
||||
@@ -8,8 +8,8 @@ import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
|
||||
@@ -72,9 +72,11 @@ public class VotiferEvent implements Listener {
|
||||
plugin.getServerData().addServiceSite(voteSite);
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getBungeeSettings().isVotifierBypass()
|
||||
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS))) {
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MQTT)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.REDIS))) {
|
||||
plugin.getLogger().severe(
|
||||
"Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled, this means you aren't setup correctly for those methods, please check: https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups");
|
||||
"Ignoring vote from votifier since pluginmessaging, socket, redis, or mqtt bungee method is enabled, this means you aren't setup correctly for those methods, please check: https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups");
|
||||
return;
|
||||
}
|
||||
String matchSite = "";
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
+21
-10
@@ -180,6 +180,8 @@ public class PlaceHolders {
|
||||
}
|
||||
}
|
||||
|
||||
UUID uuid = user.getJavaUUID();
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
try {
|
||||
if (placeholder.matches(identifier)) {
|
||||
@@ -190,11 +192,11 @@ public class PlaceHolders {
|
||||
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
if (cPlaceholder.getCacheData().containsKey(user.getJavaUUID())) {
|
||||
if (cache.containsKey(uuid)) {
|
||||
if (cPlaceholder.getCacheData().containsKey(uuid)) {
|
||||
return cPlaceholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
return cache.get(p.getUniqueId());
|
||||
return cache.get(uuid);
|
||||
} else if (!forceProcess) {
|
||||
schedulePlaceholderCheck(user);
|
||||
return "...";
|
||||
@@ -226,8 +228,9 @@ public class PlaceHolders {
|
||||
}
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
return cache.get(p.getUniqueId());
|
||||
|
||||
if (cache.containsKey(uuid)) {
|
||||
return cache.get(uuid);
|
||||
} else if (!forceProcess) {
|
||||
schedulePlaceholderCheck(user);
|
||||
return "...";
|
||||
@@ -541,6 +544,14 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get number of sites available to be voted on").updateDataKey("LastVotes"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("SitesAvailableTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getTotalNumberOfSites();
|
||||
}
|
||||
}.withDescription("Get total number of sites available to be voted on"));
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
placeholders.add(new CalculatingPlaceholder<VotingPluginUser>("Next_" + voteSite.getKey()) {
|
||||
|
||||
@@ -642,7 +653,7 @@ public class PlaceHolders {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
}.useStartsWith().withDescription("Get username at postion in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Month_Position") {
|
||||
|
||||
@@ -658,7 +669,7 @@ public class PlaceHolders {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
}.withDescription("Get user's current top voter position"));
|
||||
|
||||
if (plugin.getGui().isLastMonthGUI()) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_LastMonth_Position") {
|
||||
@@ -730,7 +741,7 @@ public class PlaceHolders {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at position in top voter"));
|
||||
}.useStartsWith().withDescription("Get username at position in top voter"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_MonthVotes_") {
|
||||
|
||||
@@ -781,7 +792,7 @@ public class PlaceHolders {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
}.useStartsWith().withDescription("Get username at postion in top voter"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_WeekVotes_") {
|
||||
|
||||
@@ -832,7 +843,7 @@ public class PlaceHolders {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
}.useStartsWith().withDescription("Get username at postion in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("VotePartyContributedVotes") {
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
+6
-2
@@ -1,7 +1,11 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
public enum BungeeMethod {
|
||||
MYSQL, PLUGINMESSAGING, SOCKETS, REDIS;
|
||||
MYSQL, PLUGINMESSAGING, SOCKETS, REDIS, MQTT;
|
||||
|
||||
public boolean requiresPlayerOnline() {
|
||||
return this == MYSQL || this == PLUGINMESSAGING;
|
||||
}
|
||||
|
||||
public static BungeeMethod getByName(String str) {
|
||||
for (BungeeMethod method : values()) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
public class BungeeVersion {
|
||||
public static int getPluginMessageVersion() {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -0,0 +1,549 @@
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.bencodez.simpleapi.sql.Column;
|
||||
import com.bencodez.simpleapi.sql.DataType;
|
||||
import com.bencodez.simpleapi.sql.data.DataValue;
|
||||
import com.bencodez.simpleapi.sql.data.DataValueInt;
|
||||
import com.bencodez.simpleapi.sql.data.DataValueString;
|
||||
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfig;
|
||||
import com.bencodez.simpleapi.sql.mysql.queries.Query;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public abstract class ProxyMysqlUserTable {
|
||||
private List<String> columns = Collections.synchronizedList(new ArrayList<String>());
|
||||
|
||||
private List<String> intColumns = new ArrayList<>();
|
||||
|
||||
// private HashMap<String, ArrayList<Column>> table;
|
||||
|
||||
// ConcurrentMap<String, ArrayList<Column>> table = new
|
||||
// ConcurrentHashMap<String, ArrayList<Column>>();
|
||||
|
||||
@Getter
|
||||
private com.bencodez.simpleapi.sql.mysql.MySQL mysql;
|
||||
|
||||
private String name;
|
||||
|
||||
private Object object2 = new Object();
|
||||
|
||||
private Object object3 = new Object();
|
||||
|
||||
private Object object4 = new Object();
|
||||
|
||||
private Set<String> uuids = Collections.synchronizedSet(new HashSet<String>());
|
||||
|
||||
public abstract void logSevere(String string);
|
||||
|
||||
public abstract void logInfo(String string);
|
||||
|
||||
public ProxyMysqlUserTable(String tableName, MysqlConfig config, boolean debug) {
|
||||
|
||||
if (config.hasTableNameSet()) {
|
||||
tableName = config.getTableName();
|
||||
}
|
||||
name = tableName;
|
||||
if (config.getTablePrefix() != null) {
|
||||
name = config.getTablePrefix() + tableName;
|
||||
}
|
||||
mysql = new com.bencodez.simpleapi.sql.mysql.MySQL(config.getMaxThreads()) {
|
||||
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
if (debug) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String string) {
|
||||
logSevere(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String msg) {
|
||||
if (debug) {
|
||||
logInfo("MYSQL DEBUG: " + msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (!mysql.connect(config)) {
|
||||
|
||||
}
|
||||
try {
|
||||
Query q = new Query(mysql, "USE `" + config.getDatabase() + "`;");
|
||||
q.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
severe("Failed to send use database query: " + config.getDatabase() + " Error: " + e.getMessage());
|
||||
debug(e);
|
||||
}
|
||||
String sql = "CREATE TABLE IF NOT EXISTS " + getName() + " (";
|
||||
sql += "uuid VARCHAR(37),";
|
||||
sql += "PRIMARY KEY ( uuid )";
|
||||
sql += ");";
|
||||
Query query;
|
||||
try {
|
||||
query = new Query(mysql, sql);
|
||||
|
||||
query.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
loadData();
|
||||
|
||||
// tempoary to improve performance from old tables
|
||||
// addToQue("ALTER TABLE " + getName() + " MODIFY uuid VARCHAR(37);");
|
||||
alterColumnType("uuid", "VARCHAR(37)");
|
||||
}
|
||||
|
||||
public void addColumn(String column, DataType dataType) {
|
||||
synchronized (object3) {
|
||||
String sql = "ALTER TABLE " + getName() + " ADD COLUMN `" + column + "` text" + ";";
|
||||
try {
|
||||
Query query = new Query(mysql, sql);
|
||||
query.executeUpdate();
|
||||
|
||||
getColumns().add(column);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void alterColumnType(String column, String newType) {
|
||||
checkColumn(column, DataType.STRING);
|
||||
|
||||
try {
|
||||
new Query(mysql, "ALTER TABLE " + getName() + " MODIFY `" + column + "` " + newType + ";")
|
||||
.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (newType.contains("INT")) {
|
||||
if (!intColumns.contains(column)) {
|
||||
intColumns.add(column);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void checkColumn(String column, DataType dataType) {
|
||||
synchronized (object4) {
|
||||
if (!getColumns().contains(column)) {
|
||||
if (!getColumnsQueury().contains(column)) {
|
||||
addColumn(column, dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
clearCacheBasic();
|
||||
}
|
||||
|
||||
public void clearCacheBasic() {
|
||||
columns.clear();
|
||||
columns.addAll(getColumnsQueury());
|
||||
uuids.clear();
|
||||
uuids.addAll(getUuidsQuery());
|
||||
}
|
||||
|
||||
public void close() {
|
||||
mysql.disconnect();
|
||||
}
|
||||
|
||||
public boolean containsKeyQuery(String index) {
|
||||
String sqlStr = "SELECT uuid FROM " + getName() + ";";
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
while (rs.next()) {
|
||||
if (rs.getString("uuid").equals(index)) {
|
||||
rs.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void copyColumnData(String columnFromName, String columnToName) {
|
||||
checkColumn(columnFromName, DataType.STRING);
|
||||
checkColumn(columnToName, DataType.STRING);
|
||||
String sql = "UPDATE `" + getName() + "` SET `" + columnToName + "` = `" + columnFromName + "`;";
|
||||
try {
|
||||
Query query = new Query(mysql, sql);
|
||||
query.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void debug(SQLException e);
|
||||
|
||||
public List<String> getColumns() {
|
||||
if (columns == null || columns.size() == 0) {
|
||||
loadData();
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
public ArrayList<String> getColumnsQueury() {
|
||||
ArrayList<String> columns = new ArrayList<>();
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement("SHOW COLUMNS FROM `" + getName() + "`;")) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
String columnName = rs.getString(1);
|
||||
columns.add(columnName);
|
||||
|
||||
}
|
||||
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
public ArrayList<Column> getExactQuery(Column column) {
|
||||
ArrayList<Column> result = new ArrayList<>();
|
||||
String query = "SELECT * FROM " + getName() + " WHERE `" + column.getName() + "`='"
|
||||
+ column.getValue().getString() + "';";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(query)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
|
||||
/*
|
||||
* Query sql = new Query(mysql, query); sql.setParameter(1,
|
||||
* column.getValue().toString()); ResultSet rs = sql.executeQuery();
|
||||
*/
|
||||
if (rs.next()) {
|
||||
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
|
||||
String columnName = rs.getMetaData().getColumnLabel(i);
|
||||
Column rCol = null;
|
||||
if (intColumns.contains(columnName)) {
|
||||
rCol = new Column(columnName, DataType.INTEGER);
|
||||
rCol.setValue(new DataValueInt(rs.getInt(i)));
|
||||
} else {
|
||||
rCol = new Column(columnName, DataType.STRING);
|
||||
rCol.setValue(new DataValueString(rs.getString(i)));
|
||||
}
|
||||
result.add(rCol);
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
return result;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
|
||||
for (String col : getColumns()) {
|
||||
result.add(new Column(col, DataType.STRING));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArrayList<String> getNamesQuery() {
|
||||
ArrayList<String> uuids = new ArrayList<>();
|
||||
|
||||
checkColumn("PlayerName", DataType.STRING);
|
||||
ArrayList<Column> rows = getRowsNameQuery();
|
||||
if (rows != null) {
|
||||
for (Column c : rows) {
|
||||
if (c.getValue().isString()) {
|
||||
uuids.add(c.getValue().getString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public ArrayList<Column> getRowsNameQuery() {
|
||||
ArrayList<Column> result = new ArrayList<>();
|
||||
String sqlStr = "SELECT PlayerName FROM " + getName() + ";";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
while (rs.next()) {
|
||||
Column rCol = new Column("PlayerName", new DataValueString(rs.getString("PlayerName")));
|
||||
result.add(rCol);
|
||||
}
|
||||
sql.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ArrayList<Column> getRowsQuery() {
|
||||
ArrayList<Column> result = new ArrayList<>();
|
||||
String sqlStr = "SELECT uuid FROM " + getName() + ";";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
while (rs.next()) {
|
||||
Column rCol = new Column("uuid", new DataValueString(rs.getString("uuid")));
|
||||
result.add(rCol);
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<UUID, String> getRowsUUIDNameQuery() {
|
||||
ConcurrentHashMap<UUID, String> uuidNames = new ConcurrentHashMap<>();
|
||||
String sqlStr = "SELECT UUID, PlayerName FROM " + getName() + ";";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
while (rs.next()) {
|
||||
String uuid = rs.getString("uuid");
|
||||
String playerName = rs.getString("PlayerName");
|
||||
if (uuid != null && !uuid.isEmpty() && !uuid.equals("null") && playerName != null) {
|
||||
uuidNames.put(UUID.fromString(uuid), playerName);
|
||||
}
|
||||
}
|
||||
sql.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
|
||||
return uuidNames;
|
||||
}
|
||||
|
||||
public String getUUID(String playerName) {
|
||||
String query = "SELECT uuid FROM " + getName() + " WHERE " + "PlayerName" + "='" + playerName + "';";
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(query)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query sql = new Query(mysql, query); ResultSet rs = sql.executeQuery();
|
||||
*/
|
||||
if (rs.next()) {
|
||||
String uuid = rs.getString("uuid");
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
rs.close();
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<String> getUuids() {
|
||||
if (uuids == null || uuids.size() == 0) {
|
||||
uuids.clear();
|
||||
uuids.addAll(getUuidsQuery());
|
||||
return uuids;
|
||||
}
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public ArrayList<String> getUuidsQuery() {
|
||||
ArrayList<String> uuids = new ArrayList<>();
|
||||
|
||||
ArrayList<Column> rows = getRowsQuery();
|
||||
for (Column c : rows) {
|
||||
if (c.getValue().isString()) {
|
||||
uuids.add(c.getValue().getString());
|
||||
}
|
||||
}
|
||||
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public void insert(String index, String column, DataValue value) {
|
||||
insertQuery(index, Arrays.asList(new Column(column, value)));
|
||||
}
|
||||
|
||||
public void insertQuery(String index, List<Column> cols) {
|
||||
String query = "INSERT IGNORE " + getName() + " ";
|
||||
|
||||
query += "set uuid='" + index + "', ";
|
||||
|
||||
for (int i = 0; i < cols.size(); i++) {
|
||||
Column col = cols.get(i);
|
||||
if (i == cols.size() - 1) {
|
||||
if (col.getValue().isString()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getString() + "';";
|
||||
} else if (col.getValue().isBoolean()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getBoolean() + "';";
|
||||
} else if (col.getValue().isInt()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getInt() + "';";
|
||||
}
|
||||
} else {
|
||||
if (col.getValue().isString()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getString() + "', ";
|
||||
} else if (col.getValue().isBoolean()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getBoolean() + "', ";
|
||||
} else if (col.getValue().isInt()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getInt() + "', ";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
uuids.add(index);
|
||||
new Query(mysql, query).executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isIntColumn(String key) {
|
||||
return intColumns.contains(key);
|
||||
}
|
||||
|
||||
public void loadData() {
|
||||
columns = getColumnsQueury();
|
||||
}
|
||||
|
||||
public abstract void severe(String str);
|
||||
|
||||
public void shutdown() {
|
||||
mysql.disconnect();
|
||||
}
|
||||
|
||||
public void update(String index, List<Column> cols) {
|
||||
for (Column col : cols) {
|
||||
checkColumn(col.getName(), col.getDataType());
|
||||
}
|
||||
if (getUuids().contains(index)) {
|
||||
synchronized (object2) {
|
||||
|
||||
String query = "UPDATE " + getName() + " SET ";
|
||||
|
||||
for (int i = 0; i < cols.size(); i++) {
|
||||
Column col = cols.get(i);
|
||||
if (i == cols.size() - 1) {
|
||||
if (col.getValue().isString()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getString() + "'";
|
||||
} else if (col.getValue().isBoolean()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getBoolean() + "'";
|
||||
} else if (col.getValue().isInt()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getInt() + "'";
|
||||
}
|
||||
} else {
|
||||
if (col.getValue().isString()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getString() + "', ";
|
||||
} else if (col.getValue().isBoolean()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getBoolean() + "', ";
|
||||
} else if (col.getValue().isInt()) {
|
||||
query += "`" + col.getName() + "`='" + col.getValue().getInt() + "', ";
|
||||
}
|
||||
}
|
||||
}
|
||||
query += " WHERE `uuid`=";
|
||||
query += "'" + index + "';";
|
||||
|
||||
try {
|
||||
Query q = new Query(mysql, query);
|
||||
q.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
insertQuery(index, cols);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(String index, String column, DataValue value) {
|
||||
checkColumn(column, value.getType());
|
||||
if (getUuids().contains(index)) {
|
||||
synchronized (object2) {
|
||||
String query = "UPDATE " + getName() + " SET ";
|
||||
|
||||
if (value.isString()) {
|
||||
query += column + "='" + value.getString() + "'";
|
||||
} else if (value.isBoolean()) {
|
||||
query += column + "='" + value.getBoolean() + "'";
|
||||
} else if (value.isInt()) {
|
||||
query += column + "='" + value.getInt() + "'";
|
||||
}
|
||||
query += " WHERE `uuid`=";
|
||||
query += "'" + index + "';";
|
||||
|
||||
try {
|
||||
Query q = new Query(mysql, query);
|
||||
q.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
insert(index, column, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void wipeColumnData(String columnName, DataType dataType) {
|
||||
checkColumn(columnName, dataType);
|
||||
String sql = "UPDATE " + getName() + " SET " + columnName + " = " + dataType.getNoValue() + ";";
|
||||
try {
|
||||
Query query = new Query(mysql, sql);
|
||||
query.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+367
-227
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.proxy;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -9,6 +9,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
@@ -24,31 +25,33 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
|
||||
import com.bencodez.advancedcore.bungeeapi.mysql.ProxyMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisListener;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.advancedcore.bungeeapi.time.BungeeTimeChecker;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.encryption.EncryptionHandler;
|
||||
import com.bencodez.simpleapi.json.JsonParser;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyHandler;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyMethod;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyServerSocketConfiguration;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyServerSocketConfigurationBungee;
|
||||
import com.bencodez.simpleapi.servercomm.global.GlobalMessageListener;
|
||||
import com.bencodez.simpleapi.servercomm.global.GlobalMessageProxyHandler;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttHandler;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttHandler.MessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttServerComm;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisListener;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.ClientHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketReceiver;
|
||||
import com.bencodez.simpleapi.sql.Column;
|
||||
import com.bencodez.simpleapi.sql.data.DataValue;
|
||||
import com.bencodez.simpleapi.sql.data.DataValueBoolean;
|
||||
import com.bencodez.simpleapi.sql.data.DataValueInt;
|
||||
import com.bencodez.simpleapi.sql.data.DataValueString;
|
||||
import com.bencodez.votingplugin.proxy.multiproxy.MultiProxyHandler;
|
||||
import com.bencodez.votingplugin.proxy.multiproxy.MultiProxyMethod;
|
||||
import com.bencodez.votingplugin.proxy.multiproxy.MultiProxyServerSocketConfiguration;
|
||||
import com.bencodez.votingplugin.proxy.multiproxy.MultiProxyServerSocketConfigurationBungee;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -58,6 +61,7 @@ import lombok.Setter;
|
||||
|
||||
public abstract class VotingPluginProxy {
|
||||
@Getter
|
||||
@Setter
|
||||
private int votePartyVotes = 0;
|
||||
|
||||
@Getter
|
||||
@@ -66,14 +70,16 @@ public abstract class VotingPluginProxy {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private ProxyMySQL proxyMySQL;
|
||||
private ProxyMysqlUserTable proxyMySQL;
|
||||
|
||||
private EncryptionHandler encryptionHandler;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new ConcurrentHashMap<>();
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>> cachedVotes = new ConcurrentHashMap<>();
|
||||
|
||||
private HashMap<String, ClientHandler> clientHandles;
|
||||
@@ -97,6 +103,7 @@ public abstract class VotingPluginProxy {
|
||||
private boolean enabled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private MultiProxyHandler multiProxyHandler;
|
||||
|
||||
@Getter
|
||||
@@ -109,6 +116,12 @@ public abstract class VotingPluginProxy {
|
||||
@Getter
|
||||
private Queue<VoteTimeQueue> timeChangeQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
@Getter
|
||||
private MqttHandler mqttHandler;
|
||||
|
||||
@Getter
|
||||
private GlobalMessageProxyHandler globalMessageProxyHandler;
|
||||
|
||||
public VotingPluginProxy() {
|
||||
enabled = true;
|
||||
|
||||
@@ -270,9 +283,9 @@ public abstract class VotingPluginProxy {
|
||||
|
||||
}
|
||||
if (toSend) {
|
||||
sendMessageServer(server, "Vote", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(),
|
||||
globalMessageProxyHandler.sendMessage(server, "Vote", cache.getPlayerName(),
|
||||
cache.getUuid(), cache.getService(), "" + cache.getTime(),
|
||||
Boolean.FALSE.toString(), "" + cache.isRealVote(), cache.getText(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + getConfig().getBroadcast(),
|
||||
"" + num, "" + numberOfVotes);
|
||||
@@ -302,8 +315,8 @@ public abstract class VotingPluginProxy {
|
||||
int num = 1;
|
||||
int numberOfVotes = c.size();
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
sendMessageServer(server, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
globalMessageProxyHandler.sendMessage(server, "VoteOnline", cache.getPlayerName(),
|
||||
cache.getUuid(), cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + getConfig().getBroadcast(), "" + num,
|
||||
"" + numberOfVotes);
|
||||
@@ -323,7 +336,8 @@ public abstract class VotingPluginProxy {
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedOnlineVotes.entrySet()) {
|
||||
ArrayList<OfflineBungeeVote> votes = entry.getValue();
|
||||
for (int i = votes.size() - 1; i >= 0; i--) {
|
||||
if (cTime - votes.get(i).getTime() > getConfig().getVoteCacheTime() * 24 * 60 * 60 * 1000) {
|
||||
if (votes.get(i).getTime() + (getConfig().getVoteCacheTime() * 24 * 60 * 60 * 1000) < cTime) {
|
||||
debug("Removing vote from cache: " + votes.get(i).toString());
|
||||
votes.remove(i);
|
||||
}
|
||||
}
|
||||
@@ -332,7 +346,8 @@ public abstract class VotingPluginProxy {
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedVotes.entrySet()) {
|
||||
ArrayList<OfflineBungeeVote> votes = entry.getValue();
|
||||
for (int i = votes.size() - 1; i >= 0; i--) {
|
||||
if (cTime - votes.get(i).getTime() > getConfig().getVoteCacheTime() * 24 * 60 * 60 * 1000) {
|
||||
if (votes.get(i).getTime() + (getConfig().getVoteCacheTime() * 24 * 60 * 60 * 1000) < cTime) {
|
||||
debug("Removing vote from cache: " + votes.get(i).toString());
|
||||
votes.remove(i);
|
||||
}
|
||||
}
|
||||
@@ -357,15 +372,16 @@ public abstract class VotingPluginProxy {
|
||||
runConsoleCommand(command);
|
||||
}
|
||||
|
||||
/*
|
||||
* if (method.equals(BungeeMethod.PLUGINMESSAGING)) { if
|
||||
* (getConfig().getVotePartySendToAllServers()) { for (Entry<String, ServerInfo>
|
||||
* entry : getProxy().getServers().entrySet()) { //sendVoteParty(entry.getKey(),
|
||||
* entry.getValue()); } } else { for (String server :
|
||||
* getConfig().getVotePartyServersToSend()) { ServerInfo serverInfo =
|
||||
* getProxy().getServerInfo(server); if (serverInfo != null) {
|
||||
* //sendVoteParty(server, serverInfo); } } } }
|
||||
*/
|
||||
if (getConfig().getVotePartySendToAllServers()) {
|
||||
for (String server : getAllAvailableServers()) {
|
||||
sendVoteParty(server);
|
||||
}
|
||||
} else {
|
||||
for (String server : getConfig().getVotePartyServersToSend()) {
|
||||
sendVoteParty(server);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
saveVoteCacheFile();
|
||||
}
|
||||
@@ -479,10 +495,11 @@ public abstract class VotingPluginProxy {
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
if (getConfig().getPluginMessageEncryption()) {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolderPlugin(), "secretkey.key"));
|
||||
encryptionHandler = new EncryptionHandler("VotingPlugin",
|
||||
new File(getDataFolderPlugin(), "secretkey.key"));
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolderPlugin(), "secretkey.key"));
|
||||
encryptionHandler = new EncryptionHandler("VotingPlugin", new File(getDataFolderPlugin(), "secretkey.key"));
|
||||
|
||||
socketHandler = new SocketHandler(getPluginVersion(), getConfig().getBungeeHost(),
|
||||
getConfig().getBungeePort(), encryptionHandler, getConfig().getDebug()) {
|
||||
@@ -498,27 +515,9 @@ public abstract class VotingPluginProxy {
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 1) {
|
||||
if (data.length > 2) {
|
||||
if (data[0].equalsIgnoreCase("Broadcast")) {
|
||||
sendServerMessage(data);
|
||||
}
|
||||
}
|
||||
globalMessageProxyHandler.onMessage(data[0].toLowerCase(),
|
||||
ArrayUtils.convertAndRemoveFirst(data));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 1) {
|
||||
if (data[0].equalsIgnoreCase("StatusOkay")) {
|
||||
String server = data[1];
|
||||
log("Voting communicaton okay with " + server);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -550,22 +549,9 @@ public abstract class VotingPluginProxy {
|
||||
@Override
|
||||
protected void onMessage(String channel, String[] message) {
|
||||
if (message.length > 0) {
|
||||
if (message[0].equalsIgnoreCase("statusokay")) {
|
||||
String server = message[1];
|
||||
log("Status okay for " + server);
|
||||
} else if (message[0].equalsIgnoreCase("TimeChangeFinished")) {
|
||||
|
||||
} else if (message[0].equalsIgnoreCase("login")) {
|
||||
String player = message[1];
|
||||
String uuid = message[2];
|
||||
String server = "";
|
||||
if (message.length > 3) {
|
||||
server = message[3];
|
||||
}
|
||||
debug("Login: " + player + "/" + uuid + " " + server);
|
||||
addNonVotedPlayer(uuid, player);
|
||||
|
||||
login(player, uuid, server);
|
||||
if (message.length > 0) {
|
||||
globalMessageProxyHandler.onMessage(message[0].toLowerCase(),
|
||||
ArrayUtils.convertAndRemoveFirst(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -579,11 +565,110 @@ public abstract class VotingPluginProxy {
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.MQTT))
|
||||
|
||||
{
|
||||
// use MqttHander
|
||||
|
||||
try {
|
||||
mqttHandler = new MqttHandler(new MqttServerComm(getConfig().getMqttClientID(),
|
||||
getConfig().getMqttBrokerURL(), getConfig().getMqttUsername(), getConfig().getMqttPassword()),
|
||||
2);
|
||||
mqttHandler.subscribe(getConfig().getMqttPrefix() + "votingplugin/servers/proxy", new MessageHandler() {
|
||||
|
||||
@Override
|
||||
public void onMessage(String topic, String payload) {
|
||||
debug("Received mqtt message: " + topic + " - " + payload);
|
||||
String[] message = payload.split(":");
|
||||
|
||||
if (message.length > 0) {
|
||||
globalMessageProxyHandler.onMessage(message[0].toLowerCase(),
|
||||
ArrayUtils.convertAndRemoveFirst(message));
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ getVoteCacheVotePartyIncreaseVotesRequired();
|
||||
currentVotePartyVotesRequired =
|
||||
|
||||
getConfig().getVotePartyVotesRequired() + getVoteCacheVotePartyIncreaseVotesRequired();
|
||||
votePartyVotes = getVoteCacheCurrentVotePartyVotes();
|
||||
|
||||
globalMessageProxyHandler = new GlobalMessageProxyHandler() {
|
||||
|
||||
@Override
|
||||
public void sendMessage(String server, String channel, String... messageData) {
|
||||
switch (method) {
|
||||
case MQTT:
|
||||
sendMqttMessageServer(server, channel, messageData);
|
||||
break;
|
||||
case MYSQL:
|
||||
sendPluginMessageServer(server, channel, messageData);
|
||||
break;
|
||||
case PLUGINMESSAGING:
|
||||
sendPluginMessageServer(server, channel, messageData);
|
||||
break;
|
||||
case REDIS:
|
||||
sendRedisMessageServer(server, channel, messageData);
|
||||
break;
|
||||
case SOCKETS:
|
||||
ArrayList<String> data = new ArrayList<>();
|
||||
data.add(channel);
|
||||
data.addAll(ArrayUtils.convert(messageData));
|
||||
sendServerMessageServer(server, ArrayUtils.convert(data));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
globalMessageProxyHandler.addListener(new GlobalMessageListener("login") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> message) {
|
||||
if (message.size() < 2) {
|
||||
logSevere("Invalid login message received: " + message);
|
||||
return;
|
||||
}
|
||||
String player = message.get(0);
|
||||
String uuid = message.get(1);
|
||||
String server = "";
|
||||
if (message.size() > 2) {
|
||||
server = message.get(2);
|
||||
}
|
||||
debug("Login: " + player + "/" + uuid + " " + server);
|
||||
|
||||
login(player, uuid, server);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageProxyHandler.addListener(new GlobalMessageListener("statusokay") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> message) {
|
||||
String server = message.get(0);
|
||||
log("Status okay for " + server);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageProxyHandler.addListener(new GlobalMessageListener("voteupdate") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> message) {
|
||||
for (String send : getAllAvailableServers()) {
|
||||
globalMessageProxyHandler.sendMessage(send, "VoteUpdate", ArrayUtils.convert(message));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
loadMultiProxySupport();
|
||||
}
|
||||
|
||||
@@ -726,7 +811,9 @@ public abstract class VotingPluginProxy {
|
||||
public abstract void log(String message);
|
||||
|
||||
public void login(String playerName, String uuid, String serverName) {
|
||||
addNonVotedPlayer(uuid, playerName);
|
||||
if (getConfig().getOnlineMode()) { // no need to cache in offline mode
|
||||
addNonVotedPlayer(uuid, playerName);
|
||||
}
|
||||
if (isPlayerOnline(playerName)) {
|
||||
if (getConfig().getGlobalDataEnabled()) {
|
||||
if (getGlobalDataHandler().isTimeChangedHappened()) {
|
||||
@@ -764,8 +851,6 @@ public abstract class VotingPluginProxy {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(outstream);
|
||||
String subchannel = "";
|
||||
if (getConfig().getPluginMessageEncryption() && encryptionHandler != null) {
|
||||
subchannel = encryptionHandler.decrypt(in.readUTF());
|
||||
@@ -774,7 +859,7 @@ public abstract class VotingPluginProxy {
|
||||
}
|
||||
int size = in.readInt();
|
||||
|
||||
debug("Received plugin message, processing...");
|
||||
debug("Received plugin message, processing..." + subchannel + " " + size);
|
||||
|
||||
String data = "";
|
||||
if (size > 0) {
|
||||
@@ -785,39 +870,9 @@ public abstract class VotingPluginProxy {
|
||||
}
|
||||
}
|
||||
String[] list = data.split("/a/");
|
||||
// check for status message returns
|
||||
if (subchannel.equalsIgnoreCase("statusokay")) {
|
||||
String server = list[0];
|
||||
log("Status okay for " + server);
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("TimeChangeFinished")) {
|
||||
// not used currently
|
||||
} else if (subchannel.equalsIgnoreCase("login")) {
|
||||
|
||||
String player = list[0];
|
||||
String uuid = list[1];
|
||||
String server = list[2];
|
||||
debug("Login: " + player + "/" + uuid + " " + server);
|
||||
login(player, uuid, server);
|
||||
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("VoteUpdate")) {
|
||||
out.writeUTF(subchannel);
|
||||
out.writeInt(size);
|
||||
|
||||
if (getConfig().getPluginMessageEncryption() && encryptionHandler != null) {
|
||||
out.writeUTF(encryptionHandler.encrypt(data));
|
||||
} else {
|
||||
out.writeUTF(data);
|
||||
}
|
||||
for (String send : getAllAvailableServers()) {
|
||||
if (isSomeoneOnlineServer(send)) {
|
||||
sendPluginMessageData(send, getConfig().getPluginMessageChannel().toLowerCase(),
|
||||
outstream.toByteArray(), false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
debug("Ignoring plugin message: " + subchannel);
|
||||
if (list.length > 0) {
|
||||
globalMessageProxyHandler.onMessage(subchannel.toLowerCase(), ArrayUtils.convert(list));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -872,13 +927,14 @@ public abstract class VotingPluginProxy {
|
||||
|
||||
public abstract void reloadCore(boolean mysql);
|
||||
|
||||
public void sendMessageServer(String server, String channel, String... messageData) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(server, channel, messageData);
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
sendRedisMessageServer(server, channel, messageData);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* public void sendMessageServer(String server, String channel, String...
|
||||
* messageData) { if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
* sendPluginMessageServer(server, channel, messageData); } else if
|
||||
* (method.equals(BungeeMethod.REDIS)) { sendRedisMessageServer(server, channel,
|
||||
* messageData); } else if (method.equals(BungeeMethod.MQTT)) {
|
||||
* sendMqttMessageServer(server, channel, messageData); } }
|
||||
*/
|
||||
|
||||
public abstract void sendPluginMessageData(String server, String channel, byte[] data, boolean queue);
|
||||
|
||||
@@ -921,6 +977,18 @@ public abstract class VotingPluginProxy {
|
||||
redisHandler.sendMessage(getConfig().getRedisPrefix() + "VotingPlugin_" + server, ArrayUtils.convert(list));
|
||||
}
|
||||
|
||||
public void sendMqttMessageServer(String server, String channel, String... messageData) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(channel);
|
||||
list.addAll(ArrayUtils.convert(messageData));
|
||||
|
||||
try {
|
||||
mqttHandler.publish(getConfig().getMqttPrefix() + "votingplugin/servers/" + server, String.join(":", list));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendServerMessage(String... messageData) {
|
||||
for (ClientHandler h : clientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
@@ -942,45 +1010,9 @@ public abstract class VotingPluginProxy {
|
||||
|
||||
}
|
||||
|
||||
public void sendSocketVote(String name, String service, BungeeMessageData text) {
|
||||
String uuid = getUUID(name);
|
||||
|
||||
if (getConfig().getSendVotesToAllServers()) {
|
||||
sendServerMessage("bungeevote", uuid, name, service, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals());
|
||||
if (getConfig().getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
} else {
|
||||
// online server only
|
||||
|
||||
String server = "";
|
||||
if (isPlayerOnline(name)) {
|
||||
server = getCurrentPlayerServer(name);
|
||||
} else {
|
||||
server = getConfig().getFallBack();
|
||||
}
|
||||
if (getConfig().getBlockedServers().contains(server)) {
|
||||
server = getConfig().getFallBack();
|
||||
}
|
||||
|
||||
sendServerMessageServer(server, "bungeevoteonline", uuid, name, service, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals());
|
||||
if (getConfig().getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
sendServerMessage("BungeeUpdate");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sendVoteParty(String server) {
|
||||
if (isSomeoneOnlineServer(server)) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
|
||||
sendMessageServer(server, "VotePartyBungee");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessageServer(server, "VotePartyBungee");
|
||||
}
|
||||
globalMessageProxyHandler.sendMessage(server, "VotePartyBungee", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1005,20 +1037,117 @@ public abstract class VotingPluginProxy {
|
||||
public abstract void setVoteCacheVotePartyIncreaseVotesRequired(int votes);
|
||||
|
||||
public void status() {
|
||||
if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage("status");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
|
||||
for (String s : getAllAvailableServers()) {
|
||||
if (!isSomeoneOnlineServer(s)) {
|
||||
log("No players on server " + s
|
||||
+ " to send test status message, please retest with someone online");
|
||||
} else {
|
||||
// send
|
||||
log("Sending request for status message on " + s);
|
||||
sendMessageServer(s, "Status", s);
|
||||
for (String s : getAllAvailableServers()) {
|
||||
if (!isSomeoneOnlineServer(s)) {
|
||||
log("No players on server " + s + " to send test status message, please retest with someone online");
|
||||
} else {
|
||||
// send
|
||||
log("Sending request for status message on " + s);
|
||||
globalMessageProxyHandler.sendMessage(s, "Status", s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getWaitUntilDelaySiteFromService(String service) {
|
||||
for (String site : getConfig().getWaitUntilVoteDelaySites()) {
|
||||
if (getConfig().getWaitUntilVoteDelayService(site).equalsIgnoreCase(service)) {
|
||||
return site;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private long getLastVotesTime(String uuid, ArrayList<Column> cols, String site, String service) {
|
||||
long mostRecentTime = 0;
|
||||
|
||||
// Check cached online votes
|
||||
if (cachedOnlineVotes.containsKey(uuid)) {
|
||||
ArrayList<OfflineBungeeVote> onlineVotes = cachedOnlineVotes.get(uuid);
|
||||
for (OfflineBungeeVote vote : onlineVotes) {
|
||||
if (vote.getService().equalsIgnoreCase(service)) {
|
||||
mostRecentTime = Math.max(mostRecentTime, vote.getTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check cached votes
|
||||
for (ArrayList<OfflineBungeeVote> votes : cachedVotes.values()) {
|
||||
for (OfflineBungeeVote vote : votes) {
|
||||
if (vote.getUuid().equals(uuid) && vote.getService().equalsIgnoreCase(service)) {
|
||||
mostRecentTime = Math.max(mostRecentTime, vote.getTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Column d : cols) {
|
||||
if (d.getName().equalsIgnoreCase("LastVotes")) {
|
||||
|
||||
DataValue value = d.getValue();
|
||||
String[] list = value.getString().split("%line%");
|
||||
for (String str : list) {
|
||||
String[] data = str.split("//");
|
||||
if (data[0].equalsIgnoreCase(site)) {
|
||||
mostRecentTime = Math.max(mostRecentTime, Long.valueOf(data[1]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return mostRecentTime;
|
||||
}
|
||||
|
||||
public boolean checkVoteDelay(String uuid, String service, ArrayList<Column> data) {
|
||||
String site = getWaitUntilDelaySiteFromService(service);
|
||||
if (site.isEmpty()) {
|
||||
debug("No service site set for " + service + ", skipping vote delay check");
|
||||
return true;
|
||||
}
|
||||
|
||||
int voteDelay = getConfig().getWaitUntilVoteDelayVoteDelay(site);
|
||||
int voteDelayMin = getConfig().getWaitUntilVoteDelayVoteDelayMin(site);
|
||||
|
||||
long lastVote = getLastVotesTime(uuid, data, site, service);
|
||||
if (lastVote == 0) {
|
||||
debug("No last vote time found for " + uuid + "/" + service + ", skipping vote delay check");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
LocalDateTime now = getBungeeTimeChecker().getTime();
|
||||
LocalDateTime lastVoteTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(lastVote), ZoneId.systemDefault())
|
||||
.plusHours(getConfig().getTimeHourOffSet());
|
||||
|
||||
if (!getConfig().getWaitUntilVoteDelayVoteDelayDaily(site)) {
|
||||
if (voteDelay == 0 && voteDelayMin == 0) {
|
||||
debug("Vote delay is 0 for " + site + ", skipping vote delay check");
|
||||
return true;
|
||||
}
|
||||
|
||||
LocalDateTime nextvote = lastVoteTime.plusHours((long) voteDelay).plusMinutes((long) voteDelayMin);
|
||||
|
||||
return now.isAfter(nextvote);
|
||||
}
|
||||
LocalDateTime resetTime = lastVoteTime.withHour(getConfig().getWaitUntilVoteDelayVoteDelayHour(site))
|
||||
.withMinute(0).withSecond(0);
|
||||
LocalDateTime resetTimeTomorrow = resetTime.plusHours(24);
|
||||
|
||||
if (lastVoteTime.isBefore(resetTime)) {
|
||||
if (now.isAfter(resetTime)) {
|
||||
debug("Vote delay is met for " + uuid + "/" + service + ", vote can be processed");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (now.isAfter(resetTimeTomorrow)) {
|
||||
debug("Vote delay is met for " + uuid + "/" + service + ", vote can be processed");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
debug("Vote delay is not met for " + uuid + "/" + service + ", skipping vote");
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized void vote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
|
||||
@@ -1043,6 +1172,15 @@ public abstract class VotingPluginProxy {
|
||||
|
||||
if (uuid == null || uuid.isEmpty()) {
|
||||
uuid = getUUID(player);
|
||||
if (uuid.isEmpty() && !getConfig().getBedrockPlayerPrefix().isEmpty()
|
||||
&& !player.startsWith(getConfig().getBedrockPlayerPrefix())) {
|
||||
String uuid1 = getUUID(getConfig().getBedrockPlayerPrefix() + player);
|
||||
if (!uuid1.isEmpty()) {
|
||||
debug("Detected bedrock player without prefix, adjusting...");
|
||||
player = getConfig().getBedrockPlayerPrefix() + player;
|
||||
uuid = uuid1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uuid.isEmpty()) {
|
||||
@@ -1095,6 +1233,11 @@ public abstract class VotingPluginProxy {
|
||||
ArrayList<Column> data = getProxyMySQL()
|
||||
.getExactQuery(new Column("uuid", new DataValueString(uuid)));
|
||||
|
||||
if (!checkVoteDelay(uuid, service, data)) {
|
||||
log("Vote delay is not met for " + player + "/" + service + ", skipping vote");
|
||||
return;
|
||||
}
|
||||
|
||||
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
|
||||
int monthTotal = getValue(data, "MonthTotal", 1);
|
||||
int dateMonthTotal = -1;
|
||||
@@ -1148,71 +1291,68 @@ public abstract class VotingPluginProxy {
|
||||
time = queueTime;
|
||||
}
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
|
||||
|
||||
if (getConfig().getSendVotesToAllServers()) {
|
||||
for (String s : getAllAvailableServers()) {
|
||||
boolean forceCache = false;
|
||||
if (!isPlayerOnline(player) && getConfig().getWaitForUserOnline()) {
|
||||
forceCache = true;
|
||||
debug("Forcing vote to cache");
|
||||
}
|
||||
if (getConfig().getBroadcast()) {
|
||||
sendMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
if (!isSomeoneOnlineServer(s) || forceCache) {
|
||||
// cache
|
||||
if (!cachedVotes.containsKey(s)) {
|
||||
cachedVotes.put(s, new ArrayList<>());
|
||||
}
|
||||
ArrayList<OfflineBungeeVote> list = cachedVotes.get(s);
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
|
||||
cachedVotes.put(s, list);
|
||||
|
||||
debug("Caching vote for " + player + " on " + service + " for " + s);
|
||||
|
||||
} else {
|
||||
// send
|
||||
sendMessageServer(s, "Vote", player, uuid, service, "" + time, Boolean.TRUE.toString(),
|
||||
"" + realVote, text.toString(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + getConfig().getBroadcast(), "1",
|
||||
"1");
|
||||
}
|
||||
|
||||
if (getConfig().getSendVotesToAllServers()) {
|
||||
for (String s : getAllAvailableServers()) {
|
||||
boolean forceCache = false;
|
||||
if (!isPlayerOnline(player) && getConfig().getWaitForUserOnline()) {
|
||||
forceCache = true;
|
||||
debug("Forcing vote to cache");
|
||||
}
|
||||
} else {
|
||||
if (isPlayerOnline(player) && getAllAvailableServers().contains(getCurrentPlayerServer(player))) {
|
||||
sendMessageServer(getCurrentPlayerServer(player), "VoteOnline", player, uuid, service,
|
||||
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
if (getConfig().getBroadcast()) {
|
||||
|
||||
globalMessageProxyHandler.sendMessage(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
if ((!isSomeoneOnlineServer(s) && method.requiresPlayerOnline()) || forceCache) {
|
||||
// cache
|
||||
if (!cachedVotes.containsKey(s)) {
|
||||
cachedVotes.put(s, new ArrayList<>());
|
||||
}
|
||||
ArrayList<OfflineBungeeVote> list = cachedVotes.get(s);
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
|
||||
cachedVotes.put(s, list);
|
||||
|
||||
debug("Caching vote for " + player + " on " + service + " for " + s);
|
||||
|
||||
} else {
|
||||
// send
|
||||
globalMessageProxyHandler.sendMessage(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
|
||||
"" + getConfig().getBroadcast(), "1", "1");
|
||||
if (getConfig().getMultiProxySupport() && getConfig().getMultiProxyOneGlobalReward()) {
|
||||
multiProxyHandler.sendMultiProxyServerMessage("ClearVote", player, uuid);
|
||||
}
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<>());
|
||||
}
|
||||
ArrayList<OfflineBungeeVote> list = cachedOnlineVotes.get(uuid);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
|
||||
cachedOnlineVotes.put(uuid, list);
|
||||
debug("Caching online vote for " + player + " on " + service);
|
||||
}
|
||||
for (String s : getAllAvailableServers()) {
|
||||
if (getConfig().getBroadcast()) {
|
||||
sendMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
sendMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired, text.toString());
|
||||
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendSocketVote(player, service, text);
|
||||
} else {
|
||||
if (isPlayerOnline(player) && getAllAvailableServers().contains(getCurrentPlayerServer(player))) {
|
||||
globalMessageProxyHandler.sendMessage(getCurrentPlayerServer(player), "VoteOnline", player, uuid,
|
||||
service, "" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
|
||||
"" + getConfig().getBroadcast(), "1", "1");
|
||||
if (getConfig().getMultiProxySupport() && getConfig().getMultiProxyOneGlobalReward()) {
|
||||
multiProxyHandler.sendMultiProxyServerMessage("ClearVote", player, uuid);
|
||||
}
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<>());
|
||||
}
|
||||
ArrayList<OfflineBungeeVote> list = cachedOnlineVotes.get(uuid);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
|
||||
cachedOnlineVotes.put(uuid, list);
|
||||
debug("Caching online vote for " + player + " on " + service);
|
||||
}
|
||||
for (String s : getAllAvailableServers()) {
|
||||
if (getConfig().getBroadcast()) {
|
||||
globalMessageProxyHandler.sendMessage(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
globalMessageProxyHandler.sendMessage(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired, text.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (getConfig().getMultiProxySupport() && getConfig().getPrimaryServer()) {
|
||||
if (!getConfig().getMultiProxyOneGlobalReward()) {
|
||||
debug("Seending global proxy vote message");
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package com.bencodez.votingplugin.bungee.proxy;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
|
||||
public class VotingPluginProxyCommand {
|
||||
private VotingPluginProxy plugin;
|
||||
+23
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.proxy;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -28,6 +28,16 @@ public interface VotingPluginProxyConfig {
|
||||
|
||||
public boolean getDebug();
|
||||
|
||||
public String getMqttClientID();
|
||||
|
||||
public String getMqttBrokerURL();
|
||||
|
||||
public String getMqttUsername();
|
||||
|
||||
public String getMqttPassword();
|
||||
|
||||
public String getMqttPrefix();
|
||||
|
||||
public String getFallBack();
|
||||
|
||||
public boolean getGlobalDataEnabled();
|
||||
@@ -120,6 +130,18 @@ public interface VotingPluginProxyConfig {
|
||||
|
||||
public List<String> getWhiteListedServers();
|
||||
|
||||
public Collection<String> getWaitUntilVoteDelaySites();
|
||||
|
||||
public String getWaitUntilVoteDelayService(String site);
|
||||
|
||||
public int getWaitUntilVoteDelayVoteDelay(String site);
|
||||
|
||||
public int getWaitUntilVoteDelayVoteDelayMin(String site);
|
||||
|
||||
public int getWaitUntilVoteDelayVoteDelayHour(String site);
|
||||
|
||||
public boolean getWaitUntilVoteDelayVoteDelayDaily(String site);
|
||||
|
||||
public void load();
|
||||
|
||||
public void save();
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
+112
-2
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -9,7 +9,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.proxy.VotingPluginProxyConfig;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
@@ -33,226 +33,306 @@ public class Config implements VotingPluginProxyConfig {
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAllowUnJoined() {
|
||||
return getData().getBoolean("AllowUnJoined", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBedrockPlayerPrefix() {
|
||||
return getData().getString("BedrockPlayerPrefix", ".");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBlockedServers() {
|
||||
return getData().getStringList("BlockedServers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBroadcast() {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBungeeHost() {
|
||||
return getData().getString("BungeeServer.Host", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBungeeManageTotals() {
|
||||
return getData().getBoolean("BungeeManageTotals", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBungeeMethod() {
|
||||
return getData().getString("BungeeMethod", "SOCKETS");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBungeePort() {
|
||||
return getData().getInt("BungeeServer.Port", 1297);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDebug() {
|
||||
return getData().getBoolean("Debug", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFallBack() {
|
||||
return getData().getString("FallBackServer", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGlobalDataEnabled() {
|
||||
return getData().getBoolean("GlobalData.Enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGlobalDataUseMainMySQL() {
|
||||
return getData().getBoolean("GlobalData.UseMainMySQL", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLimitVotePoints() {
|
||||
return getData().getInt("LimitVotePoints", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxAmountOfVotesPerDay() {
|
||||
return getData().getInt("MaxAmountOfVotesPerDay", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyMethod() {
|
||||
return getData().getString("MultiProxyMethod", "SOCKET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMultiProxyOneGlobalReward() {
|
||||
return getData().getBoolean("MultiProxyOneGlobalReward", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyRedisHost() {
|
||||
return getData().getString("MultiProxyRedis.Host", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyRedisPassword() {
|
||||
return getData().getString("MultiProxyRedis.Password", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultiProxyRedisPort() {
|
||||
return getData().getInt("MultiProxyRedis.Port", 6379);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMultiProxyRedisUseExistingConnection() {
|
||||
return getData().getBoolean("MultiProxyRedis.UseExistingConnection", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyRedisUsername() {
|
||||
return getData().getString("MultiProxyRedis.Username", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getMultiProxyServers() {
|
||||
return getData().getSection("MultiProxyServers").getKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMultiProxyServersConfiguration(String s) {
|
||||
return configToMap(getData().getSection("MultiProxyServers." + s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxySocketHostHost() {
|
||||
return getData().getString("MultiProxySocketHost.Host", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultiProxySocketHostPort() {
|
||||
return getData().getInt("MultiProxySocketHost.Port", 1297);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMultiProxySupport() {
|
||||
return getData().getBoolean("MultiProxySupport", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getOnlineMode() {
|
||||
return getData().getBoolean("OnlineMode", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPrimaryServer() {
|
||||
return getData().getBoolean("PrimaryServer", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProxyServerName() {
|
||||
return getData().getString("ProxyServerName", "SOCKET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getProxyServers() {
|
||||
return getData().getStringList("ProxyServers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedisHost() {
|
||||
return getData().getString("Redis.Host", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedisPassword() {
|
||||
return getData().getString("Redis.Password", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedisPort() {
|
||||
return getData().getInt("Redis.Port", 6379);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedisPrefix() {
|
||||
return getData().getString("Redis.Prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedisUsername() {
|
||||
return getData().getString("Redis.Username", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getData().getBoolean("SendVotesToAllServers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSpigotServerConfiguration(String s) {
|
||||
return configToMap(getData().getSection("SpigotServers." + s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getSpigotServers() {
|
||||
return getData().getSection("SpigotServers").getKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getStoreMonthTotalsWithDate() {
|
||||
return getData().getBoolean("StoreMonthTotalsWithDate", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getTimeChangeFailSafeBypass() {
|
||||
return getData().getBoolean("TimeChangeFailSafeBypass", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTimeHourOffSet() {
|
||||
return getData().getInt("TimeHourOffSet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTimeZone() {
|
||||
return getData().getString("TimeZone", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseMonthDateTotalsAsPrimaryTotal() {
|
||||
return getData().getBoolean("UseMonthDateTotalsAsPrimaryTotal", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUUIDLookup() {
|
||||
return getData().getBoolean("UUIDLookup", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCacheTime() {
|
||||
return getData().getInt("VoteCacheTime", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVotePartyBroadcast() {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVotePartyBungeeCommands() {
|
||||
return getData().getStringList("VoteParty.BungeeCommands");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getData().getBoolean("VoteParty.Enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVotePartyIncreaseVotesRequired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRequired", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getVotePartySendToAllServers() {
|
||||
return getData().getBoolean("VoteParty.SendToAllServers", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getData().getStringList("VoteParty.ServersToSend");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getData().getInt("VoteParty.VotesRequired", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getData().getBoolean("WaitForUserOnline", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWhiteListedServers() {
|
||||
return getData().getStringList("WhiteListedServers");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMqttClientID() {
|
||||
return getData().getString("MQTT.ClientID", "proxy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMqttBrokerURL() {
|
||||
return getData().getString("MQTT.BrokerURL", "tcp://localhost:1883");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMqttUsername() {
|
||||
return getData().getString("MQTT.Username", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMqttPassword() {
|
||||
return getData().getString("MQTT.Password", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMqttPrefix() {
|
||||
return getData().getString("MQTT.Prefix", "");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
@@ -294,4 +374,34 @@ public class Config implements VotingPluginProxyConfig {
|
||||
return getData().getBoolean("PluginMessageEncryption", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getWaitUntilVoteDelaySites() {
|
||||
return getData().getSection("WaitUntilVoteDelay").getKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWaitUntilVoteDelayService(String site) {
|
||||
return getData().getString("WaitUntilVoteDelay." + site + ".ServiceSite", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaitUntilVoteDelayVoteDelay(String site) {
|
||||
return getData().getInt("WaitUntilVoteDelay." + site + ".VoteDelay", 24);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWaitUntilVoteDelayVoteDelayDaily(String site) {
|
||||
return getData().getBoolean("WaitUntilVoteDelay." + site + ".VoteDelayDaily", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaitUntilVoteDelayVoteDelayHour(String site) {
|
||||
return getData().getInt("WaitUntilVoteDelay." + site + ".VoteDelayDailyHour", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaitUntilVoteDelayVoteDelayMin(String site) {
|
||||
return getData().getInt("WaitUntilVoteDelay." + site + ".VoteDelayMin", 0);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.simpleapi.file.BungeeJsonFile;
|
||||
import com.bencodez.votingplugin.proxy.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import com.vexsoftware.votifier.bungee.events.VotifierEvent;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
+34
-13
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
@@ -20,13 +20,16 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigBungee;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.mysql.BungeeMySQL;
|
||||
import com.bencodez.votingplugin.bungee.proxy.VotingPluginProxy;
|
||||
import com.bencodez.votingplugin.bungee.proxy.VotingPluginProxyConfig;
|
||||
import com.bencodez.simpleapi.sql.DataType;
|
||||
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfigBungee;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.BungeeVersion;
|
||||
import com.bencodez.votingplugin.proxy.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.proxy.ProxyMysqlUserTable;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxy;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -133,7 +136,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
private void loadMysql() {
|
||||
votingPluginProxy.setProxyMySQL(new BungeeMySQL(this, "VotingPlugin_Users", config.getData()) {
|
||||
votingPluginProxy.setProxyMySQL(new ProxyMysqlUserTable("VotingPlugin_Users",
|
||||
new MysqlConfigBungee(config.getData()), config.getDebug()) {
|
||||
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
@@ -141,6 +145,23 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String string) {
|
||||
getLogger().severe(string);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logInfo(String string) {
|
||||
getLogger().info(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String string) {
|
||||
getLogger().severe(string);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ArrayList<String> servers = new ArrayList<>();
|
||||
@@ -154,14 +175,14 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", getVotingPluginProxy().getProxyMySQL().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
public void debugEx(Exception e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
public void debugLog(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
|
||||
@@ -172,7 +193,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
public void logSevere(String text) {
|
||||
getLogger().severe(text);
|
||||
}
|
||||
|
||||
@@ -220,14 +241,14 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
new MysqlConfigBungee(config.getData().getSection("GlobalData"))) {
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
public void debugEx(Exception e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
public void debugLog(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
|
||||
@@ -238,7 +259,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
public void logSevere(String text) {
|
||||
getLogger().severe(text);
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.proxy.VotingPluginProxyCommand;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyCommand;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@@ -22,7 +22,7 @@ public class VotingPluginBungeeCommand extends Command {
|
||||
sender.sendMessage(new TextComponent(result.replace("&", "§")));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("&cYou do not have permission to do this!"));
|
||||
sender.sendMessage(new TextComponent("&cYou do not have permission to do this!".replace("&", "§")));
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -1,17 +1,17 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
package com.bencodez.votingplugin.proxy.multiproxy;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisListener;
|
||||
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.simpleapi.encryption.EncryptionHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisListener;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.ClientHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketReceiver;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMessageData;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class MultiProxyHandler {
|
||||
if (getMultiProxySupportEnabled()) {
|
||||
if (getMultiProxyMethod().equals(MultiProxyMethod.SOCKETS)) {
|
||||
if (getEncryptionHandler() == null) {
|
||||
setEncryptionHandler(new EncryptionHandler(new File(getPluginDataFolder(), "secretkey.key")));
|
||||
setEncryptionHandler(new EncryptionHandler("VotingPlugin",new File(getPluginDataFolder(), "secretkey.key")));
|
||||
}
|
||||
|
||||
if (multiproxySocketHandler != null) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
package com.bencodez.votingplugin.proxy.multiproxy;
|
||||
|
||||
public enum MultiProxyMethod {
|
||||
SOCKETS, REDIS;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
package com.bencodez.votingplugin.proxy.multiproxy;
|
||||
|
||||
public interface MultiProxyServerSocketConfiguration {
|
||||
String getHost();
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
package com.bencodez.votingplugin.proxy.multiproxy;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
package com.bencodez.votingplugin.proxy.multiproxy;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
+112
-2
@@ -1,7 +1,8 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
package com.bencodez.votingplugin.proxy.velocity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -9,7 +10,7 @@ import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import com.bencodez.simpleapi.file.velocity.VelocityYMLFile;
|
||||
import com.bencodez.votingplugin.bungee.proxy.VotingPluginProxyConfig;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
@@ -19,90 +20,113 @@ public class Config extends VelocityYMLFile implements VotingPluginProxyConfig {
|
||||
super(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAllowUnJoined() {
|
||||
return getBoolean(getNode("AllowUnJoined"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBedrockPlayerPrefix() {
|
||||
return getString(getNode("BedrockPlayerPrefix"), ".");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public List<String> getBlockedServers() {
|
||||
return getStringList(getNode("BlockedServers"), new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBroadcast() {
|
||||
return getBoolean(getNode("Broadcast"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBungeeManageTotals() {
|
||||
return getBoolean(getNode("BungeeManageTotals"), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBungeeMethod() {
|
||||
return getString(getNode("BungeeMethod"), "PLUGINMESSAGING");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBungeePort() {
|
||||
return getInt(getNode("BungeeServer", "Port"), 1297);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDebug() {
|
||||
return getBoolean(getNode("Debug"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFallBack() {
|
||||
return getString(getNode("FallBackServer"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGlobalDataEnabled() {
|
||||
return getBoolean(getNode("GlobalData", "Enabled"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGlobalDataUseMainMySQL() {
|
||||
return getBoolean(getNode("GlobalData", "UseMainMySQL"), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLimitVotePoints() {
|
||||
return getInt(getNode("LimitVotePoints"), -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxAmountOfVotesPerDay() {
|
||||
return getInt(getNode("MaxAmountOfVotesPerDay"), -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyMethod() {
|
||||
return getString(getNode("MultiProxyMethod"), "SOCKET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMultiProxyOneGlobalReward() {
|
||||
return getBoolean(getNode("MultiProxyOneGlobalReward"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyRedisHost() {
|
||||
return getString(getNode("MultiProxyRedis", "Host"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyRedisPassword() {
|
||||
return getString(getNode("MultiProxyRedis", "Password"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultiProxyRedisPort() {
|
||||
return getInt(getNode("MultiProxyRedis", "Port"), 6379);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMultiProxyRedisUseExistingConnection() {
|
||||
return getBoolean(getNode("MultiProxyRedis", "UseExistingConnection"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyRedisUsername() {
|
||||
return getString(getNode("MultiProxyRedis", "Username"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<String> getMultiProxyServers() {
|
||||
return getChildrenAsList(getNode("MultiProxyServers"));
|
||||
}
|
||||
@@ -117,18 +141,22 @@ public class Config extends VelocityYMLFile implements VotingPluginProxyConfig {
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMultiProxyServersConfiguration(String s) {
|
||||
return configToMap(getNode("MultiProxyServers", s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxySocketHostHost() {
|
||||
return getString(getNode("MultiProxySocketHost", "Host"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultiProxySocketHostPort() {
|
||||
return getInt(getNode("MultiProxySocketHost", "Port"), 1297);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMultiProxySupport() {
|
||||
return getBoolean(getNode("MultiProxySupport"), false);
|
||||
}
|
||||
@@ -137,54 +165,91 @@ public class Config extends VelocityYMLFile implements VotingPluginProxyConfig {
|
||||
return getNode("MySQL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getOnlineMode() {
|
||||
return getBoolean(getNode("OnlineMode"), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPointsOnVote() {
|
||||
return getInt(getNode("PointsOnVote"), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPrimaryServer() {
|
||||
return getBoolean(getNode("PrimaryServer"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProxyServerName() {
|
||||
return getString(getNode("ProxyServerName"), "SOCKET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getProxyServers() {
|
||||
return getStringList(getNode("ProxyServers"), new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedisHost() {
|
||||
return getString(getNode("Redis", "Host"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedisPassword() {
|
||||
return getString(getNode("Redis", "Password"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedisPort() {
|
||||
return getInt(getNode("Redis", "Port"), 6379);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedisPrefix() {
|
||||
return getString(getNode("Redis", "Prefix"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedisUsername() {
|
||||
return getString(getNode("Redis", "Username"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getBoolean(getNode("SendVotesToAllServers"), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getSpigotServerConfiguration(String s) {
|
||||
return configToMap(getNode("SpigotServers", s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMqttClientID() {
|
||||
return getString(getNode("MQTT", "ClientID"), "proxy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMqttBrokerURL() {
|
||||
return getString(getNode("MQTT", "BrokerURL"), "tcp://localhost:1883");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMqttUsername() {
|
||||
return getString(getNode("MQTT", "Username"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMqttPassword() {
|
||||
return getString(getNode("MQTT", "Password"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMqttPrefix() {
|
||||
return getString(getNode("MQTT", "Prefix"), "");
|
||||
}
|
||||
|
||||
public Map<String, Object> configToMap(ConfigurationNode config) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (config != null) {
|
||||
@@ -195,42 +260,52 @@ public class Config extends VelocityYMLFile implements VotingPluginProxyConfig {
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<String> getSpigotServers() {
|
||||
return getChildrenAsList(getNode("SpigotServers"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getStoreMonthTotalsWithDate() {
|
||||
return getBoolean(getNode("StoreMonthTotalsWithDate"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getTimeChangeFailSafeBypass() {
|
||||
return getBoolean(getNode("TimeChangeFailSafeBypass"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseMonthDateTotalsAsPrimaryTotal() {
|
||||
return getBoolean(getNode("UseMonthDateTotalsAsPrimaryTotal"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUUIDLookup() {
|
||||
return getBoolean(getNode("UUIDLookup"), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCacheTime() {
|
||||
return getInt(getNode("VoteCacheTime"), -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVotePartyBroadcast() {
|
||||
return getString(getVotePartyNode().getNode("Broadcast"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVotePartyBungeeCommands() {
|
||||
return getStringList(getVotePartyNode().getNode("BungeeCommands"), new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getBoolean(getVotePartyNode().getNode("Enabled"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVotePartyIncreaseVotesRequired() {
|
||||
return getInt(getVotePartyNode().getNode("IncreaseVotesRequired"), 0);
|
||||
}
|
||||
@@ -239,22 +314,27 @@ public class Config extends VelocityYMLFile implements VotingPluginProxyConfig {
|
||||
return getNode("VoteParty");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getVotePartySendToAllServers() {
|
||||
return getBoolean(getVotePartyNode().getNode("SendToAllServers"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getStringList(getVotePartyNode().getNode("ServersToSend"), new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getInt(getVotePartyNode().getNode("VotesRequired"), 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getBoolean(getNode("WaitForUserOnline"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWhiteListedServers() {
|
||||
return getStringList(getNode("WhiteListedServers"), new ArrayList<>());
|
||||
}
|
||||
@@ -285,4 +365,34 @@ public class Config extends VelocityYMLFile implements VotingPluginProxyConfig {
|
||||
return getBoolean(getNode("PluginMessageEncryption"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getWaitUntilVoteDelaySites() {
|
||||
return getChildrenAsList(getNode("WaitUntilVoteDelay"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWaitUntilVoteDelayService(String site) {
|
||||
return getString(getNode("WaitUntilVoteDelay", site, "ServiceSite"), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaitUntilVoteDelayVoteDelay(String site) {
|
||||
return getInt(getNode("WaitUntilVoteDelay", site, "VoteDelay"), 24);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWaitUntilVoteDelayVoteDelayDaily(String site) {
|
||||
return getBoolean(getNode("WaitUntilVoteDelay", site, "VoteDelayDaily"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaitUntilVoteDelayVoteDelayHour(String site) {
|
||||
return getInt(getNode("WaitUntilVoteDelay", site, "VoteDelayDailyHour"), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaitUntilVoteDelayVoteDelayMin(String site) {
|
||||
return getInt(getNode("WaitUntilVoteDelay", site, "VoteDelayMin"), 0);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
package com.bencodez.votingplugin.proxy.velocity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
package com.bencodez.votingplugin.proxy.velocity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.simpleapi.file.velocity.VelocityJSONFile;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.proxy.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
package com.bencodez.votingplugin.proxy.velocity;
|
||||
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.vexsoftware.votifier.velocity.event.VotifierEvent;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
package com.bencodez.votingplugin.proxy.velocity;
|
||||
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
|
||||
+50
-36
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
package com.bencodez.votingplugin.proxy.velocity;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
@@ -31,17 +31,17 @@ import org.bstats.velocity.Metrics;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigVelocity;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.mysql.VelocityMySQL;
|
||||
import com.bencodez.simpleapi.file.velocity.VelocityYMLFile;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.bungee.proxy.VotingPluginProxy;
|
||||
import com.bencodez.votingplugin.bungee.proxy.VotingPluginProxyConfig;
|
||||
import com.bencodez.simpleapi.sql.DataType;
|
||||
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfigVelocity;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.BungeeVersion;
|
||||
import com.bencodez.votingplugin.proxy.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.proxy.ProxyMysqlUserTable;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxy;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.google.inject.Inject;
|
||||
@@ -61,7 +61,7 @@ import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
|
||||
@@ -191,20 +191,31 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
private void loadMysql() {
|
||||
votingPluginProxy.setProxyMySQL(new VelocityMySQL("VotingPlugin_Users", config) {
|
||||
votingPluginProxy.setProxyMySQL(
|
||||
new ProxyMysqlUserTable("VotingPlugin_Users", new MysqlConfigVelocity(config), config.getDebug()) {
|
||||
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String str) {
|
||||
getLogger().error(str);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void severe(String str) {
|
||||
getLogger().error(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String string) {
|
||||
logger.error(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logInfo(String string) {
|
||||
logger.info(string);
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<String> servers = new ArrayList<>();
|
||||
for (String s : getAvailableAllServers()) {
|
||||
@@ -217,14 +228,14 @@ public class VotingPluginVelocity {
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", getVotingPluginProxy().getProxyMySQL().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
public void debugEx(Exception e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
public void debugLog(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
|
||||
@@ -234,7 +245,7 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
public void logSevere(String text) {
|
||||
logger.error(text);
|
||||
}
|
||||
|
||||
@@ -280,14 +291,14 @@ public class VotingPluginVelocity {
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigVelocity("GlobalData", config)) {
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
public void debugEx(Exception e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
public void debugLog(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
|
||||
@@ -297,7 +308,7 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
public void logSevere(String text) {
|
||||
logger.error(text);
|
||||
}
|
||||
|
||||
@@ -395,10 +406,10 @@ public class VotingPluginVelocity {
|
||||
if (event.getIdentifier().getId().equals(CHANNEL.getId())) {
|
||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
|
||||
if (!(event.getSource() instanceof ServerConnection)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getSource() instanceof ServerConnection)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayInputStream instream = new ByteArrayInputStream(event.getData());
|
||||
DataInputStream in = new DataInputStream(instream);
|
||||
try {
|
||||
@@ -496,7 +507,8 @@ public class VotingPluginVelocity {
|
||||
|
||||
@Override
|
||||
public void broadcast(String message) {
|
||||
server.getAllPlayers().forEach(player -> player.sendMessage(Component.text(message)));
|
||||
server.getAllPlayers().forEach(
|
||||
player -> player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -517,8 +529,10 @@ public class VotingPluginVelocity {
|
||||
@Override
|
||||
public String getCurrentPlayerServer(String player) {
|
||||
if (server.getPlayer(player).isPresent()) {
|
||||
return server.getPlayer(player).get().getCurrentServer().get().getServer().getServerInfo()
|
||||
.getName();
|
||||
if (server.getPlayer(player).get().getCurrentServer().isPresent()) {
|
||||
return server.getPlayer(player).get().getCurrentServer().get().getServer().getServerInfo()
|
||||
.getName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -903,7 +917,7 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
public void reloadPlugin(boolean loadMysql) {
|
||||
config.load();
|
||||
config.reload();
|
||||
if (loadMysql) {
|
||||
try {
|
||||
if (!config.getString(config.getNode("Host"), "").isEmpty()) {
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
package com.bencodez.votingplugin.proxy.velocity;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.proxy.VotingPluginProxyCommand;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyCommand;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class VotingPluginVelocityCommand implements SimpleCommand {
|
||||
|
||||
String result = new VotingPluginProxyCommand(plugin.getVotingPluginProxy()).execute(args);
|
||||
if (result != null) {
|
||||
source.sendMessage(Component.text(result));
|
||||
source.sendMessage(Component.text(result.replace("&", "§")));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.bencodez.votingplugin.signs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -9,6 +10,7 @@ import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
@@ -37,13 +39,12 @@ public class SignHandler {
|
||||
@Setter
|
||||
private Location location;
|
||||
|
||||
/** The player name. */
|
||||
private String playerName;
|
||||
|
||||
/** The plugin. */
|
||||
private UUID uuid;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/** The position. */
|
||||
private int position;
|
||||
|
||||
@Getter
|
||||
@@ -58,7 +59,6 @@ public class SignHandler {
|
||||
@Setter
|
||||
private boolean valid;
|
||||
|
||||
/** The votes. */
|
||||
private int votes;
|
||||
|
||||
public SignHandler(VotingPluginMain plugin, String sign, Location location, Location skullLocation, String data,
|
||||
@@ -80,8 +80,17 @@ public class SignHandler {
|
||||
if (block.getState() instanceof Skull) {
|
||||
if (!playerName.equals("No Player")) {
|
||||
Skull skull = (Skull) block.getState();
|
||||
skull.setOwner(playerName);
|
||||
skull.update();
|
||||
try {
|
||||
SkullMeta meta = (SkullMeta) plugin.getSkullCacheHandler().getSkull(uuid, playerName).getItemMeta();
|
||||
skull.setOwnerProfile(meta.getOwnerProfile());
|
||||
skull.update(true, false);
|
||||
} catch (Exception e) {
|
||||
plugin.debug("Failed to set skull for " + playerName);
|
||||
plugin.debug(e);
|
||||
skull.setOwner(playerName);
|
||||
skull.update(true, false);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -200,6 +209,7 @@ public class SignHandler {
|
||||
if (users != null && users.size() >= position) {
|
||||
TopVoterPlayer user = users.get(position - 1);
|
||||
playerName = user.getPlayerName();
|
||||
uuid = user.getUuid();
|
||||
|
||||
votes = 0;
|
||||
if (data.equalsIgnoreCase("all")) {
|
||||
|
||||
+1
-1
@@ -11,9 +11,9 @@ import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
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.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.PreDateChangedEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.YMLFileHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.sql.Column;
|
||||
import com.bencodez.simpleapi.sql.DataType;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.bencodez.advancedcore.api.user.usercache.UserDataManager;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyBoolean;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyString;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.simpleapi.sql.Column;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
|
||||
@@ -24,15 +24,15 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.sql.data.DataValue;
|
||||
import com.bencodez.simpleapi.sql.data.DataValueInt;
|
||||
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.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
|
||||
@@ -1010,6 +1010,18 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return amount;
|
||||
}
|
||||
|
||||
public int getTotalNumberOfSites() {
|
||||
int amount = 0;
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
if (site.getPermissionToView().isEmpty() || hasPermission(site.getPermissionToView())) {
|
||||
amount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
public int getSitesVotedOn() {
|
||||
int amount = 0;
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
@@ -1377,6 +1389,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
Player player = getPlayer();
|
||||
if (!plugin.getOptions().isOnlineMode()) {
|
||||
player = Bukkit.getPlayer(getPlayerName());
|
||||
}
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ 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.userstorage.DataType;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.sql.DataType;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.VotePartyEvent;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -11,10 +11,11 @@ UseBungeecord: false
|
||||
# Requires restart and set on all servers
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING (Recommended)
|
||||
# MYSQL
|
||||
# REDIS (2nd Most Recommended)
|
||||
# MQTT
|
||||
# MYSQL
|
||||
# SOCKETS (Not recommended)
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
# Use Redis for between server communication, set BungeeMethod to REDIS to use this
|
||||
@@ -26,6 +27,16 @@ Redis:
|
||||
Password: ''
|
||||
# Set a prefix from an entire proxy network if using multi-proxy setup below
|
||||
Prefix: ''
|
||||
|
||||
MQTT:
|
||||
# clientid must be unique on each server
|
||||
# Default will use the server name below
|
||||
#ClientID: 'server1'
|
||||
BrokerURL: "tcp://localhost:1883"
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Set a prefix from an entire proxy network if using mutli-proxy setup below
|
||||
Prefix: ''
|
||||
|
||||
# Enables more debug messages for communication between servers
|
||||
# Use /votingpluginbungee status for testing communication
|
||||
|
||||
@@ -480,8 +480,8 @@ TreatVanishAsOffline: false
|
||||
# In miliseconds, 1000 = 1 second
|
||||
DelayLoginEvent: 0
|
||||
|
||||
# Wait until user is logged in with AuthMe
|
||||
# Requires AuthMe or LoginSecurity
|
||||
# Wait until user is logged in with AuthMe or NLogin
|
||||
# Requires AuthMe or LoginSecurity or NLogin
|
||||
WaitUntilLoggedIn: true
|
||||
|
||||
###########################################
|
||||
@@ -569,6 +569,9 @@ OnlineMode: true
|
||||
# Disable javascript processing in messages/rewards
|
||||
DisableJavascript: false
|
||||
|
||||
# Enable command /av javascript (javascript)
|
||||
EnableJavascriptCommand: false
|
||||
|
||||
# If true, number of vote shop purchases will be tracked
|
||||
# Data will be tracked in serverdata.yml, may change in the future
|
||||
# No commands to view data currently
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.bencodez.votingplugin.bungee.VotingPluginBungee
|
||||
main: com.bencodez.votingplugin.proxy.bungee.VotingPluginBungee
|
||||
author: BenCodez
|
||||
softDepends:
|
||||
- RedisBungee
|
||||
@@ -55,9 +55,7 @@ GlobalData:
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# Time offset for time changes
|
||||
# Must match on all servers
|
||||
TimeHourOffSet: 0
|
||||
|
||||
|
||||
####################################################################################
|
||||
|
||||
@@ -79,12 +77,22 @@ WhiteListedServers: []
|
||||
# Requires restart and set on all servers
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecoord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING (Recommended)
|
||||
# MYSQL
|
||||
# REDIS
|
||||
# MQTT
|
||||
# SOCKETS
|
||||
# MYSQL (Not recommended)
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
|
||||
|
||||
######################################################################################
|
||||
# Settings for each setup below
|
||||
|
||||
###########################################
|
||||
# PLUGINMESSAGING settings
|
||||
###########################################
|
||||
|
||||
# Default is vp:vp, can be changed to prevent potential exploits
|
||||
# Must match on all servers
|
||||
# This setting requires a restart
|
||||
@@ -96,6 +104,10 @@ PluginMessageChannel: "vp:vp"
|
||||
# This setting requires a restart
|
||||
PluginMessageEncryption: false
|
||||
|
||||
###########################################
|
||||
# REDIS Settings
|
||||
###########################################
|
||||
|
||||
# Use Redis for between server communication, set BungeeMethod to REDIS to use this
|
||||
Redis:
|
||||
Host: localhost
|
||||
@@ -104,6 +116,32 @@ Redis:
|
||||
Password: ''
|
||||
# Set a prefix from an entire proxy network if using mutli-proxy setup below
|
||||
Prefix: ''
|
||||
|
||||
###########################################
|
||||
# SOCKETS Settings
|
||||
###########################################
|
||||
|
||||
# Settings hidden to avoid confusion, highly recommend other methods first
|
||||
# Settings available here https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
|
||||
###########################################
|
||||
# MQTT Settings
|
||||
###########################################
|
||||
|
||||
MQTT:
|
||||
# clientid must be unique on each server
|
||||
ClientID: 'proxy'
|
||||
BrokerURL: "tcp://localhost:1883"
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Set a prefix from an entire proxy network if using mutli-proxy setup below
|
||||
Prefix: ''
|
||||
|
||||
######################################################################################
|
||||
|
||||
# Votes will be forwarded when specific player is online
|
||||
# If set to false, rewards should still reward when player logs in (by default)
|
||||
WaitForUserOnline: false
|
||||
|
||||
# If false, votes will be checked if user is a valid player that has joined to server
|
||||
# Works for PLUGINMESSAGING and SOCKETS methods only
|
||||
@@ -142,6 +180,10 @@ MaxAmountOfVotesPerDay: -1
|
||||
# Maxium amount of vote points possible, -1 to disable
|
||||
LimitVotePoints: -1
|
||||
|
||||
# Time offset for time changes
|
||||
# Must match on all servers
|
||||
TimeHourOffSet: 0
|
||||
|
||||
VoteParty:
|
||||
# If enabled, will trigger vote party reward
|
||||
# in BungeeSettings.yml under BungeeVotePartyReward
|
||||
@@ -161,18 +203,30 @@ VoteParty:
|
||||
Broadcast: '&aVote party has been reached!'
|
||||
|
||||
# Online mode for UUIDS
|
||||
# Offline mode setups are not fully tested and are not supported currently
|
||||
# If using mixed uuids (premium and cracked players leave this enabled and disable UUIDLookup below)
|
||||
# More details here: https://github.com/BenCodez/VotingPlugin/wiki/Online-Offline-Mode
|
||||
OnlineMode: true
|
||||
|
||||
# If true plugin will atempt to lookup uuids if none exist
|
||||
UUIDLookup: true
|
||||
|
||||
|
||||
# If you use this plugin will ignore votes from these service sites for said amount of time
|
||||
WaitUntilVoteDelay:
|
||||
# sitename must match what's in VoteSites.yml on backend servers
|
||||
SITENAME:
|
||||
# Set service site here and vote delay
|
||||
ServiceSite: SERVICESITE
|
||||
VoteDelay: 24
|
||||
VoteDelayMin: 0
|
||||
# If true it resets based on the day isntead
|
||||
VoteDelayDaily: false
|
||||
VoteDelayDailyHour: 0
|
||||
|
||||
###########################################
|
||||
# Month Date Totals
|
||||
# Experimental feature
|
||||
# Settings must match on backend servers
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Month-Date-Totals
|
||||
###########################################
|
||||
|
||||
# Experimental
|
||||
@@ -188,15 +242,6 @@ StoreMonthTotalsWithDate: false
|
||||
# This setting may be very buggy as it's in early stages
|
||||
UseMonthDateTotalsAsPrimaryTotal: false
|
||||
|
||||
##########################################
|
||||
# PLUGINMESSAGING Settings
|
||||
##########################################
|
||||
|
||||
# Applies to PLUGINMESSAGING only
|
||||
# Votes will be forwarded when specific player is online
|
||||
# If set to false, rewards should still reward when player logs in (by default)
|
||||
WaitForUserOnline: false
|
||||
|
||||
|
||||
##########################################
|
||||
# Multi-proxy setup
|
||||
@@ -223,7 +268,7 @@ MultiProxyOneGlobalReward: false
|
||||
MultiProxyMethod: SOCKET
|
||||
|
||||
##########################################
|
||||
# REDIS Settings
|
||||
# REDIS multi-proxy settings
|
||||
##########################################
|
||||
|
||||
# Set multiproxymethod to REDIS to use redis
|
||||
@@ -247,7 +292,7 @@ ProxyServers:
|
||||
- proxy3
|
||||
|
||||
##########################################
|
||||
# SOCKET settings for mutli-proxy
|
||||
# SOCKET multi-proxy settings
|
||||
##########################################
|
||||
|
||||
# Set this for each proxy
|
||||
|
||||
@@ -17,6 +17,7 @@ softdepend:
|
||||
- SuperVanish
|
||||
- PremiumVanish
|
||||
- LuckPerms
|
||||
- nLogin
|
||||
loadbefore:
|
||||
- MCPerks
|
||||
api-version: 1.13
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.bencodez.votingplugin.tests;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
public class HttpURLConnectionMock {
|
||||
|
||||
public static void setupMockHttpURLConnection(String playerName, int responseCode, String responseBody)
|
||||
throws Exception {
|
||||
// Mock URL and HttpURLConnection
|
||||
URL mockUrl = mock(URL.class);
|
||||
HttpURLConnection mockConnection = mock(HttpURLConnection.class);
|
||||
|
||||
when(mockUrl.openConnection()).thenReturn(mockConnection);
|
||||
when(mockConnection.getResponseCode()).thenReturn(responseCode);
|
||||
InputStream mockInputStream = new ByteArrayInputStream(responseBody.getBytes());
|
||||
when(mockConnection.getInputStream()).thenReturn(mockInputStream);
|
||||
|
||||
// When new URL is called, return the mocked URL
|
||||
// Note: This requires PowerMockito or a similar tool to mock the `new` keyword
|
||||
// Here, it's simplified and assumes the method uses a helper that can be mocked
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
|
||||
package com.bencodez.votingplugin.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
|
||||
import com.bencodez.votingplugin.proxy.ProxyMysqlUserTable;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxy;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
import com.bencodez.votingplugin.proxy.multiproxy.MultiProxyHandler;
|
||||
|
||||
public class VotingPluginProxyTest {
|
||||
|
||||
@InjectMocks
|
||||
private VotingPluginProxyTestImpl votingPluginProxy;
|
||||
|
||||
@Mock
|
||||
private ProxyMysqlUserTable proxyMySQL;
|
||||
|
||||
@Mock
|
||||
private VotingPluginProxyConfig config;
|
||||
|
||||
@Mock
|
||||
private GlobalDataHandlerProxy globalDataHandler;
|
||||
|
||||
@Mock
|
||||
private MultiProxyHandler multiProxyHandler;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
votingPluginProxy.setProxyMySQL(proxyMySQL);
|
||||
votingPluginProxy.setGlobalDataHandler(globalDataHandler);
|
||||
votingPluginProxy.setMultiProxyHandler(multiProxyHandler);
|
||||
|
||||
// Mocking config methods
|
||||
when(config.getVotePartyEnabled()).thenReturn(true);
|
||||
when(config.getVotePartyVotesRequired()).thenReturn(5);
|
||||
when(config.getVotePartyIncreaseVotesRequired()).thenReturn(5);
|
||||
when(config.getBungeeManageTotals()).thenReturn(true);
|
||||
when(config.getPluginMessageEncryption()).thenReturn(false);
|
||||
when(config.getDebug()).thenReturn(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddVoteParty() {
|
||||
// Initial votePartyVotes should be 0
|
||||
assertEquals(0, votingPluginProxy.getVotePartyVotes());
|
||||
|
||||
// Spy on the votingPluginProxy object
|
||||
VotingPluginProxy spyProxy = Mockito.spy(votingPluginProxy);
|
||||
doNothing().when(spyProxy).checkVoteParty();
|
||||
|
||||
// Add one vote party
|
||||
spyProxy.addCurrentVotePartyVotes(1);
|
||||
|
||||
// Verify that votePartyVotes increased by 1
|
||||
assertEquals(1, spyProxy.getVotePartyVotes());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
void testAddCurrentVotePartyVotes() {
|
||||
// Initial votePartyVotes should be 0
|
||||
assertEquals(0, votingPluginProxy.getVotePartyVotes());
|
||||
|
||||
// Add 3 votes
|
||||
votingPluginProxy.addCurrentVotePartyVotes(3);
|
||||
assertEquals(3, votingPluginProxy.getVotePartyVotes());
|
||||
|
||||
// Add 2 more votes
|
||||
votingPluginProxy.addCurrentVotePartyVotes(2);
|
||||
assertEquals(5, votingPluginProxy.getVotePartyVotes());
|
||||
}
|
||||
}
|
||||
+202
@@ -0,0 +1,202 @@
|
||||
package com.bencodez.votingplugin.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxy;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
|
||||
public class VotingPluginProxyTestImpl extends VotingPluginProxy {
|
||||
|
||||
@Override
|
||||
public void addNonVotedPlayer(String uuid, String playerName) {
|
||||
// Implementation for testing purposes
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(String message) {
|
||||
// Implementation for testing purposes
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getAllAvailableServers() {
|
||||
return new HashSet<>(Arrays.asList("Server1", "Server2"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VotingPluginProxyConfig getConfig() {
|
||||
return Mockito.mock(VotingPluginProxyConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentPlayerServer(String player) {
|
||||
return "Server1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolderPlugin() {
|
||||
return new File(".");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperName(String uuid, String playerName) {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUUID(String playerName) {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginVersion() {
|
||||
return "1.0.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCacheCurrentVotePartyVotes() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVoteCacheLastUpdated() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCachePrevDay() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVoteCachePrevMonth() {
|
||||
return "January-2023";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCachePrevWeek() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCacheVotePartyIncreaseVotesRequired() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServerValid(String server) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSomeoneOnlineServer(String server) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoteCacheIgnoreTime() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAsync(Runnable run) {
|
||||
run.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runConsoleCommand(String command) {
|
||||
// Mocked for testing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveVoteCacheFile() {
|
||||
// Mocked for testing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadCore(boolean mysql) {
|
||||
// Mocked for testing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
// For testing, simply print the message
|
||||
System.out.println("LOG: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String message) {
|
||||
// For testing, simply print the severe message
|
||||
System.err.println("SEVERE: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message) {
|
||||
// For testing, simply print the warning message
|
||||
System.err.println("WARNING: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String str) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPluginMessageData(String server, String channel, byte[] data, boolean queue) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheLastUpdated() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCachePrevDay(int day) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCachePrevMonth(String text) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCachePrevWeek(int week) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheVoteCacheIgnoreTime(boolean ignore) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheVotePartyCurrentVotes(int votes) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheVotePartyIncreaseVotesRequired(int votes) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
|
||||
package com.bencodez.votingplugin.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.CALLS_REAL_METHODS;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.bencodez.votingplugin.proxy.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxy;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
|
||||
public class VotingPluginProxyVoteCacheTest {
|
||||
private VotingPluginProxy proxy;
|
||||
private VotingPluginProxyConfig config;
|
||||
private ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes;
|
||||
private ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>> cachedVotes;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
proxy = mock(VotingPluginProxy.class, CALLS_REAL_METHODS);
|
||||
config = mock(VotingPluginProxyConfig.class);
|
||||
when(proxy.getConfig()).thenReturn(config);
|
||||
cachedOnlineVotes = new ConcurrentHashMap<>();
|
||||
cachedVotes = new ConcurrentHashMap<>();
|
||||
proxy.setCachedOnlineVotes(cachedOnlineVotes);
|
||||
proxy.setCachedVotes(cachedVotes);
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkVoteCacheTime_removesExpiredVotesFromCachedOnlineVotes() {
|
||||
when(config.getVoteCacheTime()).thenReturn(1); // 1 day
|
||||
long currentTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
long expiredTime = currentTime - (2 * 24 * 60 * 60 * 1000); // 2 days ago
|
||||
|
||||
ArrayList<OfflineBungeeVote> votes = new ArrayList<>();
|
||||
votes.add(new OfflineBungeeVote("player1", "uuid1", "service1", expiredTime, true, "text1"));
|
||||
cachedOnlineVotes.put("server1", votes);
|
||||
|
||||
proxy.checkVoteCacheTime();
|
||||
|
||||
assertTrue(cachedOnlineVotes.get("server1").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkVoteCacheTime_doesNotRemoveNonExpiredVotesFromCachedOnlineVotes() {
|
||||
when(config.getVoteCacheTime()).thenReturn(1); // 1 day
|
||||
long currentTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
long validTime = currentTime - (12 * 60 * 60 * 1000); // 12 hours ago
|
||||
|
||||
ArrayList<OfflineBungeeVote> votes = new ArrayList<>();
|
||||
votes.add(new OfflineBungeeVote("player1", "uuid1", "service1", validTime, true, "text1"));
|
||||
cachedOnlineVotes.put("server1", votes);
|
||||
|
||||
proxy.checkVoteCacheTime();
|
||||
|
||||
assertFalse(cachedOnlineVotes.get("server1").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkVoteCacheTime_removesExpiredVotesFromCachedVotes() {
|
||||
when(config.getVoteCacheTime()).thenReturn(1); // 1 day
|
||||
long currentTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
long expiredTime = currentTime - (2 * 24 * 60 * 60 * 1000); // 2 days ago
|
||||
|
||||
ArrayList<OfflineBungeeVote> votes = new ArrayList<>();
|
||||
votes.add(new OfflineBungeeVote("player1", "uuid1", "service1", expiredTime, true, "text1"));
|
||||
cachedVotes.put("server1", votes);
|
||||
|
||||
proxy.checkVoteCacheTime();
|
||||
|
||||
assertTrue(cachedVotes.get("server1").isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkVoteCacheTime_doesNotRemoveNonExpiredVotesFromCachedVotes() {
|
||||
when(config.getVoteCacheTime()).thenReturn(1); // 1 day
|
||||
long currentTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
long validTime = currentTime - (12 * 60 * 60 * 1000); // 12 hours ago
|
||||
|
||||
ArrayList<OfflineBungeeVote> votes = new ArrayList<>();
|
||||
votes.add(new OfflineBungeeVote("player1", "uuid1", "service1", validTime, true, "text1"));
|
||||
cachedVotes.put("server1", votes);
|
||||
|
||||
proxy.checkVoteCacheTime();
|
||||
|
||||
assertFalse(cachedVotes.get("server1").isEmpty());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user