mirror of
https://github.com/plexusorg/Module-FalseOp.git
synced 2024-12-22 17:27:36 +00:00
Fix fake op permission level on world change.
This commit is contained in:
parent
12a16c1634
commit
81020af843
@ -7,6 +7,8 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class FalseOp extends PlexModule
|
||||
{
|
||||
private PlayerListener playerListener;
|
||||
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
@ -15,11 +17,17 @@ public class FalseOp extends PlexModule
|
||||
PlexLog.error("The Plex-FalseOp module requires the ProtocolLib plugin to work.");
|
||||
return;
|
||||
}
|
||||
registerListener(new PlayerListener());
|
||||
playerListener = new PlayerListener();
|
||||
registerListener(playerListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
if (playerListener != null)
|
||||
{
|
||||
playerListener.cleanUp();
|
||||
playerListener = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,6 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -27,19 +26,30 @@ import org.bukkit.util.Vector;
|
||||
public class PlayerListener extends PlexListener
|
||||
{
|
||||
private final ProtocolManager protocolManager;
|
||||
private final PacketListener packetListener;
|
||||
|
||||
public PlayerListener()
|
||||
{
|
||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
packetListener = new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.ENTITY_STATUS)
|
||||
{
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event)
|
||||
{
|
||||
PacketContainer packet = event.getPacket();
|
||||
byte b;
|
||||
if (packet.getIntegers().getValues().get(0) == event.getPlayer().getEntityId() && (b = packet.getBytes().getValues().get(0)) >= (byte) 24 && b <= (byte) 27)
|
||||
{
|
||||
packet.getBytes().write(0, (byte) 28);
|
||||
}
|
||||
}
|
||||
};
|
||||
protocolManager.addPacketListener(packetListener);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
public void cleanUp()
|
||||
{
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_STATUS);
|
||||
packet.getIntegers().write(0, event.getPlayer().getEntityId());
|
||||
packet.getBytes().write(0, (byte) 28);
|
||||
protocolManager.sendServerPacket(event.getPlayer(), packet);
|
||||
protocolManager.removePacketListener(packetListener);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user