diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index f5a2cc0b..4a08c8cf 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -247,6 +247,9 @@ public class DisguiseConfig { @Getter @Setter private static boolean randomDisguises; + @Getter + @Setter + private static boolean loginPayloadPackets; public static boolean isArmorstandsName() { return getPlayerNameType() == PlayerNameType.ARMORSTANDS; @@ -632,6 +635,7 @@ public class DisguiseConfig { setMaxClonedDisguises(config.getInt("DisguiseCloneSize")); setMaxHealthDeterminedByDisguisedEntity(config.getBoolean("MaxHealthDeterminedByEntity")); setMetaPacketsEnabled(config.getBoolean("PacketsEnabled.Metadata")); + setLoginPayloadPackets(config.getBoolean("PacketsEnabled.LoginPayload")); setMiscDisguisesForLivingEnabled(config.getBoolean("MiscDisguisesForLiving")); setModifyBoundingBox(config.getBoolean("ModifyBoundingBox")); setModifyCollisions(config.getBoolean("Scoreboard.Collisions")); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/listeners/ModdedListener.java b/src/main/java/me/libraryaddict/disguise/utilities/listeners/ModdedListener.java index 982073e7..cab6bdda 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/listeners/ModdedListener.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/listeners/ModdedListener.java @@ -18,27 +18,6 @@ import java.util.ArrayList; public class ModdedListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onLogin(PlayerLoginEvent event) { - Player player = event.getPlayer(); - - ArrayList mods = ModdedManager.getForgeMods().getIfPresent(player.getName()); - - player.setMetadata("forge_mods", new FixedMetadataValue(LibsDisguises.getInstance(), mods)); - - for (ModdedEntity e : ModdedManager.getEntities().values()) { - if (e.getMod() == null) { - continue; - } - - if (mods.contains(e.getMod().toLowerCase())) { - continue; - } - - if (e.getRequired() == null) { - continue; - } - - player.kickPlayer(e.getRequired()); - break; - } + ModdedManager.doMods(event.getPlayer()); } } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/modded/ModdedManager.java b/src/main/java/me/libraryaddict/disguise/utilities/modded/ModdedManager.java index 620780ec..9afeda35 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/modded/ModdedManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/modded/ModdedManager.java @@ -5,6 +5,7 @@ import com.comphenix.protocol.utility.StreamSerializer; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import lombok.Getter; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.utilities.listeners.ModdedListener; @@ -13,6 +14,8 @@ import me.libraryaddict.disguise.utilities.parser.DisguisePerm; import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; import org.bukkit.Bukkit; import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.metadata.FixedMetadataValue; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; @@ -41,11 +44,15 @@ public class ModdedManager { return; } - if (fmlRegistries == null) { + if (fmlRegistries == null && DisguiseConfig.isLoginPayloadPackets()) { ProtocolLibrary.getProtocolManager().addPacketListener(new PacketListenerModdedClient()); Bukkit.getPluginManager().registerEvents(new ModdedListener(), LibsDisguises.getInstance()); } + createPayloads(channels); + } + + private void createPayloads(ArrayList channels) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); DataOutputStream output = new DataOutputStream(stream); @@ -163,6 +170,29 @@ public class ModdedManager { return null; } + public static void doMods(Player player) { + ArrayList mods = getForgeMods().getIfPresent(player.getName()); + + player.setMetadata("forge_mods", new FixedMetadataValue(LibsDisguises.getInstance(), mods)); + + for (ModdedEntity e : ModdedManager.getEntities().values()) { + if (e.getMod() == null) { + continue; + } + + if (mods.contains(e.getMod().toLowerCase())) { + continue; + } + + if (e.getRequired() == null) { + continue; + } + + player.kickPlayer(e.getRequired()); + break; + } + } + public static ArrayList getDisguiseTypes() { ArrayList perms = new ArrayList<>(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 1817d5b8..7859366b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -319,6 +319,9 @@ PacketsEnabled: Riding: true # When disguised as a wither skull, it sends a look packet every tick so that the wither skull is facing the right way. WitherSkull: true + # This is only used when using a modded disguises thingy, check disguises.yml for more info + # This is used as a hack to bypass bungeecord issues + LoginPayload: true # Added to support a Chinese Minecraft Server which uses their own skin server unless the UUID is not version 4. # Changing this from 4 to say, 3. Means their server will fetch skins from Mojang instead.