
<?php
echo "PocketMine-MP plugin KillScore v0.1
This file has been generated using DevTools v1.13.1 at Tue, 18 Jun 2019 13:05:30 +0930
----------------
";

if(extension_loaded("phar")){
	$phar = new \Phar(__FILE__);
	foreach($phar->getMetadata() as $key => $value){
		echo ucfirst($key) . ": " . (is_array($value) ? implode(", ", $value) : $value) . "\n";
	}
}

__HALT_COMPILER(); ?>
ý             ÿ   a:9:{s:4:"name";s:9:"KillScore";s:7:"version";d:0.1;s:4:"main";s:14:"rib\score\Main";s:3:"api";a:2:{i:0;s:5:"3.4.0";i:1;s:5:"4.0.0";}s:6:"depend";s:0:"";s:11:"description";s:0:"";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1560828930;}   LICENSE   \]   ¿`4€¶      
   plugin.yml_   \]_   >«™¶      &   src/rib/score/command/ScoreCommand.php¯  \]¯  ÐÀê¶         src/rib/score/Main.php  \]  ,~V¶      (   src/RuinPray/ui/elements/BaseElement.php'  \]'  ¨ëhê¶      %   src/RuinPray/ui/elements/Dropdown.php‚  \]‚  ´sÈ÷¶      $   src/RuinPray/ui/elements/Element.phps   \]s   ìr”l¶      "   src/RuinPray/ui/elements/Input.php.  \].  t€Ú¶      "   src/RuinPray/ui/elements/Label.phpÔ   \]Ô   h"ÿì¶      #   src/RuinPray/ui/elements/Slider.phpÍ  \]Í  þ‚Å¶      '   src/RuinPray/ui/elements/StepSlider.phpz  \]z  Öy±f¶      #   src/RuinPray/ui/elements/Toggle.phpp  \]p  }‚¸¶      $   src/RuinPray/ui/forms/CustomForm.phpÜ  \]Ü  Æ‘È«¶      #   src/RuinPray/ui/forms/ModalForm.phpJ  \]J  ?¶      $   src/RuinPray/ui/forms/SimpleForm.php¶  \]¶  L°ø¶          src/RuinPray/ui/forms/Window.phpH  \]H  ’> ·¶         src/RuinPray/ui/UI.phpò  \]ò  QŸA¶      GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright Â© 2007 Free Software Foundation, Inc. <https://fsf.org/>

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.

0. Additional Definitions.
As used herein, â€œthis Licenseâ€ refers to version 3 of the GNU Lesser General Public License, and the â€œGNU GPLâ€ refers to version 3 of the GNU General Public License.

â€œThe Libraryâ€ refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.

An â€œApplicationâ€ is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.

A â€œCombined Workâ€ is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the â€œLinked Versionâ€.

The â€œMinimal Corresponding Sourceâ€ for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.

The â€œCorresponding Application Codeâ€ for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:

a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:

a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License â€œor any later versionâ€ applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.name: KillScore
main: rib\score\Main
version: 0.1
author: ribnil
api:
  - 3.4.0
  - 4.0.0<?php

declare( strict_types = 1 );

namespace rib\score\command;

use pocketmine\{
	Server,
	Player
};

use pocketmine\command\{
	Command,
	CommandSender,
	defaults\VanillaCommand
};

use RuinPray\ui\UI;
use RuinPray\ui\elements\{
	Dropdown,
	Input,
	Label,
	Slider,
	StepSlider,
	Toggle
};

use rib\score\Main;

class ScoreCommand extends VanillaCommand {

	private static function error( $sender ): void {
		$sender->sendMessage( "ä½¿ã„æ–¹: Â§7/score [ ran, res ]" );
	}

	public static function rankSort( array $conf_data, string $player_name ): string {

		$rank = 1;
		$ranking_content = "";

		if(empty( $conf_data )) return "Â§7Not found score data.";

		arsort( $conf_data );

		foreach( $conf_data as $key => $value )
		{
			if( $player_name === $key ) {
				$key   = "Â§b{$key}";
				$value = "Â§e{$value}";
			}

			$content = "{$rank}: Â§7{$key}\nÂ§c => {$value}Â§r\n";
			$ranking_content = "{$ranking_content}{$content}";

			$rank++;
		}

		return $ranking_content;
	}

	public static function sendForm( string $title, string $content, $player ): void {

		$rand_id = mt_rand( 500, 5000 );
		$form = UI::createSimpleForm( $rand_id );

		$form->setTitle( $title );
		$form->setContent( $content );
		UI::sendForm( $player, $form );

		return;
	}

	public function execute( CommandSender $sender, string $commandLabel, array $args ): bool {

		$name = $sender->getName();
		$config = Main::scoreData();
		$score_data = $config->getAll();

		if(!isset( $args[0] )) {
			self::error( $sender );
			return true;
		}

		switch( $args[0] ) {

			case "1":
			case "ran":
			case "ranking":

				$title = "Â§lÂ§cKILLÂ§fRANKINGÂ§e!!";
				$sort_data = self::rankSort( $score_data, $name );

				self::sendForm( $title, $sort_data, $sender );

				return true;

			case "2":
			case "res":
			case "reset":

				if( !$sender->isOp() ) return true;

				foreach( $score_data as $key => $value ) {
					$config->set( $key, 0 );
				}

				$sender->sendMessage( "Â§aã‚¹ã‚³ã‚¢ã‚’Â§cå‰Šé™¤Â§aã—ã¾ã—ãŸã€‚" );

				return true;

			default:
				break;
		}

		self::error( $sender );
		return true;
	}
}<?php

/*
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ï¾„ï½¤
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€/ | |
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ ãƒŸï¿£ï½€ãƒ½ï½¤,,ï¾‰'''ãƒŽ'''/ ,/ï¾‰ãƒ‹ï¼'
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€.ï¼¿ãƒŸ'ã€€ã€€ã€€ã€€| ï¾„ï½¤ï½¤ã€€,,ãƒŽ ,//,,ãƒŽ,ï¾†''_ãƒŽj_,,
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ï¾ : : : : ã€€ã€€ã€€ã€€|ã€‰ï½€l ï¼‰|/,,/ /ã€€/ä¸‰ï¼å½¡'ã€€ã€€ã€€ï¼¿ã€€ãã•ã¾ï¼
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ãƒŸ::::::âˆ ï¼¿ãƒŸ--ï¾‰ã€€,,_,,å½¡_,ï½²_ãƒŽï¿£ãƒŸï½¤ Tã€€_,,ï½¨Yå½³âŒ’    ã€€ ã“ã®ã‚½ãƒ¼ã‚¹ã‚’
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ï½€lï½¤_ãƒˆ-â€''âŒ’ä¸‰ã {::::::::<ä¸‰/ï¾Šï¼¶ãƒŸï¼¿ Lï½²ï¾‰ï¼          è¦‹ã¦ã„ã‚‹ãªãƒƒï¼
ã€€ã€€ã€€ã€€ã€€ã€€ ï¼¿ãƒŽ / rj ï½Ž ,,;ï½´ !:::R::::::: ãƒ¾Â´ ï¾‰ãƒã€€ã€€ï¾‰::âˆ ã€€ã€€ï¼¿
ã€€ã€€ã€€ã€€ã€€ã€€ ï¼œäºŒ_ï¾‰/ ï¾„'j å½¡ l::::::I::::::::ã€€ã€€r'|,,ï½²ãƒ½:::::-ï½¤ ï¾ži /.......ï¾žl
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ ãƒ½--'ãƒŽ ãƒˆ|ãƒ‹-ï½¤::::::::B:::::::ã€€ jã€€ã€€Vï¾„ï½¤:::::::|,/ ::::::: ï¾‰
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ï¾žï¾—ï¼¿ï¾‰.|/ / ,ï½¤ ï¼¼::::::::::ã€€/:::ï¼¼,,-â”´â€'_ãƒï¼¿_/
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ { ã€Œã€€ Vâ”´ï¾:::::::::/:::::ï¼ ï¼¿,-//ï½¤ï¼¿_,,ãƒˆï½¤_
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€Vãƒ½:ã€€ï½€ãƒ½â””,ï½¤'::::ï¼râˆ ã€€ ã .{::::::::::: |â”.ï¾žl
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ ã‚ï½¤ï¼¿__.}_,-ï¾‰_:::|_/ãƒŽã€€ãƒ½ ã€€ï¼¼ï¾žãƒ¼-ï½²,,l_ã€€|ï½€ãƒ½
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ ,-â”€ï½ª| {::::::,,-lï¼::::|::âˆ ï½¤: : :: ï¾‰--ï½¤ã€€ã€€ /ã€€ã€€.ï¾Š:::::|
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ã€€ï¼::ï¼ãƒãƒ½__//:::::::::ï¼: : ::}__,ï½¨'ï½¤ï¼¿ï¾‰ã€€ã€€/./ï½€Vã€€.|::::|
ã€€ã€€ã€€ã€€ã€€ã€€_âˆ _ï¼:::::::::::::,ãƒ•ï½² /ã€€lÂ´: : ::ï¼|ã€€|ã€€|::::ãƒ½ ã€€ {_ï¾ž=ãƒŽ ï¼|:::}ï½¤
ã€€ã€€ã€€ã€€_âˆ ã€€ã€€|ï¼::::::::ï¼/ã€€ |ã€€ã€€ï½€ãƒ¼ï½²ãƒ.l-ï¾„ï½¤ãƒ::::|ï¼ ï¼ ,,ï½² |_|:/ï¾‰
ã€€ã€€ ï¼ã€€ã€€ã€€ã€€|::::::::::/ /::::::,âŠ¥ï¼¿__ã€€|ã€€ ï¾Šãƒ½ãƒ½|:::::rï¾†ï½¤ã‚¤ ï¼:::| lã€€|Y
ã€€ /ã€€ã€€ ,,-â€'':::ï½€ãƒ¼ï½² /_,,ï¼/:::ã€€ã€€ã€€ãƒ½V::::::ï¾Šãƒ½ï¼¼{__ï¾‰â€'Â´::::::::,ãƒˆ|_jÂ´
ã€€j::::::::/::::::::::::::::::://|:::::::::::ï¾‰ãƒŠ-ï½¤ï¼¿ï¼¿}::::::::::|.|:::::::::::ï¿£ï¿£ï¿£|,L/
/ã€€ã€€/::::::::::::::::ï¼: ã€ˆã€ˆ::::::âˆ __}ï¼¿ï¼¿}:::::::âˆ§:::::::||:::::::::::::::::::ä¸‰ã€ï¾žï½°'
ãƒ½ãƒ¼'--ï½¤ï¼¿ï¼|::::::::|.|:| {ï¼¿__}ï¼¿ï¼¿_::::::|ï¼¿:::::::||::::::::::::ä¸‰ï¼žï¾‰Â´
ã€€ã€€ã€€ã€€ã€€ã€€ã€€ {ä¸‰ä¸‰|||:::::::::::}:::::::::::::::::::|ã€€ ï¾„::::::ãƒ¾ï½¤ä¸‰ä¸‰ï¾‰ã€€|
*/

namespace rib\score;

use pocketmine\plugin\PluginBase;
use pocketmine\event\Listener;
use pocketmine\{
	Server,
	Player
};

use pocketmine\event\player\{
	PlayerJoinEvent,
	PlayerDeathEvent
};

use pocketmine\event\entity\EntityDamageByEntityEvent;

use pocketmine\utils\Config;
use rib\score\command\ScoreCommand;

class Main extends PluginBase implements Listener {

	private static $score_data;
  	private static $instance;

  	public static function getInstance(): Main {
    	return Main::$instance;
  	}

  	public static function scoreData(): Config {
  		return self::$score_data;
  	}

	public function onEnable() {

		Main::$instance = $this;

		if( !file_exists( $this->getDataFolder() )) mkdir( $this->getDataFolder(), 0744, true );
		self::$score_data = new Config( $this->getDataFolder()."Score.yml", Config::YAML, [] );

		Server::getInstance()->getPluginManager()->registerEvents( $this,  $this );
		Server::getInstance()->getCommandMap()->register( "pocketmine", new ScoreCommand( "score" ) );
	}

	public function onDeath( PlayerDeathEvent $e ) {

		$cause = $e->getPlayer()->getLastDamageCause();

		if( $cause instanceof EntityDamageByEntityEvent ) {

			$damager = $cause->getDamager();

			if( $damager instanceof Player ) {

				$name = $damager->getName();
				$kill_count = self::$score_data->get( $name );

				self::$score_data->set( $name, ++$kill_count );
			}
		}
	}

	public function onJoin( PlayerJoinEvent $e ) {

		$player = $e->getPlayer();
		$name = $player->getName();

		if( !self::$score_data->exists( $name ) ) {
			self::$score_data->set( $name, 0 );
		}
	}

	public function onDisable() {
		self::$score_data->save();
	}
}<?php

namespace RuinPray\ui\elements;

abstract class BaseElement implements Element {

	const TYPE = "";
	public $text = "text!"; /** @var string */

	public function text(string $text) : BaseElement {
		$this->text = $text;
		return $this;
	}

	public function content() {
		return [];
	}

}
<?php

namespace RuinPray\ui\elements;

class Dropdown extends BaseElement {

	const TYPE = "dropdown";

	public $options; /** @var array */

	public function options(array $options) : Dropdown {
		$this->options = $options;
		return $this;
	}

	public function content() : array {
		return [
			"type" => self::TYPE,
			"text" => $this->text,
			"options" => $this->options,
		];
	}
}
<?php

namespace RuinPray\ui\elements;

interface Element {

  /** @return array */
	public function content();

}
<?php

namespace RuinPray\ui\elements;

class Input extends BaseElement {

	const TYPE = "input";

	public $placeholder = null;
	public $default = null;

	public function placeholder(string $placeholder) : Input {
		$this->placeholder = $placeholder;
		return $this;
	}

	public function default(string $default) : Input {
		$this->default = $default;
		return $this;
	}

	public function content() : array {
		return [
			"type" => self::TYPE,
			"text" => $this->text,
			"placeholder" => $this->placeholder,
			"default" => $this->default ?? ""
		];
	}
}
<?php

namespace RuinPray\ui\elements;

class Label extends BaseElement {

  const TYPE = "label";

  public function content() {
    return [
      "type" => self::TYPE,
      "text" => $this->text
    ];
  }
}
<?php

namespace RuinPray\ui\elements;

class Slider extends BaseElement {

	const TYPE = "slider";

	public $min = 0;
	public $max = 10;

	public function min(int $min) : Slider {
		$this->min = $min;
		return $this;
	}

	public function max(int $max) : Slider {
		$this->max = $max;
		return $this;
	}

	public function content() : array {
		return [
			"type" => self::TYPE,
			"text" => $this->text,
			"min" => $this->min,
			"max" => $this->max
		];
	}
}
<?php

namespace RuinPray\ui\elements;

class StepSlider extends BaseElement {

	const TYPE = "step_slider";

	public $steps; /** @var array */

	public function steps(array $steps) : StepSlider {
		$this->steps = $steps;
		return $this;
	}

	public function content() : array {
		return [
			"type" => self::TYPE,
			"text" => $this->text,
			"steps" => $this->steps
		];
	}
}
<?php

namespace RuinPray\ui\elements;

class Toggle extends BaseElement {

	const TYPE = "toggle";
	public $default = false;


	public function default(bool $default) : Toggle {
		$this->default = $default;
		return $this;
	}

	public function content() : array {
		return [
			"type" => self::TYPE,
			"text" => $this->text,
			"default" => $this->default
		];
	}
}
<?php

namespace RuinPray\ui\forms;

use RuinPray\ui\elements\Element;

class CustomForm extends Window {

	public function __construct(Int $id){
		parent::__construct($id);

		$this->data = [
			"type" => "custom_form",
			"title" => "",
			"content" => []
		];
	}

	public function setTitle(String $title){
		$this->data["title"] = $title;
	}

/*----- Elements -----*/

	public function addContent(Element $element) {
		$this->data["content"][] = $element->content();
	}

}
<?php

namespace RuinPray\ui\forms;

class ModalForm extends Window {

	public function __construct(Int $id){
		parent::__construct($id);

		$this->data = [
			"type" => "modal",
			"title" => "",
			"content" => "",
			"button1" => "",
			"button2" => ""
		];
	}

	public function setTitle(String $title){
		$this->data["title"] = $title;
	}

	public function setContent(String $text){
		$this->data["content"] = $text;
	}

	public function setButton1(String $text){
		$this->data["button1"] = $text;
	}
	public function setButton2(String $text){
		$this->data["button2"] = $text;
	}
}<?php

namespace RuinPray\ui\forms;

class SimpleForm extends Window {

	public function __construct(Int $id){
		parent::__construct($id);
        
		$this->data = [
			"type" => "form",
			"title" => "",
			"content" => "",
			"buttons" => []
		];
	}

	public function setTitle(String $title){
		$this->data["title"] = $title;
	}

	public function setContent(String $text){
		$this->data["content"] = $text;
	}

	public function addButton(String $text, $image = null){
		if($image !== null){
			$this->data["buttons"][] = [
				"text" => $text,
				"image" => [
					"type" => "url",
					"data" => $image
				]
			];
		}else{
			$this->data["buttons"][] = [
				"text" => $text
			];
		}
	}
}<?php

namespace RuinPray\ui\forms;

class Window {

	protected $id;
	protected $data;

	public function __construct(Int $id){
		$this->id = $id;
	}

	public function encode(){
		$this->data = json_encode($this->data);
	}

	public function getId(){
		return $this->id;
	}
	
	public function getData(){
		return $this->data;
	}
}<?php

namespace RuinPray\ui;

use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;
use pocketmine\network\mcpe\protocol\ModalFormRequestPacket;

use pocketmine\Player;

use RuinPray\ui\forms\CustomForm;
use RuinPray\ui\forms\SimpleForm;
use RuinPray\ui\forms\ModalForm;

class UI {

	public static function createCustomForm(Int $id){
		return new CustomForm($id);
	}

	public static function createModalForm(Int $id){
		return new ModalForm($id);
	}

	public static function createSimpleForm(Int $id){
		return new SimpleForm($id);
	}

	public static function sendForm($player, $form){
		$pk = new ModalFormRequestPacket();
		$form->encode();
		$pk->formId = $form->getId();
		$pk->formData = $form->getData();
		$player->dataPacket($pk);
	}

}Ôü!IDkLŒGüxZ)AµÇy   GBMB