/FileExtraction/Java_unseen/ionar2_summit/src/main/java/com/salhack/summit/module/exploit/Swing.java
package com.salhack.summit.module.exploit;

import com.salhack.summit.events.MinecraftEvent;
import com.salhack.summit.events.bus.EventHandler;
import com.salhack.summit.events.bus.Listener;
import com.salhack.summit.events.network.EventClientPacket;
import com.salhack.summit.events.player.EventPlayerSwingArm;
import com.salhack.summit.events.player.EventPlayerUpdate;
import com.salhack.summit.module.Module;
import com.salhack.summit.module.Value;
import net.minecraft.network.play.client.CPacketAnimation;
import net.minecraft.util.EnumHand;

public class Swing extends Module
{
    public final Value<String> Mode = new Value<>("Mode", new String[]
    { "Mode", "M" }, "The Swining mode to use", "Packet");
    
    public Swing()
    {
        super("Swing", new String[]
        { "AntiSwing" }, "Prevents swinging server-side", "NONE", 0x8D24DB, ModuleType.EXPLOIT);
        setMetaData(getMetaData());
        
        Mode.addString("Full");
        Mode.addString("Packet");
        Mode.addString("Offhand");
    }
    
    public String getMetaData()
    {
        return Mode.getValue().toString();
    }

    @EventHandler
    private Listener<EventPlayerUpdate> onPlayerUpdate  = new Listener<>(event ->
    {
        setMetaData(getMetaData());
    });
    
    @EventHandler
    private Listener<EventClientPacket> onClientPacket = new Listener<>(event ->
    {
        if (event.getStage() != MinecraftEvent.Stage.Pre)
            return;
        
        if (event.getPacket() instanceof CPacketAnimation && Mode.getValue().equals("Packet"))
            event.cancel();
    });

    @EventHandler
    private Listener<EventPlayerSwingArm> SwingArm = new Listener<>(event ->
    {
        if (Mode.getValue().equals("Full"))
            event.cancel();
        else if (Mode.getValue().equals("Offhand"))
            event.Hand = EnumHand.OFF_HAND;
    });
}