diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 80881f36..05a55883 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -25,6 +25,7 @@ import de.steamwar.bungeecore.listeners.*; import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker; import de.steamwar.bungeecore.listeners.mods.Forge; import de.steamwar.bungeecore.listeners.mods.LabyMod; +import de.steamwar.bungeecore.listeners.mods.WorldDownloader; import de.steamwar.bungeecore.sql.SQL; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.Team; @@ -85,6 +86,7 @@ public class BungeeCore extends Plugin { new BanListener(); new CheckListener(); new ModLoaderBlocker(); + new WorldDownloader(); commands.put("/b", null); commands.put("/gs", null); diff --git a/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java b/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java new file mode 100644 index 00000000..44270b61 --- /dev/null +++ b/src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java @@ -0,0 +1,33 @@ +package de.steamwar.bungeecore.listeners.mods; + +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import de.steamwar.bungeecore.listeners.BasicListener; +import de.steamwar.bungeecore.sql.Mod; +import net.md_5.bungee.api.connection.Connection; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.event.EventHandler; + +import java.util.Collections; +import java.util.Set; + +public class WorldDownloader extends BasicListener { + + private static final Set wdlTags = Collections.unmodifiableSet( + Sets.newHashSet("WDL|INIT", "wdl:init", "WDL|REQUEST", "wdl:request") + ); + + @EventHandler + public void onPluginMessageEvent(PluginMessageEvent event){ + if(!wdlTags.contains(event.getTag())) + return; + + Connection sender = event.getSender(); + if(!(sender instanceof ProxiedPlayer)) + return; + + event.setCancelled(true); + Utils.handleMods((ProxiedPlayer) sender, Lists.newArrayList(Mod.get("wdl", Mod.Platform.FORGE))); + } +}