├── .gitignore ├── .poggit.yml ├── LICENSE ├── README.md ├── plugin.yml ├── resources ├── eng.ini └── jpn.ini └── src └── aieuo └── ip ├── EventListener.php ├── IFAPI.php ├── IFPlugin.php ├── Session.php ├── commands └── IFCommand.php ├── conditions ├── CanAddItem.php ├── Comparison.php ├── Condition.php ├── ConditionFactory.php ├── ConditionIds.php ├── ExistsItem.php ├── ExistsVariable.php ├── GameMode.php ├── InArea.php ├── InAreaWithAxis.php ├── InHand.php ├── IsFlying.php ├── IsOp.php ├── IsSneaking.php ├── LessMoney.php ├── NoCheck.php ├── OverMoney.php ├── RandomNumber.php ├── RemoveItem.php ├── TakeMoney.php ├── TypeItem.php └── TypeMoney.php ├── economy ├── EconomyAPILoader.php ├── EconomyLoader.php ├── MoneySystemLoader.php └── PocketMoneyLoader.php ├── form ├── BlockForm.php ├── ChainIfForm.php ├── CommandForm.php ├── Elements.php ├── EventForm.php ├── ExportForm.php ├── Form.php ├── FormIFForm.php └── ImportForm.php ├── formAPI ├── CustomForm.php ├── Form.php ├── ListForm.php ├── ModalForm.php └── element │ ├── Button.php │ ├── Dropdown.php │ ├── Element.php │ ├── Input.php │ ├── Label.php │ ├── Slider.php │ ├── StepSlider.php │ └── Toggle.php ├── manager ├── BlockManager.php ├── ChainIfManager.php ├── CommandManager.php ├── EventManager.php ├── FormIFManager.php └── IFManager.php ├── processes ├── AddEffect.php ├── AddEnchantment.php ├── AddItem.php ├── AddMoney.php ├── AddParticle.php ├── AddParticleRange.php ├── AddSound.php ├── AddVariable.php ├── Attack.php ├── BroadcastMessage.php ├── Calculation.php ├── ChangeItemData.php ├── ClearInventory.php ├── Command.php ├── CommandConsole.php ├── Cooperation.php ├── CooperationRepeat.php ├── DelayedCommand.php ├── DelayedCommandConsole.php ├── DelayedCooperation.php ├── DeleteVariable.php ├── DoNothing.php ├── EquipArmor.php ├── EventCancel.php ├── ExecuteOtherPlayer.php ├── GenerateRandomNumber.php ├── GetInventoryContents.php ├── Kick.php ├── Motion.php ├── Process.php ├── ProcessFactory.php ├── ProcessIds.php ├── RemoveBossbar.php ├── RemoveItem.php ├── SaveDatas.php ├── SendForm.php ├── SendMessage.php ├── SendMessageToOp.php ├── SendTip.php ├── SendTitle.php ├── SendVoiceMessage.php ├── SetBlocks.php ├── SetFood.php ├── SetGamemode.php ├── SetHealth.php ├── SetImmobile.php ├── SetItem.php ├── SetMaxHealth.php ├── SetMoney.php ├── SetNametag.php ├── SetScale.php ├── SetSitting.php ├── SetSleeping.php ├── ShowBossbar.php ├── TakeMoney.php ├── Teleport.php ├── TypeCommand.php ├── TypeItem.php ├── TypeMessage.php ├── TypeMoney.php ├── TypePosition.php └── UnSetImmobile.php ├── task ├── DelayedCommandTask.php ├── DelayedCooperationTask.php ├── KickTask.php └── SaveTask.php ├── utils ├── Bossbar.php └── Language.php └── variable ├── ListVariable.php ├── NumberVariable.php ├── StringVariable.php ├── Variable.php └── VariableHelper.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | /composer.json 3 | /composer.lock 4 | /.idea/ -------------------------------------------------------------------------------- /.poggit.yml: -------------------------------------------------------------------------------- 1 | --- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/aieuo/if_plugin 2 | branches: 3 | - master 4 | projects: 5 | if_plugin: 6 | path: "" 7 | ... 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | University of Illinois/NCSA Open Source License 2 | 3 | Copyright © 2020, aieuo. All rights reserved. 4 | 5 | Developed by: aieuo 6 | https://github.com/aieuo 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of   9 | this software and associated documentation files (the "Software"), to deal with 10 | the Software without restriction, including without limitation the rights to 11 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | of the Software, and to permit persons to whom the Software is furnished to do 13 | so, subject to the following conditions: 14 | 15 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers. 16 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution. 17 | * Neither the names of aieuo, nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # if_plugin 2 | https://forum.mcbe.jp/resources/172/ 3 | 4 | # TODO 5 | - [ ] フォームを何とかする 6 | - [ ] IF内だけの変数みたいなの追加する 7 | - [ ] IFをまとめて出力できるようにする 8 | - [ ] 値を比較する の型を厳しくする 9 | - [ ] 条件,処理内の順番入れ替えできるようにする 10 | - [ ] 処理のスリープみたいなの追加する 11 | - [ ] 処理のループ追加する 12 | - [ ] 条件,処理の関数みたいなの 13 | -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: if 3 | main: aieuo\ip\IFPlugin 4 | version: 3.9.1 5 | api: 3.0.0 6 | load: POSTWORLD 7 | author: aieuo 8 | permissions: 9 | ifplugin.customcommand.op: 10 | default: op 11 | description: "ifplugin.customcommand.op" 12 | ifplugin.customcommand.true: 13 | default: true 14 | description: "ifplugin.customcommand.true" 15 | ... -------------------------------------------------------------------------------- /src/aieuo/ip/Session.php: -------------------------------------------------------------------------------- 1 | getName()])) self::createSession($player); 23 | return self::$sessions[$player->getName()]; 24 | } 25 | 26 | public static function createSession(Player $player) { 27 | self::$sessions[$player->getName()] = new Session(); 28 | } 29 | 30 | //////////////////////////////////////////////////////////////////////// 31 | 32 | /** @var bool */ 33 | private $valid = false; 34 | private $if_type = null; 35 | /** @var array */ 36 | private $datas = []; 37 | 38 | public function isValid(): bool { 39 | return $this->valid; 40 | } 41 | 42 | public function setValid($valid = true, $deleteDatas = true): self { 43 | $this->valid = $valid; 44 | if (!$valid and $deleteDatas) $this->removeAll(); 45 | return $this; 46 | } 47 | 48 | public function get($key, $default = null) { 49 | if (!isset($this->datas[$key])) return $default; 50 | return $this->datas[$key]; 51 | } 52 | 53 | public function set($key, $data): self { 54 | $this->datas[$key] = $data; 55 | return $this; 56 | } 57 | 58 | public function remove($key) { 59 | unset($this->datas[$key]); 60 | } 61 | 62 | public function removeAll() { 63 | $this->datas = []; 64 | } 65 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/CanAddItem.php: -------------------------------------------------------------------------------- 1 | getItem(); 17 | if (!($item instanceof Item)) return false; 18 | return Language::get("condition.canadditem.detail", [$item->getId(), $item->getDamage(), $item->getName(), $item->getCount()]); 19 | } 20 | 21 | public function check() { 22 | $player = $this->getPlayer(); 23 | $item = $this->getItem(); 24 | if (!($item instanceof Item)) { 25 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 26 | return self::ERROR; 27 | } 28 | if ($player->getInventory()->canAddItem($item)) return self::MATCHED; 29 | return self::NOT_MATCHED; 30 | } 31 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/Condition.php: -------------------------------------------------------------------------------- 1 | player = $player; 36 | } 37 | 38 | public static function get($id) { 39 | return ConditionFactory::get($id); 40 | } 41 | 42 | public function getId() { 43 | return $this->id; 44 | } 45 | 46 | public function getName(): string { 47 | if ($this->name[0] === "@") { 48 | return Language::get(substr($this->name, 1)); 49 | } 50 | return $this->name; 51 | } 52 | 53 | public function getDescription(): string { 54 | if ($this->description[0] === "@") { 55 | return Language::get(substr($this->description, 1)); 56 | } 57 | return $this->description; 58 | } 59 | 60 | // TODO 失敗したときfalse返すかnull返すか統一する 61 | public function getDetail(): string { 62 | if ($this->detail[0] === "@") { 63 | return Language::get(substr($this->detail, 1)); 64 | } 65 | return $this->detail; 66 | } 67 | 68 | public function parse(string $str) { 69 | return $str; 70 | } 71 | 72 | public function setPlayer(Player $player) : self { 73 | $this->player = $player; 74 | return $this; 75 | } 76 | 77 | // TODO オンラインのチェック 78 | public function getPlayer() : Player { 79 | return $this->player; 80 | } 81 | 82 | public function setValues($values) : self { 83 | $this->values = $values; 84 | return $this; 85 | } 86 | 87 | public function getValues() { 88 | return $this->values; 89 | } 90 | 91 | public function getEditForm(string $default = "", string $mes = "") { 92 | $data = [ 93 | "type" => "custom_form", 94 | "title" => $this->getName(), 95 | "content" => [ 96 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 97 | Elements::getToggle(Language::get("form.delete")), 98 | Elements::getToggle(Language::get("form.cancel")) 99 | ] 100 | ]; 101 | $json = Form::encodeJson($data); 102 | return $json; 103 | } 104 | 105 | public function parseFormData(array $data) { 106 | return ["status" => true, "contents" => "", "delete" => $data[1], "cancel" => $data[2]]; 107 | } 108 | 109 | public function check() { 110 | return Ifs::NOT_FOUND; 111 | } 112 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/ConditionFactory.php: -------------------------------------------------------------------------------- 1 | getEconomy() instanceof EconomyLoader; 13 | 14 | self::register(new NoCheck()); 15 | if ($existsEconomy) self::register(new TakeMoney()); 16 | if ($existsEconomy) self::register(new OverMoney()); 17 | if ($existsEconomy) self::register(new LessMoney()); 18 | self::register(new InHand()); 19 | self::register(new ExistsItem()); 20 | self::register(new RemoveItem()); 21 | self::register(new CanAddItem()); 22 | self::register(new IsOp()); 23 | self::register(new IsSneaking()); 24 | self::register(new IsFlying()); 25 | self::register(new GameMode()); 26 | self::register(new InArea()); 27 | self::register(new InAreaWithAxis()); 28 | self::register(new RandomNumber()); 29 | self::register(new Comparison()); 30 | self::register(new ExistsVariable()); 31 | } 32 | /** 33 | * @param int $id 34 | * @return Condition|null 35 | */ 36 | public static function get($id): ?Condition { 37 | if (isset(self::$list[$id])) { 38 | return clone self::$list[$id]; 39 | } 40 | return null; 41 | } 42 | 43 | public static function getAll(): array { 44 | return self::$list; 45 | } 46 | 47 | /** 48 | * @param Condition $condition 49 | */ 50 | public static function register(Condition $condition) { 51 | self::$list[$condition->getId()] = clone $condition; 52 | } 53 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/ConditionIds.php: -------------------------------------------------------------------------------- 1 | getItem(); 17 | if (!($item instanceof Item)) return false; 18 | return Language::get("condition.existsitem.detail", [$item->getId(), $item->getDamage(), $item->getName(), $item->getCount()]); 19 | } 20 | 21 | public function check() { 22 | $player = $this->getPlayer(); 23 | $item = $this->getItem(); 24 | if (!($item instanceof Item)) { 25 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 26 | return self::ERROR; 27 | } 28 | if ($player->getInventory()->contains($item)) return self::MATCHED; 29 | return self::NOT_MATCHED; 30 | } 31 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/ExistsVariable.php: -------------------------------------------------------------------------------- 1 | getVariableName(); 18 | return Language::get("condition.existsvariable.detail", [$name]); 19 | } 20 | 21 | public function getVariableName(): ?string { 22 | $name = $this->getValues(); 23 | return is_string($name) ? $name : null; 24 | } 25 | 26 | public function setVariableName(string $variable) { 27 | $this->setValues($variable); 28 | } 29 | 30 | public function check() { 31 | if (IFPlugin::getInstance()->getVariableHelper()->exists($this->getVariableName())) return self::MATCHED; 32 | return self::NOT_MATCHED; 33 | } 34 | 35 | 36 | public function getEditForm(string $default = "", string $mes = "") { 37 | $data = [ 38 | "type" => "custom_form", 39 | "title" => $this->getName(), 40 | "content" => [ 41 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 42 | Elements::getInput(Language::get("condition.existsvariable.form.name"), Language::get("input.example", ["aieuo"]), $default), 43 | Elements::getToggle(Language::get("form.delete")), 44 | Elements::getToggle(Language::get("form.cancel")) 45 | ] 46 | ]; 47 | $json = Form::encodeJson($data); 48 | return $json; 49 | } 50 | 51 | public function parseFormData(array $data){ 52 | $status = true; 53 | if ($data[1] === "") $status = null; 54 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 55 | } 56 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/GameMode.php: -------------------------------------------------------------------------------- 1 | getGamemode(); 26 | if ($gamemode === false) return false; 27 | return Language::get("condition.gamemode.detail", [Language::get($this->gamemodes[$gamemode])]); 28 | } 29 | 30 | public function getGamemode() { 31 | return $this->getValues(); 32 | } 33 | 34 | public function setGamemode(int $gamemode) { 35 | $this->setValues($gamemode); 36 | } 37 | 38 | public function parse(string $gamemode) { 39 | $intGamemode = Server::getInstance()->getGamemodeFromString($gamemode); 40 | if ($intGamemode === -1) return false; 41 | return $intGamemode; 42 | } 43 | 44 | public function check() { 45 | $player = $this->getPlayer(); 46 | $gamemode = $this->getGamemode(); 47 | if ($gamemode === false) { 48 | $player->sendMessage(Language::get("condition.gamemode.notfound")); 49 | return self::ERROR; 50 | } 51 | return $player->getGamemode() === $gamemode ? self::MATCHED : self::NOT_MATCHED; 52 | } 53 | 54 | 55 | public function getEditForm(string $default = "", string $mes = "") { 56 | if ($default === "") { 57 | $gamemode = 0; 58 | } elseif (($gamemode = $this->parse($default)) === false) { 59 | $mes .= Language::get("condition.gamemode.notfound"); 60 | $gamemode = 0; 61 | } 62 | $data = [ 63 | "type" => "custom_form", 64 | "title" => $this->getName(), 65 | "content" => [ 66 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 67 | Elements::getDropdown( 68 | Language::get("condition.gamemode.form.gamemode"), 69 | array_map(function ($g) { 70 | return Language::get($g); 71 | }, $this->gamemodes), 72 | $gamemode 73 | ), 74 | Elements::getToggle(Language::get("form.delete")), 75 | Elements::getToggle(Language::get("form.cancel")) 76 | ] 77 | ]; 78 | $json = Form::encodeJson($data); 79 | return $json; 80 | } 81 | 82 | public function parseFormData(array $data) { 83 | $status = true; 84 | if ($data[1] === "") { 85 | $status = null; 86 | } else { 87 | $gamemode = $this->parse((string)$data[1]); 88 | if ($gamemode === false) $status = false; 89 | } 90 | return ["status" => $status, "contents" => (string)$data[1], "delete" => $data[2], "cancel" => $data[3]]; 91 | } 92 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/InArea.php: -------------------------------------------------------------------------------- 1 | setValues($area); 18 | } 19 | 20 | public function getDetail(): string { 21 | $areas = $this->getArea(); 22 | if ($areas === false) return false; 23 | $message = Language::get("condition.inarea.detail1"); 24 | $mes = []; 25 | foreach ($areas as $axis => $area) { 26 | $mes[] = Language::get("condition.inarea.detail2", [$axis, $area[0], $area[1]]); 27 | } 28 | return $message.Language::get("condition.inarea.detail3", [implode(",", $mes)]); 29 | } 30 | 31 | public function getArea() { 32 | return $this->getValues(); 33 | } 34 | 35 | public function setArea(Array $area) { 36 | $this->setValues($area); 37 | } 38 | 39 | public function parse(string $areas) { 40 | if (!preg_match_all("/([xyz]\(-?[0-9]+\.?[0-9]*,-?[0-9]+\.?[0-9]*\))/", $areas, $matches)) return false; 41 | $areas = []; 42 | foreach ($matches[1] as $match) { 43 | if (!preg_match("/([xyz])\((-?[0-9]+\.?[0-9]*),(-?[0-9]+\.?[0-9]*)\)/", $match, $matches1)) continue; 44 | $min = min((float)$matches1[2], (float)$matches1[3]); 45 | $max = max((float)$matches1[2], (float)$matches1[3]); 46 | $areas[$matches1[1]] = [$min, $max]; 47 | } 48 | return $areas; 49 | } 50 | 51 | public function check() { 52 | $player = $this->getPlayer(); 53 | $areas = $this->getArea(); 54 | if ($areas === false) { 55 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 56 | return self::ERROR; 57 | } 58 | foreach ($areas as $axis => $area) { 59 | if ($player->$axis < $area[0] or $player->$axis > $area[1]) return self::NOT_MATCHED; 60 | } 61 | return self::MATCHED; 62 | } 63 | 64 | public function getEditForm(string $default = "", string $mes = "") { 65 | $mes .= Language::get("condition.inarea.error"); 66 | $areas = $this->parse($default); 67 | if ($areas === false) { 68 | $areas = ["x" => $default, "y" => "", "z" => ""]; 69 | if ($default !== "") $mes .= Language::get("form.error"); 70 | } 71 | 72 | $content = [Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes))]; 73 | foreach (["x", "y", "z"] as $axis) { 74 | if (!isset($areas[$axis])) $areas[$axis] = ""; 75 | if (is_array(($areas[$axis]))) $areas[$axis] = $areas[$axis][0].",".$areas[$axis][1]; 76 | $content[] = Elements::getInput( 77 | Language::get("condition.inarea.form.area", [$axis]), 78 | Language::get("input.example", ["0,100"]), 79 | $areas[$axis] 80 | ); 81 | } 82 | $content[] = Elements::getToggle(Language::get("form.delete")); 83 | $content[] = Elements::getToggle(Language::get("form.cancel")); 84 | $data = [ 85 | "type" => "custom_form", 86 | "title" => $this->getName(), 87 | "content" => $content 88 | ]; 89 | $json = Form::encodeJson($data); 90 | return $json; 91 | } 92 | 93 | public function parseFormData(array $data) { 94 | $status = true; 95 | $area_str = $data[1] !== "" ? "x(".$data[1].")" : ""; 96 | $area_str .= $data[2] !== "" ? "y(".$data[2].")" : ""; 97 | $area_str .= $data[3] !== "" ? "z(".$data[3].")" : ""; 98 | if ($data[1] === "" and $data[2] === "" and $data[3] === "") { 99 | $status = null; 100 | } else { 101 | $areas = $this->parse($area_str); 102 | if ($areas == false) $status = false; 103 | } 104 | return ["status" => $status, "contents" => $area_str, "delete" => $data[4], "cancel" => $data[5]]; 105 | } 106 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/InAreaWithAxis.php: -------------------------------------------------------------------------------- 1 | getValues(); 19 | if ($areas === false) return false; 20 | return Language::get("condition.inAreaWithAxis.detail", [$this->axes[$this->getAxis()], $this->getMin(), $this->getMax()]); 21 | } 22 | 23 | public function getAxis() { 24 | return $this->getValues()[0]; 25 | } 26 | 27 | public function getMin() { 28 | return $this->getValues()[1]; 29 | } 30 | 31 | public function getMax() { 32 | return $this->getValues()[2]; 33 | } 34 | 35 | public function parse(string $areas) { 36 | $data = explode("[min]", $areas); 37 | $axis = (int)$data[0]; 38 | if (!isset($data[1])) return false; 39 | $data = explode("[max]", $data[1]); 40 | $min = $data[0]; 41 | if (!isset($data[1])) return false; 42 | $max = $data[1]; 43 | return [$axis, $min == "" ? null : (float)$min, $max == "" ? null : (float)$max]; 44 | } 45 | 46 | public function check() { 47 | $player = $this->getPlayer(); 48 | $areas = $this->getValues(); 49 | if ($areas === false) { 50 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 51 | return self::ERROR; 52 | } 53 | $axis = $this->axes[$areas[0]]; 54 | $min = $areas[1]; 55 | $max = $areas[2]; 56 | $pos = $player->$axis; 57 | 58 | if (($min === null or $pos >= $min) and ($max === null or $pos <= $max)) { 59 | return self::MATCHED; 60 | } 61 | return self::NOT_MATCHED; 62 | } 63 | 64 | public function getEditForm(string $default = "", string $mes = "") { 65 | $settings = $this->parse($default); 66 | $data1 = explode("[min]", $default); 67 | $axis = (int)$data1[0]; 68 | $data2 = explode("[max]", $data1[1] ?? $default); 69 | $min = $data2[0]; 70 | $max = $data2[1] ?? $data1[1] ?? $default; 71 | if ($settings !== false) { 72 | $axis = $settings[0]; 73 | $min = (string)$settings[1]; 74 | $max = (string)$settings[2]; 75 | } elseif ($default !== "") { 76 | $mes .= Language::get("form.error"); 77 | } 78 | $data = [ 79 | "type" => "custom_form", 80 | "title" => $this->getName(), 81 | "content" => [ 82 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 83 | Elements::getDropdown( 84 | Language::get("condition.inAreaWithAxis.form.axis"), 85 | array_map(function ($a) { 86 | return $a.Language::get("condition.inAreaWithAxis.axis"); 87 | }, $this->axes), 88 | $axis 89 | ), 90 | Elements::getInput(Language::get("condition.inAreaWithAxis.form.min"), "", $min), 91 | Elements::getInput(Language::get("condition.inAreaWithAxis.form.max"), "", $max), 92 | Elements::getToggle(Language::get("form.delete")), 93 | Elements::getToggle(Language::get("form.cancel")) 94 | ] 95 | ]; 96 | $json = Form::encodeJson($data); 97 | return $json; 98 | } 99 | 100 | public function parseFormData(array $data) { 101 | $status = true; 102 | $contents = $data[1]."[min]".$data[2]."[max]".$data[3]; 103 | if ($data[2] === "" and $data[3] === "") { 104 | $status = null; 105 | } else { 106 | $areas = $this->parse($contents); 107 | if ($areas == false) $status = false; 108 | } 109 | return ["status" => $status, "contents" => $contents, "delete" => $data[4], "cancel" => $data[5]]; 110 | } 111 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/InHand.php: -------------------------------------------------------------------------------- 1 | getItem(); 17 | if (!($item instanceof Item)) return false; 18 | return Language::get("condition.inhand.detail", [$item->getId(), $item->getDamage(), $item->getName(), $item->getCount()]); 19 | } 20 | 21 | public function check() { 22 | $player = $this->getPlayer(); 23 | $item = $this->getItem(); 24 | if (!($item instanceof Item)) { 25 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 26 | return self::ERROR; 27 | } 28 | $hand = $player->getInventory()->getItemInHand(); 29 | if ($this->itemEquals($item, $hand) and $hand->getCount() >= $item->getCount()) { 30 | return self::MATCHED; 31 | } 32 | return self::NOT_MATCHED; 33 | } 34 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/IsFlying.php: -------------------------------------------------------------------------------- 1 | getPlayer(); 14 | return $player->isFlying() ? self::MATCHED : self::NOT_MATCHED; 15 | } 16 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/IsOp.php: -------------------------------------------------------------------------------- 1 | getPlayer(); 14 | return $player->isOp() ? self::MATCHED : self::NOT_MATCHED; 15 | } 16 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/IsSneaking.php: -------------------------------------------------------------------------------- 1 | getPlayer(); 14 | return $player->isSneaking() ? self::MATCHED : self::NOT_MATCHED; 15 | } 16 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/LessMoney.php: -------------------------------------------------------------------------------- 1 | getAmount()]); 18 | } 19 | 20 | public function check() { 21 | $player = $this->getPlayer(); 22 | $economy = IFPlugin::getInstance()->getEconomy(); 23 | if ($economy === null) { 24 | $player->sendMessage(TextFormat::RED.Language::get("economy.notfound")); 25 | return self::ERROR; 26 | } 27 | $mymoney = $economy->getMoney($player->getName()); 28 | if ($mymoney <= $this->getAmount()) return self::MATCHED; 29 | return self::NOT_MATCHED; 30 | } 31 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/NoCheck.php: -------------------------------------------------------------------------------- 1 | getAmount()]); 18 | } 19 | 20 | public function check() { 21 | $player = $this->getPlayer(); 22 | $economy = IFPlugin::getInstance()->getEconomy(); 23 | if ($economy === null) { 24 | $player->sendMessage(TextFormat::RED.Language::get("economy.notfound")); 25 | return self::ERROR; 26 | } 27 | $mymoney = $economy->getMoney($player->getName()); 28 | if ($mymoney >= $this->getAmount()) return self::MATCHED; 29 | return self::NOT_MATCHED; 30 | } 31 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/RandomNumber.php: -------------------------------------------------------------------------------- 1 | getValues() === false) return false; 17 | return Language::get("condition.randomnumber.detail", [$this->getMin(), $this->getMax(), $this->getCheck()]); 18 | } 19 | 20 | public function getMin() { 21 | return $this->getValues()[0]; 22 | } 23 | 24 | public function getMax() { 25 | return $this->getValues()[1]; 26 | } 27 | 28 | public function getCheck() { 29 | return $this->getValues()[2]; 30 | } 31 | 32 | public function setNumbers(int $min, int $max, int $check) { 33 | $this->setValues([$min, $max, $check]); 34 | } 35 | 36 | public function parse(string $numbers) { 37 | if (!preg_match("/(-?[0-9]+),(-?[0-9]+),(-?[0-9]+)/", $numbers, $matches)) return false; 38 | $min = min((int)$matches[1], (int)$matches[2]); 39 | $max = max((int)$matches[1], (int)$matches[2]); 40 | return [$min, $max, (int)$matches[3]]; 41 | } 42 | 43 | public function check() { 44 | $player = $this->getPlayer(); 45 | if ($this->getValues() === false) { 46 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 47 | return self::ERROR; 48 | } 49 | $rand = mt_rand($this->getMin(), $this->getMax()); 50 | if ($rand === $this->getCheck()) return self::MATCHED; 51 | return self::NOT_MATCHED; 52 | } 53 | 54 | 55 | public function getEditForm(string $default = "", string $mes = "") { 56 | $numbers = $this->parse($default); 57 | $min = $default; 58 | $max = ""; 59 | $check = ""; 60 | if ($numbers !== false) { 61 | $min = $numbers[0]; 62 | $max = $numbers[1]; 63 | $check = $numbers[2]; 64 | if ($check > $max or $check < $min) { 65 | $mes .= Language::get("condition.randomnumber.form.warning", [$check, $min, $max]); 66 | } 67 | } elseif ($default !== "") { 68 | $mes .= Language::get("form.error"); 69 | } 70 | $data = [ 71 | "type" => "custom_form", 72 | "title" => $this->getName(), 73 | "content" => [ 74 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 75 | Elements::getInput(Language::get("condition.randomnumber.form.min"), Language::get("input.example", ["1"]), $min), 76 | Elements::getInput(Language::get("condition.randomnumber.form.max"), Language::get("input.example", ["5"]), $max), 77 | Elements::getInput(Language::get("condition.randomnumber.form.check"), Language::get("input.example", ["3"]), $check), 78 | Elements::getToggle(Language::get("form.delete")), 79 | Elements::getToggle(Language::get("form.cancel")) 80 | ] 81 | ]; 82 | $json = Form::encodeJson($data); 83 | return $json; 84 | } 85 | 86 | public function parseFormData(array $data) { 87 | $status = true; 88 | $num_str = $data[1].",".$data[2].",".$data[3]; 89 | if ($data[1] === "" or $data[2] === "" or $data[3] === "") { 90 | $status = null; 91 | } else { 92 | $num = $this->parse($num_str); 93 | if ($num === false) $status = false; 94 | } 95 | return ["status" => $status, "contents" => $num_str, "delete" => $data[4], "cancel" => $data[5]]; 96 | } 97 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/RemoveItem.php: -------------------------------------------------------------------------------- 1 | getItem(); 19 | if (!($item instanceof Item)) return false; 20 | return Language::get("condition.removeitem.detail", [$item->getId(), $item->getDamage(), $item->getName(), $item->getCount()]); 21 | } 22 | 23 | public function check() { 24 | $player = $this->getPlayer(); 25 | $item = $this->getItem(); 26 | if (!($item instanceof Item)) { 27 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 28 | return self::ERROR; 29 | } 30 | if ($item->getCount() === 0) { 31 | $player->getInventory()->remove($item); 32 | return self::MATCHED; 33 | } 34 | if ($player->getInventory()->contains($item)) { 35 | $player->getInventory()->removeItem($item); 36 | return self::MATCHED; 37 | } 38 | return self::NOT_MATCHED; 39 | } 40 | 41 | public function getEditForm(string $default = "", string $mes = "") { 42 | $item = explode(":", $default); 43 | $id = $default; 44 | $count = ""; 45 | $name = ""; 46 | $lore = ""; 47 | $enchant = ""; 48 | if (count($item) >= 3) { 49 | $id = $item[0].":".$item[1]; 50 | $count = $item[2]; 51 | $name = $item[3] ?? ""; 52 | $lore = $item[4] ?? ""; 53 | $enchant = $item[5] ?? ""; 54 | if ($count === 0) $mes .= Language::get("condition.removeitem.all"); 55 | } elseif ($default !== "") { 56 | $mes .= Language::get("condition.item.form.invalid"); 57 | } 58 | $data = [ 59 | "type" => "custom_form", 60 | "title" => $this->getName(), 61 | "content" => [ 62 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 63 | Elements::getInput(Language::get("condition.item.form.id"), Language::get("input.example", ["1:0"]), $id), 64 | Elements::getInput(Language::get("condition.removeitem.form.count"), Language::get("input.example", ["5"]), $count), 65 | Elements::getInput(Language::get("condition.item.form.name"), Language::get("input.example", ["aieuo"]), $name), 66 | Elements::getInput(Language::get("process.item.form.lore"), Language::get("input.example", ["aiueo;aieuo;aeiuo"]), $lore), 67 | Elements::getInput(Language::get("process.item.form.enchant"), Language::get("input.example", ["id,level;1,1;5,10"]), $enchant), 68 | Elements::getToggle(Language::get("form.delete")), 69 | Elements::getToggle(Language::get("form.cancel")) 70 | ] 71 | ]; 72 | return Form::encodeJson($data); 73 | } 74 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/TakeMoney.php: -------------------------------------------------------------------------------- 1 | getAmount()]); 18 | } 19 | 20 | public function check() { 21 | $player = $this->getPlayer(); 22 | $economy = IFPlugin::getInstance()->getEconomy(); 23 | if ($economy === null) { 24 | $player->sendMessage(TextFormat::RED.Language::get("economy.notfound")); 25 | return self::ERROR; 26 | } 27 | $mymoney = $economy->getMoney($player->getName()); 28 | if ($mymoney >= $this->getAmount()) { 29 | $economy->takeMoney($player->getName(), $this->getAmount()); 30 | return self::MATCHED; 31 | } 32 | return self::NOT_MATCHED; 33 | } 34 | } -------------------------------------------------------------------------------- /src/aieuo/ip/conditions/TypeMoney.php: -------------------------------------------------------------------------------- 1 | getValues(); 12 | if (!is_int($amount)) return null; 13 | return (int)$amount; 14 | } 15 | 16 | public function setAmount(int $amount) { 17 | $this->setValues($amount); 18 | } 19 | 20 | public function parse(string $amount) { 21 | $amount = (int)mb_convert_kana($amount, "n"); 22 | return $amount; 23 | } 24 | 25 | public function getEditForm(string $default = "", string $mes = "") { 26 | $money = $this->parse($default); 27 | if ($money <= 0) $money = $default; 28 | if ($money <= 0 and $default !== "") $mes .= Language::get("condition.overmoney.zero"); 29 | $data = [ 30 | "type" => "custom_form", 31 | "title" => $this->getName(), 32 | "content" => [ 33 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)."\n"), 34 | Elements::getInput(Language::get("condition.overmoney.form.amount"), Language::get("input.example", ["1000"]), $money), 35 | Elements::getToggle(Language::get("form.delete")), 36 | Elements::getToggle(Language::get("form.cancel")) 37 | ] 38 | ]; 39 | $json = Form::encodeJson($data); 40 | return $json; 41 | } 42 | 43 | public function parseFormData(array $data) { 44 | $status = true; 45 | if ($data[1] === "") $status = null; 46 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 47 | } 48 | } -------------------------------------------------------------------------------- /src/aieuo/ip/economy/EconomyAPILoader.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 11 | } 12 | 13 | public function getPlugin() { 14 | return $this->plugin; 15 | } 16 | 17 | public function getMoney(string $name) { 18 | return (int)$this->getPlugin()->mymoney($name); 19 | } 20 | 21 | public function addMoney(string $name, int $money) { 22 | $this->getPlugin()->addMoney($name, $money); 23 | return true; 24 | } 25 | 26 | public function takeMoney(string $name, int $money) { 27 | $this->getPlugin()->reduceMoney($name, $money); 28 | return true; 29 | } 30 | 31 | public function setMoney(string $name, int $money) { 32 | $this->getPlugin()->setMoney($name, $money); 33 | return true; 34 | } 35 | } -------------------------------------------------------------------------------- /src/aieuo/ip/economy/EconomyLoader.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 11 | } 12 | 13 | public function getPlugin(){ 14 | return $this->plugin; 15 | } 16 | 17 | public function getMoney(string $name){ 18 | return (int)$this->getPlugin()->getAPI()->get($name); 19 | } 20 | 21 | public function addMoney(string $name, int $money){ 22 | $this->getPlugin()->getAPI()->increase($name, $money); 23 | return true; 24 | } 25 | 26 | public function takeMoney(string $name, int $money){ 27 | $this->getPlugin()->getAPI()->reduce($name, $money); 28 | return true; 29 | } 30 | 31 | public function setMoney(string $name, int $money) { 32 | $this->getPlugin()->getAPI()->set($name, $money); 33 | return true; 34 | } 35 | } -------------------------------------------------------------------------------- /src/aieuo/ip/economy/PocketMoneyLoader.php: -------------------------------------------------------------------------------- 1 | plugin = $plugin; 11 | } 12 | 13 | public function getPlugin(){ 14 | return $this->plugin; 15 | } 16 | 17 | public function getMoney(string $name){ 18 | return (int)$this->getPlugin()->getMoney($name); 19 | } 20 | 21 | public function addMoney(string $name, int $money){ 22 | $mymoney = $this->getMoney($name); 23 | $this->getPlugin()->setMoney($name, $mymoney + $money); 24 | return true; 25 | } 26 | 27 | public function takeMoney(string $name, int $money){ 28 | $mymoney = $this->getMoney($name); 29 | $this->getPlugin()->setMoney($name, $mymoney - $money); 30 | return true; 31 | } 32 | 33 | public function setMoney(string $name, int $money) { 34 | $this->getPlugin()->setMoney($name, $money); 35 | return true; 36 | } 37 | } -------------------------------------------------------------------------------- /src/aieuo/ip/form/BlockForm.php: -------------------------------------------------------------------------------- 1 | setContent("@form.selectButton") 15 | ->setButtons([ 16 | new Button(Language::get("form.action.edit")), 17 | new Button("@form.action.check"), 18 | new Button("@form.action.delete"), 19 | new Button("@form.action.copy"), 20 | new Button("@form.cancel"), 21 | new Button("@form.back") 22 | ])->onReceive(function (Player $player, int $data) { 23 | $session = Session::getSession($player); 24 | switch ($data) { 25 | case 0: 26 | $session->set("action", "edit"); 27 | $player->sendMessage(Language::get("form.block.action.edit")); 28 | break; 29 | case 1: 30 | $session->set("action", "check"); 31 | $player->sendMessage(Language::get("form.block.action.check")); 32 | break; 33 | case 2: 34 | $session->set("action", "del"); 35 | $player->sendMessage(Language::get("form.block.action.delete")); 36 | break; 37 | case 3: 38 | $session->set("action", "copy"); 39 | $player->sendMessage(Language::get("form.block.action.copy")); 40 | break; 41 | case 4: 42 | $session->setValid(false); 43 | $player->sendMessage(Language::get("form.cancelled")); 44 | return; 45 | case 5: 46 | (new Form())->sendSelectIfTypeForm($player); 47 | return; 48 | } 49 | $session->setValid()->set("if_type", Session::BLOCK); 50 | })->show($player); 51 | } 52 | } -------------------------------------------------------------------------------- /src/aieuo/ip/form/Elements.php: -------------------------------------------------------------------------------- 1 | "label", 9 | "text" => (string)$text 10 | ]; 11 | } 12 | 13 | public static function getInput($text, $placeholder = "", $default = ""){ 14 | return [ 15 | "type" => "input", 16 | "text" => (string)$text, 17 | "default" => (string)$default, 18 | "placeholder" => (string)$placeholder 19 | ]; 20 | } 21 | 22 | public static function getToggle($text, $default = false){ 23 | return [ 24 | "type" => "toggle", 25 | "text" => (string)$text, 26 | "default" => $default, 27 | ]; 28 | } 29 | 30 | public static function getDropdown($text, $options = [], $default = 0){ 31 | return [ 32 | "type" => "dropdown", 33 | "text" => (string)$text, 34 | "options" => $options, 35 | "default" => $default 36 | ]; 37 | } 38 | 39 | public static function getSlider($text, $min = 0, $max = 0, $default = 0, $step = 1) { 40 | return [ 41 | "type" => "slider", 42 | "text" => (string)$text, 43 | "min" => (int)$min, 44 | "max" => (int)$max, 45 | "default" => (int)$default, 46 | "step" => (int)$step 47 | ]; 48 | } 49 | 50 | public static function getButton($text){ 51 | return [ 52 | "text" => (string)$text 53 | ]; 54 | } 55 | } -------------------------------------------------------------------------------- /src/aieuo/ip/form/ExportForm.php: -------------------------------------------------------------------------------- 1 | setContents([ 19 | new Input("@if.export.form.content0", "", $default[0] ?? ""), 20 | new Input("@if.export.form.content1", "", $default[1] ?? ""), 21 | new Input("@if.export.form.content2", "", $default[2] ?? ""), 22 | new Toggle("@form.cancel"), 23 | ])->onReceive(function (Player $player, array $data) { 24 | $session = Session::getSession($player); 25 | $type = $session->get("if_type"); 26 | $manager = IFManager::getBySession($session); 27 | $options = IFPlugin::getInstance()->getOptionsBySession($session); 28 | $key = $session->get("if_key"); 29 | $ifData = $manager->get($key, $options); 30 | 31 | if ($data[3]) { 32 | (new Form)->sendEditIfForm($player, $ifData); 33 | return; 34 | } 35 | if ($data[0] == "" or $data[1] == "" or $data[2] == "") { 36 | $this->sendExportForm($player, $data, [["@form.insufficient", 0]]); 37 | return; 38 | } 39 | $ifData["type"] = $type; 40 | $ifData["options"] = $options; 41 | $export = [ 42 | "name" => $data[0], 43 | "author" => $data[1], 44 | "details" => $data[2], 45 | "plugin_version" => IFPlugin::getInstance()->getDescription()->getVersion(), 46 | "ifs" => [ 47 | $key => $ifData 48 | ] 49 | ]; 50 | $filename = $data[0]."_".$data[1]."_".$type."_".$key.".json"; 51 | $path = IFPlugin::getInstance()->getDataFolder()."exports/".$filename; 52 | file_put_contents($path, json_encode($export, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); 53 | 54 | $player->sendMessage(Language::get("if.export.success", [$filename])); 55 | $session->setValid(false); 56 | })->onClose(function (Player $player) { 57 | Session::getSession($player)->setValid(false, false); 58 | })->addErrors($errors)->show($player); 59 | } 60 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/CustomForm.php: -------------------------------------------------------------------------------- 1 | contents = $contents; 21 | return $this; 22 | } 23 | 24 | /** 25 | * @param Element $content 26 | * @param bool $add 27 | * @return self 28 | */ 29 | public function addContent(Element $content, bool $add = true): self { 30 | if ($add) $this->contents[] = $content; 31 | return $this; 32 | } 33 | 34 | /** 35 | * @return Element[] 36 | */ 37 | public function getContents(): array { 38 | return $this->contents; 39 | } 40 | 41 | public function getContent(int $index): ?Element { 42 | return $this->contents[$index] ?? null; 43 | } 44 | 45 | public function addContents(Element ...$contents): self { 46 | $this->contents = array_merge($this->contents, $contents); 47 | return $this; 48 | } 49 | 50 | public function jsonSerialize(): array { 51 | $form = [ 52 | "type" => "custom_form", 53 | "title" => $this->checkTranslate($this->title), 54 | "content" => $this->contents 55 | ]; 56 | $form = $this->reflectErrors($form); 57 | return $form; 58 | } 59 | 60 | public function reflectErrors(array $form): array { 61 | for ($i=0; $ihighlights[$i])) continue; 63 | $content = $form["content"][$i]; 64 | $content->setHighlight(TextFormat::YELLOW); 65 | } 66 | if (!empty($this->messages) and !empty($this->contents)) { 67 | $form["content"][0]->setText(implode("\n", array_keys($this->messages))."\n".$form["content"][0]->getText()); 68 | } 69 | return $form; 70 | } 71 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/ListForm.php: -------------------------------------------------------------------------------- 1 | content = $content; 22 | return $this; 23 | } 24 | 25 | /** 26 | * @return string 27 | */ 28 | public function getContent(): string { 29 | return $this->content; 30 | } 31 | 32 | /** 33 | * @param Button $button 34 | * @return self 35 | */ 36 | public function addButton(Button $button): self { 37 | $this->buttons[] = $button; 38 | return $this; 39 | } 40 | 41 | /** 42 | * @param Button[] $buttons 43 | * @return self 44 | */ 45 | public function addButtons(array $buttons): self { 46 | $this->buttons = array_merge($this->buttons, $buttons); 47 | return $this; 48 | } 49 | 50 | /** 51 | * @param Button[] $buttons 52 | * @return self 53 | */ 54 | public function setButtons(array $buttons): self { 55 | $this->buttons = $buttons; 56 | return $this; 57 | } 58 | 59 | /** 60 | * @return Button[] 61 | */ 62 | public function getButtons(): array { 63 | return $this->buttons; 64 | } 65 | 66 | public function getButton(int $index): ?Button { 67 | return $this->buttons[$index] ?? null; 68 | } 69 | 70 | public function getButtonById(string $id): ?Button { 71 | foreach ($this->getButtons() as $button) { 72 | if ($button->getUUId() === $id) return $button; 73 | } 74 | return null; 75 | } 76 | 77 | public function jsonSerialize(): array { 78 | $form = [ 79 | "type" => "form", 80 | "title" => $this->checkTranslate($this->title), 81 | "content" => $this->checkTranslate($this->content), 82 | "buttons" => $this->buttons 83 | ]; 84 | $form = $this->reflectErrors($form); 85 | return $form; 86 | } 87 | 88 | public function reflectErrors(array $form): array { 89 | if (!empty($this->messages)) { 90 | $form["content"] = implode("\n", array_keys($this->messages))."\n".$form["content"]; 91 | } 92 | return $form; 93 | } 94 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/ModalForm.php: -------------------------------------------------------------------------------- 1 | content = $content; 22 | return $this; 23 | } 24 | 25 | /** 26 | * @return string 27 | */ 28 | public function getContent(): string { 29 | return $this->content; 30 | } 31 | 32 | /** 33 | * @param string $text 34 | * @return self 35 | */ 36 | public function setButton1(string $text): self { 37 | $this->button1 = $text; 38 | return $this; 39 | } 40 | 41 | /** 42 | * @return string 43 | */ 44 | public function getButton1(): string { 45 | return $this->button1; 46 | } 47 | 48 | /** 49 | * @param string $text 50 | * @return self 51 | */ 52 | public function setButton2(string $text): self { 53 | $this->button2 = $text; 54 | return $this; 55 | } 56 | 57 | /** 58 | * @return string 59 | */ 60 | public function getButton2(): string { 61 | return $this->button2; 62 | } 63 | 64 | public function jsonSerialize(): array { 65 | $form = [ 66 | "type" => self::MODAL_FORM, 67 | "title" => $this->checkTranslate($this->title), 68 | "content" => $this->checkTranslate($this->content), 69 | "button1" => $this->checkTranslate($this->button1), 70 | "button2" => $this->checkTranslate($this->button2) 71 | ]; 72 | $form = $this->reflectErrors($form); 73 | return $form; 74 | } 75 | 76 | public function reflectErrors(array $form): array { 77 | if (!empty($this->messages)) { 78 | $form["content"] = implode("\n", array_keys($this->messages))."\n".$form["content"]; 79 | } 80 | return $form; 81 | } 82 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/element/Button.php: -------------------------------------------------------------------------------- 1 | $this->checkTranslate($this->text), 9 | "id" => $this->getUUId(), 10 | ]; 11 | } 12 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/element/Dropdown.php: -------------------------------------------------------------------------------- 1 | options = $options; 17 | $this->default = $default; 18 | } 19 | 20 | /** 21 | * @param string $option 22 | * @return self 23 | */ 24 | public function addOption(string $option): self { 25 | $this->options[] = $option; 26 | return $this; 27 | } 28 | 29 | /** 30 | * @param array $options 31 | * @return self 32 | */ 33 | public function setOptions(array $options): self { 34 | $this->options = $options; 35 | return $this; 36 | } 37 | 38 | /** 39 | * @return array 40 | */ 41 | public function getOptions(): array { 42 | return $this->options; 43 | } 44 | 45 | /** 46 | * @param int $default 47 | * @return self 48 | */ 49 | public function setDefault(int $default): self { 50 | $this->default = $default; 51 | return $this; 52 | } 53 | 54 | /** 55 | * @return int 56 | */ 57 | public function getDefault(): int { 58 | return $this->default; 59 | } 60 | 61 | public function jsonSerialize(): array { 62 | return [ 63 | "type" => $this->type, 64 | "text" => $this->reflectHighlight($this->checkTranslate($this->text)), 65 | "options" => $this->options, 66 | "default" => $this->default, 67 | ]; 68 | } 69 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/element/Element.php: -------------------------------------------------------------------------------- 1 | text = $text; 29 | $this->uuid = $uuid; 30 | } 31 | 32 | /** 33 | * @param string $text 34 | * @return self 35 | */ 36 | public function setText(string $text): self { 37 | $this->text = $text; 38 | return $this; 39 | } 40 | 41 | /** 42 | * @return string 43 | */ 44 | public function getText(): string { 45 | return $this->text; 46 | } 47 | 48 | /** 49 | * @return string 50 | */ 51 | public function getType(): string { 52 | return $this->type; 53 | } 54 | 55 | /** 56 | * @param string|null $color 57 | */ 58 | public function setHighlight(?string $color): void { 59 | $this->highlight = $color; 60 | } 61 | 62 | /** 63 | * @return String 64 | */ 65 | public function getUUId(): string { 66 | return !empty($this->uuid) ? $this->uuid : UUID::fromRandom()->toString(); 67 | } 68 | 69 | /** 70 | * @param string $text 71 | * @return string 72 | */ 73 | public function checkTranslate(string $text): string { 74 | $text = preg_replace_callback("/@([a-zA-Z0-9.]+)/", function ($matches) { 75 | return Language::get($matches[1]); 76 | }, $text); 77 | return $text; 78 | } 79 | 80 | /** 81 | * @param string $text 82 | * @return string 83 | */ 84 | public function reflectHighlight(string $text): string { 85 | if (empty($this->highlight)) return $text; 86 | return $this->highlight.preg_replace("/§[a-f0-9]/", "", $text); 87 | } 88 | 89 | /** 90 | * @return array 91 | */ 92 | abstract public function jsonSerialize(): array; 93 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/element/Input.php: -------------------------------------------------------------------------------- 1 | placeholder = $placeholder; 18 | $this->default = $default; 19 | } 20 | 21 | /** 22 | * @param string $placeholder 23 | * @return self 24 | */ 25 | public function setPlaceholder(string $placeholder): self { 26 | $this->placeholder = $placeholder; 27 | return $this; 28 | } 29 | 30 | /** 31 | * @return string 32 | */ 33 | public function getPlaceholder(): string { 34 | return $this->placeholder; 35 | } 36 | 37 | /** 38 | * @param string $default 39 | * @return self 40 | */ 41 | public function setDefault(string $default): self { 42 | $this->default = $default; 43 | return $this; 44 | } 45 | 46 | /** 47 | * @return string 48 | */ 49 | public function getDefault(): string { 50 | return $this->default; 51 | } 52 | 53 | public function jsonSerialize(): array { 54 | return [ 55 | "type" => $this->type, 56 | "text" => $this->reflectHighlight($this->checkTranslate($this->text)), 57 | "placeholder" => $this->checkTranslate($this->placeholder), 58 | "default" => $this->checkTranslate($this->default), 59 | ]; 60 | } 61 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/element/Label.php: -------------------------------------------------------------------------------- 1 | $this->type, 13 | "text" => $this->reflectHighlight($this->checkTranslate($this->text)), 14 | ]; 15 | } 16 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/element/Slider.php: -------------------------------------------------------------------------------- 1 | min = $min; 22 | $this->max = $max; 23 | $this->step = $step; 24 | $this->default = $default ?? $min; 25 | } 26 | 27 | /** 28 | * @param float $min 29 | * @return self 30 | */ 31 | public function setMin(float $min): self { 32 | $this->min = $min; 33 | return $this; 34 | } 35 | 36 | /** 37 | * @return float 38 | */ 39 | public function getMin(): float { 40 | return $this->min; 41 | } 42 | 43 | /** 44 | * @param float $max 45 | * @return self 46 | */ 47 | public function setMax(float $max): self { 48 | $this->max = $max; 49 | return $this; 50 | } 51 | 52 | /** 53 | * @return float 54 | */ 55 | public function getMax(): float { 56 | return $this->max; 57 | } 58 | 59 | /** 60 | * @param float $step 61 | * @return self 62 | */ 63 | public function setStep(float $step): self { 64 | $this->step = $step; 65 | return $this; 66 | } 67 | 68 | /** 69 | * @return float 70 | */ 71 | public function getStep(): float { 72 | return $this->step; 73 | } 74 | 75 | /** 76 | * @param float $default 77 | * @return self 78 | */ 79 | public function setDefault(float $default): self { 80 | $this->default = $default; 81 | return $this; 82 | } 83 | 84 | /** 85 | * @return float 86 | */ 87 | public function getDefault(): float { 88 | return $this->default; 89 | } 90 | 91 | public function jsonSerialize(): array { 92 | if ($this->min > $this->max) { 93 | list($this->min, $this->max) = [$this->max, $this->min]; // 入れ替える 94 | } 95 | if ($this->default === null or $this->default < $this->min) { 96 | $this->default = $this->min; 97 | } 98 | return [ 99 | "type" => $this->type, 100 | "text" => $this->reflectHighlight($this->checkTranslate($this->text)), 101 | "min" => $this->min, 102 | "max" => $this->max, 103 | "step" => $this->step, 104 | "default" => $this->default, 105 | ]; 106 | } 107 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/element/StepSlider.php: -------------------------------------------------------------------------------- 1 | $this->type, 13 | "text" => $this->reflectHighlight($this->checkTranslate($this->text)), 14 | "steps" => $this->options, 15 | "default" => $this->default, 16 | ]; 17 | } 18 | } -------------------------------------------------------------------------------- /src/aieuo/ip/formAPI/element/Toggle.php: -------------------------------------------------------------------------------- 1 | default = $default; 16 | } 17 | 18 | /** 19 | * @param boolean $default 20 | * @return self 21 | */ 22 | public function setDefault(bool $default): self { 23 | $this->default = $default; 24 | return $this; 25 | } 26 | 27 | /** 28 | * @return boolean 29 | */ 30 | public function getDefault(): bool { 31 | return $this->default; 32 | } 33 | 34 | public function jsonSerialize(): array { 35 | return [ 36 | "type" => $this->type, 37 | "text" => $this->reflectHighlight($this->checkTranslate($this->text)), 38 | "default" => $this->default, 39 | ]; 40 | } 41 | } -------------------------------------------------------------------------------- /src/aieuo/ip/manager/BlockManager.php: -------------------------------------------------------------------------------- 1 | repairIF($data); 20 | parent::set($key, $data); 21 | } 22 | 23 | public function getPosition($block){ 24 | return $block->x.",".$block->y.",".$block->z.",".$block->level->getFolderName(); 25 | } 26 | 27 | public function getReplaceData($data) { 28 | $variables = parent::getReplaceData($data); 29 | $block = $data["block"]; 30 | $event = $data["event"]; 31 | $add = [ 32 | "block" => new StringVariable("block", $block->__toString()), 33 | "block_name" => new StringVariable("block_name", $block->getName()), 34 | "block_id" => new NumberVariable("block_id", $block->getId()), 35 | "block_damage" => new NumberVariable("block_damage", $block->getDamage()), 36 | "block_ids" => new StringVariable("block_ids", $block->getId().":".$block->getDamage()), 37 | "block_pos" => new StringVariable("block_pos", $block->x.",".$block->y.",".$block->z.",".$block->level->getFolderName()), 38 | "block_x" => new NumberVariable("block_x", $block->x), 39 | "block_y" => new NumberVariable("block_y", $block->y), 40 | "block_z" => new NumberVariable("block_z", $block->z), 41 | "block_level" => new StringVariable("block_level", $block->level->getFolderName()), 42 | "touch_face" => new NumberVariable("touch_face", $event->getFace()) 43 | ]; 44 | if ($block instanceof SignPost) { 45 | $sign = $block->level->getTile($block); 46 | if ($sign instanceof Sign) { 47 | $variables["sign_lines"] = new ListVariable("sign_lines", $sign->getText()); 48 | } 49 | } 50 | return array_merge($variables, $add); 51 | } 52 | } -------------------------------------------------------------------------------- /src/aieuo/ip/manager/ChainIfManager.php: -------------------------------------------------------------------------------- 1 | repairIF($data); 16 | parent::set($key, $data); 17 | } 18 | 19 | public function getReplaceData($data) { 20 | $variables = parent::getReplaceData($data); 21 | if (isset($data["count"])) $variables["i"] = new NumberVariable("i", $data["count"]); 22 | if (isset($data["origin"])) { 23 | $origin = $data["origin"]; 24 | $add = [ 25 | "origin_name" => new StringVariable("origin_name", $origin->getName()), 26 | "origin_pos" => new StringVariable("origin_pos", $origin->x.",".$origin->y.",".$origin->z.",".$origin->level->getFolderName()), 27 | "origin_x" => new NumberVariable("origin_x", $origin->x), 28 | "origin_y" => new NumberVariable("origin_y", $origin->y), 29 | "origin_z" => new NumberVariable("origin_z", $origin->z), 30 | "origin_level" => new StringVariable("origin_level", $origin->level->getFolderName()) 31 | ]; 32 | $variables = array_merge($variables, $add); 33 | } 34 | if (isset($data["replaces"])) $variables = array_merge($data["replaces"], $variables); 35 | return $variables; 36 | } 37 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/AddEffect.php: -------------------------------------------------------------------------------- 1 | getEffect(); 20 | if (!($effect instanceof EffectInstance)) return false; 21 | return Language::get("process.addeffect.detail", [$effect->getId(), $effect->getAmplifier() + 1, $effect->getDuration() / 20]); 22 | } 23 | 24 | public function getEffect() { 25 | return $this->getValues(); 26 | } 27 | 28 | public function setEffect(EffectInstance $effect) { 29 | $this->setValues($effect); 30 | } 31 | 32 | public function parse(string $content) { 33 | $args = explode(",", $content); 34 | if (!isset($args[1])) $args[1] = 1; 35 | if (!isset($args[2]) or (float)$args[2] <= 0) $args[2] = 30; 36 | $effect = Effect::getEffectByName($args[0]); 37 | $args[1] --; 38 | if ($effect === null) $effect = Effect::getEffect((int)$args[0]); 39 | if ($effect === null) return null; 40 | return new EffectInstance($effect, (float)$args[2] * 20, (int)$args[1], true); 41 | } 42 | 43 | public function execute() { 44 | $player = $this->getPlayer(); 45 | $effect = $this->getEffect(); 46 | if (!($effect instanceof EffectInstance)) { 47 | if ($effect === false) $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 48 | if ($effect === null) $player->sendMessage(Language::get("process.addeffect.notfound")); 49 | return; 50 | } 51 | $player->addEffect($effect); 52 | } 53 | 54 | 55 | public function getEditForm(string $default = "", string $mes = "") { 56 | $effect = $this->parse($default); 57 | $id = $default; 58 | $power = ""; 59 | $time = ""; 60 | if ($effect instanceof EffectInstance) { 61 | $id = $effect->getId(); 62 | $power = $effect->getAmplifier() + 1; 63 | $time = $effect->getDuration() / 20; 64 | } elseif ($default !== "") { 65 | if ($effect === false)$mes .= Language::get("form.error"); 66 | if ($effect === null)$mes .= Language::get("process.addeffect.notfound"); 67 | } 68 | $data = [ 69 | "type" => "custom_form", 70 | "title" => $this->getName(), 71 | "content" => [ 72 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 73 | Elements::getInput(Language::get("process.addeffect.form.id"), Language::get("input.example", ["1"]), $id), 74 | Elements::getInput(Language::get("process.addeffect.form.power"), Language::get("input.example", ["5"]), $power), 75 | Elements::getInput(Language::get("process.addeffect.form.time"), Language::get("input.example", ["5"]), $time), 76 | Elements::getToggle(Language::get("form.delete")), 77 | Elements::getToggle(Language::get("form.cancel")) 78 | ] 79 | ]; 80 | $json = Form::encodeJson($data); 81 | return $json; 82 | } 83 | 84 | public function parseFormData(array $data) { 85 | $status = true; 86 | $effect_str = $data[1].",".$data[2].",".$data[3]; 87 | if ($data[1] === "" or $data[2] === "" or $data[3] === "") $status = null; 88 | return ["status" => $status, "contents" => $effect_str, "delete" => $data[4], "cancel" => $data[5]]; 89 | } 90 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/AddEnchantment.php: -------------------------------------------------------------------------------- 1 | getEnchantment(); 20 | if (!($enchant instanceof EnchantmentInstance)) return false; 21 | return Language::get("process.addenchant.detail", [$enchant->getId(), $enchant->getLevel()]); 22 | } 23 | 24 | public function getEnchantment() { 25 | return $this->getValues(); 26 | } 27 | 28 | public function setEnchantment(EnchantmentInstance $enchant) { 29 | $this->setValues($enchant); 30 | } 31 | 32 | public function parse(string $content) { 33 | $args = explode(",", $content); 34 | if (!isset($args[1]) or (int)$args[1] <= 0) $args[1] = 1; 35 | if (is_numeric($args[0])) { 36 | $enchantment = Enchantment::getEnchantment((int)$args[0]); 37 | } else { 38 | $enchantment = Enchantment::getEnchantmentByName($args[0]); 39 | } 40 | if (!($enchantment instanceof Enchantment)) return null; 41 | return new EnchantmentInstance($enchantment, (int)$args[1]); 42 | } 43 | 44 | public function execute() { 45 | $player = $this->getPlayer(); 46 | $enchant = $this->getEnchantment(); 47 | if (!($enchant instanceof EnchantmentInstance)) { 48 | if ($enchant === false) $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 49 | if ($enchant === null) $player->sendMessage(Language::get("process.addenchant.notfound")); 50 | return; 51 | } 52 | $item = $player->getInventory()->getItemInHand(); 53 | $item->addEnchantment($enchant); 54 | $player->getInventory()->setItemInHand($item); 55 | } 56 | 57 | 58 | public function getEditForm(string $default = "", string $mes = "") { 59 | $enchant = $this->parse($default); 60 | $id = $default; 61 | $power = ""; 62 | if ($enchant instanceof EnchantmentInstance) { 63 | $id = $enchant->getId(); 64 | $power = $enchant->getLevel(); 65 | } elseif ($default !== "") { 66 | if ($enchant === false) $mes .= Language::get("form.error"); 67 | if ($enchant === null) $mes .= Language::get("process.addenchant.notfound"); 68 | } 69 | $data = [ 70 | "type" => "custom_form", 71 | "title" => $this->getName(), 72 | "content" => [ 73 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 74 | Elements::getInput(Language::get("process.addenchant.form.id"), Language::get("input.example", ["1"]), $id), 75 | Elements::getInput(Language::get("process.addenchant.form.power"), Language::get("input.example", ["5"]), $power), 76 | Elements::getToggle(Language::get("form.delete")), 77 | Elements::getToggle(Language::get("form.cancel")) 78 | ] 79 | ]; 80 | $json = Form::encodeJson($data); 81 | return $json; 82 | } 83 | 84 | public function parseFormData(array $data) { 85 | $status = true; 86 | $enchant_str = $data[1].",".$data[2]; 87 | if ($data[1] === "" or $data[2] === "") $status = null; 88 | return ["status" => $status, "contents" => $enchant_str, "delete" => $data[3], "cancel" => $data[4]]; 89 | } 90 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/AddItem.php: -------------------------------------------------------------------------------- 1 | getItem(); 17 | if (!($item instanceof Item)) return false; 18 | return Language::get("process.additem.detail", [$item->getId(), $item->getDamage(), $item->getName(), $item->getCount()]); 19 | } 20 | 21 | public function execute() { 22 | $player = $this->getPlayer(); 23 | $item = $this->getItem(); 24 | if (!($item instanceof Item)) { 25 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 26 | return; 27 | } 28 | $player->getInventory()->addItem($item); 29 | } 30 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/AddMoney.php: -------------------------------------------------------------------------------- 1 | getAmount()]); 16 | } 17 | 18 | public function execute() { 19 | $player = $this->getPlayer(); 20 | $economy = IFPlugin::getInstance()->getEconomy(); 21 | if ($economy === null) { 22 | $player->sendMessage(Language::get("economy.notfound")); 23 | return; 24 | } 25 | $economy->addMoney($player->getName(), $this->getAmount()); 26 | } 27 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/AddSound.php: -------------------------------------------------------------------------------- 1 | getSound(); 18 | return Language::get("process.addSound.detail", [$sound]); 19 | } 20 | 21 | public function getSound(): ?string { 22 | $reason = $this->getValues(); 23 | return is_string($reason) ? $reason : null; 24 | } 25 | 26 | public function execute() { 27 | $player = $this->getPlayer(); 28 | $sound = $this->getSound(); 29 | 30 | $pk = new PlaySoundPacket(); 31 | $pk->soundName = $sound; 32 | $pk->x = $player->x; 33 | $pk->y = $player->y; 34 | $pk->z = $player->z; 35 | $pk->volume = 1.0; 36 | $pk->pitch = 1.0; 37 | $player->dataPacket($pk); 38 | } 39 | 40 | public function getEditForm(string $default = "", string $mes = "") { 41 | $data = [ 42 | "type" => "custom_form", 43 | "title" => $this->getName(), 44 | "content" => [ 45 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 46 | Elements::getInput(Language::get("process.addSound.form.sound"), Language::get("input.example", ["random.levelup"]), $default), 47 | Elements::getToggle(Language::get("form.delete")), 48 | Elements::getToggle(Language::get("form.cancel")) 49 | ] 50 | ]; 51 | return Form::encodeJson($data); 52 | } 53 | 54 | public function parseFormData(array $data) { 55 | $status = true; 56 | if ($data[1] === "") $status = null; 57 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/AddVariable.php: -------------------------------------------------------------------------------- 1 | getVariable(); 19 | if ($variable === false) return false; 20 | return Language::get("process.addvariable.detail", [$variable->getName(), $variable->getString()]); 21 | } 22 | 23 | public function getVariable(): ?Variable { 24 | $variable = $this->getValues(); 25 | if (!($variable instanceof Variable)) return null; 26 | return $variable; 27 | } 28 | 29 | public function setVariable(Variable $variable) { 30 | $this->setValues($variable); 31 | } 32 | 33 | public function parse(string $content) { 34 | $data = explode(";", $content); 35 | if (!isset($data[1]) or $data[1] === "") return false; 36 | $helper = IFPlugin::getInstance()->getVariableHelper(); 37 | $value = $helper->currentType($data[1]); 38 | return Variable::create($data[0], $value, $helper->getType($data[1])); 39 | } 40 | 41 | public function execute() { 42 | $player = $this->getPlayer(); 43 | $variable = $this->getVariable(); 44 | if ($variable === false) { 45 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 46 | return; 47 | } 48 | IFPlugin::getInstance()->getVariableHelper()->add($variable); 49 | } 50 | 51 | 52 | public function getEditForm(string $default = "", string $mes = "") { 53 | $var = $this->parse($default); 54 | $name = $default; 55 | $value = ""; 56 | if ($var instanceof Variable) { 57 | $name = $var->getName(); 58 | $value = $var->getString(); 59 | if (is_numeric($value) and $var->getType() === Variable::STRING) { 60 | $value = "(str)".$value; 61 | } elseif (!is_numeric($value) and $var->getType() === Variable::NUMBER) { 62 | $value = "(num)".$value; 63 | } 64 | } elseif ($default !== "") { 65 | $mes .= Language::get("form.error"); 66 | } 67 | $data = [ 68 | "type" => "custom_form", 69 | "title" => $this->getName(), 70 | "content" => [ 71 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 72 | Elements::getInput(Language::get("process.addvariable.form.name"), Language::get("input.example", ["aieuo"]), $name), 73 | Elements::getInput(Language::get("process.addvariable.form.value"), Language::get("input.example", ["1000"]), $value), 74 | Elements::getToggle(Language::get("form.delete")), 75 | Elements::getToggle(Language::get("form.cancel")) 76 | ] 77 | ]; 78 | $json = Form::encodeJson($data); 79 | return $json; 80 | } 81 | 82 | public function parseFormData(array $data) { 83 | $status = true; 84 | $var_str = $data[1].";".$data[2]; 85 | if ($data[1] === "" or $data[2] === "") { 86 | $status = null; 87 | } else { 88 | $var = $this->parse($var_str); 89 | if ($var === false) $status = false; 90 | } 91 | return ["status" => $status, "contents" => $var_str, "delete" => $data[3], "cancel" => $data[4]]; 92 | } 93 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/Attack.php: -------------------------------------------------------------------------------- 1 | getDamage(); 19 | if ($damage === false) return false; 20 | return Language::get("process.attack.detail", [$damage]); 21 | } 22 | 23 | public function getDamage() { 24 | return $this->getValues(); 25 | } 26 | 27 | public function setDamage(float $damage) { 28 | $this->setValues($damage); 29 | } 30 | 31 | public function parse(string $content) { 32 | $damage = (float)$content; 33 | if ($damage <= 0) return false; 34 | return $damage; 35 | } 36 | 37 | public function execute() { 38 | $player = $this->getPlayer(); 39 | $damage = $this->getDamage(); 40 | if ($damage === false) { 41 | $player->sendMessage(Language::get("process.attack.error", [$this->getName()])); 42 | return; 43 | } 44 | $event = new EntityDamageEvent($player, EntityDamageEvent::CAUSE_ENTITY_ATTACK, (float)$damage); 45 | $player->attack($event); 46 | } 47 | 48 | public function getEditForm(string $default = "", string $mes = "") { 49 | $damage = $this->parse($default); 50 | if ($damage === false) { 51 | if ($default !== "") $mes .= Language::get("process.attack.form.error"); 52 | $damage = $default; 53 | } 54 | $data = [ 55 | "type" => "custom_form", 56 | "title" => $this->getName(), 57 | "content" => [ 58 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 59 | Elements::getInput(Language::get("process.attack.form.damage"), Language::get("input.example", ["5"]), $damage), 60 | Elements::getToggle(Language::get("form.delete")), 61 | Elements::getToggle(Language::get("form.cancel")) 62 | ] 63 | ]; 64 | $json = Form::encodeJson($data); 65 | return $json; 66 | } 67 | 68 | public function parseFormData(array $data) { 69 | $status = true; 70 | if ($data[1] === "") { 71 | $status = null; 72 | } else { 73 | $damage = $this->parse($data[1]); 74 | if ($damage === false) $status = false; 75 | } 76 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 77 | } 78 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/BroadcastMessage.php: -------------------------------------------------------------------------------- 1 | getMessage(); 17 | return Language::get("process.broadcastmessage.detail", [$message]); 18 | } 19 | 20 | public function execute() { 21 | Server::getInstance()->broadcastMessage($this->getMessage()); 22 | } 23 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/ClearInventory.php: -------------------------------------------------------------------------------- 1 | getPlayer(); 13 | $player->getInventory()->clearAll(); 14 | } 15 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/Command.php: -------------------------------------------------------------------------------- 1 | getCommand(); 17 | return Language::get("process.command.detail", [$command]); 18 | } 19 | 20 | public function execute() { 21 | $player = $this->getPlayer(); 22 | Server::getInstance()->dispatchCommand($player, $this->getCommand()); 23 | } 24 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/CommandConsole.php: -------------------------------------------------------------------------------- 1 | getCommand(); 18 | return Language::get("process.commandconsole.detail", [$command]); 19 | } 20 | 21 | public function execute() { 22 | Server::getInstance()->dispatchCommand(new ConsoleCommandSender, $this->getCommand()); 23 | } 24 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/Cooperation.php: -------------------------------------------------------------------------------- 1 | getCooperationName(); 20 | return Language::get("process.cooperation.detail", [$name]); 21 | } 22 | 23 | public function getCooperationName(): ?string { 24 | $name = $this->getValues(); 25 | return is_string($name) ? $name : null; 26 | } 27 | 28 | public function setCooperationName(string $name) { 29 | $this->setValues($name); 30 | } 31 | 32 | public function execute() { 33 | $player = $this->getPlayer(); 34 | $manager = IFPlugin::getInstance()->getChainManager(); 35 | if (!$manager->exists($this->getCooperationName())) { 36 | $player->sendMessage(Language::get("process.cooperation.notFound")); 37 | return; 38 | } 39 | $datas = $manager->get($this->getCooperationName()); 40 | $options = [ 41 | "player" => $player, 42 | ]; 43 | if ($this->getEvent() instanceof Event) $options["event"] = $this->getEvent(); 44 | $options["replaces"] = $this->replaceDatas; 45 | $manager->executeIfMatchCondition( 46 | $player, 47 | $datas["if"], 48 | $datas["match"], 49 | $datas["else"], 50 | $options 51 | ); 52 | } 53 | 54 | public function getEditForm(string $default = "", string $mes = "") { 55 | $manager = IFPlugin::getInstance()->getChainManager(); 56 | if ($default !== "" and !$manager->exists($default)) $mes .= Language::get("process.cooperation.notFound"); 57 | $data = [ 58 | "type" => "custom_form", 59 | "title" => $this->getName(), 60 | "content" => [ 61 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 62 | Elements::getInput(Language::get("process.cooperation.form.name"), Language::get("input.example", ["aieuo"]), $default), 63 | Elements::getToggle(Language::get("form.delete")), 64 | Elements::getToggle(Language::get("form.cancel")) 65 | ] 66 | ]; 67 | $json = Form::encodeJson($data); 68 | return $json; 69 | } 70 | 71 | public function parseFormData(array $data) { 72 | $status = true; 73 | if ($data[1] === "") $status = null; 74 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 75 | } 76 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/CooperationRepeat.php: -------------------------------------------------------------------------------- 1 | getCooperationName(); 20 | $count = $this->getCount(); 21 | return Language::get("process.cooperationrepeat.detail", [$name, $count]); 22 | } 23 | 24 | public function getCooperationName() { 25 | return $this->getValues()[0]; 26 | } 27 | 28 | public function getCount() { 29 | return $this->getValues()[1]; 30 | } 31 | 32 | public function setNames(string $name, int $count) { 33 | $this->setValues([$name, $count]); 34 | } 35 | 36 | public function parse(string $content) { 37 | $datas = explode(";", $content); 38 | if (!isset($datas[1])) return false; 39 | $count = array_pop($datas); 40 | $name = implode(";", $datas); 41 | return [$name, $count]; 42 | } 43 | 44 | public function execute() { 45 | $player = $this->getPlayer(); 46 | $manager = IFPlugin::getInstance()->getChainManager(); 47 | if (!$manager->exists($this->getCooperationName())) { 48 | $player->sendMessage(Language::get("process.cooperation.notfound")); 49 | return; 50 | } 51 | $datas = $manager->get($this->getCooperationName()); 52 | $count = $this->getCount(); 53 | for ($i = 0; $i < $count; $i ++) { 54 | $options = [ 55 | "player" => $player, 56 | "count" => $i, 57 | ]; 58 | if ($this->getEvent() instanceof Event) $options["event"] = $this->getEvent(); 59 | $options["replaces"] = $this->replaceDatas; 60 | $manager->executeIfMatchCondition( 61 | $player, 62 | $datas["if"], 63 | $datas["match"], 64 | $datas["else"], 65 | $options 66 | ); 67 | } 68 | } 69 | 70 | public function getEditForm(string $default = "", string $mes = "") { 71 | $manager = IFPlugin::getInstance()->getChainManager(); 72 | $names = $this->parse($default); 73 | $name = $default; 74 | $count = ""; 75 | if ($names === false and $default !== "") { 76 | $mes .= Language::get("form.error"); 77 | } else { 78 | $name = $names[0]; 79 | $count = $names[1]; 80 | } 81 | if ($default !== "" and !$manager->exists($name)) $mes .= Language::get("process.cooperation.notfound"); 82 | $data = [ 83 | "type" => "custom_form", 84 | "title" => $this->getName(), 85 | "content" => [ 86 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 87 | Elements::getInput(Language::get("process.cooperation.form.name"), Language::get("input.example", ["aieuo"]), $name), 88 | Elements::getInput(Language::get("process.cooperationrepeat.form.count"), Language::get("input.example", ["5"]), $count), 89 | Elements::getToggle(Language::get("form.delete")), 90 | Elements::getToggle(Language::get("form.cancel")) 91 | ] 92 | ]; 93 | $json = Form::encodeJson($data); 94 | return $json; 95 | } 96 | 97 | public function parseFormData(array $data) { 98 | $status = true; 99 | $status = true; 100 | if ($data[1] === "" or $data[2] === "") { 101 | $status = null; 102 | } else { 103 | $names = $this->parse($data[1].";".$data[2]); 104 | if ($names === false) $status = false; 105 | } 106 | return ["status" => $status, "contents" => $data[1].";".$data[2], "delete" => $data[3], "cancel" => $data[4]]; 107 | } 108 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/DelayedCommand.php: -------------------------------------------------------------------------------- 1 | getValues() === false) return false; 19 | $command = $this->getCommand(); 20 | $time = $this->getTime(); 21 | return Language::get("process.delayedcommand.detail", [$time, $command]); 22 | } 23 | 24 | public function getTime() { 25 | return $this->getValues()[1]; 26 | } 27 | 28 | public function getCommand() { 29 | return $this->getValues()[0]; 30 | } 31 | 32 | public function setCommands(string $command, int $time) { 33 | $this->setValues($command, $time); 34 | } 35 | 36 | public function parse(string $commands) { 37 | if (!preg_match("/([0-9]+),(.+)/", $commands, $matches)) return false; 38 | return [$matches[2], (int)$matches[1]]; 39 | } 40 | 41 | public function execute() { 42 | $player = $this->getPlayer(); 43 | if ($this->getValues() === false) { 44 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 45 | return; 46 | } 47 | $time = $this->getTime(); 48 | $command = $this->getCommand(); 49 | IFPlugin::getInstance()->getScheduler()->scheduleDelayedTask(new DelayedCommandTask($player, $command), $time*20); 50 | } 51 | 52 | public function getEditForm(string $default = "", string $mes = "") { 53 | $commands = $this->parse($default); 54 | $command = $default; 55 | $time = ""; 56 | if ($commands !== false) { 57 | $command = $commands[0]; 58 | $time = $commands[1]; 59 | } elseif ($default !== "") { 60 | $mes .= Language::get("form.error"); 61 | } 62 | $data = [ 63 | "type" => "custom_form", 64 | "title" => $this->getName(), 65 | "content" => [ 66 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 67 | Elements::getInput(Language::get("process.delayedcommand.form.command"), Language::get("input.example", ["help"]), $command), 68 | Elements::getInput(Language::get("process.delayedcommand.form.time"), Language::get("input.example", ["10"]), $time), 69 | Elements::getToggle(Language::get("form.delete")), 70 | Elements::getToggle(Language::get("form.cancel")) 71 | ] 72 | ]; 73 | $json = Form::encodeJson($data); 74 | return $json; 75 | } 76 | 77 | public function parseFormData(array $data) { 78 | $status = true; 79 | if ($data[1] === "" or $data[2] === "") { 80 | $status = null; 81 | } else { 82 | $value = $this->parse($data[2].",".$data[1]); 83 | if ($value === false) $status = false; 84 | } 85 | return ["status" => $status, "contents" => $data[2].",".$data[1], "delete" => $data[3], "cancel" => $data[4]]; 86 | } 87 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/DelayedCommandConsole.php: -------------------------------------------------------------------------------- 1 | getValues() === false) return false; 18 | $command = $this->getCommand(); 19 | $time = $this->getTime(); 20 | return Language::get("process.delayedcommandconsole.detail", [$time, $command]); 21 | } 22 | 23 | public function execute() { 24 | $player = $this->getPlayer(); 25 | if ($this->getValues() === false) { 26 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 27 | return; 28 | } 29 | $time = $this->getTime(); 30 | $command = $this->getCommand(); 31 | IFPlugin::getInstance()->getScheduler()->scheduleDelayedTask(new DelayedCommandTask(new ConsoleCommandSender(), $command), $time*20); 32 | } 33 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/DelayedCooperation.php: -------------------------------------------------------------------------------- 1 | getCooperationName(); 19 | $time = $this->getTime(); 20 | return Language::get("process.delayedCooperation.detail", [$name, $time]); 21 | } 22 | 23 | public function getCooperationName(): ?string { 24 | $name = $this->getValues()[1] ?? null; 25 | return is_string($name) ? $name : null; 26 | } 27 | 28 | public function getTime(): ?float { 29 | $time = $this->getValues()[0] ?? null; 30 | return is_float($time) ? $time : null; 31 | } 32 | 33 | public function parse(string $content) { 34 | $names = explode("[name]", $content); 35 | if (!isset($names[1])) return false; 36 | if (!preg_match("/([0-9]+.?[0-9]*)/", $names[0], $matches)) return false; 37 | return [(float)$matches[1], $names[1]]; 38 | } 39 | 40 | public function execute() { 41 | $player = $this->getPlayer(); 42 | $time = $this->getTime(); 43 | $name = $this->getCooperationName(); 44 | if ($time === null or $name === null) { 45 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 46 | return; 47 | } 48 | IFPlugin::getInstance()->getScheduler()->scheduleDelayedTask(new DelayedCooperationTask($player, $name, $this->getEvent(), $this->replaceDatas), $time*20); 49 | } 50 | 51 | public function getEditForm(string $default = "", string $mes = "") { 52 | $manager = IFPlugin::getInstance()->getChainManager(); 53 | $names = $this->parse($default); 54 | $name = explode("[name]", $default)[1] ?? $default; 55 | $time = explode("[name]", $default)[0]; 56 | if ($default !== "" and $names === false) { 57 | $mes .= Language::get("form.error"); 58 | } elseif ($default !== "" and !$manager->exists($name)) { 59 | $mes .= Language::get("process.cooperation.notFound"); 60 | } 61 | $data = [ 62 | "type" => "custom_form", 63 | "title" => $this->getName(), 64 | "content" => [ 65 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 66 | Elements::getInput(Language::get("process.cooperation.form.name"), Language::get("input.example", ["aieuo"]), $name), 67 | Elements::getInput(Language::get("process.delayedcommand.form.time"), Language::get("input.example", ["10"]), $time), 68 | Elements::getToggle(Language::get("form.delete")), 69 | Elements::getToggle(Language::get("form.cancel")) 70 | ] 71 | ]; 72 | $json = Form::encodeJson($data); 73 | return $json; 74 | } 75 | 76 | public function parseFormData(array $data) { 77 | $status = true; 78 | if ($data[1] === "" or $data[2] === "") { 79 | $status = null; 80 | } else { 81 | $value = $this->parse($data[2]."[name]".$data[1]); 82 | if ($value === false) $status = false; 83 | } 84 | return ["status" => $status, "contents" => $data[2]."[name]".$data[1], "delete" => $data[3], "cancel" => $data[4]]; 85 | } 86 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/DeleteVariable.php: -------------------------------------------------------------------------------- 1 | getVariableName()]); 19 | } 20 | 21 | public function getVariableName(): ?string { 22 | $name = $this->getValues(); 23 | return is_string($name) ? $name : null; 24 | } 25 | 26 | public function setVariableName(string $variable) { 27 | $this->setValues($variable); 28 | } 29 | 30 | public function execute() { 31 | IFPlugin::getInstance()->getVariableHelper()->del($this->getVariableName()); 32 | } 33 | 34 | 35 | public function getEditForm(string $default = "", string $mes = "") { 36 | $data = [ 37 | "type" => "custom_form", 38 | "title" => $this->getName(), 39 | "content" => [ 40 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 41 | Elements::getInput(Language::get("process.deletevariable.form.name"), Language::get("input.example", ["aieuo"]), $default), 42 | Elements::getToggle(Language::get("form.delete")), 43 | Elements::getToggle(Language::get("form.cancel")) 44 | ] 45 | ]; 46 | $json = Form::encodeJson($data); 47 | return $json; 48 | } 49 | 50 | public function parseFormData(array $data) { 51 | $status = true; 52 | if ($data[1] === "") $status = null; 53 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 54 | } 55 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/DoNothing.php: -------------------------------------------------------------------------------- 1 | getPlace(); 27 | $armor = $this->getArmor(); 28 | if (!is_int($place) or !($armor instanceof Item)) return false; 29 | return Language::get("process.equipArmor.detail", [Language::get($this->places[$place]), $armor->getId(), $armor->getDamage(), $armor->getName()]); 30 | } 31 | 32 | public function getPlace() { 33 | return $this->getValues()[0]; 34 | } 35 | 36 | public function getArmor() { 37 | return $this->getValues()[1]; 38 | } 39 | 40 | public function parse(string $content) { 41 | $place = explode("[item]", $content)[0]; 42 | $id = explode("[item]", $content)[1] ?? ""; 43 | if (!preg_match("/\s*([0-9]+)\s*:?\s*([0-9]*)\s*/", $id, $ids)) return false; 44 | $item = Item::get((int)$ids[1], empty($ids[2]) ? 0 : (int)$ids[2]); 45 | return [(int)$place, $item]; 46 | } 47 | 48 | public function execute() { 49 | $player = $this->getPlayer(); 50 | $place = $this->getPlace(); 51 | $armor = $this->getArmor(); 52 | if (!($armor instanceof Item)) { 53 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 54 | return; 55 | } elseif (!($armor instanceof Armor) and !($armor instanceof ItemBlock)) { 56 | $player->sendMessage(Language::get("process.equipArmor.notArmor", [$this->getName(), $armor->getName()])); 57 | return; 58 | } 59 | $player->getArmorInventory()->setItem($place, $armor); 60 | } 61 | 62 | 63 | public function getEditForm(string $default = "", string $mes = "") { 64 | $datas = $this->parse($default); 65 | $place = 0; 66 | $armor = explode("[item]", $default)[1] ?? $default; 67 | if ($armor instanceof Armor or $armor instanceof ItemBlock) { 68 | $place = $datas[0]; 69 | $armor = $datas->getId().":".$datas->getDamage(); 70 | } elseif ($default !== "" and $armor instanceof Item) { 71 | $mes .= Language::get("process.equipArmor.notArmor", [$armor->getName()]); 72 | } elseif ($default !== "") { 73 | $mes .= Language::get("process.equipArmor.form.invalid"); 74 | } 75 | $data = [ 76 | "type" => "custom_form", 77 | "title" => $this->getName(), 78 | "content" => [ 79 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 80 | Elements::getDropdown(Language::get("process.equipArmor.form.place"), array_map(function ($item) { 81 | return Language::get($item); 82 | }, $this->places), $place), 83 | Elements::getInput(Language::get("process.equipArmor.form.id"), Language::get("input.example", ["5"]), $armor), 84 | Elements::getToggle(Language::get("form.delete")), 85 | Elements::getToggle(Language::get("form.cancel")) 86 | ] 87 | ]; 88 | $json = Form::encodeJson($data); 89 | return $json; 90 | } 91 | 92 | public function parseFormData(array $data) { 93 | $status = true; 94 | $ids_str = $data[1]."[item]".$data[2]; 95 | if ($data[2] === "") { 96 | $status = null; 97 | } else { 98 | $ids = $this->parse($ids_str); 99 | if ($ids === false) $status = false; 100 | } 101 | if ($data[1] === "" or $data[2] === "") $status = null; 102 | return ["status" => $status, "contents" => $ids_str, "delete" => $data[3], "cancel" => $data[4]]; 103 | } 104 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/EventCancel.php: -------------------------------------------------------------------------------- 1 | getValues(); 17 | } 18 | 19 | public function setCancelEvent(Event $event) { 20 | $this->setValues($event); 21 | } 22 | 23 | public function execute() { 24 | $event = $this->getCancelEvent(); 25 | if ($event instanceof Cancellable) $event->setCancelled(); 26 | } 27 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/ExecuteOtherPlayer.php: -------------------------------------------------------------------------------- 1 | getCooperationName(); 20 | $playerName = $this->getPlayerNames(); 21 | return Language::get("process.executeotherplayer.detail", [$cname, $playerName]); 22 | } 23 | 24 | public function getCooperationName() { 25 | return $this->getValues()[0]; 26 | } 27 | 28 | public function getPlayerNames() { 29 | return $this->getValues()[1]; 30 | } 31 | 32 | public function setNames(string $name, string $playerName) { 33 | $this->setValues([$name, $playerName]); 34 | } 35 | 36 | public function parse(string $content) { 37 | $data = explode(";", $content); 38 | if (!isset($data[1])) return false; 39 | $playerName = array_pop($data); 40 | $cname = implode(";", $data); 41 | return [$cname, $playerName]; 42 | } 43 | 44 | public function execute() { 45 | $player = $this->getPlayer(); 46 | $manager = IFPlugin::getInstance()->getChainManager(); 47 | if (!$manager->exists($this->getCooperationName())) { 48 | $player->sendMessage(Language::get("process.cooperation.notFound")); 49 | return; 50 | } 51 | $playerNames = explode(",", $this->getPlayerNames()); 52 | foreach ($playerNames as $name) { 53 | $name = trim($name); 54 | if (empty($name)) continue; 55 | $target = Server::getInstance()->getPlayer($name); 56 | if ($target === null) { 57 | $player->sendMessage(Language::get("process.executeotherplayer.offline", [$name])); 58 | return; 59 | } 60 | $data = $manager->get($this->getCooperationName()); 61 | $manager->executeIfMatchCondition( 62 | $target, 63 | $data["if"], 64 | $data["match"], 65 | $data["else"], 66 | [ 67 | "player" => $target, 68 | "origin" => $player 69 | ] 70 | ); 71 | } 72 | } 73 | 74 | public function getEditForm(string $default = "", string $mes = "") { 75 | $manager = IFPlugin::getInstance()->getChainManager(); 76 | $names = $this->parse($default); 77 | $cname = $default; 78 | $playerName = ""; 79 | if ($names === false and $default !== "") { 80 | $mes .= Language::get("form.error"); 81 | } else { 82 | $cname = $names[0]; 83 | $playerName = $names[1]; 84 | } 85 | if ($default !== "" and !$manager->exists($cname)) $mes .= Language::get("process.cooperation.notFound"); 86 | $data = [ 87 | "type" => "custom_form", 88 | "title" => $this->getName(), 89 | "content" => [ 90 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 91 | Elements::getInput(Language::get("process.executeotherplayer.form.name"), Language::get("input.example", ["aieuo"]), $cname), 92 | Elements::getInput(Language::get("process.executeotherplayer.form.player"), Language::get("input.example", ["aiueo421, aiueo422, aiueo423"]), $playerName), 93 | Elements::getToggle(Language::get("form.delete")), 94 | Elements::getToggle(Language::get("form.cancel")) 95 | ] 96 | ]; 97 | return Form::encodeJson($data); 98 | } 99 | 100 | public function parseFormData(array $data) { 101 | $status = true; 102 | if ($data[1] === "" or $data[2] === "") { 103 | $status = null; 104 | } else { 105 | $names = $this->parse($data[1].";".$data[2]); 106 | if ($names === false) $status = false; 107 | } 108 | return ["status" => $status, "contents" => $data[1].";".$data[2], "delete" => $data[3], "cancel" => $data[4]]; 109 | } 110 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/GenerateRandomNumber.php: -------------------------------------------------------------------------------- 1 | getValues(); 19 | if ($values === false) return false; 20 | return Language::get("process.generateRandomNumber.detail", [$this->getMin(), $this->getMax(), $this->getResultName()]); 21 | } 22 | 23 | public function getMin() { 24 | return $this->getValues()[0]; 25 | } 26 | 27 | public function getMax() { 28 | return $this->getValues()[1]; 29 | } 30 | 31 | public function getResultName() { 32 | return $this->getValues()[2]; 33 | } 34 | 35 | public function parse(string $content) { 36 | $data = explode("[max]", $content); 37 | $min = (int)$data[0]; 38 | if (!isset($data[1])) return false; 39 | $data = explode("[result]", $data[1]); 40 | $max = (int)$data[0]; 41 | $result = empty($data[1]) ? "result" : $data[1]; 42 | return [min($min, $max), max($min, $max), $result]; 43 | } 44 | 45 | public function execute() { 46 | $player = $this->getPlayer(); 47 | if ($this->getValues() === false) { 48 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 49 | return; 50 | } 51 | $number = mt_rand($this->getMin(), $this->getMax()); 52 | $variable = Variable::create($this->getResultName(), $number); 53 | IFPlugin::getInstance()->getVariableHelper()->add($variable); 54 | } 55 | 56 | 57 | public function getEditForm(string $default = "", string $mes = "") { 58 | $datas = $this->parse($default); 59 | $datas1 = explode("[max]", $default); 60 | $min = $datas1[0]; 61 | $datas2 = explode("[result]", $datas1[1] ?? $default); 62 | $max = $datas2[0]; 63 | $result = $datas2[1] ?? $datas1[1] ?? $default; 64 | if ($datas !== false) { 65 | $min = $datas[0]; 66 | $max = $datas[1]; 67 | $result = $datas[2]; 68 | } elseif ($default !== "") { 69 | $mes .= Language::get("form.error"); 70 | } 71 | $data = [ 72 | "type" => "custom_form", 73 | "title" => $this->getName(), 74 | "content" => [ 75 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 76 | Elements::getInput(Language::get("process.generateRandomNumber.form.min"), Language::get("input.example", ["0"]), $min), 77 | Elements::getInput(Language::get("process.generateRandomNumber.form.max"), Language::get("input.example", ["9"]), $max), 78 | Elements::getInput(Language::get("process.generateRandomNumber.form.result"), Language::get("input.example", ["result"]), $result), 79 | Elements::getToggle(Language::get("form.delete")), 80 | Elements::getToggle(Language::get("form.cancel")) 81 | ] 82 | ]; 83 | $json = Form::encodeJson($data); 84 | return $json; 85 | } 86 | 87 | public function parseFormData(array $data) { 88 | $status = true; 89 | $contents = $data[1]."[max]".$data[2]."[result]".$data[3]; 90 | if ($data[1] === "" or $data[2] === "") { 91 | $status = null; 92 | } else { 93 | $result = $this->parse($contents); 94 | if ($result === false) $status = false; 95 | } 96 | return ["status" => $status, "contents" => $contents, "delete" => $data[4], "cancel" => $data[5]]; 97 | } 98 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/GetInventoryContents.php: -------------------------------------------------------------------------------- 1 | getResultName(); 22 | return Language::get("process.getInventory.detail", [$reason]); 23 | } 24 | 25 | public function getResultName(): ?string { 26 | $reason = $this->getValues(); 27 | return is_string($reason) ? $reason : null; 28 | } 29 | 30 | public function execute() { 31 | $player = $this->getPlayer(); 32 | $result = $this->getResultName(); 33 | $contents = $player->getInventory()->getContents(); 34 | 35 | $variable = new ListVariable($result, array_map(function (Item $item) { 36 | return $item->getId().":".$item->getDamage(); 37 | }, $contents)); 38 | IFPlugin::getInstance()->getVariableHelper()->add($variable); 39 | } 40 | 41 | public function getEditForm(string $default = "", string $mes = "") { 42 | $data = [ 43 | "type" => "custom_form", 44 | "title" => $this->getName(), 45 | "content" => [ 46 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 47 | Elements::getInput(Language::get("process.getInventory.form.result"), Language::get("input.example", ["items"]), $default), 48 | Elements::getToggle(Language::get("form.delete")), 49 | Elements::getToggle(Language::get("form.cancel")) 50 | ] 51 | ]; 52 | return Form::encodeJson($data); 53 | } 54 | 55 | public function parseFormData(array $data) { 56 | $status = true; 57 | if ($data[1] === "") $status = null; 58 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 59 | } 60 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/Kick.php: -------------------------------------------------------------------------------- 1 | getReason(); 20 | return Language::get("process.kick.detail", [$reason]); 21 | } 22 | 23 | public function getReason(): ?string { 24 | $reason = $this->getValues(); 25 | return is_string($reason) ? $reason : null; 26 | } 27 | 28 | public function setReason(string $reason) { 29 | $this->setValues($reason); 30 | } 31 | 32 | public function execute() { 33 | $player = $this->getPlayer(); 34 | $reason = $this->getReason(); 35 | IFPlugin::getInstance()->getScheduler()->scheduleDelayedTask(new KickTask($player, $reason), 5); 36 | } 37 | 38 | public function getEditForm(string $default = "", string $mes = "") { 39 | $data = [ 40 | "type" => "custom_form", 41 | "title" => $this->getName(), 42 | "content" => [ 43 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 44 | Elements::getInput(Language::get("process.kick.form.reason"), Language::get("input.example", ["aieuo"]), $default), 45 | Elements::getToggle(Language::get("form.delete")), 46 | Elements::getToggle(Language::get("form.cancel")) 47 | ] 48 | ]; 49 | $json = Form::encodeJson($data); 50 | return $json; 51 | } 52 | 53 | public function parseFormData(array $data) { 54 | $status = true; 55 | if ($data[1] === "") $status = null; 56 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 57 | } 58 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/Motion.php: -------------------------------------------------------------------------------- 1 | getPosition(); 19 | if ($pos === false) return false; 20 | return Language::get("process.motion.detail", [$pos->x, $pos->y, $pos->z]); 21 | } 22 | 23 | public function execute() { 24 | $player = $this->getPlayer(); 25 | $pos = $this->getPosition(); 26 | if (!($pos instanceof Vector3)) { 27 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 28 | return; 29 | } 30 | $player->setMotion($pos); 31 | } 32 | 33 | public function getEditForm(string $default = "", string $mes = "") { 34 | $pos = $this->parse($default); 35 | $x = $default; 36 | $y = ""; 37 | $z = ""; 38 | if ($pos instanceof Vector3) { 39 | $x = $pos->x; 40 | $y = $pos->y; 41 | $z = $pos->z; 42 | } elseif ($default !== "") { 43 | $mes .= Language::get("form.error"); 44 | } 45 | $data = [ 46 | "type" => "custom_form", 47 | "title" => $this->getName(), 48 | "content" => [ 49 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 50 | Elements::getInput(Language::get("process.motion.form.x"), Language::get("input.example", ["1"]), $x), 51 | Elements::getInput(Language::get("process.motion.form.y"), Language::get("input.example", ["10"]), $y), 52 | Elements::getInput(Language::get("process.motion.form.z"), Language::get("input.example", ["100"]), $z), 53 | Elements::getToggle(Language::get("form.delete")), 54 | Elements::getToggle(Language::get("form.cancel")) 55 | ] 56 | ]; 57 | $json = Form::encodeJson($data); 58 | return $json; 59 | } 60 | 61 | public function parseFormData(array $data) { 62 | $status = true; 63 | if ($data[1] === "" and $data[2] === "" and $data[3] === "") { 64 | $status = null; 65 | } else { 66 | $pos = $this->parse($data[1].",".$data[2].",".$data[3]); 67 | if ($pos === false) $status = false; 68 | } 69 | return ["status" => $status, "contents" => $data[1].",".$data[2].",".$data[3], "delete" => $data[4], "cancel" => $data[5]]; 70 | } 71 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/Process.php: -------------------------------------------------------------------------------- 1 | player = $player; 36 | } 37 | 38 | public static function get($id) { 39 | return ProcessFactory::get($id); 40 | } 41 | 42 | public function getId() { 43 | return $this->id; 44 | } 45 | 46 | public function getName() { 47 | if ($this->name[0] === "@") { 48 | return Language::get(substr($this->name, 1)); 49 | } 50 | return $this->name; 51 | } 52 | 53 | public function getDescription() { 54 | if ($this->description[0] === "@") { 55 | return Language::get(substr($this->description, 1)); 56 | } 57 | return $this->description; 58 | } 59 | 60 | // TODO 失敗したときfalse返すかnull返すか統一する 61 | public function getDetail(): string { 62 | if ($this->detail[0] === "@") { 63 | return Language::get(substr($this->detail, 1)); 64 | } 65 | return $this->detail; 66 | } 67 | 68 | public function parse(string $str) { 69 | return $str; 70 | } 71 | 72 | public function setPlayer(Player $player) : self { 73 | $this->player = $player; 74 | return $this; 75 | } 76 | 77 | // TODO オンラインのチェック 78 | public function getPlayer() : Player { 79 | return $this->player; 80 | } 81 | 82 | public function setValues($values) : self { 83 | $this->values = $values; 84 | return $this; 85 | } 86 | 87 | public function getValues() { 88 | return $this->values; 89 | } 90 | 91 | public function setEvent(Event $event) { 92 | $this->event = $event; 93 | } 94 | 95 | public function getEvent() : ?Event { 96 | return $this->event; 97 | } 98 | 99 | public function getEditForm(string $default = "", string $mes = "") { 100 | if ($mes !== "") $mes = "\n".$mes; 101 | $data = [ 102 | "type" => "custom_form", 103 | "title" => $this->getName(), 104 | "content" => [ 105 | Elements::getLabel($this->getDescription().$mes), 106 | Elements::getToggle(Language::get("form.delete")), 107 | Elements::getToggle(Language::get("form.cancel")) 108 | ] 109 | ]; 110 | return Form::encodeJson($data); 111 | } 112 | 113 | public function parseFormData(array $data) { 114 | return ["status" => true, "contents" => "", "delete" => $data[1], "cancel" => $data[2]]; 115 | } 116 | 117 | public function execute() { 118 | } 119 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/ProcessFactory.php: -------------------------------------------------------------------------------- 1 | getEconomy() instanceof EconomyLoader; 13 | self::register(new DoNothing()); 14 | self::register(new SendMessage()); 15 | self::register(new SendTip()); 16 | self::register(new SendTitle()); 17 | self::register(new BroadcastMessage()); 18 | self::register(new SendMessageToOp()); 19 | self::register(new SendVoiceMessage()); 20 | self::register(new SendForm()); 21 | self::register(new Command()); 22 | self::register(new CommandConsole()); 23 | self::register(new DelayedCommand()); 24 | self::register(new DelayedCommandConsole()); 25 | if ($existsEconomy) self::register(new AddMoney()); 26 | if ($existsEconomy) self::register(new TakeMoney()); 27 | if ($existsEconomy) self::register(new SetMoney()); 28 | self::register(new Teleport()); 29 | self::register(new Motion()); 30 | self::register(new AddParticle()); 31 | self::register(new AddParticleRange()); 32 | self::register(new SetScale()); 33 | self::register(new Calculation()); 34 | self::register(new AddVariable()); 35 | self::register(new DeleteVariable()); 36 | self::register(new AddItem()); 37 | self::register(new RemoveItem()); 38 | self::register(new SetItem()); 39 | self::register(new ClearInventory()); 40 | self::register(new SetImmobile()); 41 | self::register(new UnSetImmobile()); 42 | self::register(new EquipArmor()); 43 | self::register(new AddEnchantment()); 44 | self::register(new AddEffect()); 45 | self::register(new AddSound()); 46 | self::register(new SetNametag()); 47 | self::register(new SetSleeping()); 48 | self::register(new SetSitting()); 49 | self::register(new EventCancel()); 50 | self::register(new SetGamemode()); 51 | self::register(new Cooperation()); 52 | self::register(new CooperationRepeat()); 53 | self::register(new DelayedCooperation()); 54 | self::register(new ExecuteOtherPlayer()); 55 | self::register(new SetBlocks()); 56 | self::register(new SaveDatas()); 57 | self::register(new SetHealth()); 58 | self::register(new SetMaxHealth()); 59 | self::register(new SetFood()); 60 | self::register(new Attack()); 61 | self::register(new Kick()); 62 | self::register(new ShowBossbar()); 63 | self::register(new RemoveBossbar()); 64 | self::register(new GenerateRandomNumber()); 65 | self::register(new GetInventoryContents()); 66 | self::register(new ChangeItemData()); 67 | } 68 | 69 | /** 70 | * @param int $id 71 | * @return Process|null 72 | */ 73 | public static function get($id): ?Process { 74 | if (isset(self::$list[$id])) { 75 | return clone self::$list[$id]; 76 | } 77 | return null; 78 | } 79 | 80 | public static function getAll(): array { 81 | return self::$list; 82 | } 83 | 84 | /** 85 | * @param Process $process 86 | */ 87 | public static function register(Process $process) { 88 | self::$list[$process->getId()] = clone $process; 89 | } 90 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/ProcessIds.php: -------------------------------------------------------------------------------- 1 | getBossbarId(); 18 | return Language::get("process.removeBossbar.detail", [$id]); 19 | } 20 | 21 | public function getBossbarId(): ?string { 22 | $id = $this->getValues(); 23 | if (!is_string($id)) return null; 24 | return $id; 25 | } 26 | 27 | public function parse(string $content) { 28 | return $content; 29 | } 30 | 31 | public function execute() { 32 | $player = $this->getPlayer(); 33 | if ($this->getValues() === false) { 34 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 35 | return; 36 | } 37 | Bossbar::remove($player, $this->getBossbarId()); 38 | } 39 | 40 | public function getEditForm(string $default = "", string $mes = "") { 41 | $id = $default; 42 | $data = [ 43 | "type" => "custom_form", 44 | "title" => $this->getName(), 45 | "content" => [ 46 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 47 | Elements::getInput(Language::get("process.showBossbar.form.id"), Language::get("input.example", ["aieuo"]), $id), 48 | Elements::getToggle(Language::get("form.delete")), 49 | Elements::getToggle(Language::get("form.cancel")) 50 | ] 51 | ]; 52 | $json = Form::encodeJson($data); 53 | return $json; 54 | } 55 | 56 | public function parseFormData(array $data) { 57 | $status = true; 58 | if ($data[1] === "") { 59 | $status = null; 60 | } 61 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 62 | } 63 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/RemoveItem.php: -------------------------------------------------------------------------------- 1 | getItem(); 20 | if (!($item instanceof Item)) return false; 21 | return Language::get("process.removeitem.detail", [$item->getId(), $item->getDamage(), $item->getName(), $item->getCount()]); 22 | } 23 | 24 | public function execute() { 25 | $player = $this->getPlayer(); 26 | $item = $this->getItem(); 27 | if ($item->getCount() > 0) { 28 | $player->getInventory()->removeItem($item); 29 | return; 30 | } 31 | $count = 0; 32 | foreach ($player->getInventory()->getContents() as $item1) { 33 | if ($item1->getId() == $item->getId() and $item1->getDamage() == $item->getDamage()) { 34 | $count += $item1->getCount(); 35 | } 36 | } 37 | $item->setCount($count); 38 | if ($item->getCount() > 0) { 39 | $player->getInventory()->removeItem($item); 40 | } 41 | } 42 | 43 | 44 | public function getEditForm(string $default = "", string $mes = "") { 45 | $item = $this->parse($default); 46 | $id = $default; 47 | $count = ""; 48 | $name = ""; 49 | $lore = ""; 50 | $enchant = ""; 51 | if ($item instanceof Item) { 52 | $id = $item->getId().":".$item->getDamage(); 53 | $count = $item->getCount(); 54 | $name = $item->hasCustomName() ? $item->getName() : ""; 55 | $lore = implode(";", $item->getLore()); 56 | $enchant = implode(";", array_map(function (EnchantmentInstance $enchant) { 57 | return $enchant->getId().",".$enchant->getLevel(); 58 | }, $item->getEnchantments())); 59 | if ($count === 0) $mes .= Language::get("process.removeitem.removeall"); 60 | } elseif ($default !== "") { 61 | $mes .= Language::get("process.item.form.invalid"); 62 | } 63 | $data = [ 64 | "type" => "custom_form", 65 | "title" => $this->getName(), 66 | "content" => [ 67 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 68 | Elements::getInput(Language::get("process.item.form.id"), Language::get("input.example", ["1:0"]), $id), 69 | Elements::getInput(Language::get("process.removeitem.form.count"), Language::get("input.example", ["5"]), $count), 70 | Elements::getInput(Language::get("process.item.form.name"), Language::get("input.example", ["aieuo"]), $name), 71 | Elements::getInput(Language::get("process.item.form.lore"), Language::get("input.example", ["aiueo;aieuo;aeiuo"]), $lore), 72 | Elements::getInput(Language::get("process.item.form.enchant"), Language::get("input.example", ["id,level;1,1;5,10"]), $enchant), 73 | Elements::getToggle(Language::get("form.delete")), 74 | Elements::getToggle(Language::get("form.cancel")) 75 | ] 76 | ]; 77 | return Form::encodeJson($data); 78 | } 79 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SaveDatas.php: -------------------------------------------------------------------------------- 1 | getBlockManager()->save(); 16 | IFPlugin::getInstance()->getCommandManager()->save(); 17 | IFPlugin::getInstance()->getEventManager()->save(); 18 | IFPlugin::getInstance()->getChainManager()->save(); 19 | IFPlugin::getInstance()->getFormIFManager()->save(); 20 | IFPlugin::getInstance()->getVariableHelper()->save(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SendForm.php: -------------------------------------------------------------------------------- 1 | getFormName(); 21 | return Language::get("process.sendform.detail", [$name]); 22 | } 23 | 24 | public function getFormName(): ?string { 25 | $name = $this->getValues(); 26 | return is_string($name) ? $name : null; 27 | } 28 | 29 | public function setFormName(string $name) { 30 | $this->setValues($name); 31 | } 32 | 33 | public function execute() { 34 | $player = $this->getPlayer(); 35 | $name = $this->getFormName(); 36 | $manager = IFPlugin::getInstance()->getFormIFManager(); 37 | if (!$manager->exists($name)) { 38 | $player->sendMessage(Language::get("process.sendform.notfound", [$this->getName()])); 39 | return; 40 | } 41 | $form = json_encode($manager->getForm($name, $this->replaceDatas)); 42 | Session::getSession($player)->set("form_name", $name); 43 | Form::sendForm($player, $form, $this, "onReceive", false); 44 | } 45 | 46 | public function onReceive(Player $player, $data) { 47 | $session = Session::getSession($player); 48 | if ($data === null) { 49 | $session->setValid(false, false); 50 | return; 51 | } 52 | $formName = $session->get("form_name"); 53 | $manager = IFPlugin::getInstance()->getFormIFManager(); 54 | if (!$manager->exists($formName)) { 55 | $player->sendMessage(Language::get("process.sendform.notfound", [$this->getName()])); 56 | return; 57 | } 58 | $data1 = $manager->getIF($formName); 59 | $form = $manager->getForm($formName, $this->replaceDatas); 60 | foreach ($data1["ifs"] as $ifData) { 61 | $manager->executeIfMatchCondition( 62 | $player, 63 | $ifData["if"], 64 | $ifData["match"], 65 | $ifData["else"], 66 | [ 67 | "player" => $player, 68 | "form" => $form, 69 | "form_name" => $formName, 70 | "form_data" => $data, 71 | ] 72 | ); 73 | } 74 | } 75 | 76 | public function getEditForm(string $default = "", string $mes = "") { 77 | $data = [ 78 | "type" => "custom_form", 79 | "title" => $this->getName(), 80 | "content" => [ 81 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 82 | Elements::getInput(Language::get("process.sendform.form.name"), Language::get("input.example", ["aieuo"]), $default), 83 | Elements::getToggle(Language::get("form.delete")), 84 | Elements::getToggle(Language::get("form.cancel")) 85 | ] 86 | ]; 87 | $json = Form::encodeJson($data); 88 | return $json; 89 | } 90 | 91 | public function parseFormData(array $data) { 92 | $status = true; 93 | if ($data[1] === "") $status = null; 94 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 95 | } 96 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SendMessage.php: -------------------------------------------------------------------------------- 1 | getMessage(); 15 | return Language::get("process.sendmessage.detail", [$message]); 16 | } 17 | 18 | public function execute() { 19 | $player = $this->getPlayer(); 20 | $player->sendMessage($this->getMessage()); 21 | } 22 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SendMessageToOp.php: -------------------------------------------------------------------------------- 1 | getMessage(); 17 | return Language::get("process.sendmessagetoop.detail", [$message]); 18 | } 19 | 20 | public function execute() { 21 | $players = Server::getInstance()->getOnlinePlayers(); 22 | foreach ($players as $player) { 23 | if ($player->isOp()) { 24 | $player->sendMessage($this->getMessage()); 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SendTip.php: -------------------------------------------------------------------------------- 1 | getMessage()]); 15 | } 16 | 17 | public function execute() { 18 | $player = $this->getPlayer(); 19 | $player->sendTip($this->getMessage()); 20 | } 21 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SendTitle.php: -------------------------------------------------------------------------------- 1 | getTitle(), $this->getSubTitle(), $this->getFadeIn(), $this->getStay(), $this->getFadeOut()]); 17 | } 18 | 19 | public function getTitle(): ?string { 20 | $message = $this->getValues()[0]; 21 | if (!is_string($message)) return null; 22 | return $message; 23 | } 24 | 25 | public function getSubTitle(): ?string { 26 | $message = $this->getValues()[1]; 27 | if (!is_string($message)) return null; 28 | return $message; 29 | } 30 | 31 | public function getFadeIn(): int { 32 | return $this->getValues()[2] ?? -1; 33 | } 34 | 35 | public function getStay(): int { 36 | return $this->getValues()[3] ?? -1; 37 | } 38 | 39 | public function getFadeOut(): int { 40 | return $this->getValues()[4] ?? -1; 41 | } 42 | 43 | public function parse(string $content) { 44 | $titles = explode("[subtitle]", $content); 45 | $title = $titles[0]; 46 | $subtitles = explode("[fadeIn]", $titles[1] ?? ""); 47 | $subtitle = $subtitles[0]; 48 | $fadeIns = explode("[stay]", $subtitles[1] ?? "10[stay]20[fadeOut]10"); 49 | $fadeIn = $fadeIns[0]; 50 | $stays = explode("[fadeOut]", $fadeIns[1] ?? "20[fadeOut]10"); 51 | $stay = $stays[0]; 52 | $fadeOut = $stays[1]; 53 | return [$title, $subtitle, (int)$fadeIn, (int)$stay, (int)$fadeOut]; 54 | } 55 | 56 | public function execute() { 57 | $player = $this->getPlayer(); 58 | $player->addTitle($this->getTitle(), $this->getSubTitle(), $this->getFadeIn(), $this->getStay(), $this->getFadeOut()); 59 | } 60 | 61 | public function getEditForm(string $default = "", string $mes = "") { 62 | $messages = $this->parse($default); 63 | $title = $messages[0]; 64 | $subtitle = $messages[1]; 65 | $fadeIn = (string)$messages[2]; 66 | $stay = (string)$messages[3]; 67 | $fadeOut = (string)$messages[4]; 68 | $data = [ 69 | "type" => "custom_form", 70 | "title" => $this->getName(), 71 | "content" => [ 72 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 73 | Elements::getInput(Language::get("process.sendtitle.form.title"), Language::get("input.example", ["aieuo"]), $title), 74 | Elements::getInput(Language::get("process.sendtitle.form.subtitle"), Language::get("input.example", ["aiueo"]), $subtitle), 75 | Elements::getInput(Language::get("process.sendtitle.form.fadeIn"), Language::get("input.example", ["-1"]), $fadeIn), 76 | Elements::getInput(Language::get("process.sendtitle.form.stay"), Language::get("input.example", ["-1"]), $stay), 77 | Elements::getInput(Language::get("process.sendtitle.form.fadeOut"), Language::get("input.example", ["-1"]), $fadeOut), 78 | Elements::getToggle(Language::get("form.delete")), 79 | Elements::getToggle(Language::get("form.cancel")) 80 | ] 81 | ]; 82 | return Form::encodeJson($data); 83 | } 84 | 85 | public function parseFormData(array $data) { 86 | $status = true; 87 | if ($data[1] === "" or $data[2] === "") { 88 | $status = null; 89 | } 90 | for ($i=3; $i<=5; $i++) { 91 | if ($data[$i] === "") $data[$i] = "-1"; 92 | } 93 | $content = $data[1]."[subtitle]".$data[2]."[fadeIn]".$data[3]."[stay]".$data[4]."[fadeOut]".$data[5]; 94 | return ["status" => $status, "contents" => $content, "delete" => $data[6], "cancel" => $data[7]]; 95 | } 96 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SendVoiceMessage.php: -------------------------------------------------------------------------------- 1 | getMessage(); 17 | return Language::get("process.sendvoicemessage.detail", [$message]); 18 | } 19 | 20 | public function execute() { 21 | $player = $this->getPlayer(); 22 | $text = new TranslationContainer($this->getMessage()); 23 | $player->sendMessage($text); 24 | } 25 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetFood.php: -------------------------------------------------------------------------------- 1 | getFood(); 17 | if ($health === false) return false; 18 | return Language::get("process.setFood.detail", [$health]); 19 | } 20 | 21 | public function getFood(): ?int { 22 | $health = $this->getValues(); 23 | if (!is_int($health) or $health <= 0) return null; 24 | return $health; 25 | } 26 | 27 | public function setFood(int $health) { 28 | $this->setValues($health); 29 | } 30 | 31 | public function parse(string $content) { 32 | return (int)$content; 33 | } 34 | 35 | public function execute() { 36 | $player = $this->getPlayer(); 37 | $food = $this->getFood(); 38 | $player->setFood($food); 39 | } 40 | 41 | public function getEditForm(string $default = "", string $mes = "") { 42 | $health = $this->parse($default); 43 | $data = [ 44 | "type" => "custom_form", 45 | "title" => $this->getName(), 46 | "content" => [ 47 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 48 | Elements::getInput(Language::get("process.setFood.form.food"), Language::get("input.example", ["10"]), $health), 49 | Elements::getToggle(Language::get("form.delete")), 50 | Elements::getToggle(Language::get("form.cancel")) 51 | ] 52 | ]; 53 | return Form::encodeJson($data); 54 | } 55 | 56 | public function parseFormData(array $data) { 57 | $status = true; 58 | if ($data[1] === "") { 59 | $status = null; 60 | } else { 61 | $health = $this->parse($data[1]); 62 | if ($health === false) $status = false; 63 | } 64 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 65 | } 66 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetGamemode.php: -------------------------------------------------------------------------------- 1 | getValues(); 26 | if (!(is_int($gamemode) and $gamemode >= 0 and $gamemode <= 3)) return null; 27 | return $gamemode; 28 | } 29 | 30 | public function setGamemode(int $gamemode) { 31 | $this->setValues($gamemode); 32 | } 33 | 34 | public function parse(string $content) { 35 | $gamemode = Server::getInstance()->getGamemodeFromString($content); 36 | if ($gamemode === -1) return false; 37 | return $gamemode; 38 | } 39 | 40 | public function getDetail(): string { 41 | $gamemode = $this->getGamemode(); 42 | if ($gamemode === false) return false; 43 | return Language::get("process.gamemode.detail", [Language::get($this->gamemodes[$gamemode])]); 44 | } 45 | 46 | public function execute() { 47 | $player = $this->getPlayer(); 48 | $gamemode = $this->getGamemode(); 49 | if ($gamemode === false) { 50 | $player->sendMessage(Language::get("process.gamemode.notfound")); 51 | return; 52 | } 53 | $player->setGamemode($gamemode); 54 | } 55 | 56 | public function getEditForm(string $default = "", string $mes = "") { 57 | $gamemode = $this->parse($default); 58 | if ($gamemode === false) { 59 | if ($default !== "") $mes .= Language::get("process.gamemode.notfound"); 60 | $gamemode = 0; 61 | } 62 | $data = [ 63 | "type" => "custom_form", 64 | "title" => $this->getName(), 65 | "content" => [ 66 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 67 | Elements::getDropdown( 68 | Language::get("process.gamemode.form.gamemode"), 69 | array_map(function ($g) { 70 | return Language::get($g); 71 | }, $this->gamemodes), 72 | $gamemode 73 | ), 74 | Elements::getToggle(Language::get("form.delete")), 75 | Elements::getToggle(Language::get("form.cancel")) 76 | ] 77 | ]; 78 | $json = Form::encodeJson($data); 79 | return $json; 80 | } 81 | 82 | public function parseFormData(array $data) { 83 | $status = true; 84 | if ($data[1] === "") { 85 | $status = null; 86 | } else { 87 | $gamemode = $this->parse($data[1]); 88 | if ($gamemode === false) $status = false; 89 | } 90 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 91 | } 92 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetHealth.php: -------------------------------------------------------------------------------- 1 | getHealth(); 17 | if ($health === false) return false; 18 | return Language::get("process.sethealth.detail", [$health]); 19 | } 20 | 21 | public function getHealth(): ?int { 22 | $health = $this->getValues(); 23 | if (!is_int($health) or $health <= 0) return null; 24 | return $health; 25 | } 26 | 27 | public function setHealth(int $health) { 28 | $this->setValues($health); 29 | } 30 | 31 | public function parse(string $content) { 32 | $health = (int)$content; 33 | if ($health <= 0) return false; 34 | return $health; 35 | } 36 | 37 | public function execute() { 38 | $player = $this->getPlayer(); 39 | $health = $this->gethealth(); 40 | if ($health === false) { 41 | $player->sendMessage(Language::get("process.sethealth.zero", [$this->getName()])); 42 | return; 43 | } 44 | $player->setHealth($health); 45 | } 46 | 47 | public function getEditForm(string $default = "", string $mes = "") { 48 | $health = $this->parse($default); 49 | if ($health === false) { 50 | if ($default !== "") $mes = Language::get("process.sethealth.form.zero"); 51 | $health = $default; 52 | } 53 | $data = [ 54 | "type" => "custom_form", 55 | "title" => $this->getName(), 56 | "content" => [ 57 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 58 | Elements::getInput(Language::get("process.sethealth.form.health"), Language::get("input.example", ["10"]), $health), 59 | Elements::getToggle(Language::get("form.delete")), 60 | Elements::getToggle(Language::get("form.cancel")) 61 | ] 62 | ]; 63 | $json = Form::encodeJson($data); 64 | return $json; 65 | } 66 | 67 | public function parseFormData(array $data) { 68 | $status = true; 69 | if ($data[1] === "") { 70 | $status = null; 71 | } else { 72 | $health = $this->parse($data[1]); 73 | if ($health === false) $status = false; 74 | } 75 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 76 | } 77 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetImmobile.php: -------------------------------------------------------------------------------- 1 | getPlayer(); 14 | $player->setImmobile(); 15 | } 16 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetItem.php: -------------------------------------------------------------------------------- 1 | getValues()) return false; 19 | $item = $this->getItem(); 20 | if (!($item instanceof Item)) return false; 21 | $index = $this->getIndex(); 22 | return Language::get("process.setitem.detail", [$index, $item->getId(), $item->getDamage(), $item->getName(), $item->getCount()]); 23 | } 24 | 25 | public function getIndex() { 26 | return $this->getValues()[0]; 27 | } 28 | 29 | public function getItem() { 30 | return $this->getValues()[1]; 31 | } 32 | 33 | public function setItems(int $index, Item $item) { 34 | $this->setValues([$index, $item]); 35 | } 36 | 37 | public function parse(string $id) { 38 | if (!preg_match("/\s*([0-9]+)\s*,\s*([0-9]+)\s*:?\s*([0-9]*)\s*:?\s*([0-9]*)\s*:?\s*(\.*)\s*/", $id, $ids)) return false; 39 | $item = Item::get((int)$ids[2], empty($ids[3]) ? 0 : (int)$ids[3], empty($ids[4]) ? 0 : (int)$ids[4]); 40 | if (!empty($ids[5])) $item->setCustomName($ids[5]); 41 | return [(int)$ids[1], $item]; 42 | } 43 | 44 | public function execute() { 45 | $player = $this->getPlayer(); 46 | if ($this->getValues() === false) { 47 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 48 | return; 49 | } 50 | $item = $this->getItem(); 51 | $index = $this->getIndex(); 52 | $player->getInventory()->setItem($index, $item); 53 | } 54 | 55 | 56 | public function getEditForm(string $default = "", string $mes = "") { 57 | $items = $this->parse($default); 58 | $id = $default; 59 | $count = ""; 60 | $name = ""; 61 | $index = ""; 62 | if ($items === false and $default !== "") { 63 | $mes .= Language::get("process.item.form.invalid"); 64 | } elseif ($items[1] instanceof Item) { 65 | $item = $items[1]; 66 | $id = $item->getId().":".$item->getDamage(); 67 | $count = $item->getCount(); 68 | $name = $item->hasCustomName() ? $item->getName() : ""; 69 | if ($count === 0) $mes .= Language::get("process.item.form.zero"); 70 | } 71 | $data = [ 72 | "type" => "custom_form", 73 | "title" => $this->getName(), 74 | "content" => [ 75 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 76 | Elements::getInput(Language::get("process.item.form.id"), Language::get("input.example", ["1:0"]), $id), 77 | Elements::getInput(Language::get("process.item.form.count"), Language::get("input.example", ["5"]), $count), 78 | Elements::getInput(Language::get("process.item.form.name"), Language::get("input.example", ["aieuo"]), $name), 79 | Elements::getInput(Language::get("process.setitem.form.index"), Language::get("input.example", ["0"]), $index), 80 | Elements::getToggle(Language::get("form.delete")), 81 | Elements::getToggle(Language::get("form.cancel")) 82 | ] 83 | ]; 84 | $json = Form::encodeJson($data); 85 | return $json; 86 | } 87 | 88 | public function parseFormData(array $data) { 89 | $status = true; 90 | $id = explode(":", $data[1]); 91 | if (!isset($id[1])) $id[1] = 0; 92 | $ids_str = $data[4].",".$id[0].":".$id[1].":".$data[2].($data[3] !== "" ? ":".$data[3] : ""); 93 | if ($data[1] === "" or $data[2] === "" or $data[4] === "") { 94 | $status = null; 95 | } else { 96 | $ids = $this->parse($ids_str); 97 | if ($ids === false) $status = false; 98 | } 99 | return ["status" => $status, "contents" => $ids_str, "delete" => $data[5], "cancel" => $data[6]]; 100 | } 101 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetMaxHealth.php: -------------------------------------------------------------------------------- 1 | getHealth(); 15 | if ($health === false) return false; 16 | return Language::get("process.setmaxhealth.detail", [$health]); 17 | } 18 | 19 | public function execute() { 20 | $player = $this->getPlayer(); 21 | $health = $this->getHealth(); 22 | if ($health === false) { 23 | $player->sendMessage(Language::get("process.setmaxhealth.zero", [$this->getName()])); 24 | return; 25 | } 26 | $player->setMaxHealth($health); 27 | } 28 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetMoney.php: -------------------------------------------------------------------------------- 1 | getAmount()]); 16 | } 17 | 18 | public function execute() { 19 | $player = $this->getPlayer(); 20 | $economy = IFPlugin::getInstance()->getEconomy(); 21 | if ($economy === null) { 22 | $player->sendMessage(Language::get("economy.notfound")); 23 | return; 24 | } 25 | $economy->setMoney($player->getName(), $this->getAmount()); 26 | } 27 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetNametag.php: -------------------------------------------------------------------------------- 1 | getChangeName()]); 17 | } 18 | 19 | public function getChangeName(): ?string { 20 | $name = $this->getValues(); 21 | if (!is_string($name)) return null; 22 | return $name; 23 | } 24 | 25 | public function setChangeName(string $name) { 26 | $this->setValues($name); 27 | } 28 | 29 | public function execute() { 30 | $player = $this->getPlayer(); 31 | $name = $this->getChangeName(); 32 | $player->setNametag($name); 33 | $player->setDisplayName($name); 34 | } 35 | 36 | public function getEditForm(string $default = "", string $mes = "") { 37 | $data = [ 38 | "type" => "custom_form", 39 | "title" => $this->getName(), 40 | "content" => [ 41 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 42 | Elements::getInput(Language::get("process.setnametag.form.name"), Language::get("input.example", ["aieuo"]), $default), 43 | Elements::getToggle(Language::get("form.delete")), 44 | Elements::getToggle(Language::get("form.cancel")) 45 | ] 46 | ]; 47 | $json = Form::encodeJson($data); 48 | return $json; 49 | } 50 | 51 | public function parseFormData(array $data) { 52 | $status = true; 53 | if ($data[1] === "") $status = null; 54 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 55 | } 56 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetScale.php: -------------------------------------------------------------------------------- 1 | getScale(); 17 | if ($scale === false) return false; 18 | return Language::get("process.setscale.detail", [$this->getName()]); 19 | } 20 | 21 | public function getScale(): ?float { 22 | $scale = $this->getValues(); 23 | if (!is_numeric($scale)) return null; 24 | return (float)$scale; 25 | } 26 | 27 | public function setScale(float $scale) { 28 | $this->setValues($scale); 29 | } 30 | 31 | public function parse(string $content) { 32 | $scale = (float)$content; 33 | if ($scale <= 0) return false; 34 | return $scale; 35 | } 36 | 37 | public function execute() { 38 | $player = $this->getPlayer(); 39 | $scale = $this->getScale(); 40 | if ($scale === null) { 41 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 42 | return; 43 | } 44 | $player->setScale($scale); 45 | } 46 | 47 | 48 | public function getEditForm(string $default = "", string $mes = "") { 49 | $scale = $this->parse($default); 50 | if ($scale === false and $default !== "") { 51 | $scale = $default; 52 | $mes .= Language::get("process.setscale.form.error"); 53 | } 54 | $data = [ 55 | "type" => "custom_form", 56 | "title" => $this->getName(), 57 | "content" => [ 58 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 59 | Elements::getInput(Language::get("process.setscale.form.scale"), Language::get("input.example", ["2"]), $scale), 60 | Elements::getToggle(Language::get("form.delete")), 61 | Elements::getToggle(Language::get("form.cancel")) 62 | ] 63 | ]; 64 | $json = Form::encodeJson($data); 65 | return $json; 66 | } 67 | 68 | public function parseFormData(array $data) { 69 | $status = true; 70 | if ($data[1] === "") { 71 | $status = null; 72 | } else { 73 | $scale = $this->parse($data[1]); 74 | if ($scale === false) $status = false; 75 | } 76 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 77 | } 78 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetSitting.php: -------------------------------------------------------------------------------- 1 | getPosition(); 24 | if ($pos === false) return false; 25 | return Language::get("process.setsitting.detail", [$pos->x.",".$pos->y.",".$pos->z.",".$pos->level->getFolderName()]); 26 | } 27 | 28 | public function execute() { 29 | $player = $this->getPlayer(); 30 | $pos = $this->getPosition(); 31 | if (!($pos instanceof Position)) { 32 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 33 | return; 34 | } 35 | $pk = new AddActorPacket(); 36 | $pk->entityRuntimeId = ++Entity::$entityCount; 37 | $pk->type = 84; 38 | $pk->position = $pos; 39 | $pk->links = [new EntityLink($pk->entityRuntimeId, $player->getId(), EntityLink::TYPE_RIDER)]; 40 | $pk->metadata = [ 41 | Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG, 1 << Entity::DATA_FLAG_INVISIBLE] 42 | ]; 43 | $player->dataPacket($pk); 44 | self::leave($player); 45 | self::$entityIds[$player->getName()] = $pk->entityRuntimeId; 46 | } 47 | 48 | public static function leave(Player $player) { 49 | if (isset(self::$entityIds[$player->getName()])) { 50 | $pk = new RemoveActorPacket(); 51 | $pk->entityUniqueId = self::$entityIds[$player->getName()]; 52 | if ($player->isOnline()) $player->dataPacket($pk); 53 | unset(self::$entityIds[$player->getName()]); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/SetSleeping.php: -------------------------------------------------------------------------------- 1 | getPosition(); 17 | if ($pos === false) return false; 18 | return Language::get("process.setsleeping.description", [$pos->x.",".$pos->y.",".$pos->z.",".$pos->level->getFolderName()]); 19 | } 20 | 21 | public function execute() { 22 | $player = $this->getPlayer(); 23 | $pos = $this->getPosition(); 24 | if (!($pos instanceof Position)) { 25 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 26 | return; 27 | } 28 | $player->sleepOn($pos); 29 | } 30 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/ShowBossbar.php: -------------------------------------------------------------------------------- 1 | getTitle(); 18 | $max = $this->getMaxValue(); 19 | $current = $this->getCurrentValue(); 20 | return Language::get("process.showBossbar.detail", [$title, $max, $current]); 21 | } 22 | 23 | public function getTitle(): ?string { 24 | return $this->getValues()[0] ?? null; 25 | } 26 | 27 | public function getMaxValue(): ?float { 28 | return $this->getValues()[1] ?? null; 29 | } 30 | 31 | public function getCurrentValue(): ?float { 32 | return $this->getValues()[2] ?? null; 33 | } 34 | 35 | public function getBossbarId(): ?string { 36 | return $this->getValues()[3] ?? null; 37 | } 38 | 39 | public function parse(string $content) { 40 | $titles = explode("[max]", $content); 41 | if (!isset($titles[1])) return false; 42 | $title = $titles[0]; 43 | $values = explode("[value]", $titles[1]); 44 | if (!isset($values[1])) return false; 45 | $max = $values[0]; 46 | $ids = explode("[id]", $values[1]); 47 | if (!isset($ids[1])) return false; 48 | $value = $ids[0]; 49 | $id = $ids[1]; 50 | return [$title, (float)$max, (float)$value, $id]; 51 | } 52 | 53 | public function execute() { 54 | $player = $this->getPlayer(); 55 | if ($this->getValues() === false) { 56 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 57 | return; 58 | } 59 | Bossbar::add($player, $this->getBossbarId(), $this->getTitle(), $this->getMaxValue(), $this->getCurrentValue()/$this->getMaxValue()); 60 | } 61 | 62 | public function getEditForm(string $default = "", string $mes = "") { 63 | $settings = $this->parse($default); 64 | $titles = explode("[max]", $default); 65 | $title = $titles[0]; 66 | $values = explode("[value]", $titles[1] ?? $default); 67 | $max = $values[0]; 68 | $ids = explode("[id]", $values[1] ?? $titles[1] ?? $default); 69 | $value = $ids[0]; 70 | $id = $ids[1] ?? $values[1] ?? $titles[1] ?? $default; 71 | if ($settings !== false) { 72 | $title = $settings[0]; 73 | $max = $settings[1]; 74 | $value = $settings[2]; 75 | $id = $settings[3]; 76 | } elseif ($default !== "") { 77 | $mes .= Language::get("form.error"); 78 | } 79 | $data = [ 80 | "type" => "custom_form", 81 | "title" => $this->getName(), 82 | "content" => [ 83 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 84 | Elements::getInput(Language::get("process.showBossbar.form.title"), Language::get("input.example", ["aieuo"]), $title), 85 | Elements::getInput(Language::get("process.showBossbar.form.max"), Language::get("input.example", ["100"]), $max), 86 | Elements::getInput(Language::get("process.showBossbar.form.value"), Language::get("input.example", ["1"]), $value), 87 | Elements::getInput(Language::get("process.showBossbar.form.id"), Language::get("input.example", ["aieuo"]), $id), 88 | Elements::getToggle(Language::get("form.delete")), 89 | Elements::getToggle(Language::get("form.cancel")) 90 | ] 91 | ]; 92 | $json = Form::encodeJson($data); 93 | return $json; 94 | } 95 | 96 | public function parseFormData(array $data) { 97 | $status = true; 98 | $contents = $data[1]."[max]".$data[2]."[value]".$data[3]."[id]".$data[4]; 99 | if ($data[1] === "" or $data[2] === "" or $data[3] === "" or $data[3] === "") { 100 | $status = null; 101 | } else { 102 | $result = $this->parse($contents); 103 | if ($result === false) $status = false; 104 | } 105 | return ["status" => $status, "contents" => $contents, "delete" => $data[5], "cancel" => $data[6]]; 106 | } 107 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/TakeMoney.php: -------------------------------------------------------------------------------- 1 | getAmount()]); 16 | } 17 | 18 | public function execute() { 19 | $player = $this->getPlayer(); 20 | $economy = IFPlugin::getInstance()->getEconomy(); 21 | if ($economy === null) { 22 | $player->sendMessage(Language::get("economy.notfound")); 23 | return; 24 | } 25 | $economy->takeMoney($player->getName(), $this->getAmount()); 26 | } 27 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/Teleport.php: -------------------------------------------------------------------------------- 1 | getPosition(); 17 | if ($pos === false or $pos->level === null) return false; 18 | return Language::get("process.teleport.detail", [$pos->x.",".$pos->y.",".$pos->z.",".$pos->level->getFolderName()]); 19 | } 20 | 21 | public function execute() { 22 | $player = $this->getPlayer(); 23 | $pos = $this->getPosition(); 24 | if (!($pos instanceof Position)) { 25 | $player->sendMessage(Language::get("input.invalid", [$this->getName()])); 26 | return; 27 | } 28 | $player->teleport($pos); 29 | } 30 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/TypeCommand.php: -------------------------------------------------------------------------------- 1 | getValues(); 13 | if (!is_string($command)) return null; 14 | return $command; 15 | } 16 | 17 | public function setCommand(string $command) { 18 | $this->setValues($command); 19 | } 20 | 21 | public function getEditForm(string $default = "", string $mes = "") { 22 | $data = [ 23 | "type" => "custom_form", 24 | "title" => $this->getName(), 25 | "content" => [ 26 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 27 | Elements::getInput(Language::get("process.command.form.command"), Language::get("input.example", ["help"]), $default), 28 | Elements::getToggle(Language::get("form.delete")), 29 | Elements::getToggle(Language::get("form.cancel")) 30 | ] 31 | ]; 32 | $json = Form::encodeJson($data); 33 | return $json; 34 | } 35 | 36 | public function parseFormData(array $data) { 37 | $status = true; 38 | if ($data[1] === "") { 39 | $status = null; 40 | } else { 41 | $command = $this->parse($data[1]); 42 | if ($command === false) $status = false; 43 | } 44 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 45 | } 46 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/TypeItem.php: -------------------------------------------------------------------------------- 1 | getValues(); 18 | if (!($item instanceof Item)) return null; 19 | return $item; 20 | } 21 | 22 | public function setItem(Item $item) { 23 | $this->setValues($item); 24 | } 25 | 26 | public function parse(string $id) { 27 | $ids = explode(":", $id); 28 | $item = Item::get((int)$ids[0], empty($ids[1]) ? 0 : (int)$ids[1]); 29 | if (isset($ids[2])) $item->setCount((int)$ids[2]); 30 | if (!empty($ids[3])) $item->setCustomName($ids[3]); 31 | if (!empty($ids[4])) $item->setLore(explode(";", $ids[4])); 32 | if (!empty($ids[5])) { 33 | $enchants1 = explode(";", $ids[5]); 34 | foreach ($enchants1 as $enchant1) { 35 | $enchants = explode(",", trim($enchant1)); 36 | if (is_numeric(trim($enchants[0]))){ 37 | $enchant = Enchantment::getEnchantment(trim($enchants[0])); 38 | } else { 39 | $enchant = Enchantment::getEnchantmentByName(trim($enchants[0])); 40 | } 41 | 42 | if(!($enchant instanceof Enchantment)) continue; 43 | 44 | $level = (int)trim($enchants[1] ?? "1"); 45 | $item->addEnchantment(new EnchantmentInstance($enchant, $level)); 46 | } 47 | } 48 | return $item; 49 | } 50 | 51 | public function getEditForm(string $default = "", string $mes = "") { 52 | $item = explode(":", $default); 53 | $id = $default; 54 | $count = ""; 55 | $name = ""; 56 | $lore = ""; 57 | $enchant = ""; 58 | if (count($item) >= 3) { 59 | $id = $item[0].":".$item[1]; 60 | $count = $item[2]; 61 | $name = $item[3] ?? ""; 62 | $lore = $item[4] ?? ""; 63 | $enchant = $item[5] ?? ""; 64 | if ($count === 0) $mes .= Language::get("process.item.form.zero"); 65 | } elseif ($default !== "") { 66 | $mes .= Language::get("process.item.form.invalid"); 67 | } 68 | $data = [ 69 | "type" => "custom_form", 70 | "title" => $this->getName(), 71 | "content" => [ 72 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 73 | Elements::getInput(Language::get("process.item.form.id"), Language::get("input.example", ["1:0"]), $id), 74 | Elements::getInput(Language::get("process.item.form.count"), Language::get("input.example", ["5"]), $count), 75 | Elements::getInput(Language::get("process.item.form.name"), Language::get("input.example", ["aieuo"]), $name), 76 | Elements::getInput(Language::get("process.item.form.lore"), Language::get("input.example", ["aiueo;aieuo;aeiuo"]), $lore), 77 | Elements::getInput(Language::get("process.item.form.enchant"), Language::get("input.example", ["id,level;1,1;5,10"]), $enchant), 78 | Elements::getToggle(Language::get("form.delete")), 79 | Elements::getToggle(Language::get("form.cancel")) 80 | ] 81 | ]; 82 | return Form::encodeJson($data); 83 | } 84 | 85 | public function parseFormData(array $data) { 86 | $status = true; 87 | $id = explode(":", $data[1]); 88 | if (!isset($id[1])) $id[1] = 0; 89 | $ids_str = $id[0].":".$id[1].":".$data[2].":".$data[3].":".$data[4].":".$data[5]; 90 | if ($data[1] === "" or $data[2] === "") { 91 | $status = null; 92 | } elseif (!IFPlugin::getInstance()->getVariableHelper()->containsVariable($ids_str)) { 93 | $ids = $this->parse($ids_str); 94 | if ($ids === false) $status = false; 95 | } 96 | return ["status" => $status, "contents" => $ids_str, "delete" => $data[6], "cancel" => $data[7]]; 97 | } 98 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/TypeMessage.php: -------------------------------------------------------------------------------- 1 | getValues(); 13 | if (!is_string($message)) return null; 14 | return $message; 15 | } 16 | 17 | public function setMessage(string $message) { 18 | $this->setValues($message); 19 | } 20 | 21 | public function getEditForm(string $default = "", string $mes = "") { 22 | $data = [ 23 | "type" => "custom_form", 24 | "title" => $this->getName(), 25 | "content" => [ 26 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 27 | Elements::getInput(Language::get("process.message.form.message"), Language::get("input.example", ["aieuo"]), $default), 28 | Elements::getToggle(Language::get("form.delete")), 29 | Elements::getToggle(Language::get("form.cancel")) 30 | ] 31 | ]; 32 | $json = Form::encodeJson($data); 33 | return $json; 34 | } 35 | 36 | public function parseFormData(array $data) { 37 | $status = true; 38 | if ($data[1] === "") $status = null; 39 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 40 | } 41 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/TypeMoney.php: -------------------------------------------------------------------------------- 1 | getValues(); 13 | if (!is_int($amount)) return null; 14 | return $amount; 15 | } 16 | 17 | public function setAmount(int $amount) { 18 | $this->setValues($amount); 19 | } 20 | 21 | public function parse(string $amount) { 22 | $amount = (int)mb_convert_kana($amount, "n"); 23 | return $amount; 24 | } 25 | 26 | public function getEditForm(string $default = "", string $mes = "") { 27 | $money = $this->parse($default); 28 | if ($money <= 0) $money = $default; 29 | if ($money <= 0 and $default !== "") $mes .= Language::get("process.money.zero"); 30 | $data = [ 31 | "type" => "custom_form", 32 | "title" => $this->getName(), 33 | "content" => [ 34 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)."\n"), 35 | Elements::getInput(Language::get("process.money.form.amount"), Language::get("input.example", ["1000"]), $money), 36 | Elements::getToggle(Language::get("form.delete")), 37 | Elements::getToggle(Language::get("form.cancel")) 38 | ] 39 | ]; 40 | $json = Form::encodeJson($data); 41 | return $json; 42 | } 43 | 44 | public function parseFormData(array $data) { 45 | $status = true; 46 | if ($data[1] === "") $status = null; 47 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/aieuo/ip/processes/TypePosition.php: -------------------------------------------------------------------------------- 1 | getValues(); 16 | } 17 | 18 | public function setPosition(string $pos) { 19 | $this->setValues($pos); 20 | } 21 | 22 | public function parse(string $pos) { 23 | if (!preg_match("/\s*(-?[0-9]+\.?[0-9]*)\s*,\s*(-?[0-9]+\.?[0-9]*)\s*,\s*(-?[0-9]+\.?[0-9]*)\s*,?\s*(.*)\s*/", $pos, $matches)) return false; 24 | if (empty($matches[4])) $matches[4] = "world"; 25 | return new Position((float)$matches[1], (float)$matches[2], (float)$matches[3], Server::getInstance()->getLevelByName($matches[4])); 26 | } 27 | 28 | public function getEditForm(string $default = "", string $mes = "") { 29 | $pos = $this->parse($default); 30 | if ($pos instanceof Position) { 31 | if ($pos->level === null) { 32 | $mes .= Language::get("process.position.level.notfound"); 33 | $position = $default; 34 | } else { 35 | $position = $pos->x.",".$pos->y.",".$pos->z.",".$pos->level->getFolderName(); 36 | } 37 | } else { 38 | if ($default !== "") $mes .= Language::get("form.error"); 39 | $position = $default; 40 | } 41 | $data = [ 42 | "type" => "custom_form", 43 | "title" => $this->getName(), 44 | "content" => [ 45 | Elements::getLabel($this->getDescription().(empty($mes) ? "" : "\n".$mes)), 46 | Elements::getInput(Language::get("process.position.form.position"), Language::get("input.example", ["1,15,30,world"]), $position), 47 | Elements::getToggle(Language::get("form.delete")), 48 | Elements::getToggle(Language::get("form.cancel")) 49 | ] 50 | ]; 51 | $json = Form::encodeJson($data); 52 | return $json; 53 | } 54 | 55 | public function parseFormData(array $data) { 56 | $status = true; 57 | if ($data[1] === "") { 58 | $status = null; 59 | } else { 60 | $pos = $this->parse($data[1]); 61 | if ($pos === false) $status = false; 62 | } 63 | return ["status" => $status, "contents" => $data[1], "delete" => $data[2], "cancel" => $data[3]]; 64 | } 65 | } -------------------------------------------------------------------------------- /src/aieuo/ip/processes/UnSetImmobile.php: -------------------------------------------------------------------------------- 1 | getPlayer(); 14 | $player->setImmobile(false); 15 | } 16 | } -------------------------------------------------------------------------------- /src/aieuo/ip/task/DelayedCommandTask.php: -------------------------------------------------------------------------------- 1 | player = $player; 17 | $this->command = $command; 18 | } 19 | 20 | public function onRun(int $currentTick) { 21 | if ($this->player instanceof Player && !$this->player->isOnline()) return; 22 | Server::getInstance()->dispatchCommand($this->player, $this->command); 23 | } 24 | } -------------------------------------------------------------------------------- /src/aieuo/ip/task/DelayedCooperationTask.php: -------------------------------------------------------------------------------- 1 | player = $player; 22 | $this->name = $name; 23 | $this->event = $event; 24 | $this->replaceData = $replaces; 25 | } 26 | 27 | public function onRun(int $currentTick) { 28 | if (!$this->player->isOnline()) return; 29 | 30 | $manager = IFPlugin::getInstance()->getChainManager(); 31 | if (!$manager->exists($this->name)) { 32 | $this->player->sendMessage(Language::get("process.cooperation.notFound")); 33 | return; 34 | } 35 | $data = $manager->get($this->name); 36 | $options = [ 37 | "player" => $this->player, 38 | ]; 39 | if ($this->event instanceof Event) $options["event"] = $this->event; 40 | $options["replaces"] = $this->replaceData; 41 | $manager->executeIfMatchCondition( 42 | $this->player, 43 | $data["if"], 44 | $data["match"], 45 | $data["else"], 46 | $options 47 | ); 48 | } 49 | } -------------------------------------------------------------------------------- /src/aieuo/ip/task/KickTask.php: -------------------------------------------------------------------------------- 1 | player = $player; 10 | $this->reason = $reason; 11 | } 12 | 13 | public function onRun(int $currentTick) { 14 | $this->player->kick($this->reason); 15 | } 16 | } -------------------------------------------------------------------------------- /src/aieuo/ip/task/SaveTask.php: -------------------------------------------------------------------------------- 1 | owner = $owner; 13 | } 14 | 15 | public function onRun(int $currentTick) { 16 | $this->owner->getVariableHelper()->save(); 17 | if ($this->owner->saveOnChange) return; 18 | $this->owner->getBlockManager()->save(); 19 | $this->owner->getCommandManager()->save(); 20 | $this->owner->getEventManager()->save(); 21 | $this->owner->getFormIFManager()->save(); 22 | $this->owner->getChainManager()->save(); 23 | $this->owner->config->save(); 24 | } 25 | } -------------------------------------------------------------------------------- /src/aieuo/ip/utils/Bossbar.php: -------------------------------------------------------------------------------- 1 | title = $title; 31 | $this->max = $max; 32 | $this->per = $per; 33 | $this->entityId = Entity::$entityCount++; 34 | } 35 | 36 | public function setTitle(string $title) { 37 | $this->title = $title; 38 | } 39 | 40 | public function getTitle(): string { 41 | return $this->title; 42 | } 43 | 44 | public function setMax(float $max) { 45 | $this->max = $max; 46 | } 47 | 48 | public function getMax(): float { 49 | return $this->max; 50 | } 51 | 52 | public function setPercentage(float $per) { 53 | if ($per > $this->max) $per = $this->max; 54 | $this->per = $per; 55 | } 56 | 57 | public function getPercentage(): float { 58 | return $this->per; 59 | } 60 | 61 | public function getEntityId(): int { 62 | return $this->entityId; 63 | } 64 | 65 | public static function add(Player $player, string $id, string $title, float $max, float $per) { 66 | if (isset(self::$bars[$player->getName()][$id])) self::remove($player, $id); 67 | $bar = new Bossbar($title, $max, $per); 68 | self::$bars[$player->getName()][$id] = $bar; 69 | 70 | $pk = new AddActorPacket(); 71 | $pk->entityRuntimeId = $bar->getEntityId(); 72 | $pk->type = EntityIds::SHULKER; 73 | $pk->metadata = [ 74 | Entity::DATA_FLAGS => [Entity::DATA_TYPE_LONG, (1 << Entity::DATA_FLAG_INVISIBLE) | (1 << Entity::DATA_FLAG_IMMOBILE)], 75 | Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING, $title] 76 | ]; 77 | $pk->position = new Vector3(0, 0, 0); 78 | $player->sendDataPacket($pk); 79 | 80 | $pk2 = new BossEventPacket(); 81 | $pk2->bossEid = $bar->getEntityId(); 82 | $pk2->eventType = BossEventPacket::TYPE_SHOW; 83 | $pk2->title = $title; 84 | $pk2->healthPercent = $per; 85 | $pk2->color = 0; 86 | $pk2->overlay = 0; 87 | $pk2->unknownShort = 0; 88 | $player->sendDataPacket($pk2); 89 | } 90 | 91 | public static function remove(Player $player, string $id) { 92 | if (!isset(self::$bars[$player->getName()][$id])) return; 93 | $bar = self::$bars[$player->getName()][$id]; 94 | $pk = new BossEventPacket(); 95 | $pk->bossEid = $bar->getEntityId(); 96 | $pk->eventType = BossEventPacket::TYPE_HIDE; 97 | $player->sendDataPacket($pk); 98 | 99 | $pk2 = new RemoveActorPacket(); 100 | $pk2->entityUniqueId = $bar->getEntityId(); 101 | $player->sendDataPacket($pk2); 102 | 103 | unset(self::$bars[$player->getName()][$id]); 104 | } 105 | } -------------------------------------------------------------------------------- /src/aieuo/ip/utils/Language.php: -------------------------------------------------------------------------------- 1 | setMessages($messages); 11 | } 12 | 13 | public function setMessages($messages) { 14 | self::$messages = $messages; 15 | } 16 | 17 | public static function get(string $key, array $replaces = []): string { 18 | if (isset(self::$messages[$key])) { 19 | $message = self::$messages[$key]; 20 | foreach ($replaces as $cnt => $value) { 21 | $message = str_replace("{%".$cnt."}", $value, $message); 22 | } 23 | $message = str_replace(["\\n", "\\q", "\\dq"], ["\n", "'", "\""], $message); 24 | return $message; 25 | } 26 | return $key; 27 | } 28 | } -------------------------------------------------------------------------------- /src/aieuo/ip/variable/ListVariable.php: -------------------------------------------------------------------------------- 1 | getValue()); 13 | } 14 | 15 | public function addition(Variable $var, string $name = "result") { 16 | if ($var->getType() !== Variable::LIST) { 17 | return new StringVariable("ERROR", Language::get("variable.list.add.error")); 18 | } 19 | $result = array_merge($this->getValue(), $var->getValue()); 20 | return new ListVariable($name, $result); 21 | } 22 | 23 | public function subtraction(Variable $var, string $name = "result") { 24 | if ($var->getType() !== Variable::LIST) { 25 | return new StringVariable("ERROR", Language::get("variable.list.sub.error")); 26 | } 27 | $result = array_diff($this->getValue(), $var->getValue()); 28 | $result = array_values($result); 29 | return new ListVariable($name, $result); 30 | } 31 | 32 | public function multiplication(Variable $var, string $name = "result") { 33 | if ($var->getType() !== Variable::NUMBER) { 34 | return new StringVariable("ERROR", Language::get("variable.list.mul.error")); 35 | } 36 | $result = []; 37 | $max = (int)$var->getValue(); 38 | for ($i=0; $i<$max; $i ++) { 39 | $result = array_merge($result, $this->getValue()); 40 | } 41 | return new ListVariable($name, $result); 42 | } 43 | 44 | public function division(Variable $var, string $name = "result") { 45 | return new StringVariable("ERROR", Language::get("variable.list.div.error")); 46 | } 47 | 48 | public function modulo(Variable $var, string $name = "result") { 49 | return new StringVariable("ERROR", Language::get("variable.list.mod.error")); 50 | } 51 | 52 | public function getValueFromIndex($index) { 53 | if (!isset($this->value[$index])) return null; 54 | return $this->value[$index]; 55 | } 56 | 57 | public function getCount() { 58 | return count($this->value); 59 | } 60 | 61 | public function toStringVariable() { 62 | $variable = new StringVariable($this->getName(), "(list)".implode(",", $this->getValue())); 63 | return $variable; 64 | } 65 | } -------------------------------------------------------------------------------- /src/aieuo/ip/variable/NumberVariable.php: -------------------------------------------------------------------------------- 1 | getValue(); 13 | } 14 | 15 | public function addition(Variable $var, string $resultname = "result"): Variable { 16 | if ($var->getType() !== Variable::NUMBER) { 17 | return new StringVariable("ERROR", Language::get("variable.number.add.error")); 18 | } 19 | $result = $this->getValue() + $var->getValue(); 20 | return new NumberVariable($resultname, $result); 21 | } 22 | 23 | public function subtraction(Variable $var, string $resultname = "result"): Variable { 24 | if ($var->getType() !== Variable::NUMBER) { 25 | return new StringVariable("ERROR", Language::get("variable.number.sub.error")); 26 | } 27 | $result = $this->getValue() - $var->getValue(); 28 | return new NumberVariable($resultname, $result); 29 | } 30 | 31 | public function multiplication(Variable $var, string $resultname = "result"): Variable { 32 | if ($var->getType() !== Variable::NUMBER) { 33 | return new StringVariable("ERROR", Language::get("variable.number.mul.error")); 34 | } 35 | $result = $this->getValue() * $var->getValue(); 36 | return new NumberVariable($resultname, $result); 37 | } 38 | 39 | public function division(Variable $var, string $resultname = "result"): Variable { 40 | if ($var->getType() !== Variable::NUMBER) { 41 | return new StringVariable("ERROR", Language::get("variable.number.div.error")); 42 | } 43 | if ($var->getValue() === 0) { 44 | return new StringVariable("ERROR", Language::get("variable.number.div.0")); 45 | } 46 | $result = $this->getValue() / $var->getValue(); 47 | return new NumberVariable($resultname, $result); 48 | } 49 | 50 | public function modulo(Variable $var, string $resultname = "result"): Variable { 51 | if ($var->getType() !== Variable::NUMBER) { 52 | return new StringVariable("ERROR", Language::get("variable.number.mod.error")); 53 | } 54 | if ($var->getValue() === 0) { 55 | return new StringVariable("ERROR", Language::get("variable.number.div.0")); 56 | } 57 | $result = $this->getValue() % $var->getValue(); 58 | return new NumberVariable($resultname, $result); 59 | } 60 | 61 | public function toStringVariable(): Variable { 62 | $variable = new StringVariable($this->getName(), (string)$this->getValue()); 63 | return $variable; 64 | } 65 | } -------------------------------------------------------------------------------- /src/aieuo/ip/variable/StringVariable.php: -------------------------------------------------------------------------------- 1 | getValue(); 13 | } 14 | 15 | public function addition(Variable $var, string $name = "result"): Variable { 16 | $result = $this->getValue().$var->getValue(); 17 | return new StringVariable($name, $result); 18 | } 19 | 20 | public function subtraction(Variable $var, string $name = "result"): Variable { 21 | $result = str_replace((string)$var->getValue(), "", $this->getValue()); 22 | return new StringVariable($name, $result); 23 | } 24 | 25 | public function multiplication(Variable $var, string $name = "result"): Variable { 26 | if ($var->getType() !== Variable::NUMBER) { 27 | return new StringVariable("ERROR", Language::get("variable.string.mul.error")); 28 | } 29 | if ($var->getValue() <= 0) { 30 | return new StringVariable("ERROR", Language::get("variable.string.mul.0")); 31 | } 32 | $result = str_repeat($this->getValue(), (int)$var->getValue()); 33 | return new StringVariable($name, $result); 34 | } 35 | 36 | public function division(Variable $var, string $name = "result"): Variable { 37 | if ($var->getType() !== Variable::STRING) { 38 | return new StringVariable("ERROR", Language::get("variable.string.div.error")); 39 | } 40 | $result = array_map(function ($value) { 41 | return trim(rtrim($value)); 42 | }, explode((string)$var->getValue(), (string)$this->getValue())); 43 | return new ListVariable($name, $result); 44 | } 45 | 46 | public function modulo(Variable $var, string $name = "result"): Variable { 47 | return new StringVariable("ERROR", Language::get("variable.string.mod.error")); 48 | } 49 | } -------------------------------------------------------------------------------- /src/aieuo/ip/variable/Variable.php: -------------------------------------------------------------------------------- 1 | division(new StringVariable("delimiter", ","), $name); 27 | } 28 | } 29 | return $var; 30 | } 31 | 32 | public function __construct($name, $value) { 33 | $this->name = $name; 34 | $this->value = $value; 35 | } 36 | 37 | public function getName() { 38 | return $this->name; 39 | } 40 | 41 | /** 42 | * @return string|int|array 43 | */ 44 | public function getValue() { 45 | return $this->value; 46 | } 47 | 48 | public function getType() { 49 | return $this->type; 50 | } 51 | 52 | /** 53 | * 変数同士を足す 54 | * @param Variable $var 55 | * @param string $name 56 | */ 57 | abstract public function addition(Variable $var, string $name = "result"); 58 | 59 | /** 60 | * 変数同士を引く 61 | * @param Variable $var 62 | * @param string $name 63 | */ 64 | abstract public function subtraction(Variable $var, string $name = "result"); 65 | 66 | /** 67 | * 変数同士を掛ける 68 | * @param Variable $var 69 | * @param string $name 70 | */ 71 | abstract public function multiplication(Variable $var, string $name = "result"); 72 | 73 | /** 74 | * 変数同士を割る 75 | * @param Variable $var 76 | * @param string $name 77 | */ 78 | abstract public function division(Variable $var, string $name = "result"); 79 | 80 | /** 81 | * 変数同士を割った余り 82 | * @param Variable $var 83 | * @param string $name 84 | */ 85 | abstract public function modulo(Variable $var, string $name = "result"); 86 | } --------------------------------------------------------------------------------