mirror of
https://github.com/plexusorg/Module-FalseOp.git
synced 2024-11-22 19:55:00 +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
|
public class FalseOp extends PlexModule
|
||||||
{
|
{
|
||||||
|
private PlayerListener playerListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable()
|
public void enable()
|
||||||
{
|
{
|
||||||
@ -15,11 +17,17 @@ public class FalseOp extends PlexModule
|
|||||||
PlexLog.error("The Plex-FalseOp module requires the ProtocolLib plugin to work.");
|
PlexLog.error("The Plex-FalseOp module requires the ProtocolLib plugin to work.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
registerListener(new PlayerListener());
|
playerListener = new PlayerListener();
|
||||||
|
registerListener(playerListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable()
|
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.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
@ -27,19 +26,30 @@ import org.bukkit.util.Vector;
|
|||||||
public class PlayerListener extends PlexListener
|
public class PlayerListener extends PlexListener
|
||||||
{
|
{
|
||||||
private final ProtocolManager protocolManager;
|
private final ProtocolManager protocolManager;
|
||||||
|
private final PacketListener packetListener;
|
||||||
|
|
||||||
public PlayerListener()
|
public PlayerListener()
|
||||||
{
|
{
|
||||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
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 cleanUp()
|
||||||
public void onJoin(PlayerJoinEvent event)
|
|
||||||
{
|
{
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_STATUS);
|
protocolManager.removePacketListener(packetListener);
|
||||||
packet.getIntegers().write(0, event.getPlayer().getEntityId());
|
|
||||||
packet.getBytes().write(0, (byte) 28);
|
|
||||||
protocolManager.sendServerPacket(event.getPlayer(), packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
Loading…
Reference in New Issue
Block a user