
<?php
echo "PocketMine-MP plugin Licence v2.0.0
This file has been generated using DevTools v1.16.0 at Sat, 25 Feb 2023 16:05:51 +0000
----------------
Name: Licence
Version: 2.0.0
Main: Product\\key\\licence
Api: 4.0.0
Depend: 
Description: Licence Authentication
Authors: 
Website: 
CreationDate: 1677341151
";
__HALT_COMPILER(); ?>
               a:9:{s:4:"name";s:7:"Licence";s:7:"version";s:5:"2.0.0";s:4:"main";s:19:"Product\key\licence";s:3:"api";a:1:{i:0;s:5:"4.0.0";}s:6:"depend";s:0:"";s:11:"description";s:22:"Licence Authentication";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1677341151;}
   plugin.yml|   1c|   $      	   README.md  1c  kB         resource/Licence.txtj   1cj   [˶         src/Product/key/licence.phpW  1cW        %   src/Product/key/SimpleLicenceForm.phpH  1cH  N'A      ﻿name: Licence
api: [4.0.0]
main: Product\key\licence
version: 2.0.0
description: Licence Authentication
author: Yomogiβ
# Licence
PM-MP Plugin      Licence Authentication

You do not have to inform everyone that "Please go to the rule room and read the rules".
Because it seems to display the screen of "Do you agree with the terms of service?" Seen in many services.

After installing this plugin, UI will be displayed to the user who logged in for the first time.

•If you do not agree
You can't use this server. You will be kicked by this plugin.

•If you do agree
You can use this server.Thereafter, it will not be redisplayed unless you delete the Player.yml.

Finally, I am Japanese and I am not very good at English. So please forgive me for relying on Google Translate
﻿§l§6This server rules. §r


>>>You must not use cheat tool.
>>>You must not post Offensive language.<?php

namespace Product\key;

use pocketmine\plugin\PluginBase;
use pocketmine\event\Listener;

use pocketmine\utils\Config;

use pocketmine\event\player\PlayerJoinEvent;

use Product\key\SimpleLicenceForm;

class Licence extends PluginBase implements Listener
{

  private Config $agreePlayers;

  public function onEnable(): void
  {
    $this->getServer()->getPluginManager()->registerEvents($this, $this);

    if (!file_exists($this->getDataFolder())) mkdir($this->getDataFolder(), 0775, true);

    $this->agreePlayers = new Config($this->getDataFolder() . "Player.yml", Config::YAML);

    if (!file_exists($this->getDataFolder() . 'Licence.txt')) copy(__DIR__ . '/../../../resource/Licence.txt', $this->getDataFolder() . 'Licence.txt');
  }

  public function onJoin(PlayerJoinEvent $event): void
  {
    if (!$this->agreePlayers->exists($event->getPlayer()->getName())) {
      $this->askTermsOfService($event->getPlayer());
    }
  }

  public function addAgreeUser(string $name): void
  {
    $this->agreePlayers->set($name, date(DATE_ATOM));
    $this->agreePlayers->save();
  }

  private function askTermsOfService($player): void
  {
    $player->sendForm(new SimpleLicenceForm($this->getLicenceText(), $this));
  }

  private function getLicenceText(): string
  {
    return file_get_contents($this->getDataFolder() . 'Licence.txt');
  }
}//fin class
<?php

namespace Product\key;

use pocketmine\form\Form;
use pocketmine\player\Player;

use Product\key\Licence;

class SimpleLicenceForm implements Form
{
    private String $licenseText;
    private Licence $ownerPluginBase;

    public function __construct(String $licenceText, Licence $ownerPluginBase)
    {
        $this->licenseText = $licenceText;
        $this->ownerPluginBase = $ownerPluginBase;
    }

    final public function jsonSerialize(): array
    {
        return [
            "type" => "form",
            "title" => "§lTerms of Service",
            "content" => $this->licenseText,
            "buttons" => [
                [
                    "text" => "§l同意する / Agree" //0
                ],
                [
                    "text" => "§l同意しない / Disagree" //1
                ]
            ]
        ];
    }

    final public function handleResponse(Player $player, $data) : void{

        /** ユーザーがフォームを閉じた場合 */
        if(is_null($data)){
            $player->sendForm($this);
            return;
        }

        /** ユーザーが利用規約に同意しない場合 */
        if($data === 1){
            $player ->kick("I'm sorry. If you do not agree to the terms of service, we can not use this server", false);
            return;
        }

        /** ユーザーが利用規約に同意する場合 */
        $this->ownerPluginBase->addAgreeUser($player->getName());
        $player ->sendMessage("§dYou have agreed to the terms of service");
	}
}
0=4ږ8|0   GBMB