Compare commits

...
7 Commits
Author SHA1 Message Date
BenCodez 83c43331a9 Update version number 2021-02-01 17:02:59 -05:00
BenCodez afe68ef229 Little change 2021-02-01 16:53:45 -05:00
BenCodez 7eec56ee2a Changed to top voter file storing 2021-02-01 16:49:10 -05:00
BenCodez 2ed462b61c Little change for default value 2021-01-31 12:31:34 -05:00
Ben dd142d20fe Merge pull request #1106 from Gadsee/patch-1
Prevent clients from sending plugin messages
2021-01-30 21:48:05 -05:00
Gadsee 8a340dc292 Add missing import 2021-01-31 03:21:05 +01:00
Deko e77201613e Prevent clients from sending plugin messages
Clients can send data over the plugin message channels the same way servers can. Canceling the event and returning if the message was not sent by the Server fixes the issue.
In the worst case scenario, the server will crash if the client sends invalid data, due to how this plugin attempts to continually load the message.
2021-01-31 03:15:20 +01:00
4 changed files with 17 additions and 7 deletions

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>VotingPlugin</artifactId>
<version>6.1.1</version>
<version>6.1.2</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -36,6 +36,7 @@ import lombok.Getter;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.event.ServerConnectedEvent;
@@ -379,6 +380,12 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
if (!ev.getTag().equals("vp:vp".toLowerCase())) {
return;
}
ev.setCancelled(true);
if (!(ev.getSender() instanceof Server))
return;
ByteArrayInputStream instream = new ByteArrayInputStream(ev.getData());
DataInputStream in = new DataInputStream(instream);
try {
@@ -128,7 +128,7 @@ public class ConfigVoteSites extends YMLFile {
* @return the vote delay
*/
public int getVoteDelay(String siteName) {
return getData(siteName).getInt("VoteDelay");
return getData(siteName).getInt("VoteDelay", 24);
}
public int getVoteDelayMin(String siteName) {
@@ -18,6 +18,7 @@ import org.bukkit.event.Listener;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.time.TimeType;
import com.bencodez.advancedcore.api.time.events.DateChangedEvent;
import com.bencodez.advancedcore.api.time.events.DayChangeEvent;
import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
@@ -105,7 +106,9 @@ public class TopVoterHandler implements Listener {
public void onDateChanged(DateChangedEvent event) {
plugin.setUpdate(true);
plugin.update();
loadLastMonth();
if (event.getTimeType().equals(TimeType.MONTH)) {
loadLastMonth();
}
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
plugin.getMysql().clearCache();
}
@@ -171,7 +174,7 @@ public class TopVoterHandler implements Listener {
}
resetTotals(TopVoter.Daily);
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
plugin.getMysql().clearCache();
}
@@ -259,7 +262,7 @@ public class TopVoterHandler implements Listener {
}
}
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
plugin.getMysql().clearCache();
}
@@ -337,7 +340,7 @@ public class TopVoterHandler implements Listener {
e.printStackTrace();
}
resetTotals(TopVoter.Weekly);
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
plugin.getMysql().clearCache();
}
@@ -402,7 +405,7 @@ public class TopVoterHandler implements Listener {
} else if (top.equals(TopVoter.Weekly)) {
fileName += "_" + week;
}
fileName += ".yml";
fileName += "_" + System.currentTimeMillis() + ".yml";
YMLFileHandler file = new YMLFileHandler(plugin, new File(plugin.getDataFolder(), fileName));
file.setup();