Now with API for Vote
This commit is contained in:
@@ -39,7 +39,6 @@ public class VotifierListener implements Listener, PluginMessageListener {
|
|||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
timestampInt = (int) (System.currentTimeMillis() / 1000);
|
timestampInt = (int) (System.currentTimeMillis() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Got vote from " + vote.getServiceName() + " Username: " + vote.getUsername() + " with Adress: " + vote.getAddress() + " @ " + vote.getTimeStamp());
|
System.out.println("Got vote from " + vote.getServiceName() + " Username: " + vote.getUsername() + " with Adress: " + vote.getAddress() + " @ " + vote.getTimeStamp());
|
||||||
try {
|
try {
|
||||||
ResultSet rs1 = Core.getMySql().querySelect("SELECT id FROM `players` WHERE name = '" + vote.getUsername() + "'");
|
ResultSet rs1 = Core.getMySql().querySelect("SELECT id FROM `players` WHERE name = '" + vote.getUsername() + "'");
|
||||||
@@ -54,7 +53,7 @@ public class VotifierListener implements Listener, PluginMessageListener {
|
|||||||
if (rs2.first()) {
|
if (rs2.first()) {
|
||||||
int lastVoteDate = rs2.getInt("dateOfLastVote");
|
int lastVoteDate = rs2.getInt("dateOfLastVote");
|
||||||
votesInRow = rs2.getInt("votesInARow");
|
votesInRow = rs2.getInt("votesInARow");
|
||||||
if (lastVoteDate > (System.currentTimeMillis() - 86400)) {
|
if (lastVoteDate > ((System.currentTimeMillis() / 1000) - 86400)) {
|
||||||
votesInRow++;
|
votesInRow++;
|
||||||
if (votesInRow == 10) {
|
if (votesInRow == 10) {
|
||||||
addPlayerMoney(50, vote);
|
addPlayerMoney(50, vote);
|
||||||
@@ -81,7 +80,7 @@ public class VotifierListener implements Listener, PluginMessageListener {
|
|||||||
out.writeInt(money);
|
out.writeInt(money);
|
||||||
|
|
||||||
if (AnuraCore.getInstance().getServer().getOnlinePlayers().isEmpty()) {
|
if (AnuraCore.getInstance().getServer().getOnlinePlayers().isEmpty()) {
|
||||||
Socket so = new Socket("localhost", 26656);
|
Socket so = new Socket("127.0.0.1", 27767);
|
||||||
OutputStream os = so.getOutputStream();
|
OutputStream os = so.getOutputStream();
|
||||||
BufferedWriter ps = new BufferedWriter(new OutputStreamWriter(os));
|
BufferedWriter ps = new BufferedWriter(new OutputStreamWriter(os));
|
||||||
ps.write("X3Nw;a+F!R_p~(Wj#LZc");
|
ps.write("X3Nw;a+F!R_p~(Wj#LZc");
|
||||||
@@ -93,6 +92,8 @@ public class VotifierListener implements Listener, PluginMessageListener {
|
|||||||
ps.write(money + "");
|
ps.write(money + "");
|
||||||
ps.newLine();
|
ps.newLine();
|
||||||
ps.flush();
|
ps.flush();
|
||||||
|
ps.close();
|
||||||
|
so.close();
|
||||||
} else {
|
} else {
|
||||||
Player p = Iterables.get(AnuraCore.getInstance().getServer().getOnlinePlayers(), 0);
|
Player p = Iterables.get(AnuraCore.getInstance().getServer().getOnlinePlayers(), 0);
|
||||||
p.sendPluginMessage(AnuraCore.getInstance(), "BungeeCord", stream.toByteArray());
|
p.sendPluginMessage(AnuraCore.getInstance(), "BungeeCord", stream.toByteArray());
|
||||||
|
|||||||
Reference in New Issue
Block a user