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

import com.salhack.summit.events.bus.EventHandler;
import com.salhack.summit.events.bus.Listener;
import com.salhack.summit.events.player.EventPlayerUpdate;
import com.salhack.summit.module.Module;
import com.salhack.summit.module.Value;
import com.salhack.summit.util.SalVec3d;
import com.salhack.summit.waypoints.Waypoint;
import com.salhack.summit.waypoints.WaypointManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.Vec3d;

import java.util.HashMap;

public class CoordTPExploit extends Module
{
    public final Value<Float> MinDistance = new Value<Float>("MinDistance", new String[] {"MinDistance"}, "Min distance", 1000f, 500f, 3000f, 100f);
    
    public CoordTPExploit()
    {
        super("CoordTPExploit", new String[] {"EPTP"}, "Teleport exploit for ender pearls, /tpa etc", "NONE", 0x2482DB, ModuleType.EXPLOIT);
    }
    
    private HashMap<String, Vec3d> PlayersFar = new HashMap<String, Vec3d>();

    @EventHandler
    private Listener<EventPlayerUpdate> OnPlayerUpdate = new Listener<>(p_Event ->
    {
        for (EntityPlayer l_Player : mc.world.playerEntities)
        {
            if (l_Player == mc.player || l_Player.getName() == mc.player.getName())
                continue;
            
            if (l_Player.getDistance(mc.player) < 100.0f)
            {
                if (PlayersFar.containsKey(l_Player.getName()))
                {
                    SendMessage(String.format("Removing %s from list, they are now in range at %s dist", l_Player.getName(), l_Player.getDistance(mc.player)));
                    PlayersFar.remove(l_Player.getName());
                }
                continue;
            }
            
            if (PlayersFar.containsKey(l_Player.getName()))
                continue;
            
            if (l_Player.getDistance(mc.player) >= MinDistance.getValue())
            {
                Vec3d l_Coords = new Vec3d(l_Player.posX, l_Player.posY, l_Player.posZ);
                PlayersFar.put(l_Player.getName(), l_Coords);
                SendMessage(String.format("Player %s just teleported to %s", l_Player.getName(), l_Coords.toString()));
                WaypointManager.Get().AddWaypoint(Waypoint.Type.CoordTPExploit, "CoordTPExploit: " + l_Player.getName(), new SalVec3d(l_Coords.x, l_Coords.y, l_Coords.z), mc.player.dimension);
            }
        }
    });
   
}
