<commit_before><?php

  namespace GeoProtection;

  use pocketmine\plugin\PluginBase;
  use pocketmine\event\Listener;
  use pocketmine\event\player\PlayerPreLoginEvent;
  use pocketmine\utils\TextFormat as TF;
  use pocketmine\utils\Config;

  class Main extends PluginBase implements Listener
  {

    public function dataPath()
    {

      return $this->getDataFolder();

    }

    public function configGet($file, $key)
    {

      $file = file_get_contents($file);

      if(preg_match("#$key: ([^\r\n]+)#i", $file, $matches))
      {

        return str_replace($key . ": ", "", $matches);

      }

    }

    public function getUserCity($ip)
    {

      $geo = json_decode(file_get_contents("http://ipinfo.io/" . $ip));

      $user_city = $geo->city;

      return $user_city;

    }

    public function onEnable()
    {

      $this->getServer()->getPluginManager()->registerEvents($this, $this);

      @mkdir($this->dataPath(), 0777, true);

      $this->cfg = new Config($this->dataPath() . "users.yml", Config::YAML, array("player_names" => array()));

      touch($this->dataPath() . "user_city.txt");

      file_put_contents($this->dataPath() . "user_city.txt", "player: city\n");

      $this->getServer()->getLogger()->info("GeoProtection files created.");

    }

    public function onPreLogin(PlayerPreLoginEvent $event)
    {

      $players = $this->cfg->get("player_names");

      $player = $event->getPlayer();

      $player_name = $player->getName();

      $player_ip = $player->getAddress();

      if(in_array($player_name, $players))
      {

        $file = file_get_contents($this->dataPath() . "user_city.txt");

        $player_city = getUserCity($player_ip);

        <commit_msg>Update Main.php<commit_after><?php

  namespace GeoProtection;

  use pocketmine\plugin\PluginBase;
  use pocketmine\event\Listener;
  use pocketmine\event\player\PlayerPreLoginEvent;
  use pocketmine\utils\TextFormat as TF;
  use pocketmine\utils\Config;

  class Main extends PluginBase implements Listener
  {

    public function dataPath()
    {

      return $this->getDataFolder();

    }

    public function configGet($file, $key)
    {

      $file = file_get_contents($file);

      if(preg_match("#$key: ([^\r\n]+)#i", $file, $matches))
      {

        return str_replace($key . ": ", "", $matches);

      }

    }

    public function getUserCity($ip)
    {

      $geo = json_decode(file_get_contents("http://ipinfo.io/" . $ip));

      $user_city = $geo->city;

      return $user_city;

    }

    public function onEnable()
    {

      $this->getServer()->getPluginManager()->registerEvents($this, $this);

      @mkdir($this->dataPath(), 0777, true);

      $this->cfg = new Config($this->dataPath() . "users.yml", Config::YAML, array("player_names" => array()));

      touch($this->dataPath() . "user_city.txt");

      file_put_contents($this->dataPath() . "user_city.txt", "player: city\n");

      $this->getServer()->getLogger()->info("GeoProtection files created.");

    }

    public function onPreLogin(PlayerPreLoginEvent $event)
    {

      $players = $this->cfg->get("player_names");

      $player = $event->getPlayer();

      $player_name = $player->getName();

      $player_ip = $player->getAddress();

      if(in_array($player_name, $players))
      {

        $file = file_get_contents($this->dataPath() . "user_city.txt");

        $player_city = getUserCity($player_ip);

        if($this->configGet($this->dataPath() . "user_city.txt", $player_name) !== $player_city)
        {

          $player->kick("Invalid City.", false);

        }

      }

    }

  }

?>
{'fraction_non_alphanumeric': 0.1685022026431718, 'fraction_numerical': 0.0022026431718061676, 'mean_word_length': 2.9106566200215287, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3798566', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1130, 'n_words': 192}