Add config option for turning off login payloads
This commit is contained in:
		| @@ -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")); | ||||
|   | ||||
| @@ -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<String> 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()); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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<String> 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<String> 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<DisguisePerm> getDisguiseTypes() { | ||||
|         ArrayList<DisguisePerm> perms = new ArrayList<>(); | ||||
|  | ||||
|   | ||||
| @@ -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. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user