Created
January 18, 2014 19:56
-
-
Save aadnk/8495364 to your computer and use it in GitHub Desktop.
Updated version of HideChestOpeningMod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.comphenix.hidechest; | |
| import org.bukkit.Material; | |
| import org.bukkit.World; | |
| import org.bukkit.plugin.java.JavaPlugin; | |
| import com.comphenix.protocol.PacketType; | |
| import com.comphenix.protocol.ProtocolLibrary; | |
| import com.comphenix.protocol.ProtocolManager; | |
| import com.comphenix.protocol.events.PacketAdapter; | |
| import com.comphenix.protocol.events.PacketEvent; | |
| import com.comphenix.protocol.reflect.StructureModifier; | |
| public class HideChestOpeningMod extends JavaPlugin { | |
| @Override | |
| public void onEnable() { | |
| ProtocolManager manager = ProtocolLibrary.getProtocolManager(); | |
| manager.addPacketListener(new PacketAdapter(this, | |
| PacketType.Play.Server.BLOCK_ACTION, PacketType.Play.Server.NAMED_SOUND_EFFECT) { | |
| @Override | |
| public void onPacketSending(PacketEvent event) { | |
| PacketType type = event.getPacketType(); | |
| if (type == PacketType.Play.Server.BLOCK_ACTION) { | |
| World world = event.getPlayer().getWorld(); | |
| StructureModifier<Integer> ints = event.getPacket().getSpecificModifier(int.class); | |
| int blockX = ints.read(0); | |
| int blockY = ints.read(1); | |
| int blockZ = ints.read(2); | |
| // See if this is is a chest animation | |
| if (world.getBlockAt(blockX, blockY, blockZ).getType() == Material.CHEST) { | |
| // Don't send the animation | |
| event.setCancelled(true); | |
| } | |
| } else if (type == PacketType.Play.Server.NAMED_SOUND_EFFECT) { | |
| String soundEffectName = event.getPacket().getSpecificModifier(String.class).read(0); | |
| // Disable all "chest" sound effects | |
| if (soundEffectName.contains("chest")) { | |
| event.setCancelled(true); | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment