├── .gitignore ├── LICENSE ├── composer.json ├── composer.lock ├── plugin.yml └── src └── kametan0730mc └── RunForMoney2 ├── EventListener.php ├── Main.php ├── block ├── Coal.php ├── Door.php └── Lapis.php ├── command ├── BanCommand.php ├── CleanEntityCommand.php ├── GameCommand.php ├── JoinCommand.php ├── MoneyCommand.php ├── NametagCommand.php ├── RemoveInventoryCommand.php ├── SetPhotoStudioCommand.php ├── SobaCommand.php ├── SpawnCommand.php ├── StatusCommand.php ├── TeleportAllToMeCommand.php ├── UnbanCommand.php └── development │ ├── ChunkInfoCommand.php │ ├── LightningTestCommand.php │ ├── MyXuidCommand.php │ ├── SaveDataDumpCommand.php │ ├── ScanWorldSurfaceCommand.php │ ├── SetBaseBlockCommand.php │ └── SoundTestCommand.php ├── database ├── Database.php ├── MySQL.php └── type │ ├── BannedUserType.php │ ├── RunForMoneyEntryType.php │ ├── UserCrownType.php │ ├── UserLogType.php │ ├── UserMoneyCacheType.php │ ├── UserMoneyTransactionType.php │ ├── UserRunForMoneyCacheType.php │ ├── UserRunForMoneyResultType.php │ ├── UserType.php │ └── UserWebReceivedItemType.php ├── entity ├── Agent.php ├── Human.php ├── LightningBolt.php └── projectile │ ├── DragonFireball.php │ └── FishingHook.php ├── form ├── AdminForm.php ├── ItemBuyForm.php ├── ItemShopForm.php ├── MenuForm.php ├── PasswordRegisterForm.php ├── SettingForm.php ├── TeleportForm.php ├── UserForm.php └── admin │ ├── AdminBanForm.php │ ├── AdminTeleportForm.php │ ├── AdminUserListForm.php │ ├── AdminUserOperationForm.php │ └── operation │ ├── AdminEditUserGamerData.php │ └── AdminEditUserSaveDataForm.php ├── game ├── GameHandler.php ├── GameInfo.php ├── GamerData.php ├── field │ ├── Arashiyama.php │ ├── Edo.php │ ├── Field.php │ ├── FieldLoader.php │ ├── FlatField.php │ └── data │ │ ├── arashiyama.json │ │ └── edo.json └── mission │ ├── Mission.php │ ├── MissionLoader.php │ └── StopBombingBridge.php ├── item ├── AdditionalItem.php ├── Amazon.php ├── CellPhone.php ├── DoorKey.php ├── DoorKeyPlus.php ├── Ekurea.php ├── Emerald.php ├── ExMedicine1.php ├── ExMedicine2.php ├── ExMedicine3.php ├── ExMedicine4.php ├── ExMedicine5.php ├── ExMedicineS.php ├── IceGun.php ├── Lollipop.php ├── MenuPad.php ├── NetGun.php ├── RabbitFoot.php ├── Soba.php ├── Tejyou.php └── Vaccine.php ├── lang ├── Lang.php └── locale │ └── jpn.ini ├── scheduler ├── MainTask.php └── PasswordRegisterTask.php ├── sound └── PortalSound.php ├── user ├── UserHandler.php ├── UserSaveData.php ├── UserTempData.php ├── crown │ └── Crown.php ├── nametag │ └── Nametag.php └── skin │ └── SkinValidator.php └── world └── WorldHandler.php /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | vendor 3 | composer.phar -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kametan0730mc/runformoney2", 3 | "description": "A run for money plugin for PocketMine-MP", 4 | "minimum-stability": "dev", 5 | "license": "LGPL-3.0", 6 | "authors": [ 7 | { 8 | "name": "kametan0730mc", 9 | "email": "kametan0730@gmail.com" 10 | } 11 | ], 12 | "require": { 13 | "php": ">=8.0.0", 14 | "ext-json": "*", 15 | "ext-mysqli": "*" 16 | } 17 | } -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "4ce70a24cd99b342add2ee9f40abedf5", 8 | "packages": [], 9 | "packages-dev": [], 10 | "aliases": [], 11 | "minimum-stability": "dev", 12 | "stability-flags": [], 13 | "prefer-stable": false, 14 | "prefer-lowest": false, 15 | "platform": { 16 | "php": ">=8.0.0", 17 | "ext-json": "*", 18 | "ext-mysqli": "*" 19 | }, 20 | "platform-dev": [], 21 | "plugin-api-version": "2.2.0" 22 | } 23 | -------------------------------------------------------------------------------- /plugin.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: RunForMoney2 3 | version: 1.0.0 4 | author: kametan0730mc 5 | main: kametan0730mc\RunForMoney2\Main 6 | api: 4.0.0 7 | permissions: 8 | kametan.command.chunkinfo: 9 | default: op 10 | kametan.command.lightningtest: 11 | default: op 12 | kametan.command.myxuid: 13 | default: op 14 | kametan.command.savedatadump: 15 | default: op 16 | kametan.command.scanworldsurface: 17 | default: op 18 | kametan.command.setbaseblock: 19 | default: op 20 | kametan.command.soundtest: 21 | default: op 22 | kametan.command.ban: 23 | default: op 24 | kametan.command.cleanentity: 25 | default: op 26 | kametan.command.game: 27 | default: op 28 | kametan.command.unban: 29 | default: op 30 | kametan.command.soba: 31 | default: op 32 | kametan.command.tpa: 33 | default: op 34 | kametan.command.setphotostudio: 35 | default: op 36 | 37 | ... 38 | -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/EventListener.php: -------------------------------------------------------------------------------- 1 | attemptLogin($event); 35 | } 36 | 37 | public function onPlayerLogin(PlayerLoginEvent $event){ 38 | UserHandler::getInstance()->loginEvent($event->getPlayer()); 39 | } 40 | 41 | public function onPlayerJoin(PlayerJoinEvent $event){ 42 | $event->setJoinMessage(""); 43 | UserHandler::getInstance()->joinEvent($event->getPlayer()); 44 | } 45 | 46 | public function onPlayerQuit(PlayerQuitEvent $event){ 47 | $event->setQuitMessage(""); 48 | UserHandler::getInstance()->quitEvent($event->getPlayer()); 49 | } 50 | 51 | public function onPlayerDrop(PlayerDropItemEvent $event){ 52 | $event->cancel(); 53 | } 54 | 55 | public function onPlayerChat(PlayerChatEvent $event){ 56 | UserHandler::getInstance()->chatEvent($event); 57 | } 58 | 59 | public function onPlayerInteract(PlayerInteractEvent $event){ 60 | UserHandler::getInstance()->interactEvent($event); 61 | } 62 | 63 | public function onPlayerDataSave(PlayerDataSaveEvent $event){ 64 | $spawn = UserHandler::getInstance()->getSpawnPoint(); 65 | $nbt = $event->getSaveData(); 66 | $nbt->removeTag("Pos"); 67 | $nbt->setTag("Pos", new ListTag([ 68 | new DoubleTag($spawn->getFloorX()), 69 | new DoubleTag($spawn->getFloorY()), 70 | new DoubleTag($spawn->getFloorZ()) 71 | ])); 72 | $event->setSaveData($nbt); 73 | } 74 | 75 | public function onEntityDamage(EntityDamageEvent $event){ 76 | $event->cancel(); 77 | $entity = $event->getEntity(); 78 | if($entity->getLocation()->getY() < 0){ 79 | if($entity instanceof Player){ 80 | $userHandler = UserHandler::getInstance(); 81 | $userHandler->respawn($entity); 82 | $userHandler->sendTranslatedMessage($entity, "system.abyss.respawn", MESSAGE); 83 | }else{ 84 | $entity->kill(); 85 | } 86 | } 87 | if($event instanceof EntityDamageByEntityEvent){ 88 | $attacker = $event->getDamager(); 89 | if($entity instanceof Player and $attacker instanceof Player){ 90 | if($entity->getLocation()->distance($attacker->getLocation()) < 4){ 91 | GameHandler::getInstance()->touchPlayer($entity, $attacker); 92 | } 93 | } 94 | } 95 | } 96 | 97 | public function onDataPacketReceive(DataPacketReceiveEvent $event){ 98 | $packet = $event->getPacket(); 99 | if($packet instanceof PlayerActionPacket){ 100 | $action = $packet->action; 101 | $player = $event->getOrigin()->getPlayer(); 102 | switch($action){ 103 | case PlayerAction::START_SWIMMING: 104 | $player->getNetworkProperties()->setGenericFlag(EntityMetadataFlags::SWIMMING, true); 105 | break; 106 | case PlayerAction::STOP_SWIMMING: 107 | $player->getNetworkProperties()->setGenericFlag(EntityMetadataFlags::SWIMMING, false); 108 | break; 109 | } 110 | } 111 | } 112 | 113 | public function onPluginDisable(PluginDisableEvent $event){ 114 | $userHandler = UserHandler::getInstance(); 115 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 116 | $player->kick(TextFormat::GREEN . $userHandler->translateText($player, "system.server.down")); 117 | } 118 | } 119 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/Main.php: -------------------------------------------------------------------------------- 1 | getServer()->getCommandMap()->unregister($this->getServer()->getCommandMap()->getCommand("ban")); 101 | $this->getServer()->getCommandMap()->unregister($this->getServer()->getCommandMap()->getCommand("ban-ip")); 102 | $this->getServer()->getCommandMap()->unregister($this->getServer()->getCommandMap()->getCommand("banlist")); 103 | $this->getServer()->getCommandMap()->unregister($this->getServer()->getCommandMap()->getCommand("pardon")); 104 | $this->getServer()->getCommandMap()->unregister($this->getServer()->getCommandMap()->getCommand("pardon-ip")); 105 | $this->getServer()->getCommandMap()->unregister($this->getServer()->getCommandMap()->getCommand("enchant")); 106 | $this->getServer()->getCommandMap()->unregister($this->getServer()->getCommandMap()->getCommand("me")); 107 | $this->getServer()->getCommandMap()->unregister($this->getServer()->getCommandMap()->getCommand("kill")); 108 | 109 | if($isDevelopment){ 110 | $this->getServer()->getCommandMap()->register("kametan", new ChunkInfoCommand("chunkinfo")); 111 | $this->getServer()->getCommandMap()->register("kametan", new LightningTestCommand("lightningtest")); 112 | $this->getServer()->getCommandMap()->register("kametan", new MyXuidCommand("myxuid")); 113 | $this->getServer()->getCommandMap()->register("kametan", new SaveDataDumpCommand("savedatadump")); 114 | $this->getServer()->getCommandMap()->register("kametan", new ScanWorldSurfaceCommand("scanworldsurface")); 115 | $this->getServer()->getCommandMap()->register("kametan", new SetBaseBlockCommand("setbaseblock")); 116 | $this->getServer()->getCommandMap()->register("kametan", new SoundTestCommand("soundtest")); 117 | } 118 | 119 | $this->getServer()->getCommandMap()->register("kametan", new BanCommand("ban")); 120 | $this->getServer()->getCommandMap()->register("kametan", new CleanEntityCommand("cleanentity")); 121 | $this->getServer()->getCommandMap()->register("kametan", new GameCommand("game")); 122 | $this->getServer()->getCommandMap()->register("kametan", new UnbanCommand("unban")); 123 | $this->getServer()->getCommandMap()->register("kametan", new NametagCommand("nametag")); 124 | $this->getServer()->getCommandMap()->register("kametan", new RemoveInventoryCommand("removeinventory")); 125 | $this->getServer()->getCommandMap()->register("kametan", new SobaCommand("soba")); 126 | $this->getServer()->getCommandMap()->register("kametan", new MoneyCommand("money")); 127 | $this->getServer()->getCommandMap()->register("kametan", new SpawnCommand("spawn")); 128 | $this->getServer()->getCommandMap()->register("kametan", new JoinCommand("join")); 129 | $this->getServer()->getCommandMap()->register("kametan", new TeleportAllToMeCommand("tpa")); 130 | $this->getServer()->getCommandMap()->register("kametan", new SetPhotoStudioCommand("setphotostudio")); 131 | } 132 | 133 | private function initEntities(){ 134 | /** @var EntityFactory $factory */ 135 | $factory = EntityFactory::getInstance(); 136 | $factory->register(Agent::class, function(World $world, CompoundTag $nbt): Agent{ 137 | return new Agent(EntityDataHelper::parseLocation($nbt, $world), $nbt); 138 | }, ['Agent', EntityIds::AGENT], EntityLegacyIds::AGENT); 139 | 140 | $factory->register(LightningBolt::class, function(World $world, CompoundTag $nbt): LightningBolt{ 141 | return new LightningBolt(EntityDataHelper::parseLocation($nbt, $world), $nbt); 142 | }, ['Lightning Bolt', EntityIds::LIGHTNING_BOLT], EntityLegacyIds::LIGHTNING_BOLT); 143 | 144 | $factory->register(DragonFireball::class, function(World $world, CompoundTag $nbt): DragonFireball{ 145 | return new DragonFireball(EntityDataHelper::parseLocation($nbt, $world), null, $nbt); 146 | }, ['Dragon Fireball', EntityIds::DRAGON_FIREBALL], EntityLegacyIds::DRAGON_FIREBALL); 147 | 148 | $factory->register(FishingHook::class, function(World $world, CompoundTag $nbt): FishingHook{ 149 | return new FishingHook(EntityDataHelper::parseLocation($nbt, $world), null, $nbt); 150 | }, ['Fishing Hook', EntityIds::FISHING_HOOK], EntityLegacyIds::FISHING_HOOK); 151 | 152 | /* 153 | $factory->register(Husk::class, function(World $world, CompoundTag $nbt) : Husk{ 154 | return new Husk(EntityDataHelper::parseLocation($nbt, $world), $nbt); 155 | }, ['Husk', EntityIds::HUSK], EntityLegacyIds::HUSK);*/ 156 | } 157 | 158 | private function initBlocks(){ 159 | $factory = BlockFactory::getInstance(); 160 | 161 | $factory->register(new Door(new BID(Ids::IRON_DOOR_BLOCK, 0), "Iron Door", new BlockBreakInfo(5.0, BlockToolType::PICKAXE, ToolTier::WOOD()->getHarvestLevel(), 25.0)), true); 162 | $factory->register(new Coal(new BID(Ids::COAL_BLOCK, 0), "Coal Block", BlockBreakInfo::instant()), true); 163 | $factory->register(new Lapis(new BID(Ids::LAPIS_BLOCK, 0), "Lapis Block", BlockBreakInfo::instant()), true); 164 | 165 | } 166 | 167 | private function initItems(){ 168 | 169 | $factory = ItemFactory::getInstance(); 170 | 171 | $factory->register(new class(new ItemIdentifier(ItemIds::SPAWN_EGG, EntityLegacyIds::AGENT), "Agent Spawn Egg") extends SpawnEgg{ 172 | protected function createEntity(World $world, Vector3 $pos, float $yaw, float $pitch): Entity{ 173 | return new Agent(Location::fromObject($pos, $world, $yaw, $pitch)); 174 | } 175 | }); 176 | 177 | $factory->register(new class(new ItemIdentifier(ItemIds::SPAWN_EGG, EntityLegacyIds::LIGHTNING_BOLT), "Lightning Bolt Spawn Egg") extends SpawnEgg{ 178 | protected function createEntity(World $world, Vector3 $pos, float $yaw, float $pitch): Entity{ 179 | return new LightningBolt(Location::fromObject($pos, $world, $yaw, $pitch)); 180 | } 181 | }); 182 | 183 | /* 184 | $factory->register(new class(new ItemIdentifier(ItemIds::SPAWN_EGG, EntityLegacyIds::HUSK), "Husk Spawn Egg") extends SpawnEgg{ 185 | protected function createEntity(World $world, Vector3 $pos, float $yaw, float $pitch) : Entity{ 186 | return new Husk(Location::fromObject($pos, $world, $yaw, $pitch)); 187 | } 188 | });*/ 189 | $factory->register(new Emerald(new ItemIdentifier(ItemIds::EMERALD, 0), "Emerald"), true); 190 | $factory->register(new RabbitFoot(new ItemIdentifier(ItemIds::RABBIT_FOOT, 0), "Rabbit Foot"), true); 191 | 192 | $factory->register(new Amazon(new ItemIdentifier(900, 0), "Amazon")); 193 | $factory->register(new CellPhone(new ItemIdentifier(910, 0), "Cell Phone")); 194 | $factory->register(new DoorKeyPlus(new ItemIdentifier(920, 0), "Door Key Plus")); 195 | $factory->register(new DoorKey(new ItemIdentifier(930, 0), "Door Key")); 196 | $factory->register(new Ekurea(new ItemIdentifier(940, 0), "Ekurea")); 197 | $factory->register(new ExMedicine1(new ItemIdentifier(950, 0), "Ex Medicine 1")); 198 | $factory->register(new ExMedicine2(new ItemIdentifier(960, 0), "Ex Medicine 2")); 199 | $factory->register(new ExMedicine3(new ItemIdentifier(970, 0), "Ex Medicine 3")); 200 | $factory->register(new ExMedicine4(new ItemIdentifier(980, 0), "Ex Medicine 4")); 201 | $factory->register(new ExMedicine5(new ItemIdentifier(990, 0), "Ex Medicine 5")); 202 | $factory->register(new ExMedicineS(new ItemIdentifier(1000, 0), "Ex Medicine S")); 203 | $factory->register(new IceGun(new ItemIdentifier(1010, 0), "Ice Gun")); 204 | $factory->register(new Lollipop(new ItemIdentifier(1020, 0), "Lollipop")); 205 | $factory->register(new NetGun(new ItemIdentifier(1030, 0), "Net Gun")); 206 | $factory->register(new Soba(new ItemIdentifier(1040, 0), "Soba")); 207 | $factory->register(new Tejyou(new ItemIdentifier(1050, 0), "Tejyou")); 208 | $factory->register(new Vaccine(new ItemIdentifier(1060, 0), "Vaccine")); 209 | $factory->register(new MenuPad(new ItemIdentifier(1070, 0), "Menu Pad")); 210 | 211 | //VanillaItems::register("menu_pad", new MenuPad(new ItemIdentifier(1070, 0))); 212 | 213 | } 214 | 215 | private function initEnchantment(){ 216 | EnchantmentIdMap::getInstance()->register(EnchantmentIds::SHARPNESS, VanillaEnchantments::THORNS()); 217 | } 218 | 219 | protected function onEnable(): void{ 220 | date_default_timezone_set("Japan"); 221 | 222 | $this->getServer()->getWorldManager()->setAutoSave(false); 223 | if(!$this->getServer()->getOnlineMode()){ 224 | //throw new InvalidStateException("This plugin cannot work without xbox auth"); 225 | } 226 | 227 | $conf = new Config($this->getDataFolder() . "config.yml", Config::YAML, array( 228 | "development" => false, 229 | "server" => [ 230 | "name" => "KametanServer01", 231 | "id" => mt_rand(100000, 999999), 232 | ], 233 | "spawn" => [ 234 | "x" => 147, 235 | "y" => 71, 236 | "z" => -257, 237 | ], 238 | "database" => [ 239 | "type" => "mysql", 240 | "host" => "host", 241 | "username" => "username", 242 | "password" => "password", 243 | "dbname" => "dbname", 244 | ] 245 | )); 246 | 247 | if($conf->get("server")["id"] === ""){ 248 | //throw new InvalidStateException("Server id not found in configuration file"); 249 | } 250 | 251 | $isDevelopment = (bool)$conf->get("development"); 252 | if($isDevelopment){ 253 | $this->getLogger()->info("This server is running in development mode!!!!"); 254 | } 255 | 256 | Lang::init(); 257 | FieldLoader::init(); 258 | MissionLoader::init(); 259 | 260 | $this->initEntities(); 261 | $this->initItems(); 262 | $this->initBlocks(); 263 | $this->initEnchantment(); 264 | $this->initCommands($isDevelopment); 265 | 266 | $dbConf = $conf->get("database"); 267 | $databaseType = $dbConf["type"]; 268 | if($databaseType === "mysql"){ 269 | if($dbConf["host"] === "host"){ 270 | //throw new InvalidStateException("Please configure mysql authentication information in configuration file"); 271 | } 272 | $this->database = new MySQL(); 273 | if(!$this->database->initDatabase($dbConf["host"], $dbConf["username"], $dbConf["password"], $dbConf["dbname"])){ 274 | //throw new InvalidStateException("Cannot connect to mysql server"); 275 | } 276 | }else{ 277 | //throw new InvalidStateException("Unknown database type (".$databaseType.")"); 278 | } 279 | 280 | $spawnConf = $conf->get("spawn"); 281 | $spawnPoint = new Vector3($spawnConf["x"], $spawnConf["y"], $spawnConf["z"]); 282 | 283 | UserHandler::getInstance()->init($this->database, $spawnPoint); 284 | GameHandler::getInstance()->init($this->database); 285 | WorldHandler::getInstance()->init($this->database); 286 | 287 | $this->getServer()->getPluginManager()->registerEvents(new EventListener(), $this); 288 | $this->getScheduler()->scheduleRepeatingTask(new MainTask($this), 2); // 0.25s 289 | } 290 | 291 | /** @var int */ 292 | private $count = 0; 293 | 294 | /** 295 | * 0.1秒毎に呼び出す 296 | */ 297 | public function timer(){ 298 | 299 | if($this->count % 300 === 0){ 300 | $this->database->test(); 301 | } 302 | 303 | UserHandler::getInstance()->timer(); 304 | 305 | if($this->count % 10 === 0){ 306 | GameHandler::getInstance()->second(); 307 | WorldHandler::getInstance()->second(); 308 | } 309 | 310 | $this->count++; 311 | } 312 | } 313 | -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/block/Coal.php: -------------------------------------------------------------------------------- 1 | isFinalPhase()){ 25 | $userHandler->sendTranslatedMessage($player, "game.surrender.finalPhase", ERROR); 26 | return false; 27 | } 28 | $gamerData = $gameHandler->getGameInfo()->getGamerData($player); 29 | if($gamerData->gamerType !== GamerData::GAMER_TYPE_RUNNER){ 30 | $userHandler->sendTranslatedMessage($player, "game.surrender.notRunner", ERROR); 31 | return false; 32 | } 33 | if($gamerData->surrenderCountDown !== -1){ 34 | $userHandler->sendTranslatedMessage($player, "game.surrender.alreadyApplied", ERROR); 35 | return false; 36 | } 37 | $gameHandler->applySurrender($player); 38 | 39 | return false; 40 | } 41 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/block/Door.php: -------------------------------------------------------------------------------- 1 | open = !$this->open; 24 | 25 | $other = $this->getSide($this->top ? Facing::DOWN : Facing::UP); 26 | if($other instanceof Door and $other->isSameType($this)){ 27 | $other->open = $this->open; 28 | $this->position->getWorld()->setBlock($other->position, $other); 29 | } 30 | 31 | $this->position->getWorld()->setBlock($this->position, $this); 32 | $this->position->getWorld()->addSound($this->position, new DoorSound()); 33 | 34 | return false; 35 | } 36 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/block/Lapis.php: -------------------------------------------------------------------------------- 1 | getHarvestLevel(), 30.0)); 22 | } 23 | 24 | public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null): bool{ 25 | $userHandler = UserHandler::getInstance(); 26 | $gameHandler = GameHandler::getInstance(); 27 | if(!$gameHandler->isGameRunning() or $gameHandler->isFinalPhase()){ 28 | return false; 29 | } 30 | $gamerData = $gameHandler->getGameInfo()->getGamerData($player); 31 | if($gamerData->gamerType !== GamerData::GAMER_TYPE_CAUGHT){ 32 | $userHandler->sendTranslatedMessage($player, "game.revival.notCaught", ERROR); 33 | return false; 34 | } 35 | $gameHandler->revival($player); 36 | return false; 37 | } 38 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/BanCommand.php: -------------------------------------------------------------------------------- 1 | " 20 | ); 21 | $this->setPermission("kametan.command.ban"); 22 | } 23 | 24 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 25 | if(!$this->testPermission($sender)){ 26 | return true; 27 | } 28 | if(!isset($args[0]) or !isset($args[1])){ 29 | if($sender instanceof Player){ 30 | UserHandler::getInstance()->sendTranslatedMessage($sender, "command.ban.usage", ERROR); 31 | }else{ 32 | $sender->sendMessage("Usage : /ban "); 33 | } 34 | return true; 35 | } 36 | 37 | $name = $args[0]; 38 | $reason = $args[1]; 39 | $player = Server::getInstance()->getPlayerByPrefix($name); 40 | if(!$player instanceof Player){ 41 | if($sender instanceof Player){ 42 | UserHandler::getInstance()->sendTranslatedMessage($sender, "command.ban.targetNotFound", ERROR, [$name]); 43 | }else{ 44 | $sender->sendMessage("Target " . $name . " not found"); 45 | } 46 | return true; 47 | } 48 | UserHandler::getInstance()->ban($player, $reason); 49 | if(strtolower($player->getName()) === strtolower($sender->getName())){ 50 | return true; // 文字自分をBanしたら、メッセージを送るときにエラーになる 51 | } 52 | UserHandler::getInstance()->sendTranslatedMessage($sender, "command.ban.success", MESSAGE, [$name, $reason]); 53 | return true; 54 | } 55 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/CleanEntityCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.cleanentity"); 22 | } 23 | 24 | 25 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 26 | if(!$this->testPermission($sender)){ 27 | return true; 28 | } 29 | if(!$sender instanceof Player){ 30 | $sender->sendMessage(ERROR . "This command is only for player"); 31 | return true; 32 | } 33 | $world = $sender->getWorld(); 34 | $count = 0; 35 | foreach ($world->getEntities() as $entity) { 36 | if(!$entity instanceof Player){ 37 | $count++; 38 | $entity->close(); 39 | } 40 | } 41 | UserHandler::getInstance()->sendTranslatedMessage($sender, "command.cleanEntity.execute", INFO, [$count]); 42 | return true; 43 | } 44 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/GameCommand.php: -------------------------------------------------------------------------------- 1 | [option...]" 20 | ); 21 | $this->setPermission("kametan.command.game"); 22 | } 23 | 24 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 25 | if(!$this->testPermission($sender)){ 26 | return true; 27 | } 28 | if(!isset($args[0])){ 29 | return true; 30 | } 31 | 32 | switch($args[0]){ 33 | case "start": 34 | GameHandler::getInstance()->startWaiting(); 35 | UserHandler::getInstance()->sendTranslatedMessage($sender, "command.game.startCountdown", MESSAGE); 36 | break; 37 | case "stop": // 必ず待機時間に使う 38 | GameHandler::getInstance()->stopGame(); 39 | UserHandler::getInstance()->sendTranslatedMessage($sender, "command.game.stop", MESSAGE); 40 | break; 41 | } 42 | return true; 43 | 44 | } 45 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/JoinCommand.php: -------------------------------------------------------------------------------- 1 | testPermission($sender)){ 26 | return true; 27 | } 28 | if(!$sender instanceof Player){ 29 | $sender->sendMessage(ERROR . "This command is only for player"); 30 | return true; 31 | } 32 | $userHandler = UserHandler::getInstance(); 33 | $gameHandler = GameHandler::getInstance(); 34 | if(!$gameHandler->isGameRunning() or $gameHandler->isFinalPhase()){ 35 | $userHandler->sendTranslatedMessage($sender, "game.join.fail", ERROR); 36 | return true; 37 | } 38 | 39 | if($gameHandler->getGameInfo()->hasGamerData($sender) and $gameHandler->getGameInfo()->getGamerData($sender)->gamerType !== GamerData::GAMER_TYPE_WAITING){ 40 | $userHandler->sendTranslatedMessage($sender, "game.join.fail", ERROR); 41 | return true; 42 | } 43 | 44 | if($gameHandler->getGameInfo()->hasGamerData($sender) and $gameHandler->getGameInfo()->getGamerData($sender)->surrender !== 0){ 45 | $userHandler->sendTranslatedMessage($sender, "game.join.fail", ERROR); 46 | return true; 47 | } 48 | $gameHandler->getGameInfo()->initGamerData($sender); 49 | $gameHandler->getGameInfo()->getGamerData($sender)->gamerType = GamerData::GAMER_TYPE_CAUGHT; 50 | $sender->teleport($gameHandler->getGameInfo()->field->getJailPoint()); 51 | $userHandler->sendTranslatedMessage($sender, "game.join.success", MESSAGE); 52 | $userHandler->updateState($sender); 53 | return true; 54 | } 55 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/MoneyCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.mymoney"); 22 | } 23 | 24 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 25 | if(!$this->testPermission($sender)){ 26 | return true; 27 | } 28 | if(!$sender instanceof Player){ 29 | $sender->sendMessage(ERROR . "This command is only for player"); 30 | return true; 31 | } 32 | $userHandler = UserHandler::getInstance(); 33 | $userId = $userHandler->getUserIdByUser($sender); 34 | $money = UserHandler::getInstance()->getUserMoney($userId); 35 | $sender->sendMessage(MESSAGE . ">> You have " . $money . " meta"); 36 | return true; 37 | } 38 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/NametagCommand.php: -------------------------------------------------------------------------------- 1 | " 21 | ); 22 | //$this->setPermission("kametan.command.nametag"); 23 | } 24 | 25 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 26 | if(!$this->testPermission($sender)){ 27 | return true; 28 | } 29 | if(!$sender instanceof Player){ 30 | $sender->sendMessage(ERROR . "This command is only for player"); 31 | return true; 32 | } 33 | $userHandler = UserHandler::getInstance(); 34 | if(!isset($args[0])){ 35 | $userHandler->sendTranslatedMessage($sender, "command.nametag.usage", ERROR); 36 | return true; 37 | } 38 | $nametag = $args[0]; 39 | 40 | if($nametag === "reset"){ 41 | $userHandler->getSaveDataByUser($sender)->setNametag(""); 42 | $userHandler->updateState($sender); 43 | $userHandler->sendTranslatedMessage($sender, "system.nametag.reset", MESSAGE); 44 | return true; 45 | } 46 | 47 | if(!Nametag::testIsValidNametag($sender, $nametag)){ 48 | return true; 49 | } 50 | 51 | $userHandler->getSaveDataByUser($sender)->setNametag($args[0]); 52 | $userHandler->updateState($sender); 53 | $userHandler->sendTranslatedMessage($sender, "command.nametag.success", MESSAGE, [$nametag]); 54 | return true; 55 | } 56 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/RemoveInventoryCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.removeinventory"); 23 | } 24 | 25 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 26 | if(!$this->testPermission($sender)){ 27 | return true; 28 | } 29 | if(!$sender instanceof Player){ 30 | $sender->sendMessage(ERROR . "This command is only for player"); 31 | return true; 32 | } 33 | $userHandler = UserHandler::getInstance(); 34 | if($userHandler->getTempData($sender)->cleanInventoryConfirm){ 35 | $sender->getInventory()->clearAll(); 36 | $userHandler->getTempData($sender)->cleanInventoryConfirm = false; 37 | $userHandler->sendTranslatedMessage($sender, "command.removeInventory.success", MESSAGE); 38 | }else{ 39 | $userHandler->sendTranslatedMessage($sender, "command.removeInventory.confirm", MESSAGE); 40 | $userHandler->getTempData($sender)->cleanInventoryConfirm = true; 41 | } 42 | return true; 43 | } 44 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/SetPhotoStudioCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.setphotostudio"); 23 | } 24 | 25 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 26 | if(!$this->testPermission($sender)){ 27 | return true; 28 | } 29 | if(!$sender instanceof Player){ 30 | $sender->sendMessage(ERROR . "This command is only for player"); 31 | return true; 32 | } 33 | UserHandler::getInstance()->setPhotoStudioPos($sender->getLocation()); 34 | $sender->sendMessage(MESSAGE . ">> 撮影台の場所を設定しました"); 35 | return true; 36 | } 37 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/SobaCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.soba"); 23 | } 24 | 25 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 26 | if(!$this->testPermission($sender)){ 27 | return true; 28 | } 29 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 30 | $player->getInventory()->addItem(ItemFactory::getInstance()->get(Soba::ITEM_ID, 0, 1)); 31 | $player->sendMessage("§a>> サーバーから年越しそばが送られました"); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/SpawnCommand.php: -------------------------------------------------------------------------------- 1 | testPermission($sender)){ 25 | return true; 26 | } 27 | if(!$sender instanceof Player){ 28 | $sender->sendMessage(ERROR . "This command is only for player"); 29 | return true; 30 | } 31 | $userHandler = UserHandler::getInstance(); 32 | $userHandler->respawn($sender); 33 | $userHandler->sendTranslatedMessage($sender, "command.spawn.success", MESSAGE); 34 | return true; 35 | } 36 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/StatusCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.nametag"); 21 | } 22 | 23 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 24 | if(!$this->testPermission($sender)){ 25 | return true; 26 | } 27 | if(!$sender instanceof Player){ 28 | $sender->sendMessage(ERROR . "This command is only for player"); 29 | return true; 30 | } 31 | $userHandler = UserHandler::getInstance(); 32 | $userId = $userHandler->getUserIdByUser($sender); 33 | $status = $userHandler->calcUserGameStatus($userId); 34 | $clear = $status[0]; 35 | $death = $status[1]; 36 | $catch = $status[2]; 37 | $surrender = $status[3]; 38 | $revival = $status[4]; 39 | 40 | $sender->sendMessage("§a|=============================="); 41 | $sender->sendMessage("§a|・".$sender->getName()."様のステータス"); 42 | $sender->sendMessage("§a|・逃走成功した回数 : ".$clear.""); 43 | $sender->sendMessage("§a|・確保された回数 : ".$death.""); 44 | $sender->sendMessage("§a|・確保した回数 : ".$catch.""); 45 | $sender->sendMessage("§a|・自首回数 : ".$surrender.""); 46 | $sender->sendMessage("§a|・復活回数 : ".$revival.""); 47 | $sender->sendMessage("§a|=============================="); 48 | return true; 49 | } 50 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/TeleportAllToMeCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.tpa"); 22 | } 23 | 24 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 25 | if(!$this->testPermission($sender)){ 26 | return true; 27 | } 28 | if(!$sender instanceof Player){ 29 | $sender->sendMessage(ERROR . "This command is only for player"); 30 | return true; 31 | } 32 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 33 | $player->teleport($sender->getLocation()); 34 | } 35 | return true; 36 | } 37 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/UnbanCommand.php: -------------------------------------------------------------------------------- 1 | " 17 | ); 18 | $this->setPermission("kametan.command.unban"); 19 | } 20 | 21 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 22 | $sender->sendMessage(">> This command is not available now"); 23 | return true; 24 | } 25 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/development/ChunkInfoCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.chunkinfo"); 22 | } 23 | 24 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 25 | if(!$this->testPermission($sender)){ 26 | return true; 27 | } 28 | if(!$sender instanceof Player){ 29 | $sender->sendMessage("This command is only for player"); 30 | return true; 31 | } 32 | $x = (int) round($sender->getLocation()->x); 33 | $z = (int) round($sender->getLocation()->z); 34 | $chunk = $sender->getWorld()->getChunk($x >> 4, $z >> 4); 35 | $chunkX = $chunk->getX(); 36 | $chunkZ = $chunk->getZ(); 37 | $sender->sendMessage(MESSAGE . ">> Here is a chunk (X, Z) = ($chunkX, $chunkZ)"); 38 | return true; 39 | } 40 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/development/LightningTestCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.lightningtest"); 29 | } 30 | 31 | 32 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 33 | if(!$this->testPermission($sender)){ 34 | return true; 35 | } 36 | if(!$sender instanceof Player){ 37 | $sender->sendMessage(ERROR . "This command is only for player"); 38 | return true; 39 | } 40 | 41 | //$sender->getWorld()->addEntity(new LightningBolt($sender->getLocation())); 42 | //new LightningBolt(Location::fromObject($sender->getPosition(), $sender->getWorld(), 0, 0)); 43 | 44 | 45 | $entity = new LightningBolt($sender->getLocation()); 46 | $entity->spawnToAll(); 47 | 48 | /** 49 | $pk = new AddActorPacket(); 50 | $pk->actorRuntimeId = 1000000000; 51 | $pk->type = EntityIds::LIGHTNING_BOLT; 52 | $pk->position = $sender->getPosition(); 53 | $pk->motion = new Vector3(0, 0, 0); 54 | $sender->getNetworkSession()->sendDataPacket($pk); 55 | return true; 56 | * */ 57 | return true; 58 | } 59 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/development/MyXuidCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.myxuid"); 20 | } 21 | 22 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 23 | if(!$this->testPermission($sender)){ 24 | return true; 25 | } 26 | if(!$sender instanceof Player){ 27 | $sender->sendMessage(ERROR . "This command is only for player"); 28 | return true; 29 | } 30 | 31 | $xuid = $sender->getXuid(); 32 | $sender->sendMessage(MESSAGE . ">> Your xuid is " . $xuid); 33 | return true; 34 | 35 | } 36 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/development/SaveDataDumpCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.savedatadump"); 22 | } 23 | 24 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 25 | if(!$this->testPermission($sender)){ 26 | return true; 27 | } 28 | if(!$sender instanceof Player){ 29 | $sender->sendMessage(ERROR . "This command is only for player"); 30 | return true; 31 | } 32 | $sender->sendMessage(MESSAGE . ">> Your save data:" . UserHandler::getInstance()->getSaveDataByUser($sender)->jsonSerialize()); 33 | return true; 34 | } 35 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/development/ScanWorldSurfaceCommand.php: -------------------------------------------------------------------------------- 1 | " 21 | ); 22 | $this->setPermission("kametan.command.scanworldsurface"); 23 | } 24 | 25 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 26 | if(!$this->testPermission($sender)){ 27 | return true; 28 | } 29 | 30 | if(!isset($args[0],$args[1],$args[2],$args[3])){ 31 | UserHandler::getInstance()->sendTranslatedMessage($sender, "command.scanWorldSurface.usage", ERROR); 32 | 33 | return true; 34 | }else{ 35 | $x1 = (int) $args[0]; 36 | $z1 = (int) $args[1]; 37 | $x2 = (int) $args[2]; 38 | $z2 = (int) $args[3]; 39 | $minX = min($x1, $x2); 40 | $maxX = max($x1, $x2); 41 | $minZ = min($z1, $z2); 42 | $maxZ = max($z1, $z2); 43 | $xOffset = $minX; 44 | $zOffset = $minZ; 45 | $xSize = $maxX - $minX + 1; 46 | $zSize = $maxZ - $minZ + 1; 47 | $world = Server::getInstance()->getWorldManager()->getDefaultWorld(); 48 | $data = []; 49 | $data["areaName"] = "Area"; 50 | $data["minX"] = $minX; 51 | $data["maxX"] = $maxX; 52 | $data["minZ"] = $minZ; 53 | $data["maxZ"] = $maxZ; 54 | $data["xOffset"] = $xOffset; 55 | $data["zOffset"] = $zOffset; 56 | $data["xSize"] = $xSize; 57 | $data["zSize"] = $zSize; 58 | $data["data"] = []; 59 | for($x=0;$x<$xSize;$x++){ 60 | for($z=0;$z<$zSize;$z++){ 61 | if(!isset($data["data"][$x])){ 62 | $data["data"][$x] = []; 63 | } 64 | 65 | $y = $world->getHighestBlockAt($x+$xOffset, $z+$zOffset); 66 | $block = $world->getBlockAt($x+$xOffset, $y, $z+$zOffset); 67 | $id = $block->getId(); 68 | $meta = $block->getMeta(); 69 | $data["data"][$x][$z] = [$y, $id, $meta]; 70 | } 71 | } 72 | $json = json_encode($data); 73 | $fileName = "scan_world_surface_" . $sender->getName() . "_" . time() . ".json"; 74 | file_put_contents($fileName, $json); 75 | $sender->sendMessage(">> Saved to " . $fileName); 76 | return true; 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/development/SetBaseBlockCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.setbaseblock"); 25 | } 26 | 27 | 28 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 29 | if(!$this->testPermission($sender)){ 30 | return true; 31 | } 32 | if(!$sender instanceof Player){ 33 | $sender->sendMessage(ERROR . "This command is only for player"); 34 | return true; 35 | } 36 | $world = $sender->getWorld(); 37 | $world->setBlock($sender->getLocation(), BlockFactory::getInstance()->get(1, 0)); 38 | UserHandler::getInstance()->sendTranslatedMessage($sender, "command.setBaseBlock.success", MESSAGE); 39 | return true; 40 | } 41 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/command/development/SoundTestCommand.php: -------------------------------------------------------------------------------- 1 | setPermission("kametan.command.soundtest"); 24 | } 25 | 26 | 27 | public function execute(CommandSender $sender, string $commandLabel, array $args){ 28 | if(!$this->testPermission($sender)){ 29 | return true; 30 | } 31 | if(!$sender instanceof Player){ 32 | $sender->sendMessage("This command is only for player"); 33 | return true; 34 | } 35 | if(!isset($args[0])){ 36 | UserHandler::getInstance()->sendTranslatedMessage($sender, "command.soundTest.usage", ERROR); 37 | return true; 38 | } 39 | $id = (int) $args[0]; 40 | $packet = LevelEventPacket::create($id, 0, $sender->getLocation()); 41 | $sender->getNetworkSession()->sendDataPacket($packet); 42 | $sender->sendMessage(">> Played ".$id." sound"); 43 | return true; 44 | } 45 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/Database.php: -------------------------------------------------------------------------------- 1 | connection->ping(); 29 | } 30 | 31 | /** 32 | * @param string $host 33 | * @param string $username 34 | * @param string $password 35 | * @param string $dbname 36 | * @return bool 37 | */ 38 | public function initDatabase(string $host, string $username, string $password, string $dbname) : bool{ 39 | $this->connection = new \mysqli($host, $username, $password, $dbname); 40 | if($this->connection->connect_error){ 41 | return false; 42 | } 43 | return true; 44 | } 45 | 46 | /** 47 | * @param BannedUserType $record 48 | */ 49 | public function putBannedUser(BannedUserType $record){ 50 | $stmt = $this->connection->prepare("INSERT INTO `banned_users` (`xuid`, `user_id`, `username`, `ip_address`, `expiration_date`, `enforcer_sign`, `reason`) VALUES (?, ?, ?, ?, ?, ?, ?)"); 51 | $stmt->bind_param("isssiss", $record->userId, $record->xuid, $record->username, $record->ipAddress, $record->expirationDate, $record->enforcerSign, $record->reason); 52 | $stmt->execute(); 53 | } 54 | 55 | /** 56 | * @param string $xuid 57 | * @param string $username 58 | * @param string $ipAddress 59 | * @return BannedUserType[] 60 | */ 61 | public function getBannedUsers(string $xuid, string $username, string $ipAddress) : array{ 62 | $now = time(); 63 | $stmt = $this->connection->prepare("SELECT `id`, `user_id`, `xuid`, `username`, `ip_address`, `expiration_date`, `enforcer_sign`, `reason` FROM `banned_users` WHERE (`xuid` = ? OR `username` = ? OR `ip_address` = ?) AND `is_valid` = 1 AND `expiration_date` > ?"); 64 | $stmt->bind_param("sssi", $xuid, $username, $ipAddress, $now); 65 | $stmt->execute(); 66 | $stmt->bind_result($id, $userId, $xuid, $username, $ipAddress, $expirationDate, $enforcerSign, $reason); 67 | $result = []; 68 | while($stmt->fetch()){ 69 | $result[] = new BannedUserType($id, $userId, $xuid, $username, $ipAddress, $expirationDate, $enforcerSign, $reason); 70 | } 71 | return $result; 72 | } 73 | 74 | public function putRunForMoneyEntry(RunForMoneyEntryType $entry) : int{ 75 | $stmt = $this->connection->prepare("INSERT INTO `run_for_money_entries` (`information`) VALUES (?)"); 76 | $stmt->bind_param("s", $entry->information); 77 | if($stmt->execute()){ 78 | $result = $this->connection->query("SELECT LAST_INSERT_ID()"); 79 | $row = $result->fetch_assoc(); 80 | if(!isset($row["LAST_INSERT_ID()"])){ 81 | return -1; 82 | } 83 | return (int) $row["LAST_INSERT_ID()"]; 84 | } 85 | return -1; 86 | } 87 | 88 | /** 89 | * @param $userId 90 | * @return UserCrownType[] 91 | */ 92 | public function getUserCrowns($userId) : array{ 93 | $stmt = $this->connection->prepare("SELECT `id`, `type`, `color`, `data`, `expires_at` FROM `user_crowns` WHERE `user_id` = ?"); 94 | $stmt->bind_param("i", $userId); 95 | $stmt->execute(); 96 | $stmt->bind_result($id, $type, $color, $data, $expiresAt); 97 | $crowns = []; 98 | while($stmt->fetch()){ 99 | $crowns[] = new UserCrownType($id, $userId, $type, $color, $data, $expiresAt); 100 | } 101 | return $crowns; 102 | } 103 | 104 | public function putUserLog(UserLogType $userLog){ 105 | $stmt = $this->connection->prepare("INSERT INTO `user_logs` (`user_id`, `type`, `ip_address`) VALUES (?, ?, ?)"); 106 | $stmt->bind_param("iis", $userLog->userId,$userLog->type, $userLog->ipAddress); 107 | $stmt->execute(); 108 | } 109 | 110 | 111 | /** 112 | * @param $userId 113 | * @return UserMoneyCacheType|null 114 | */ 115 | public function getUserMoneyCache($userId) : ?UserMoneyCacheType{ 116 | $stmt = $this->connection->prepare("SELECT `amount`, `max_transaction_id`, `updated_at` FROM `user_money_caches` WHERE `user_id` = ?"); 117 | $stmt->bind_param("i", $userId); 118 | $stmt->execute(); 119 | $stmt->bind_result($amount, $maxTransactionId, $updatedAt); 120 | $stmt->fetch(); 121 | if($maxTransactionId === null){ 122 | return null; 123 | } 124 | return new UserMoneyCacheType($userId, $amount, $maxTransactionId, $updatedAt); 125 | } 126 | 127 | /** 128 | * @param UserMoneyTransactionType $transaction 129 | */ 130 | public function putUserMoneyTransaction(UserMoneyTransactionType $transaction){ 131 | $stmt = $this->connection->prepare("INSERT INTO `user_money_transactions` (`user_id`, `type`, `amount`, `data`) VALUES (?, ?, ?, ?)"); 132 | $stmt->bind_param("iiis", $transaction->userId, $transaction->type, $transaction->amount, $transaction->data); 133 | $stmt->execute(); 134 | } 135 | 136 | /** 137 | * @param $userId 138 | * @return UserMoneyTransactionType[] 139 | */ 140 | public function getUserMoneyTransactions($userId) : array{ 141 | $stmt = $this->connection->prepare("SELECT `id`, `type`, `amount`, `data` FROM `user_money_transactions` WHERE `user_id` = ?"); 142 | $stmt->bind_param("i", $userId); 143 | $stmt->execute(); 144 | $stmt->bind_result($id, $type, $amount, $data); 145 | $result = []; 146 | while($stmt->fetch()){ 147 | $result[] = new UserMoneyTransactionType($id, $userId, $type, $amount, $data); 148 | } 149 | return $result; 150 | } 151 | 152 | /** 153 | * @param UserType $user 154 | */ 155 | public function putUser(UserType $user){ 156 | $stmt = $this->connection->prepare("INSERT INTO `users` (`xuid`, `username`, `ip_address`, `save_data`) VALUES (?, ?, ?, ?)"); 157 | $json = $user->saveData->jsonSerialize(); 158 | $stmt->bind_param("ssss", $user->xuid, $user->username, $user->ipAddress, $json); 159 | $stmt->execute(); 160 | } 161 | 162 | /** 163 | * @param int $id 164 | * @return string 165 | */ 166 | public function getUserNameByUserId(int $id) : ? string{ 167 | $stmt = $this->connection->prepare("SELECT `username` FROM `users` WHERE `id` = ?"); 168 | $stmt->bind_param("i", $id); 169 | $stmt->execute(); 170 | $stmt->bind_result($username); 171 | $stmt->fetch(); 172 | if($username === null){ 173 | return "Unknown"; 174 | } 175 | return $username; 176 | } 177 | 178 | /** 179 | * @param string $xuid 180 | * @return UserType|null 181 | */ 182 | public function getUserByXuid(string $xuid) : ? UserType{ 183 | $stmt = $this->connection->prepare("SELECT `id`, `xuid`, `username`, `ip_address`, `save_data` FROM `users` WHERE `xuid` = ?"); 184 | $stmt->bind_param("s", $xuid); 185 | $stmt->execute(); 186 | $stmt->bind_result($id, $xuid, $username, $ipAddress, $saveData); 187 | $stmt->fetch(); 188 | if($username === null){ 189 | return null; 190 | } 191 | return new UserType($id, $xuid, $username, $ipAddress, UserSaveData::jsonDeserialize($saveData), null); 192 | } 193 | 194 | public function updateUserSaveData(int $userId, UserSaveData $saveData){ 195 | $stmt = $this->connection->prepare("UPDATE `users` SET `save_data` = ?, `updated_at` = ? WHERE `id` = ?"); 196 | $json = $saveData->jsonSerialize(); 197 | $updatedAt = date('Y-m-d H:i:s'); 198 | $stmt->bind_param("ssi", $json, $updatedAt, $userId); 199 | $stmt->execute(); 200 | } 201 | 202 | public function updateUserPassword(int $userId, string $hashedPassword){ 203 | $stmt = $this->connection->prepare("UPDATE `users` SET `password` = ?, `updated_at` = ? WHERE `id` = ?"); 204 | $updatedAt = date('Y-m-d H:i:s'); 205 | $stmt->bind_param("ssi", $hashedPassword, $updatedAt, $userId); 206 | $stmt->execute(); 207 | } 208 | 209 | public function getUserRunForMoneyCache(int $userId){ 210 | $stmt = $this->connection->prepare("SELECT `user_id`, `clear`, `death`, `catch`, `surrender`, `revival`, `max_result_id`, `updated_at` FROM `user_run_for_money_caches` WHERE `user_id` = ?"); 211 | $stmt->bind_param("i", $userId); 212 | $stmt->bind_result($runForMoneyId, $clear, $death, $catch, $surrender, $revival, $maxResultId, $updatedAt); 213 | $stmt->fetch(); 214 | if($runForMoneyId === null){ 215 | return null; 216 | } 217 | return new UserRunForMoneyCacheType($runForMoneyId, $clear, $death, $catch, $surrender, $revival, $maxResultId, $updatedAt); 218 | } 219 | 220 | /** 221 | * @param UserRunForMoneyResultType $result 222 | */ 223 | public function putUserRunForMoneyResult(UserRunForMoneyResultType $result){ 224 | $stmt = $this->connection->prepare("INSERT INTO `user_run_for_money_results`(`user_id`, `run_for_money_id`, `clear`, `death`, `catch`, `surrender`, `revival`) VALUES (?,?,?,?,?,?,?)"); 225 | $stmt->bind_param("iiiiiii", $result->userId, $result->runForMoneyId, $result->clear, $result->death, $result->catch, $result->surrender, $result->revival); 226 | $stmt->execute(); 227 | } 228 | 229 | public function getUserRunForMoneyResults(int $userId): array{ 230 | $stmt = $this->connection->prepare("SELECT `run_for_money_id`, `clear`, `death`, `catch`, `surrender`, `revival` FROM `user_run_for_money_results` WHERE `user_id` = ?"); 231 | $stmt->bind_param("i", $userId); 232 | $stmt->execute(); 233 | $stmt->bind_result($runForMoneyId, $clear, $death, $catch, $surrender, $revival); 234 | $result = []; 235 | while($stmt->fetch()){ 236 | $result[] = new UserRunForMoneyResultType(null, $runForMoneyId, $userId, $clear, $death, $catch, $surrender, $revival); 237 | } 238 | return $result; 239 | } 240 | 241 | public function getUserWebReceivedItems(int $userId): array{ 242 | $stmt = $this->connection->prepare("SELECT `id`, `type`, `item_id`, `item_meta`, `amount` FROM `user_web_received_items` WHERE `user_id` = ?"); 243 | $stmt->bind_param("i", $userId); 244 | $stmt->execute(); 245 | $stmt->bind_result($id, $type, $itemId, $itemMeta, $amount); 246 | $result = []; 247 | while($stmt->fetch()){ 248 | $result[] = new UserWebReceivedItemType($id, $userId, $type, $itemId, $itemMeta, $amount); 249 | } 250 | return $result; 251 | } 252 | 253 | public function deleteWebReceivedItem(int $id){ 254 | $stmt = $this->connection->prepare("DELETE FROM `user_web_received_items` WHERE `id` = ?"); 255 | $stmt->bind_param("i", $id); 256 | $stmt->execute(); 257 | } 258 | 259 | public function deleteWebReceivedItems(int $userId){ 260 | $stmt = $this->connection->prepare("DELETE FROM `user_web_received_items` WHERE `user_id` = ?"); 261 | $stmt->bind_param("i", $userId); 262 | $stmt->execute(); 263 | } 264 | 265 | ////////-------------Ranking----------//////// 266 | 267 | public function getUserMoneyCachesOrderByAmountDESC(){ 268 | $result = $this->connection->query("SELECT `user_id`, `amount`, `max_transaction_id`, `updated_at` FROM `user_money_caches` ORDER BY `amount` DESC LIMIT 10"); 269 | $caches = []; 270 | while($row = $result->fetch_assoc()){ 271 | $caches[] = new UserMoneyCacheType((int) $row["user_id"], (int) $row["amount"], (int) $row["max_transaction_id"], $row["updated_at"]); 272 | } 273 | return $caches; 274 | } 275 | 276 | public function getUserRunForMoneyCachesOrderByClearDESC(){ 277 | $result = $this->connection->query("SELECT `user_id`, `clear`, `death`, `catch`, `surrender`, `revival`, `max_result_id`, `updated_at` FROM `user_run_for_money_caches` ORDER BY `clear` DESC LIMIT 10"); 278 | $caches = []; 279 | while($row = $result->fetch_assoc()){ 280 | $caches[] = new UserRunForMoneyCacheType((int) $row["user_id"], (int) $row["clear"], (int) $row["death"], (int) $row["catch"], (int) $row["surrender"], (int) $row["revival"], (int) $row["max_result_id"], $row["updated_at"]); 281 | } 282 | return $caches; 283 | } 284 | 285 | public function getUserRunForMoneyCachesOrderByCatchDESC(){ 286 | $result = $this->connection->query("SELECT `user_id`, `clear`, `death`, `catch`, `surrender`, `revival`, `max_result_id`, `updated_at` FROM `user_run_for_money_caches` ORDER BY `catch` DESC LIMIT 10"); 287 | $caches = []; 288 | while($row = $result->fetch_assoc()){ 289 | $caches[] = new UserRunForMoneyCacheType((int) $row["user_id"], (int) $row["clear"], (int) $row["death"], (int) $row["catch"], (int) $row["surrender"], (int) $row["revival"], (int) $row["max_result_id"], $row["updated_at"]); 290 | } 291 | return $caches; 292 | } 293 | 294 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/type/BannedUserType.php: -------------------------------------------------------------------------------- 1 | banId = $banId; 46 | $this->userId = $userId; 47 | $this->xuid = $xuid; 48 | $this->username = $username; 49 | $this->ipAddress = $ipAddress; 50 | $this->expirationDate = $expirationDate; 51 | $this->enforcerSign = $enforcerSign; 52 | $this->reason = $reason; 53 | } 54 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/type/RunForMoneyEntryType.php: -------------------------------------------------------------------------------- 1 | id = $id; 22 | $this->information = $information; 23 | } 24 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/type/UserCrownType.php: -------------------------------------------------------------------------------- 1 | id = $id; 38 | $this->userId = $userId; 39 | $this->type = $type; 40 | $this->color = $color; 41 | $this->data = $data; 42 | $this->expiresAt = $expiresAt; 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/type/UserLogType.php: -------------------------------------------------------------------------------- 1 | id = $id; 35 | $this->userId = $userId; 36 | $this->type = $type; 37 | $this->ipAddress = $ipAddress; 38 | } 39 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/type/UserMoneyCacheType.php: -------------------------------------------------------------------------------- 1 | userId = $userId; 30 | $this->amount = $amount; 31 | $this->maxTransactionId = $maxTransactionId; 32 | $this->updatedAt = $updatedAt; 33 | } 34 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/type/UserMoneyTransactionType.php: -------------------------------------------------------------------------------- 1 | id = $id; 53 | $this->userId = $userId; 54 | $this->type = $type; 55 | $this->amount = $amount; 56 | $this->data = $data; 57 | } 58 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/type/UserRunForMoneyCacheType.php: -------------------------------------------------------------------------------- 1 | userId = $userId; 46 | $this->clear = $clear; 47 | $this->death = $death; 48 | $this->catch = $catch; 49 | $this->surrender = $surrender; 50 | $this->revival = $revival; 51 | $this->maxResultId = $maxResultId; 52 | $this->updatedAt = $updatedAt; 53 | } 54 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/type/UserRunForMoneyResultType.php: -------------------------------------------------------------------------------- 1 | id = $id; 47 | $this->userId = $userId; 48 | $this->runForMoneyId = $runForMoneyId; 49 | $this->clear = $clear; 50 | $this->death = $death; 51 | $this->catch = $catch; 52 | $this->surrender = $surrender; 53 | $this->revival = $revival; 54 | } 55 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/type/UserType.php: -------------------------------------------------------------------------------- 1 | id = $id; 40 | $this->xuid = $xuid; 41 | $this->username = $username; 42 | $this->ipAddress = $ipAddress; 43 | $this->saveData = $saveData; 44 | $this->password = $password; 45 | } 46 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/database/type/UserWebReceivedItemType.php: -------------------------------------------------------------------------------- 1 | id = $id; 38 | $this->userId = $userId; 39 | $this->type = $type; 40 | $this->itemId = $itemId; 41 | $this->itemMeta = $itemMeta; 42 | $this->amount = $amount; 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/entity/Agent.php: -------------------------------------------------------------------------------- 1 | height, $this->width); } 23 | 24 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/entity/Human.php: -------------------------------------------------------------------------------- 1 | getDamager(); 18 | $this->lookAt($damager->getLocation()); 19 | } 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/entity/LightningBolt.php: -------------------------------------------------------------------------------- 1 | closed and ++$this->age > 100){ 29 | $this->close(); 30 | return true; 31 | } 32 | return false; 33 | } 34 | 35 | protected function getInitialSizeInfo() : EntitySizeInfo{ return new EntitySizeInfo($this->height, $this->width); } 36 | 37 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/entity/projectile/DragonFireball.php: -------------------------------------------------------------------------------- 1 | height, $this->width); } 21 | 22 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/entity/projectile/FishingHook.php: -------------------------------------------------------------------------------- 1 | height, $this->width); } 21 | 22 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/AdminForm.php: -------------------------------------------------------------------------------- 1 | isAdmin($player)) return; 34 | if(!is_int($data)){ 35 | return; 36 | } 37 | switch($data){ 38 | case 0: 39 | $player->sendForm(new AdminBanForm($this->lang)); 40 | break; 41 | case 1: 42 | $player->sendForm(new AdminTeleportForm($this->lang)); 43 | break; 44 | case 2: 45 | $player->sendForm(new AdminUserListForm($this->lang)); 46 | break; 47 | } 48 | } 49 | 50 | /** 51 | * @inheritDoc 52 | */ 53 | public function jsonSerialize(){ 54 | $data = []; 55 | $data["type"] = "form"; 56 | $data["title"] = "§9" . Lang::translate($this->lang, "form.admin.title"); 57 | $data["content"] = Lang::translate($this->lang, "form.admin.content"); 58 | $buttons =[]; 59 | 60 | foreach(self::$menus as $menu){ 61 | $button = new \stdClass(); 62 | $button->text = Lang::translate($this->lang, $menu[0]); 63 | $image = new \stdClass(); 64 | $image->type = "path"; 65 | $image->data = $menu[1]; 66 | $button->image = $image; 67 | $buttons[] = $button; 68 | } 69 | 70 | $data["buttons"] = $buttons; 71 | return $data; 72 | } 73 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/ItemBuyForm.php: -------------------------------------------------------------------------------- 1 | itemName = $itemName; 31 | $this->itemId = $itemId; 32 | $this->itemCost = $itemCost; 33 | $this->maxCount = $maxCount; 34 | parent::__construct($lang); 35 | } 36 | 37 | public function handleResponse(Player $player, $data): void{ 38 | if(!is_array($data) or count($data) !== 2){ 39 | return; 40 | } 41 | $count = (int) $data[1]; 42 | 43 | /** @var UserHandler $userHandler */ 44 | $userHandler = UserHandler::getInstance(); 45 | 46 | if($count <= 0 or $this->maxCount < $count){ 47 | $userHandler->sendTranslatedMessage($player, "form.invalid.message", ERROR); 48 | return; 49 | } 50 | $totalCost = (int) $count*$this->itemCost; 51 | 52 | $userId = $userHandler->getUserIdByUser($player); 53 | 54 | if($userHandler->getUserMoney($userId) < $totalCost){ 55 | $userHandler->sendTranslatedMessage($player, "system.item.buy.no_money", ERROR); 56 | return; 57 | } 58 | 59 | $item = ItemFactory::getInstance()->get($this->itemId, 0, $count); 60 | 61 | if(!$player->getInventory()->canAddItem($item)){ 62 | $userHandler->sendTranslatedMessage($player, "system.item.buy.no_space", ERROR); 63 | return; 64 | } 65 | 66 | $userHandler->reduceUserMoney($userId, $totalCost, UserMoneyTransactionType::TYPE_ITEM_BUY); 67 | $userHandler->sendTranslatedMessage($player, "system.item.buy.success", MESSAGE); 68 | 69 | $player->getInventory()->addItem($item); 70 | } 71 | 72 | public function jsonSerialize(){ 73 | $data = []; 74 | $data["type"] = "custom_form"; 75 | $data["title"] = "§9" . Lang::translate($this->lang, "form.itemBuy.title"); 76 | $contents =[]; 77 | 78 | $label = new \stdClass(); 79 | $label->type = "label"; 80 | $label->text = "アイテム名:" . Lang::translate($this->lang, $this->itemName) . "\n" . "単価:" . $this->itemCost . "メタ"; 81 | $contents[] = $label; 82 | 83 | $slider = new \stdClass(); 84 | $slider->text = Lang::translate($this->lang, "form.itemBuy.count"); 85 | $slider->type = "slider"; 86 | $slider->min = 1; 87 | $slider->max = $this->maxCount; 88 | $contents[] = $slider; 89 | $data["content"] = $contents; 90 | return $data; 91 | } 92 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/ItemShopForm.php: -------------------------------------------------------------------------------- 1 | sendForm(new ItemBuyForm($this->lang, $item[0], $item[3], $item[4], $item[5])); 51 | } 52 | 53 | public function jsonSerialize(){ 54 | $data = []; 55 | $data["type"] = "form"; 56 | $data["title"] = "§9アイテムショップ"; 57 | $data["content"] = "購入したい商品を選んでね"; 58 | $buttons =[]; 59 | 60 | foreach(self::$items as $itemInfo){ 61 | $button = new \stdClass(); 62 | $button->text = TextFormat::GOLD . Lang::translate($this->lang, $itemInfo[0]) . " (. " . $itemInfo[4] . "メタ)\n" . TextFormat::WHITE .Lang::translate($this->lang, $itemInfo[1]); 63 | $image = new \stdClass(); 64 | $image->type = "path"; 65 | $image->data = $itemInfo[2]; 66 | $button->image = $image; 67 | $buttons[] = $button; 68 | } 69 | 70 | $data["buttons"] = $buttons; 71 | return $data; 72 | } 73 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/MenuForm.php: -------------------------------------------------------------------------------- 1 | player = $player; 31 | parent::__construct($lang); 32 | } 33 | 34 | /** 35 | * @inheritDoc 36 | */ 37 | public function handleResponse(Player $player, $data): void{ 38 | if(!is_int($data)){ 39 | return; 40 | } 41 | switch($data){ 42 | case 0: 43 | $player->sendForm(new TeleportForm($this->lang)); 44 | break; 45 | case 1: 46 | $player->sendForm(new ItemShopForm($this->lang)); 47 | break; 48 | case 2: 49 | $player->sendForm(new SettingForm($this->lang, $player)); 50 | break; 51 | case 3: 52 | $player->sendForm(new PasswordRegisterForm($this->lang)); 53 | break; 54 | case 4: 55 | $player->kick(MESSAGE . "ログアウトしました"); 56 | break; 57 | case 5: 58 | if(UserHandler::getInstance()->isAdmin($player)){ 59 | $player->sendForm(new AdminForm($this->lang)); 60 | } 61 | break; 62 | } 63 | } 64 | 65 | /** 66 | * @inheritDoc 67 | */ 68 | public function jsonSerialize(){ 69 | $data = []; 70 | $data["type"] = "form"; 71 | $data["title"] = "§9" . Lang::translate($this->lang, "form.menu.title"); 72 | $data["content"] = Lang::translate($this->lang, "form.menu.content"); 73 | $buttons =[]; 74 | 75 | foreach(self::$menus as $menu){ 76 | if(!$menu[2] or UserHandler::getInstance()->isAdmin($this->player)){ 77 | $button = new \stdClass(); 78 | $button->text = Lang::translate($this->lang, $menu[0]); 79 | $image = new \stdClass(); 80 | $image->type = "path"; 81 | $image->data = $menu[1]; 82 | $button->image = $image; 83 | $buttons[] = $button; 84 | } 85 | } 86 | 87 | $data["buttons"] = $buttons; 88 | return $data; 89 | } 90 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/PasswordRegisterForm.php: -------------------------------------------------------------------------------- 1 | sendTranslatedMessage($player, "system.password.notRegister", MESSAGE); 21 | UserHandler::getInstance()->sendTranslatedMessage($player, "system.password.always", MESSAGE); 22 | 23 | return; 24 | } 25 | $password = $data[1]; 26 | $passwordConfirm = $data[2]; 27 | 28 | // TODO strlen 29 | 30 | if($password !== $passwordConfirm){ 31 | UserHandler::getInstance()->sendTranslatedMessage($player, "system.password.notMatch", ERROR); 32 | UserHandler::getInstance()->sendTranslatedMessage($player, "system.password.notRegister", MESSAGE); 33 | UserHandler::getInstance()->sendTranslatedMessage($player, "system.password.always", MESSAGE); 34 | 35 | return; 36 | } 37 | $userId = UserHandler::getInstance()->getUserIdByUser($player); 38 | $task = new PasswordRegisterTask($userId, $password); 39 | 40 | Server::getInstance()->getAsyncPool()->submitTask($task); 41 | UserHandler::getInstance()->sendTranslatedMessage($player, "system.password.hashing", MESSAGE); 42 | } 43 | 44 | public function jsonSerialize(){ 45 | $data = []; 46 | $data["type"] = "custom_form"; 47 | $data["title"] = "§9パスワードを登録"; 48 | $contents =[]; 49 | 50 | $label = new \stdClass(); 51 | $label->type = "label"; 52 | $label->text = TextFormat::DARK_GREEN . 53 | "パスワードを登録する場合、以下のフォームを埋めて送信してください。" . 54 | TextFormat::RED . "登録しない場合はこのフォームは何もせずに閉じてください。" . 55 | TextFormat::DARK_GREEN ."パスワードを登録するとかめたんサーバーのWebサイトにログインできるようになります。" . 56 | "また、パスワードはいつでも登録/変更できます。"; 57 | $contents[] = $label; 58 | 59 | $input1 = new \stdClass(); 60 | $input1->type = "input"; 61 | $input1->text = TextFormat::GOLD . "パスワード"; 62 | $input1->placeholder = "パスワード"; 63 | $contents[] = $input1; 64 | 65 | $input2 = new \stdClass(); 66 | $input2->type = "input"; 67 | $input2->text = TextFormat::GOLD . "パスワード(確認)"; 68 | $input2->placeholder = "パスワード"; 69 | $contents[] = $input2; 70 | $data["content"] = $contents; 71 | return $data; 72 | } 73 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/SettingForm.php: -------------------------------------------------------------------------------- 1 | player = $player; 22 | parent::__construct($lang); 23 | } 24 | 25 | public function handleResponse(Player $player, $data): void{ 26 | if(!is_array($data) or count($data) !== 2){ 27 | return; 28 | } 29 | $userHandler = UserHandler::getInstance(); 30 | $saveData = $userHandler->getSaveDataByUser($this->player); 31 | $langIndex = (int) $data[0]; 32 | if(isset(Lang::getLangList()[$langIndex])){ 33 | $lang = Lang::getLangList()[$langIndex]; 34 | $saveData->setLang($lang); 35 | }else{ 36 | $userHandler->sendTranslatedMessage($player, 'system.language.notFound', ERROR); 37 | } 38 | 39 | $nametag = $data[1]; 40 | if(Nametag::testIsValidNametag($player, $nametag)){ 41 | $saveData->setNametag($nametag); 42 | } 43 | 44 | $userHandler->sendTranslatedMessage($player, "system.setting.complete", MESSAGE); 45 | } 46 | 47 | public function jsonSerialize(){ 48 | $userHandler = UserHandler::getInstance(); 49 | $saveData = $userHandler->getSaveDataByUser($this->player); 50 | $data = []; 51 | $data["type"] = "custom_form"; 52 | $data["title"] = "§9設定"; 53 | $contents =[]; 54 | 55 | $input1 = new \stdClass(); 56 | $input1->type = "dropdown"; 57 | $input1->text = TextFormat::GOLD . "言語"; 58 | $langList = Lang::getLangList(); 59 | $default = array_search($saveData->getLang(), $langList, true); 60 | $input1->default = ($default === false) ? 0 : $default; 61 | $input1->options = $langList; 62 | $contents[] = $input1; 63 | 64 | $input2 = new \stdClass(); 65 | $input2->type = "input"; 66 | $input2->text = TextFormat::GOLD . "ネームタグ"; 67 | $input2->default = $saveData->getNametag(); 68 | $contents[] = $input2; 69 | $data["content"] = $contents; 70 | return $data; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/TeleportForm.php: -------------------------------------------------------------------------------- 1 | respawn($player); 25 | UserHandler::getInstance()->sendTranslatedMessage($player, "command.spawn.success", MESSAGE); 26 | break; 27 | case 1: 28 | //UserHandler::getInstance()->respawn($player); 29 | //UserHandler::getInstance()->sendTranslatedMessage($player, "command.spawn.success", MESSAGE); 30 | break; 31 | case 2: 32 | $userHandler = UserHandler::getInstance(); 33 | $gameHandler = GameHandler::getInstance(); 34 | if(!$gameHandler->isGameRunning() or $gameHandler->isFinalPhase()){ 35 | $userHandler->sendTranslatedMessage($player, "game.join.fail", ERROR); 36 | return; 37 | } 38 | 39 | if($gameHandler->getGameInfo()->hasGamerData($player) and $gameHandler->getGameInfo()->getGamerData($player)->gamerType !== GamerData::GAMER_TYPE_WAITING){ 40 | $userHandler->sendTranslatedMessage($player, "game.join.fail", ERROR); 41 | return; 42 | } 43 | 44 | if($gameHandler->getGameInfo()->hasGamerData($player) and $gameHandler->getGameInfo()->getGamerData($player)->surrender !== 0){ 45 | $userHandler->sendTranslatedMessage($player, "game.join.fail", ERROR); 46 | return; 47 | } 48 | $gameHandler->getGameInfo()->initGamerData($player); 49 | $gameHandler->getGameInfo()->getGamerData($player)->gamerType = GamerData::GAMER_TYPE_CAUGHT; 50 | $player->teleport($gameHandler->getGameInfo()->field->getJailPoint()); 51 | $userHandler->sendTranslatedMessage($player, "game.join.success", MESSAGE); 52 | $userHandler->updateState($player); 53 | break; 54 | 55 | } 56 | } 57 | 58 | public function jsonSerialize(){ 59 | $data = []; 60 | $data["type"] = "form"; 61 | $data["title"] = "§9" . Lang::translate($this->lang, "form.teleport.title"); 62 | $data["content"] = Lang::translate($this->lang, "form.teleport.content"); 63 | $buttons =[]; 64 | 65 | $button1 = new \stdClass(); 66 | $button1->text = Lang::translate($this->lang, "form.teleport.lobby"); 67 | $buttons[] = $button1; 68 | 69 | $button2 = new \stdClass(); 70 | $button2->text = Lang::translate($this->lang, "form.teleport.lake"); 71 | $buttons[] = $button2; 72 | 73 | $button3 = new \stdClass(); 74 | $button3->text = Lang::translate($this->lang, "form.teleport.jail"); 75 | $buttons[] = $button3; 76 | 77 | $data["buttons"] = $buttons; 78 | return $data; 79 | } 80 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/UserForm.php: -------------------------------------------------------------------------------- 1 | lang = $lang; 17 | } 18 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/admin/AdminBanForm.php: -------------------------------------------------------------------------------- 1 | userList = array_values(Server::getInstance()->getOnlinePlayers()); 20 | parent::__construct($lang); 21 | } 22 | 23 | public function handleResponse(Player $player, $data): void{ 24 | if(!UserHandler::getInstance()->isAdmin($player)) return; 25 | if(!is_int($data)){ 26 | return; 27 | } 28 | if(!isset($this->userList[$data])){ 29 | return; 30 | } 31 | $user = $this->userList[$data]; 32 | $player->sendForm(new AdminUserOperationForm($this->lang, $user)); 33 | } 34 | 35 | public function jsonSerialize(){ 36 | $data = []; 37 | $data["type"] = "form"; 38 | $data["title"] = "§9オンラインユーザーリスト"; 39 | $data["content"] = "ユーザーを選択してください"; 40 | $buttons =[]; 41 | $userHandler = UserHandler::getInstance(); 42 | foreach($this->userList as $player){ 43 | $button = new \stdClass(); 44 | $button->text = $player->getDisplayName(); 45 | $buttons[] = $button; 46 | } 47 | 48 | $data["buttons"] = $buttons; 49 | return $data; 50 | } 51 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/admin/AdminUserOperationForm.php: -------------------------------------------------------------------------------- 1 | target = $target; 23 | parent::__construct($lang); 24 | } 25 | 26 | 27 | public function handleResponse(Player $player, $data): void{ 28 | if(!UserHandler::getInstance()->isAdmin($player)) return; 29 | if(!is_int($data)){ 30 | return; 31 | } 32 | switch($data){ 33 | case 0: 34 | $player->sendForm(new AdminEditUserSaveDataForm($this->lang, $this->target)); 35 | break; 36 | case 1: 37 | //$player->sendForm(new AdminEditUserGamerData($this->lang, $this->target)); 38 | break; 39 | case 2: 40 | $player->sendForm(new AdminEditUserGamerData($this->lang, $this->target)); 41 | break; 42 | } 43 | } 44 | 45 | public function jsonSerialize(){ 46 | $data = []; 47 | $data["type"] = "form"; 48 | $data["title"] = "§9ユーザー操作"; 49 | $data["content"] = $this->target->getName() . "さんの操作"; 50 | $buttons =[]; 51 | 52 | $button1 = new \stdClass(); 53 | $button1->text = "セーブデータの編集"; 54 | $buttons[] = $button1; 55 | 56 | $button2 = new \stdClass(); 57 | $button2->text = "一時データの編集"; 58 | $buttons[] = $button2; 59 | 60 | 61 | $button3 = new \stdClass(); 62 | $button3->text = "ゲームデータの編集"; 63 | $buttons[] = $button3; 64 | 65 | $button2 = new \stdClass(); 66 | $button2->text = "Ban"; 67 | $buttons[] = $button2; 68 | 69 | $data["buttons"] = $buttons; 70 | return $data; 71 | } 72 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/admin/operation/AdminEditUserGamerData.php: -------------------------------------------------------------------------------- 1 | target = $target; 23 | $gameHandler = GameHandler::getInstance(); 24 | $this->gameId = $gameHandler->getGameInfo()->gameId; 25 | parent::__construct($lang); 26 | } 27 | 28 | public function handleResponse(Player $player, $data): void{ 29 | if(!UserHandler::getInstance()->isAdmin($player)) return; 30 | if(!is_array($data) or count($data) !== 2){ 31 | // TODO messsage 32 | return; 33 | } 34 | $userHandler = UserHandler::getInstance(); 35 | $gameHandler = GameHandler::getInstance(); 36 | $gameInfo = $gameHandler->getGameInfo(); 37 | if($gameInfo === null){ 38 | return; 39 | } 40 | $gamerData = $gameInfo->getGamerData($this->target); 41 | $gamerType = (int) $data[0]; 42 | $surrenderCount = (int) $data[1]; 43 | $gamerData->gamerType = $gamerType; 44 | $gamerData->surrenderCountDown = $surrenderCount; 45 | $userHandler->sendTranslatedMessage($player, "system.admin.user.operation.success", MESSAGE); 46 | } 47 | 48 | public function jsonSerialize(){ 49 | $gameHandler = GameHandler::getInstance(); 50 | //if($this->player->isClosed()) return []; 51 | if(!$gameHandler->isGameRunning()) return []; 52 | if(!$gameHandler->getGameInfo()->hasGamerData($this->target)) return []; 53 | $gamerData = $gameHandler->getGameInfo()->getGamerData($this->target); 54 | $data = []; 55 | $data["type"] = "custom_form"; 56 | $data["title"] = "§9".$this->target->getName()."さんのゲームデータの編集"; 57 | $contents =[]; 58 | 59 | $input1 = new \stdClass(); 60 | $input1->type = "input"; 61 | $input1->text = TextFormat::GOLD . "ゲーマータイプ"; 62 | $input1->default = (string) $gamerData->gamerType; 63 | $contents[] = $input1; 64 | 65 | $input2 = new \stdClass(); 66 | $input2->type = "input"; 67 | $input2->text = TextFormat::GOLD . "自首カウントダウン"; 68 | $input2->default = (string) $gamerData->surrenderCountDown; 69 | $contents[] = $input2; 70 | $data["content"] = $contents; 71 | return $data; 72 | } 73 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/form/admin/operation/AdminEditUserSaveDataForm.php: -------------------------------------------------------------------------------- 1 | target = $target; 20 | parent::__construct($lang); 21 | } 22 | 23 | public function handleResponse(Player $player, $data): void{ 24 | if(!UserHandler::getInstance()->isAdmin($player)) return; 25 | if(!is_array($data) or count($data) !== 2){ 26 | // TODO messsage 27 | return; 28 | } 29 | $userHandler = UserHandler::getInstance(); 30 | $saveData = $userHandler->getSaveDataByUser($this->target); 31 | $lang = $data[0]; 32 | $nametag = $data[1]; 33 | $saveData->setLang($lang); 34 | $saveData->setNametag($nametag); 35 | $userHandler->sendTranslatedMessage($player, "system.admin.user.operation.success", MESSAGE); 36 | } 37 | 38 | public function jsonSerialize(){ 39 | $userHandler = UserHandler::getInstance(); 40 | //if($this->player->isClosed()) return []; 41 | $saveData = $userHandler->getSaveDataByUser($this->target); 42 | $data = []; 43 | $data["type"] = "custom_form"; 44 | $data["title"] = "§9".$this->target->getName()."さんのセーブデータの編集"; 45 | $contents =[]; 46 | 47 | $input1 = new \stdClass(); 48 | $input1->type = "input"; 49 | $input1->text = TextFormat::GOLD . "言語"; 50 | $input1->default = $saveData->getLang(); 51 | $contents[] = $input1; 52 | 53 | $input2 = new \stdClass(); 54 | $input2->type = "input"; 55 | $input2->text = TextFormat::GOLD . "ネームタグ"; 56 | $input2->default = $saveData->getNametag(); 57 | $contents[] = $input2; 58 | $data["content"] = $contents; 59 | return $data; 60 | } 61 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/game/GameHandler.php: -------------------------------------------------------------------------------- 1 | database = $database; 37 | } 38 | 39 | /** 40 | * ゲームの待機を開始します 41 | */ 42 | public function startWaiting(){ 43 | $info = new GameInfo(); 44 | $info->status = GameInfo::GAME_STATUS_WAITING; 45 | $info->time = 0; 46 | $info->maxTime = 30; 47 | $this->gameInfo = $info; 48 | } 49 | 50 | public function stopGame(){ 51 | $this->gameInfo = null; 52 | } 53 | 54 | /** 55 | * ゲームを開始します 56 | */ 57 | public function startGame(){ 58 | if(!$this->gameInfo instanceof GameInfo){ 59 | $this->gameInfo = new GameInfo(); 60 | } 61 | $gameId = $this->database->putRunForMoneyEntry(new RunForMoneyEntryType(null, "s")); 62 | if($gameId === -1){ 63 | return; 64 | } 65 | $this->gameInfo->gameId = $gameId; 66 | $field = FieldLoader::getRandomField(); 67 | $this->gameInfo->field = $field; 68 | $this->gameInfo->maxTime = $field->getGameTime(); 69 | $this->gameInfo->status = GameInfo::GAME_STATUS_RUNNING; 70 | 71 | /** @var UserHandler $userHandler */ 72 | $userHandler = UserHandler::getInstance(); 73 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 74 | if($userHandler->getTempData($player)->isAutoJoinGame){ 75 | $this->gameInfo->initGamerData($player); 76 | $this->gameInfo->getGamerData($player)->gamerType = GamerData::GAMER_TYPE_RUNNER; 77 | } 78 | } 79 | 80 | $gamers = $this->getAllGamerPlayers(); 81 | $hunterCount = 0; 82 | $betrayerCount = 0; 83 | while(($hunterCount+$betrayerCount) < (int) ceil(count($gamers)/10)){ 84 | foreach($gamers as $gamer){ 85 | if($this->gameInfo->getGamerData($gamer)->gamerType === GamerData::GAMER_TYPE_RUNNER){ 86 | if(mt_rand(0, 25) === 20){ 87 | $this->gameInfo->getGamerData($gamer)->gamerType = GamerData::GAMER_TYPE_HUNTER; 88 | $hunterCount++; 89 | }elseif(mt_rand(0, 1000) === 300){ 90 | $this->gameInfo->getGamerData($gamer)->gamerType = GamerData::GAMER_TYPE_BETRAYAL; 91 | $betrayerCount++; 92 | } 93 | } 94 | } 95 | } 96 | 97 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 98 | $userHandler->sendTranslatedMessage($player, "game.start1", INFO, [$this->gameInfo->maxTime]); 99 | $fieldName = Lang::translate($userHandler->getSaveDataByUser($player)->getLang(), $field->getNameLangCode()); 100 | $userHandler->sendTranslatedMessage($player, "game.start2", INFO, [$fieldName, $hunterCount, 0]); 101 | } 102 | 103 | foreach($gamers as $gamer){ 104 | switch($this->gameInfo->getGamerData($gamer)->gamerType){ 105 | case GamerData::GAMER_TYPE_RUNNER: 106 | $gamer->getEffects()->add(new EffectInstance(VanillaEffects::INVISIBILITY(), 40 * 20, 1, false)); 107 | $gamer->getEffects()->add(new EffectInstance(VanillaEffects::SPEED(), 20 * 20, 1, false)); 108 | $gamer->teleport($field->getRunnerRandomSpawnPoint()); 109 | $userHandler->sendTranslatedMessage($gamer, "game.start.runner.message", MESSAGE); 110 | $userHandler->sendTranslatedTitle($gamer, "game.start.runner.title", null, TextFormat::RED, null); 111 | break; 112 | case GamerData::GAMER_TYPE_HUNTER: 113 | $gamer->teleport($field->getHunterSpawnPoint()); 114 | $userHandler->sendTranslatedMessage($gamer, "game.start.hunter.message", MESSAGE); 115 | $userHandler->sendTranslatedTitle($gamer, "game.start.hunter.title", null, TextFormat::RED, null); 116 | break; 117 | case GamerData::GAMER_TYPE_BETRAYAL: 118 | $gamer->teleport($field->getBetrayerSpawnPoint()); 119 | $userHandler->sendTranslatedMessage($gamer, "game.start.betrayer.1", MESSAGE); 120 | $userHandler->sendTranslatedMessage($gamer, "game.start.betrayer.2", MESSAGE); 121 | $userHandler->sendTranslatedMessage($gamer, "game.start.betrayer.3", MESSAGE); 122 | $userHandler->sendTranslatedMessage($gamer, "game.start.betrayer.4", MESSAGE); 123 | $userHandler->sendTranslatedTitle($gamer, "game.start.betrayer.title", null, TextFormat::RED, null); 124 | break; 125 | } 126 | $gamer->getWorld()->addSound($gamer->getLocation(), new PortalSound(), [$gamer]); 127 | $userHandler->updateState($gamer); 128 | } 129 | 130 | } 131 | 132 | /** 133 | * @return Player[] 134 | */ 135 | public function getAllGamerPlayers() : array{ 136 | $result = []; 137 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 138 | if($this->gameInfo->hasGamerData($player)){ 139 | $result[] = $player; 140 | } 141 | } 142 | return $result; 143 | } 144 | 145 | public function finishGame(){ 146 | /** @var UserHandler $userHandler */ 147 | $userHandler = UserHandler::getInstance(); 148 | $clearUsernameList = ""; 149 | foreach($this->getAllGamerPlayers() as $gamer){ 150 | $gamerData = $this->gameInfo->getGamerData($gamer); 151 | switch($gamerData->gamerType){ 152 | case GamerData::GAMER_TYPE_BETRAYAL: 153 | case GamerData::GAMER_TYPE_RUNNER: 154 | $gamerData->clear++; 155 | $clearUsernameList .= $gamer->getName() ." "; 156 | $this->database->putUserMoneyTransaction( 157 | new UserMoneyTransactionType( 158 | null, 159 | $gamerData->userId, 160 | UserMoneyTransactionType::TYPE_GAME_CLEAR, 161 | $gamerData->money, 162 | "GameId:" . $this->gameInfo->gameId 163 | ) 164 | ); 165 | break; 166 | case GamerData::GAMER_TYPE_HUNTER: 167 | break; 168 | } 169 | } 170 | 171 | $xpLevel = mt_rand(1,100); 172 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 173 | $userHandler->sendTranslatedMessage($player, "game.finish1", INFO); 174 | $userHandler->sendTranslatedMessage($player, "game.finish2", INFO); 175 | $player->sendMessage(INFO . ">> " . $clearUsernameList); 176 | $player->getWorld()->addSound($player->getLocation(), new XpLevelUpSound($xpLevel), [$player]); 177 | } 178 | 179 | foreach($this->gameInfo->gamerDataRecords as $gamerDataRecord){ 180 | $this->database->putUserRunForMoneyResult( 181 | new UserRunForMoneyResultType( 182 | null, 183 | $gamerDataRecord->userId, 184 | $this->gameInfo->gameId, 185 | $gamerDataRecord->clear, 186 | $gamerDataRecord->death, 187 | $gamerDataRecord->catch, 188 | $gamerDataRecord->surrender, 189 | $gamerDataRecord->revival, 190 | ) 191 | ); 192 | } 193 | 194 | foreach($this->getAllGamerPlayers() as $player){ 195 | $userHandler->respawn($player); 196 | } 197 | 198 | $this->gameInfo = null; 199 | $this->startWaiting(); 200 | } 201 | 202 | /** 203 | * 1秒毎に呼び出される 204 | */ 205 | public function second(){ 206 | $userHandler = UserHandler::getInstance(); 207 | if($this->gameInfo instanceof GameInfo){ 208 | switch($this->gameInfo->status){ 209 | case GameInfo::GAME_STATUS_WAITING: 210 | $this->gameInfo->time++; 211 | $restTime = $this->gameInfo->maxTime - $this->gameInfo->time; 212 | switch($restTime){ 213 | case 0: 214 | $this->startGame(); 215 | break; 216 | case 1: 217 | case 2: 218 | case 3: 219 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 220 | $player->getWorld()->addSound($player->getLocation(), new ClickSound(1.5), [$player]); 221 | } 222 | break; 223 | } 224 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 225 | $userHandler->sendTranslatedTip($player, "game.waiting.countdown", INFO, [$this->gameInfo->maxTime - $this->gameInfo->time]); 226 | } 227 | break; 228 | case GameInfo::GAME_STATUS_RUNNING: 229 | foreach($this->getAllGamerPlayers() as $gamer){ 230 | $gamerData = $this->gameInfo->getGamerData($gamer); 231 | switch($gamerData->gamerType){ 232 | case GamerData::GAMER_TYPE_RUNNER: 233 | $gamerData->money += $this->gameInfo->moneyPerSecond; 234 | if($gamerData->surrenderCountDown > 0){ 235 | $gamerData->surrenderCountDown--; 236 | if($gamerData->surrenderCountDown === 0){ 237 | $this->successSurrender($gamer); 238 | }else{ 239 | $userHandler->sendTranslatedMessage($gamer, 'game.surrender.countdown', MESSAGE, [$gamerData->surrenderCountDown]); 240 | } 241 | } 242 | break; 243 | case GamerData::GAMER_TYPE_HUNTER: 244 | break; 245 | } 246 | } 247 | $this->gameInfo->time++; 248 | if($this->gameInfo->maxTime === $this->gameInfo->time){ 249 | $this->finishGame(); 250 | return; 251 | } 252 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 253 | $userHandler->sendTranslatedTip($player, "game.running.countdown", INFO, [$this->gameInfo->maxTime - $this->gameInfo->time]); 254 | } 255 | break; 256 | } 257 | } 258 | } 259 | 260 | public function applySurrender(Player $player){ 261 | $userHandler = UserHandler::getInstance(); 262 | $gamerData = $this->gameInfo->getGamerData($player); 263 | $gamerData->surrenderCountDown = 10; 264 | $userHandler->sendTranslatedMessage($player, 'game.surrender.apply', MESSAGE); 265 | } 266 | 267 | public function successSurrender(Player $player){ 268 | $userHandler = UserHandler::getInstance(); 269 | $gamerData = $this->gameInfo->getGamerData($player); 270 | $userHandler->sendTranslatedMessage($player, 'game.surrender.success', MESSAGE, [$gamerData->money]); 271 | $this->database->putUserMoneyTransaction( 272 | new UserMoneyTransactionType( 273 | null, 274 | $userHandler->getUserIdByUser($player), 275 | UserMoneyTransactionType::TYPE_GAME_SURRENDER, 276 | $gamerData->money, 277 | "GameId:" . $this->gameInfo->gameId 278 | ) 279 | ); 280 | $gamerData->surrender++; 281 | $gamerData->money = 0; 282 | $userHandler->respawn($player); 283 | } 284 | 285 | public function revival(Player $player){ 286 | $userHandler = UserHandler::getInstance(); 287 | $gamerData = $this->gameInfo->getGamerData($player); 288 | $userHandler->sendTranslatedMessage($player, 'game.revival.success', MESSAGE); 289 | $gamerData->clear++; 290 | $gamerData->gamerType = GamerData::GAMER_TYPE_RUNNER; 291 | $player->teleport($this->gameInfo->field->getRunnerRandomSpawnPoint()); 292 | $userHandler->updateState($player); 293 | } 294 | 295 | public function touchPlayer(Player $player, Player $attacker){ 296 | if(!$this->gameInfo instanceof GameInfo or !$this->gameInfo->hasGamerData($player) or !$this->gameInfo->hasGamerData($attacker)){ 297 | return; 298 | } 299 | /** @var UserHandler $userHandler */ 300 | $userHandler = UserHandler::getInstance(); 301 | $playerGamerType = $this->gameInfo->getGamerData($player)->gamerType; 302 | $attackerGamerType = $this->gameInfo->getGamerData($attacker)->gamerType; 303 | $runnerAndHunter = ($playerGamerType === GamerData::GAMER_TYPE_RUNNER and $attackerGamerType === GamerData::GAMER_TYPE_HUNTER); 304 | $runnerAndBetrayer = ($playerGamerType === GamerData::GAMER_TYPE_RUNNER and $attackerGamerType === GamerData::GAMER_TYPE_BETRAYAL); 305 | $betrayerAndHunter = ($playerGamerType === GamerData::GAMER_TYPE_BETRAYAL and $attackerGamerType === GamerData::GAMER_TYPE_HUNTER); 306 | 307 | if($runnerAndHunter or $runnerAndBetrayer or $betrayerAndHunter){ 308 | $this->gameInfo->getGamerData($player)->death++; 309 | $this->gameInfo->getGamerData($attacker)->catch++; 310 | $this->database->putUserMoneyTransaction( 311 | new UserMoneyTransactionType( 312 | null, 313 | $userHandler->getUserIdByUser($attacker), 314 | UserMoneyTransactionType::TYPE_GAME_CATCH, 315 | 30000, 316 | "GameId:" . $this->gameInfo->gameId 317 | ) 318 | ); 319 | $entity = new LightningBolt($player->getLocation()); 320 | $entity->spawnToAll(); 321 | switch(true){ 322 | case $runnerAndHunter; 323 | $userHandler->sendTranslatedMessage($attacker, "game.catch.message", MESSAGE, [$player->getName()]); 324 | $userHandler->sendTranslatedMessage($player, "game.death.byHunter", MESSAGE); 325 | foreach(Server::getInstance()->getOnlinePlayers() as $online){ 326 | $userHandler->sendTranslatedMessage($online, "game.catch.runnerAndHunter", ERROR, [$player->getName(), $attacker->getName()]); 327 | } 328 | break; 329 | case $runnerAndBetrayer; 330 | $userHandler->sendTranslatedMessage($attacker, "game.catch.message", MESSAGE, []); 331 | $userHandler->sendTranslatedMessage($player, "game.death.byBetrayer", MESSAGE); 332 | foreach(Server::getInstance()->getOnlinePlayers() as $online){ 333 | $userHandler->sendTranslatedMessage($online, "game.catch.runnerAndBetrayer", ERROR, [$player->getName()]); 334 | } 335 | break; 336 | case $betrayerAndHunter; 337 | $userHandler->sendTranslatedMessage($attacker, "game.catch.message", MESSAGE, [$player->getName()]); 338 | $userHandler->sendTranslatedMessage($player, "game.death.byHunter", MESSAGE); 339 | foreach(Server::getInstance()->getOnlinePlayers() as $online){ 340 | $userHandler->sendTranslatedMessage($online, "game.catch.betrayerAndHunter", ERROR, [$player->getName(), $attacker->getName()]); 341 | } 342 | break; 343 | } 344 | if($this->isFinalPhase()){ 345 | $userHandler->respawn($player); 346 | }else{ 347 | $this->gameInfo->getGamerData($player)->gamerType = GamerData::GAMER_TYPE_CAUGHT; 348 | $player->teleport($this->getGameInfo()->field->getJailPoint()); 349 | $userHandler->updateState($player); 350 | } 351 | } 352 | } 353 | 354 | /** 355 | * @return GameInfo|null 356 | */ 357 | public function getGameInfo() : GameInfo{ 358 | return $this->gameInfo; 359 | } 360 | 361 | /** 362 | * @return bool 363 | */ 364 | public function isGameRunning() : bool{ 365 | return $this->gameInfo instanceof GameInfo && $this->gameInfo->status === GameInfo::GAME_STATUS_RUNNING; 366 | } 367 | 368 | /** 369 | * ゲームの残り時間がn秒以下(ファイナルフェーズ)かどうかを判定する 370 | * @return bool 371 | */ 372 | public function isFinalPhase() : bool{ 373 | return $this->isGameRunning() and ($this->gameInfo->maxTime - $this->gameInfo->time) <= GameInfo::FINAL_PHASE_REST_TIME; 374 | } 375 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/game/GameInfo.php: -------------------------------------------------------------------------------- 1 | getName(); 46 | } 47 | $gamerData = new GamerData(); 48 | $gamerData->userId = UserHandler::getInstance()->getUserIdByUser($user); 49 | $this->gamerDataRecords[strtolower($user)] = $gamerData; 50 | } 51 | 52 | /** 53 | * @param Player|string $user 54 | * @return GamerData 55 | */ 56 | public function getGamerData($user) : GamerData{ 57 | if($user instanceof Player){ // $userがPlayerオブジェクトの場合 58 | $user = $user->getName(); 59 | } 60 | return $this->gamerDataRecords[strtolower($user)]; 61 | } 62 | 63 | public function hasGamerData($user) : bool{ 64 | if($user instanceof Player){ // $userがPlayerオブジェクトの場合 65 | $user = $user->getName(); 66 | } 67 | return isset($this->gamerDataRecords[strtolower($user)]); 68 | } 69 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/game/GamerData.php: -------------------------------------------------------------------------------- 1 | searchSpawnPointFromMapData("arashiyama.json"); 21 | } 22 | 23 | public function getNameLangCode() : string { 24 | return "game.field.arashiyama.name"; 25 | } 26 | 27 | public function getRunnerRandomSpawnPoint() : Vector3 { 28 | return $this->runnerSpawnPoints[array_rand($this->runnerSpawnPoints)]; 29 | } 30 | 31 | public function getJailPoint(): Vector3{ 32 | return new Vector3(1145, 6, -360); 33 | } 34 | 35 | public function getGameTime() : int{ 36 | return 60 * 5 + mt_rand(-60, 60); 37 | } 38 | 39 | public function getHunterSpawnPoint(): Vector3{ 40 | return new Vector3(mt_rand(964, 968), 1, -393 + mt_rand(0, 1)); 41 | } 42 | 43 | public function getBetrayerSpawnPoint(): Vector3{ 44 | return $this->runnerSpawnPoints[array_rand($this->runnerSpawnPoints)]; 45 | } 46 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/game/field/Edo.php: -------------------------------------------------------------------------------- 1 | searchSpawnPointFromMapData("edo.json"); 21 | } 22 | public function getNameLangCode(): string { 23 | return "game.field.edo.name"; 24 | } 25 | 26 | public function getRunnerRandomSpawnPoint(): Vector3 { 27 | return $this->runnerSpawnPoints[array_rand($this->runnerSpawnPoints)]; 28 | } 29 | 30 | public function getJailPoint(): Vector3{ 31 | return new Vector3(1120, 46, -894); 32 | } 33 | 34 | public function getGameTime() : int { 35 | return 60 * 5 + mt_rand(-60, 60); 36 | } 37 | 38 | public function getRandomMission(){ 39 | 40 | } 41 | 42 | public function getHunterSpawnPoint(): Vector3{ 43 | return new Vector3(933, 8, -719); 44 | } 45 | 46 | public function getBetrayerSpawnPoint(): Vector3{ 47 | return new Vector3(1107, 76, -881); 48 | } 49 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/game/field/Field.php: -------------------------------------------------------------------------------- 1 | getWorldManager()->getDefaultWorld(); 34 | $mapData = $this->loadMapData($fileName); 35 | $xOffset = $mapData["xOffset"]; 36 | $zOffset = $mapData["zOffset"]; 37 | $xSize = $mapData["xSize"]; 38 | $zSize = $mapData["zSize"]; 39 | foreach($mapData["data"] as $x => $zList){ 40 | if($x <= 15 or $x >= $xSize-15){ 41 | continue; 42 | } 43 | foreach($zList as $z => $block){ 44 | if($z <= 15 or $z >= $zSize-15){ 45 | continue; 46 | } 47 | $y = $block[0]; 48 | $id = $block[1]; 49 | $meta = $block[2]; 50 | switch($id){ 51 | case BlockLegacyIds::GRASS_PATH: 52 | case BlockLegacyIds::GRASS: 53 | case BlockLegacyIds::GRAVEL: 54 | case BlockLegacyIds::SAND: 55 | $this->runnerSpawnPoints[] = new Vector3($x+$xOffset, $y + 2, $z+$zOffset); 56 | break; 57 | } 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/game/mission/Mission.php: -------------------------------------------------------------------------------- 1 | isGameRunning()){ 23 | $userHandler->sendTranslatedMessage($player, "item.use.fail.outOfGame", ERROR); 24 | return ItemUseResult::FAIL(); 25 | } 26 | $gamerData = $gameHandler->getGameInfo()->getGamerData($player); 27 | $gamerType = $gamerData->gamerType; 28 | if($gamerType !== GamerData::GAMER_TYPE_RUNNER and $gamerType !== GamerData::GAMER_TYPE_BETRAYAL){ 29 | $userHandler->sendTranslatedMessage($player, "item.use.fail.onlyForRunner", ERROR); 30 | return ItemUseResult::FAIL(); 31 | } 32 | 33 | if($gamerData->surrenderCountDown !== -1){ 34 | $userHandler->sendTranslatedMessage($player, "game.surrender.alreadyApplied", ERROR); 35 | return ItemUseResult::FAIL(); 36 | } 37 | $gameHandler->applySurrender($player); 38 | $this->pop(); 39 | return ItemUseResult::SUCCESS(); 40 | } 41 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/item/DoorKey.php: -------------------------------------------------------------------------------- 1 | sendTranslatedMessage($player, "item.use.door_key.broken", MESSAGE); 23 | }else{ 24 | $userHandler->sendTranslatedMessage($player, "item.use.door_key.success", MESSAGE); 25 | } 26 | return ItemUseResult::SUCCESS(); 27 | } 28 | return ItemUseResult::NONE(); 29 | } 30 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/item/DoorKeyPlus.php: -------------------------------------------------------------------------------- 1 | isGameRunning()){ 24 | $userHandler->sendTranslatedMessage($player, "item.use.fail.outOfGame", ERROR); 25 | return ItemUseResult::FAIL(); 26 | } 27 | if(!$gameHandler->getGameInfo()->hasGamerData($player) or $gameHandler->getGameInfo()->getGamerData($player)->gamerType !== GamerData::GAMER_TYPE_RUNNER){ 28 | $userHandler->sendTranslatedMessage($player, "item.use.fail.onlyForRunner", ERROR); 29 | return ItemUseResult::FAIL(); 30 | } 31 | 32 | switch(mt_rand(0, 3)){ 33 | case 0: 34 | $player->getEffects()->add(new EffectInstance(VanillaEffects::INVISIBILITY(), 10 * 20, 1, false)); 35 | $userHandler->sendTranslatedMessage($player, "item.use.success.ekurea.1", MESSAGE); 36 | break; 37 | case 1: 38 | $player->getEffects()->add(new EffectInstance(VanillaEffects::INVISIBILITY(), 15 * 20, 1, false)); 39 | $userHandler->sendTranslatedMessage($player, "item.use.success.ekurea.2", MESSAGE); 40 | break; 41 | case 2: 42 | $player->getEffects()->add(new EffectInstance(VanillaEffects::INVISIBILITY(), 30 * 20, 1, false)); 43 | $userHandler->sendTranslatedMessage($player, "item.use.success.ekurea.3", MESSAGE); 44 | break; 45 | case 3: 46 | $player->getEffects()->add(new EffectInstance(VanillaEffects::INVISIBILITY(), 5 * 20, 1, false)); 47 | $userHandler->sendTranslatedMessage($player, "item.use.success.ekurea.4", MESSAGE); 48 | break; 49 | } 50 | $this->pop(); 51 | return ItemUseResult::SUCCESS(); 52 | } 53 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/item/Emerald.php: -------------------------------------------------------------------------------- 1 | isGameRunning()){ 25 | $userHandler->sendTranslatedMessage($player, "item.use.fail.outOfGame", ERROR); 26 | return ItemUseResult::FAIL(); 27 | } 28 | 29 | if(!$gameHandler->getGameInfo()->hasGamerData($player)){ 30 | $userHandler->sendTranslatedMessage($player, "item.use.fail.onlyForGamer", ERROR); 31 | return ItemUseResult::FAIL(); 32 | } 33 | 34 | $gamerType = $gameHandler->getGameInfo()->getGamerData($player)->gamerType; 35 | if($gamerType !== GamerData::GAMER_TYPE_RUNNER and $gamerType !== GamerData::GAMER_TYPE_HUNTER and $gamerType !== GamerData::GAMER_TYPE_BETRAYAL){ 36 | $userHandler->sendTranslatedMessage($player, "item.use.fail.onlyForGamer", ERROR); 37 | return ItemUseResult::FAIL(); 38 | } 39 | 40 | $player->getEffects()->add(new EffectInstance(VanillaEffects::SPEED(), 10 * 20, 1, false)); 41 | $userHandler->sendTranslatedMessage($player, "item.use.emerald", MESSAGE); 42 | $this->pop(); 43 | return ItemUseResult::SUCCESS(); 44 | } 45 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/item/ExMedicine1.php: -------------------------------------------------------------------------------- 1 | sendForm(new MenuForm(UserHandler::getInstance()->getSaveDataByUser($player)->getLang(), $player)); 20 | return ItemUseResult::SUCCESS(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/item/NetGun.php: -------------------------------------------------------------------------------- 1 | isGameRunning()){ 24 | $userHandler->sendTranslatedMessage($player, "item.use.fail.outOfGame", ERROR); 25 | return ItemUseResult::FAIL(); 26 | } 27 | 28 | if(!$gameHandler->getGameInfo()->hasGamerData($player)){ 29 | $userHandler->sendTranslatedMessage($player, "item.use.fail.onlyForGamer", ERROR); 30 | return ItemUseResult::FAIL(); 31 | } 32 | 33 | $gamerType = $gameHandler->getGameInfo()->getGamerData($player)->gamerType; 34 | if($gamerType !== GamerData::GAMER_TYPE_RUNNER and $gamerType !== GamerData::GAMER_TYPE_HUNTER and $gamerType !== GamerData::GAMER_TYPE_BETRAYAL){ 35 | $userHandler->sendTranslatedMessage($player, "item.use.fail.onlyForGamer", ERROR); 36 | return ItemUseResult::FAIL(); 37 | } 38 | 39 | $player->getEffects()->add(new EffectInstance(VanillaEffects::JUMP_BOOST(), 10 * 20, 1, false)); 40 | $userHandler->sendTranslatedMessage($player, "item.use.rabbitFoot", MESSAGE); 41 | $this->pop(); 42 | return ItemUseResult::SUCCESS(); 43 | } 44 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/item/Soba.php: -------------------------------------------------------------------------------- 1 | getUserIdByUser($player); 23 | $player->sendMessage(MESSAGE.">> 年越しそばを食べた!!!"); 24 | $amount = mt_rand(20000, 60000) * 10; 25 | $userHandler->addUserMoney($userId, $amount, UserMoneyTransactionType::TYPE_ITEM_SOBA); 26 | $player->sendMessage("§6>> " . $amount . "メタお年玉をもらった!!"); 27 | $player->sendMessage("§d§l>> 明けましておめでとうございます!!!"); 28 | $player->sendMessage("§c>> 今年もかめたんサーバーをよろしくお願いします!"); 29 | $this->pop(); 30 | 31 | for($x=0;$x<10;$x++){ 32 | for($z=0;$z<10;$z++){ 33 | $particle = new DustParticle(new Color(mt_rand(120,250),mt_rand(120,250),mt_rand(120,250))); 34 | $player->getWorld()->addParticle($player->getLocation()->add(rand(-20,20)/10,rand(-20,20)/10,rand(-20,20)/10), $particle); 35 | } 36 | } 37 | return ItemUseResult::SUCCESS(); 38 | } 39 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/item/Tejyou.php: -------------------------------------------------------------------------------- 1 | $value){ 50 | self::$lang[$langCode][$key] = $value; 51 | } 52 | } 53 | 54 | public static function translate(string $langCode, string $text, array $inputs=[]) : string { 55 | $translated = @self::$lang[$langCode][$text]; 56 | if($translated === null) { 57 | return $text . ((count($inputs) !== 0) ? (" (" . implode(",", $inputs) . ")") : ""); 58 | }else{ 59 | $count = 0; 60 | foreach($inputs as $input){ 61 | $translated = str_replace("{%$count}", (string) $input, $translated); 62 | $count++; 63 | } 64 | return $translated; 65 | } 66 | } 67 | 68 | public static function getLangList(){ 69 | return array_keys(self::$lang); 70 | } 71 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/lang/locale/jpn.ini: -------------------------------------------------------------------------------- 1 | language.code=jpn 2 | game.restSecond=制限時間まであと{%0}秒です 3 | game.restMinutesSeconds=制限時間まであと{%0}分{%1}秒です 4 | game.start1=これよりゲームを開始します、制限時間は{%0}秒です 5 | game.start2=フィールドは{%0}、ハンターは{%1}体、かめレーザーは{%2}体です 6 | game.start.runner.message=あなたは逃走者です、ハンターからにげきろう 7 | game.start.runner.title=ハンターから逃げ切れ! 8 | game.start.hunter.message=あなたはハンターだ、逃走者をつかまえよう 9 | game.start.hunter.title=逃走者をつかまえろ! 10 | game.start.betrayer.1=あなたは§4裏切り者§bになった! 11 | game.start.betrayer.2=裏切り者は逃走者でありハンターである 12 | game.start.betrayer.3=あなたは逃走者を捕まえられ、ハンターはあなたを捕まえることもできる 13 | game.start.betrayer.4=外見は逃走者と何ら変わりはない、頑張ってくれたまえ 14 | game.start.betrayer.title=ハンターから逃げ逃走者を捕まえろ! 15 | game.join.success=ゲームに途中参加しました 16 | game.join.fail=現在はゲームに途中参加できません 17 | game.finish1=ゲームが終了しました 18 | game.finish2=逃走成功者は以下の通りです 19 | game.waiting.countdown=ゲーム開始まであと{%0}秒 20 | game.running.countdown=ゲーム終了まであと{%0}秒 21 | game.death.byHunter=ハンターに確保された 22 | game.death.byBetrayer=裏切り者に確保された 23 | game.catch.runnerAndHunter={%0}が{%1}に確保された 24 | game.catch.runnerAndBetrayer={%0}が裏切り者に確保された 25 | game.catch.betrayerAndHunter=裏切り者の{%0}が{$1}に確保された 26 | game.catch.message={%0}を確保した 27 | game.surrender.finalPhase=残り時間が少ないため自首できません 28 | game.surrender.notRunner=逃走者ではないので自首できません 29 | game.surrender.alreadyApplied=既に自首申請済みです 30 | game.surrender.apply=自首を申請しました 31 | game.surrender.countdown=あと{%0}秒で自首成立です 32 | game.surrender.success=自首成立しました、{%0}メタ受け取りました 33 | game.surrender.broadcast={%0}さんが自首しました 34 | game.revival.success=復活しました! 35 | game.field.sample.name=サンプルフィールド 36 | game.field.arashiyama.name=嵐山ワールド 37 | game.field.edo.name=江戸ワールド 38 | command.ban.usage=/ban <プレイヤー> <理由> 39 | command.ban.targetNotFound=ターゲットの{%0}が見つかりませんでした 40 | command.ban.success={%0}を{%1}でBanしました 41 | command.cleanEntity.execute={%0}体のEntityを削除しました 42 | command.game.startCountdown=ゲーム開始までのカウントダウンを開始します 43 | command.game.stop=ゲームが停止されました 44 | command.scanWorldSurface.usage=/scan-world-surface 45 | command.setBaseBlock.success=ベースブロックを設置しました 46 | command.soundTest.usage=Usage : /soundtest 47 | command.nametag.usage=Usage : /nametag 48 | command.removeInventory.confirm=インベントリーを空にします、実行する場合はもう一度コマンドを実行してください 49 | command.removeInventory.success=インベントリーを空にしました 50 | command.spawn.success=リスポーンしました 51 | item.use.fail.outOfGame=ゲーム時間外にはアイテムは使用できません 52 | item.use.fail.onlyForRunner=逃走者以外は使用できません 53 | item.use.fail.onlyForGamer=ゲームに参加中のプレイヤー以外使用できません 54 | item.use.emerald=エメラルドの力で速く走れるようになった! 55 | item.use.rabbitFoot=うさぎの力で高く飛べるようになった! 56 | item.use.success.ekurea.1=腐ったエクレアを食べた! 57 | item.use.success.ekurea.2=かなり腐ったエクレアを食べた! 58 | item.use.success.ekurea.3=すごいエクレアを食べた! 59 | item.use.success.ekurea.4=OPのエクレア様にかみついた!がぶっ!! 60 | item.use.door_key.broken=鍵がこれわてしまった 61 | item.use.door_key.success=鍵を使ってドアを開けた 62 | item.apple.name=りんご 63 | item.apple.description=おいしいよ 64 | item.cooked_beef.name=調理された牛肉 65 | item.cooked_beef.description=空腹を回復できます 66 | item.emerald.name=エメラルド 67 | item.emerald.description=数秒間早く走れます 68 | item.rabbit_foot.name=ウサギのあし 69 | item.rabbit_foot.description=数秒間高くジャンプできます 70 | item.ekurea.name=エクレア 71 | item.ekurea.description=数秒間透明になれます 72 | item.magical_medicine.name=魔法の薬 73 | item.magical_medicine.description=逃走者からハンターになれます 74 | item.vaccine.name=ワクチン 75 | item.vaccine.description=ハンターから逃走者になれます 76 | item.net_gun.name=ネットガン 77 | item.net_gun.description=ネットを発射してハンターを足止めできます 78 | item.ice_gun.name=冷凍銃 79 | item.ice_gun.description=ハンターを凍らせることができます 80 | item.revival_medicine.name=完全復活薬 81 | item.revival_medicine.description=囚人が復活できます 82 | item.cell_phone.name=携帯電話 83 | item.cell_phone.description=どこでも自首できます 84 | item.door_key.name=ドアの鍵 85 | item.door_key.description=鉄の扉を開けることができます 86 | form.invalid.message=入力した値が不正です 87 | form.menu.title=メニュー 88 | form.menu.content=メニューを選択してください 89 | form.menu.teleport=テレポート 90 | form.menu.shop=ショップ 91 | form.menu.setting=設定 92 | form.menu.passwordRegister=パスワード登録/変更 93 | form.menu.logout=ログアウト 94 | form.menu.admin=管理者メニュー 95 | form.teleport.title=テレポート 96 | form.teleport.content=テレポートしたい場所を選択してください 97 | form.teleport.lobby=ロビー(リスポーン) 98 | form.teleport.lake=湖 99 | form.teleport.jail=牢獄(途中参加) 100 | form.itemShop.title=アイテムショップ 101 | form.itemBuy.title=アイテム購入 102 | form.itemBuy.count=個数 103 | form.passwordRegister.title=パスワード登録 104 | form.admin.title=管理者メニュー 105 | form.admin.content=メニューを選択してください 106 | form.admin.ban=Ban 107 | form.admin.teleport=テレポート 108 | form.admin.user_list=オンラインユーザーリスト 109 | system.admin.user.operation.success=ユーザーの操作に成功しました 110 | system.ban.broadcast={%0}が{%1}を{%2}でBanしました 111 | system.chat.consecutivePosts=チャットの連続投稿はできません 112 | system.chat.tooLong=チャットが長すぎます 113 | system.server.down=サーバーが終了しました、またお越しください 114 | system.abyss.respawn=奈落に落ちたためリスポーンしました 115 | system.password.notMatch=パスワードの確認と一致しませんでした 116 | system.password.hashing=パスワードをハッシュ化しています... 117 | system.password.respawn=パスワードを登録しました [{%0}] 118 | system.password.notRegister=パスワードを登録しませんでした 119 | system.password.always=パスワードはいつでも登録/変更できます 120 | system.item.buy.no_money=メタが足りません... 121 | system.item.buy.no_space=インベントリーに十分な空きがありません... 122 | system.item.buy.success=アイテムを購入しました! 123 | system.nametag.tooLong=ネームタグが長すぎます 124 | system.nametag.reset=ネームタグをリセットしました 125 | system.nametag.invalid=ネームタグに無効な文字が含まれています 126 | system.nametag.success=ネームタグの変更に成功しました [{%0}] 127 | system.setting.complete=設定を完了しました 128 | system.language.notFound=言語が見つかりませんでした 129 | server.regularly.0=チャンクの表示距離はスペックに余裕がある場合は16を推奨しています 130 | server.regularly.1=挨拶は、心をつなぐ、おまじない 131 | server.regularly.2=本サーバーにはDiscordやLobiグループやがあります。ぜひ参加してください! 132 | server.regularly.3=サーバーのHPではアイテムを安く買えるのだ 133 | server.regularly.4=透明になっていても、持っているアイテムや足跡でハンターに気づかれてしまいます 134 | server.regularly.5=ホームページは定期的に見たほうがいいかめ 135 | server.regularly.6=重い、チャンクが抜けると感じられる方は設定から高画質をoffにしてください 136 | server.regularly.7=一日一回HPでログインボーナスを受け取れます 137 | server.regularly.8=システムのバグを発見したら報告をお願いします、報告はGithubやその他コミュニティでお願いします 138 | server.regularly.9=逃走中は自動で開始されます、/joinコマンドで途中参加もできます 139 | server.regularly.10=本サーバーのソフトウェアはオープンソースで開発おり、開発に参加したり新機能を提案することができます、興味があるユーザーさんはGithub(https://github.com/KASOSP)をご覧ください -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/scheduler/MainTask.php: -------------------------------------------------------------------------------- 1 | main = $main; 23 | } 24 | 25 | public function onRun(): void{ 26 | $this->main->timer(); 27 | } 28 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/scheduler/PasswordRegisterTask.php: -------------------------------------------------------------------------------- 1 | userId = $userId; 28 | $this->password = $password; 29 | } 30 | 31 | public function onRun(): void{ 32 | $hashedPassword = password_hash($this->password, PASSWORD_BCRYPT, ['cost' => 10]); 33 | $this->setResult($hashedPassword); 34 | } 35 | 36 | public function onCompletion(): void{ 37 | $hashedPassword = $this->getResult(); 38 | $userHandler = UserHandler::getInstance(); 39 | $target = null; 40 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 41 | if($userHandler->getUserIdByUser($player) === $this->userId){ 42 | $target = $player; 43 | break; 44 | } 45 | } 46 | if($target === null){ 47 | return; 48 | } 49 | UserHandler::getInstance()->updateUserPassword($this->userId, $hashedPassword); 50 | $userHandler->sendTranslatedMessage($target, "system.password.respawn", MESSAGE, [$this->password]); 51 | UserHandler::getInstance()->sendTranslatedMessage($player, "system.password.always", MESSAGE); 52 | 53 | } 54 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/sound/PortalSound.php: -------------------------------------------------------------------------------- 1 | database instanceof Database){ 76 | $this->database = $database; 77 | } 78 | $this->spawnPoint = $spawnPoint; 79 | } 80 | 81 | public function attemptLogin(PlayerPreLoginEvent $event){ 82 | $info = $event->getPlayerInfo(); 83 | 84 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 85 | if(strtolower($player->getName()) === strtolower($info->getUsername())){ 86 | $event->setKickReason(PlayerPreLoginEvent::KICK_REASON_BANNED, ERROR . "Error(1001) : Your login session is already exists on this server"); 87 | return; 88 | } 89 | } 90 | 91 | $banRecords = $this->database->getBannedUsers($info->getXuid(), $info->getUsername(), $event->getIp()); 92 | if(count($banRecords) > 0){ 93 | $event->setKickReason(PlayerPreLoginEvent::KICK_REASON_BANNED, "Error(1002) : You are banned (Reason:" . $banRecords[0]->reason . ")"); 94 | return; 95 | } 96 | $tempData = new UserTempData(); 97 | $tempData->loggedInAddress = $info->getExtraData()["ServerAddress"]; 98 | $this->tempDataRecords[strtolower($info->getUsername())] = $tempData; 99 | } 100 | 101 | public function loginEvent(Player $player){ 102 | $registeredUser = $this->database->getUserByXuid($player->getXuid()); 103 | if(!$registeredUser instanceof UserType){ 104 | $this->database->putUser(new UserType(null, $player->getXuid(), strtolower($player->getName()), $player->getNetworkSession()->getIp(), new UserSaveData(), null)); 105 | $registeredUser = $this->database->getUserByXuid($player->getXuid()); 106 | if(!$registeredUser instanceof UserType){ 107 | $player->kick("ERROR(1003) : Failed to create your account"); 108 | return; 109 | } 110 | $this->database->putUserMoneyTransaction(new UserMoneyTransactionType(null, $registeredUser->id, UserMoneyTransactionType::TYPE_ACCOUNT_INIT, 10000, "")); 111 | $this->tempDataRecords[strtolower($player->getName())]->isFirstLogin = true; 112 | } 113 | 114 | $userId = $registeredUser->id; 115 | $this->saveDataRecords[$userId] = $registeredUser->saveData; 116 | $loginHistory = new UserLogType(null, $userId, UserLogType::TYPE_SERVER_LOGIN, $player->getNetworkSession()->getIp()); 117 | $this->database->putUserLog($loginHistory); 118 | 119 | $this->tempDataRecords[strtolower($player->getName())]->userId = $userId; 120 | 121 | $this->tempDataRecords[strtolower($player->getName())]->crowns = $this->database->getUserCrowns($userId); 122 | 123 | $this->tempDataRecords[strtolower($player->getName())]->userStatusDisplayEntityId = Entity::nextRuntimeId(); 124 | } 125 | 126 | public function joinEvent(Player $player){ 127 | $this->respawn($player); 128 | $player->sendMessage("§b>> Welcome to §a§lKametan Server§r§b !"); 129 | $player->sendTitle("§l§6かめたんサーバー§l§b2"); 130 | if($this->tempDataRecords[strtolower($player->getName())]->isFirstLogin){ 131 | $player->sendForm(new PasswordRegisterForm($this->getSaveDataByUser($player)->getLang())); 132 | } 133 | $menuPad = ItemFactory::getInstance()->get(MenuPad::ITEM_ID, 0, 1); 134 | if(!$player->getInventory()->contains($menuPad)){ 135 | $player->getInventory()->addItem($menuPad); 136 | } 137 | 138 | $sound = new AnvilUseSound(); 139 | $player->getWorld()->addSound($player->getLocation(), $sound); 140 | $this->updateStatusDisplay($player); 141 | } 142 | 143 | public function quitEvent(Player $player){ 144 | if($this->getSaveDataByUser($player)->isSaveDataModified()){ 145 | $this->database->updateUserSaveData($this->getUserIdByUser($player), $this->getSaveDataByUser($player)); 146 | } 147 | $loginHistory = new UserLogType(null, $this->getUserIdByUser($player), UserLogType::TYPE_SERVER_LOGOUT, $player->getNetworkSession()->getIp()); 148 | $this->database->putUserLog($loginHistory); 149 | unset($this->saveDataRecords[$this->getUserIdByUser($player)]); 150 | unset($this->tempDataRecords[strtolower($player->getName())]); 151 | } 152 | 153 | public function chatEvent(PlayerChatEvent $event){ 154 | $player = $event->getPlayer(); 155 | $tempData = $this->getTempData($player); 156 | if(mb_strlen($event->getMessage()) > 60){ 157 | $this->sendTranslatedMessage($player, "system.chat.tooLong", ERROR); 158 | $event->cancel(); 159 | return; 160 | } 161 | if(!Server::getInstance()->isOp($player->getName()) and $tempData->chatRestrictionSeconds !== 0){ 162 | $this->sendTranslatedMessage($player, "system.chat.consecutivePosts", ERROR); 163 | $event->cancel(); 164 | return; 165 | } 166 | $tempData->chatRestrictionSeconds = 5; 167 | } 168 | 169 | public function interactEvent(PlayerInteractEvent $event){ 170 | $player = $event->getPlayer(); 171 | $userTempData = $this->getTempData($player); 172 | if($userTempData->interactRestrictionCount > 0){ 173 | $event->cancel(); 174 | }else{ 175 | $userTempData->interactRestrictionCount = 4; // 0.4s 176 | } 177 | } 178 | 179 | public function updateStatusDisplay(Player $player){ 180 | $status = $this->getUserRunForMoneyStatus($this->getUserIdByUser($player)); 181 | $clear = $status[0]; 182 | $death = $status[1]; 183 | $catch = $status[2]; 184 | $surrender = $status[3]; 185 | $revival = $status[4]; 186 | $text = "§a" . $player->getName() . "さんのステータス\n§b逃走成功回数 : " . $clear . " \n§c自首回数 : " . $surrender . "\n" . "§2復活回数 : " . $revival . "\n" . "§d確保された回数 : " . $death . "\n§e所持金 : " . (0) . "\n§1確保した回数 : " . $catch . "\n§aログイン時間(分) : " . (999); 187 | 188 | $entityId = $this->getTempData($player)->userStatusDisplayEntityId; 189 | $uuid = Uuid::uuid4(); 190 | $name = $text; 191 | $player->getNetworkSession()->sendDataPacket(PlayerListPacket::add([PlayerListEntry::createAdditionEntry($uuid, $entityId, $name, SkinAdapterSingleton::get()->toSkinData($player->getSkin()))])); 192 | 193 | $actorFlags = ( 194 | 1 << EntityMetadataFlags::IMMOBILE 195 | ); 196 | $actorMetadata = [ 197 | EntityMetadataProperties::FLAGS => new LongMetadataProperty($actorFlags), 198 | EntityMetadataProperties::SCALE => new FloatMetadataProperty(0.01) //zero causes problems on debug builds 199 | ]; 200 | 201 | $text = "§a" . $player->getName() . "さんのステータス\n§b逃走成功回数 : " . $clear . " \n§c自首回数 : " . $surrender . "\n" . "§2復活回数 : " . $revival . "\n" . "§d確保された回数 : " . $death . "\n§e所持金 : " . (0) . "\n§1確保した回数 : " . $catch . "\n§aログイン時間(分) : " . (999); 202 | 203 | $pk = AddPlayerPacket::create( 204 | $uuid, 205 | $text, 206 | $entityId, 207 | $entityId, 208 | "", 209 | new Vector3(132.5, 73, -236), 210 | null, 211 | 0, 212 | 0, 213 | 0, 214 | ItemStackWrapper::legacy(ItemStack::null()), 215 | $actorMetadata, 216 | AdventureSettingsPacket::create(0, 0, 0, 0, 0, $entityId), 217 | [], 218 | "", 219 | DeviceOS::UNKNOWN 220 | ); 221 | 222 | $player->getNetworkSession()->sendDataPacket($pk); 223 | $player->getNetworkSession()->sendDataPacket(PlayerListPacket::remove([PlayerListEntry::createRemovalEntry($uuid)])); 224 | } 225 | 226 | /** 227 | * @param int $userId 228 | * @return array 229 | */ 230 | public function getUserRunForMoneyStatus(int $userId) : array{ 231 | $clear = $death = $catch = $surrender = $revival = 0; 232 | $result = $this->database->getUserRunForMoneyCache($userId); 233 | if($result === null){ 234 | return [0, 0, 0, 0, 0]; 235 | } 236 | return [$result->clear, $result->death, $result->catch, $result->surrender, $result->revival]; 237 | } 238 | 239 | public function getUserMoney(int $userId) : int{ 240 | $cache = $this->database->getUserMoneyCache($userId); 241 | if(isset($cache)){ 242 | return $cache->amount; 243 | } 244 | return 0; 245 | } 246 | 247 | public function reduceUserMoney(int $userId, int $amount, int $type){ 248 | $this->addUserMoney($userId, -$amount, $type); 249 | } 250 | 251 | public function addUserMoney(int $userId, int $amount, int $type){ 252 | $this->database->putUserMoneyTransaction(new UserMoneyTransactionType(null, $userId, $type, $amount)); 253 | } 254 | 255 | public function updateUserPassword($userId, $hashedPassword){ 256 | $this->database->updateUserPassword($userId, $hashedPassword); 257 | } 258 | 259 | public function getCrownsText(Player $player){ 260 | $text = ""; 261 | foreach($this->getTempData($player)->crowns as $crown){ 262 | $text .= Crown::toText($crown->type, $crown->color); 263 | } 264 | return $text; 265 | } 266 | 267 | public function resetState(Player $player){ 268 | $player->getHungerManager()->setFood(20); 269 | $player->setGamemode(GameMode::ADVENTURE()); 270 | $player->getEffects()->clear(); 271 | 272 | /** @var GameHandler $gameHandler */ 273 | $gameHandler = GameHandler::getInstance(); 274 | if($gameHandler->isGameRunning() and $gameHandler->getGameInfo()->hasGamerData($player)){ 275 | $gameHandler->getGameInfo()->getGamerData($player)->gamerType = GamerData::GAMER_TYPE_WAITING; 276 | } 277 | $this->updateState($player); 278 | } 279 | 280 | public function respawn(Player $player){ 281 | $this->resetState($player); 282 | if($this->photoStudioPoint !== null){ 283 | $player->teleport($this->photoStudioPoint); 284 | $player->sendMessage(">> 撮影台に転送しました"); 285 | }else{ 286 | $player->teleport($this->spawnPoint); 287 | } 288 | } 289 | 290 | public function updateState(Player $player){ 291 | $gamerTag = "待機中"; 292 | $gameHandler = GameHandler::getInstance(); 293 | $userHandler = UserHandler::getInstance(); 294 | if($gameHandler->isGameRunning() and $gameHandler->getGameInfo()->hasGamerData($player)){ 295 | $gamerType = $gameHandler->getGameInfo()->getGamerData($player)->gamerType; 296 | switch($gamerType){ 297 | case GamerData::GAMER_TYPE_CAUGHT: 298 | $gamerTag = "囚人"; 299 | $player->setNameTagAlwaysVisible(false); 300 | $player->getHungerManager()->setEnabled(false); 301 | $player->getHungerManager()->setFood(20); 302 | break; 303 | case GamerData::GAMER_TYPE_RUNNER: 304 | case GamerData::GAMER_TYPE_BETRAYAL: 305 | $gamerTag = "逃走者"; 306 | $player->setNameTagAlwaysVisible(false); 307 | $player->getHungerManager()->setEnabled(true); 308 | break; 309 | case GamerData::GAMER_TYPE_HUNTER: 310 | $gamerTag = TextFormat::RED . "ハンター" . TextFormat::WHITE; 311 | $player->setNameTagAlwaysVisible(true); 312 | $player->getHungerManager()->setEnabled(false); 313 | $player->getHungerManager()->setFood(20); 314 | break; 315 | case GamerData::GAMER_TYPE_WAITING: 316 | $gamerTag = "待機中"; 317 | $player->setNameTagAlwaysVisible(true); 318 | $player->getHungerManager()->setEnabled(false); 319 | $player->getHungerManager()->setFood(20); 320 | break; 321 | default: 322 | $gamerTag = "Unknown"; 323 | $player->setNameTagAlwaysVisible(true); 324 | $player->getHungerManager()->setEnabled(false); 325 | $player->getHungerManager()->setFood(20); 326 | break; 327 | } 328 | }else{ 329 | $player->setNameTagAlwaysVisible(true); 330 | $player->getHungerManager()->setEnabled(false); 331 | $player->getHungerManager()->setFood(20); 332 | } 333 | 334 | $nametag = $this->getSaveDataByUser($player)->getNametag(); 335 | $crowns = $this->getCrownsText($player); 336 | 337 | $player->setNameTag("[" . $gamerTag . "] " . $player->getName()); 338 | $player->setDisplayName("[" . ($nametag !== "" ? $nametag . " " : "") . ($crowns !== "" ? $crowns : "") . "§r§f" . $gamerTag . "] " . $player->getName()); 339 | } 340 | 341 | /** @var int */ 342 | private $count = 0; 343 | 344 | /** 345 | * 0.1秒毎に呼び出される 346 | */ 347 | public function timer(){ 348 | if($this->count % 10 === 0){ // 1秒毎に処理する 349 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 350 | $tempData = $this->getTempData($player); 351 | if($tempData->chatRestrictionSeconds > 0){ 352 | $tempData->chatRestrictionSeconds--; 353 | } 354 | } 355 | } 356 | 357 | if($this->count % 300 === 0){ 358 | $rand = mt_rand(0, 10); 359 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 360 | $this->sendTranslatedMessage($player, "server.regularly." . $rand, INFO); 361 | } 362 | if($this->count % 600 === 0){ 363 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 364 | $this->updateStatusDisplay($player); 365 | } 366 | } 367 | } 368 | 369 | foreach(Server::getInstance()->getOnlinePlayers() as $player){ 370 | $tempData = $this->getTempData($player); 371 | if($tempData->interactRestrictionCount > 0){ 372 | $tempData->interactRestrictionCount--; 373 | } 374 | } 375 | $this->count++; 376 | } 377 | 378 | /** 379 | * @param Player $player 380 | */ 381 | public function ban(Player $player, $reason){ 382 | $xuid = $player->getXuid(); 383 | $username = strtolower($player->getName()); 384 | $userId = $this->getUserIdByUser($player); 385 | $ipAddress = $player->getNetworkSession()->getIp(); 386 | $expirationDate = time() + 60 * 60 * 24 * 30; // 30days 387 | $sign = $player->getName(); 388 | $banRecord = new BannedUserType(null, $userId, $xuid, $username, $ipAddress, $expirationDate, $sign, $reason); 389 | $this->database->putBannedUser($banRecord); 390 | $player->kick("You are banned (Reason:" . $banRecord->reason . ")"); 391 | } 392 | 393 | /** 394 | * @return Vector3 395 | */ 396 | public function getSpawnPoint(): Vector3{ 397 | return $this->spawnPoint; 398 | } 399 | 400 | public function setPhotoStudioPos(Vector3 $pos){ 401 | $this->photoStudioPoint = $pos; 402 | } 403 | 404 | /** 405 | * @param Player $player 406 | * @return bool 407 | */ 408 | public function isAdmin(Player $player) : bool{ 409 | return Server::getInstance()->isOp($player->getName()); 410 | } 411 | 412 | /** 413 | * @param Player|string $user 414 | * @return int 415 | */ 416 | public function getUserIdByUser($user){ 417 | if($user instanceof Player){ // $userがPlayerオブジェクトの場合 418 | $user = $user->getName(); 419 | } 420 | return $this->tempDataRecords[strtolower($user)]->userId; 421 | } 422 | 423 | /** 424 | * @param int $id 425 | * @return UserSaveData 426 | */ 427 | public function getSaveData(int $id){ 428 | return $this->saveDataRecords[$id]; 429 | } 430 | 431 | /** 432 | * @param Player|string $user 433 | * @return UserSaveData 434 | */ 435 | public function getSaveDataByUser($user){ 436 | if($user instanceof Player){ // $userがPlayerオブジェクトの場合 437 | $user = $user->getName(); 438 | } 439 | return $this->saveDataRecords[$this->tempDataRecords[strtolower($user)]->userId]; 440 | } 441 | 442 | /** 443 | * @param Player|string 444 | * @return UserTempData 445 | */ 446 | public function getTempData($user){ 447 | if($user instanceof Player){ // $userがPlayerオブジェクトの場合 448 | $user = $user->getName(); 449 | } 450 | return $this->tempDataRecords[strtolower($user)]; 451 | } 452 | 453 | /** 454 | * @param Player $player 455 | * @param string $message 456 | * @param array $inputs 457 | * @return string 458 | */ 459 | public function translateText(Player $player, string $message, array $inputs = []){ 460 | $lang = $this->getSaveDataByUser($player)->getLang(); 461 | return Lang::translate($lang, $message, $inputs); 462 | } 463 | 464 | /** 465 | * @param Player|CommandSender $player 466 | * @param string $message 467 | * @param string $color 468 | * @param array $inputs 469 | */ 470 | public function sendTranslatedMessage($player, string $message, string $color, array $inputs = []){ 471 | if($player instanceof Player){ 472 | $lang = $this->getSaveDataByUser($player)->getLang(); 473 | }else{ 474 | $lang = "eng"; 475 | } 476 | $player->sendMessage($color . ">> " . Lang::translate($lang, $message, $inputs)); 477 | } 478 | 479 | /** 480 | * @param Player $player 481 | * @param string $message 482 | * @param string $color 483 | * @param array $inputs 484 | */ 485 | public function sendTranslatedTip(Player $player, string $message, string $color, array $inputs = []){ 486 | $lang = $this->getSaveDataByUser($player)->getLang(); 487 | $player->sendTip($color . Lang::translate($lang, $message, $inputs)); 488 | } 489 | 490 | /** 491 | * @param Player $player 492 | * @param string $message 493 | * @param string $color 494 | * @param array $inputs 495 | */ 496 | public function sendTranslatedPopup(Player $player, string $message, string $color, array $inputs = []){ 497 | $lang = $this->getSaveDataByUser($player)->getLang(); 498 | $player->sendPopup($color . Lang::translate($lang, $message, $inputs)); 499 | } 500 | 501 | /** 502 | * @param Player $player 503 | * @param string $main 504 | * @param string|null $sub 505 | * @param string $mainColor 506 | * @param string|null $subColor 507 | * @param array $mainInput 508 | * @param array $subInput 509 | */ 510 | public function sendTranslatedTitle(Player $player, string $main, ?string $sub, string $mainColor, ?string $subColor, array $mainInput = [], array $subInput = []){ 511 | $lang = $this->getSaveDataByUser($player)->getLang(); 512 | if(isset($sub)){ 513 | $player->sendTitle($mainColor . Lang::translate($lang, $main, $mainInput), $subColor . Lang::translate($lang, $sub, $subInput)); 514 | }else{ 515 | $player->sendTitle($mainColor . Lang::translate($lang, $main, $mainInput)); 516 | } 517 | } 518 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/user/UserSaveData.php: -------------------------------------------------------------------------------- 1 | lang; 27 | } 28 | 29 | /** 30 | * @param string $lang 31 | */ 32 | public function setLang(string $lang): void{ 33 | if($this->lang !== $lang){ 34 | $this->lang = $lang; 35 | $this->isSaveDataModified = true; 36 | } 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function getNametag(): string{ 43 | return $this->nametag; 44 | } 45 | 46 | /** 47 | * @param string $nametag 48 | */ 49 | public function setNametag(string $nametag): void{ 50 | if($this->nametag !== $nametag){ 51 | $this->nametag = $nametag; 52 | $this->isSaveDataModified = true; 53 | } 54 | } 55 | 56 | /** 57 | * @return bool 58 | */ 59 | public function isSaveDataModified() : bool{ 60 | return $this->isSaveDataModified; 61 | } 62 | 63 | public function jsonSerialize(){ 64 | $data = []; 65 | $data["lang"] = $this->lang; 66 | $data["nametag"] = $this->nametag; 67 | return json_encode($data); 68 | } 69 | 70 | public static function jsonDeserialize(string $json) : self{ 71 | $json = json_decode($json, true); 72 | $saveData = new UserSaveData(); 73 | if(isset($json["lang"])){ 74 | $saveData->lang = $json["lang"]; 75 | } 76 | if(isset($json["nametag"])){ 77 | $saveData->nametag = $json["nametag"]; 78 | } 79 | return $saveData; 80 | } 81 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/user/UserTempData.php: -------------------------------------------------------------------------------- 1 | 10 or $len > 16){ 21 | $userHandler->sendTranslatedMessage($player, "system.nametag.tooLong", ERROR); 22 | return false; 23 | } 24 | 25 | for($i=0;$i<$len;$i++){ 26 | $char = mb_substr($nametag, $i, 1); 27 | if($char === '§'){ 28 | // §が最後の文字か最後から2番目文字だったり、次の文字がカラーコードとして無効な文字だったら 29 | if($i >= $len-2 or array_search(mb_substr($nametag, $i+1, 1), ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']) === false){ 30 | $userHandler->sendTranslatedMessage($player, "system.nametag.invalid", ERROR); 31 | return false; 32 | } 33 | } 34 | } 35 | return true; 36 | } 37 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/user/skin/SkinValidator.php: -------------------------------------------------------------------------------- 1 | getSkinData(); 18 | $transparent = 0; // 透明 19 | $opacity = 0; // 不透明 20 | $i = 0; 21 | while($i < strlen($data)){ 22 | $red = ord($data[$i++]); 23 | $green = ord($data[$i++]); 24 | $blue = ord($data[$i++]); 25 | $alpha = ord($data[$i++]); 26 | if($alpha === 0) $transparent++; 27 | else $opacity++; 28 | } 29 | 30 | if((int)(100*$transparent/($transparent+$opacity)) > $threshold){ 31 | return false; 32 | } 33 | return true; 34 | } 35 | } -------------------------------------------------------------------------------- /src/kametan0730mc/RunForMoney2/world/WorldHandler.php: -------------------------------------------------------------------------------- 1 | database = $database; 41 | $this->moneyRankingParticle = new FloatingTextParticle("Money Ranking"); 42 | $this->moneyRankingPos = new Vector3(122, 74, -244); 43 | $this->clearRankingParticle = new FloatingTextParticle("Clear Ranking"); 44 | $this->clearRankingPos = new Vector3(119, 74, -251); 45 | $this->catchRankingParticle = new FloatingTextParticle("Catch Ranking"); 46 | $this->catchRankingPos = new Vector3(116, 74, -257); 47 | $world = Server::getInstance()->getWorldManager()->getDefaultWorld(); 48 | $world->addParticle($this->moneyRankingPos, $this->moneyRankingParticle); 49 | } 50 | 51 | public function update(){ 52 | $world = Server::getInstance()->getWorldManager()->getDefaultWorld(); 53 | $moneyCaches = $this->database->getUserMoneyCachesOrderByAmountDESC(); 54 | $moneyRanking = "§a-------所持金ランキング-------\n"; 55 | foreach($moneyCaches as $index => $cache){ 56 | $username = $this->database->getUserNameByUserId($cache->userId); 57 | $moneyRanking .= "§e".($index+1)."位 : §b".$username."様 ".$cache->amount."メタ\n"; 58 | } 59 | $this->moneyRankingParticle->setText($moneyRanking); 60 | $world->addParticle($this->moneyRankingPos, $this->moneyRankingParticle); 61 | 62 | $particle = new PortalParticle(); 63 | for($x=0;$x<10;$x++){ 64 | for($z=0;$z<10;$z++){ 65 | $world->addParticle($this->moneyRankingPos->add(rand(-20,20)/10,rand(-20,20)/10,rand(-20,20)/10), $particle); 66 | } 67 | } 68 | 69 | $clearCaches = $this->database->getUserRunForMoneyCachesOrderByClearDESC(); 70 | $clearRanking = "§a-------逃走成功回数ランキング-------\n"; 71 | foreach($clearCaches as $index => $cache){ 72 | $username = $this->database->getUserNameByUserId($cache->userId); 73 | $clearRanking .= "§e".($index+1)."位 : §b".$username."様 ".$cache->clear."回\n"; 74 | } 75 | $this->clearRankingParticle->setText($clearRanking); 76 | $world->addParticle($this->clearRankingPos, $this->clearRankingParticle); 77 | 78 | $particle = new PortalParticle(); 79 | for($x=0;$x<10;$x++){ 80 | for($z=0;$z<10;$z++){ 81 | $world->addParticle($this->clearRankingPos->add(rand(-20,20)/10,rand(-20,20)/10,rand(-20,20)/10), $particle); 82 | } 83 | } 84 | 85 | $catchCaches = $this->database->getUserRunForMoneyCachesOrderByCatchDESC(); 86 | $catchRanking = "§a-------捕獲回数ランキング-------\n"; 87 | foreach($catchCaches as $index => $cache){ 88 | $username = $this->database->getUserNameByUserId($cache->userId); 89 | $catchRanking .= "§e".($index+1)."位 : §b".$username."様 ".$cache->catch."回\n"; 90 | } 91 | $this->catchRankingParticle->setText($catchRanking); 92 | $world->addParticle($this->catchRankingPos, $this->catchRankingParticle); 93 | 94 | $particle = new PortalParticle(); 95 | for($x=0;$x<10;$x++){ 96 | for($z=0;$z<10;$z++){ 97 | $world->addParticle($this->catchRankingPos->add(rand(-20,20)/10,rand(-20,20)/10,rand(-20,20)/10), $particle); 98 | } 99 | } 100 | } 101 | 102 | private $seconds = 0; 103 | public function second(){ 104 | $this->seconds++; 105 | if($this->seconds % 60 === 0){ 106 | $this->update(); 107 | } 108 | } 109 | } --------------------------------------------------------------------------------