Skip to content

Commit 449fe41

Browse files
committed
汉化
1 parent e5114f4 commit 449fe41

3 files changed

Lines changed: 48 additions & 51 deletions

File tree

plugin.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1+
---
12
name: ChestShop
23
main: ChestShop\ChestShop
3-
version: 2.2.0
4-
api: [3.0.0]
4+
version: 2.2.1
5+
api:
6+
- 3.0.0
57
load: POSTWORLD
68
author: MinecrafterJPN
7-
description: A PocketMine-MP plugin which enables you to open a chest shop using a sign
9+
description: A PocketMine-MP plugin which enables you to open a chest shop using a
10+
sign
811
website: https://github.com/poggit-orphanage/ChestShop
912
depend:
10-
- EconomyAPI
13+
- EconomyAPI
1114
extensions:
12-
- sqlite3
15+
- sqlite3
1316
commands:
14-
id:
15-
description: Search item ID
16-
usage: "/id <itemname>"
17-
permission: chestshop.command.id
17+
id:
18+
description: 查看手中物品ID
19+
usage: /id
1820
permissions:
19-
chestshop:
20-
default: op
21-
description: "Allows using all the ChestShop things"
22-
children:
23-
chestshop.command:
21+
chestshop:
2422
default: op
25-
description: "Allows using all the PocketMoney commands"
23+
description: Allows using all the ChestShop things
2624
children:
27-
chestshop.command.id:
28-
default: true
29-
description: "Allows searching item ID"
25+
chestshop.command:
26+
default: op
27+
description: Allows using all the PocketMoney commands
28+
...

src/ChestShop/ChestShop.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use pocketmine\command\Command;
66
use pocketmine\command\CommandSender;
77
use pocketmine\item\ItemIds;
8+
use pocketmine\Player;
89
use pocketmine\plugin\PluginBase;
910

1011
class ChestShop extends PluginBase
@@ -18,17 +19,12 @@ public function onCommand(CommandSender $sender, Command $command, string $label
1819
{
1920
switch ($command->getName()) {
2021
case "id":
21-
$name = array_shift($args);
22-
$constants = array_keys((new \ReflectionClass(ItemIds::class))->getConstants());
23-
foreach ($constants as $constant) {
24-
if (stripos($constant, $name) !== false) {
25-
$id = constant(ItemIds::class."::$constant");
26-
$constant = str_replace("_", " ", $constant);
27-
$sender->sendMessage("ID:$id $constant");
28-
}
22+
if ($sender instanceof Player){
23+
$sender->sendMessage("§a[§eChest§bShop§a]§6:你手中物品的ID为:§a" . $sender->getInventory()->getItemInHand()->getId() . ":" . $sender->getInventory()->getItemInHand()->getDamage());
24+
} else {
25+
$sender->sendMessage("§a[§eChest§bShop§a]§6:控制台可以GUN犊子(ノ`Д)ノ");
2926
}
3027
return true;
31-
3228
default:
3329
return false;
3430
}

src/ChestShop/EventListener.php

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
declare(strict_types=1);
3+
34
namespace ChestShop;
45

56
use onebone\economyapi\EconomyAPI;
@@ -17,6 +18,7 @@ class EventListener implements Listener
1718
{
1819
private $plugin;
1920
private $databaseManager;
21+
private $prefix = "§a[§eChest§bShop§a]§6:";
2022

2123
public function __construct(ChestShop $plugin, DatabaseManager $databaseManager)
2224
{
@@ -38,18 +40,18 @@ public function onPlayerInteract(PlayerInteractEvent $event)
3840
"signZ" => $block->getZ()
3941
])) === false) return;
4042
if ($shopInfo['shopOwner'] === $player->getName()) {
41-
$player->sendMessage("Cannot purchase from your own shop!");
43+
$player->sendMessage($this->prefix . "你不能购买自己出售的物品!");
4244
return;
43-
}else{
44-
$event->setCancelled();
45+
} else {
46+
$event->setCancelled();
4547
}
4648
$buyerMoney = EconomyAPI::getInstance()->myMoney($player->getName());
4749
if ($buyerMoney === false) {
48-
$player->sendMessage("Couldn't acquire your money data!");
50+
$player->sendMessage($this->prefix . "无法获取您的金币数据!");
4951
return;
5052
}
5153
if ($buyerMoney < $shopInfo['price']) {
52-
$player->sendMessage("Your money is not enough!");
54+
$player->sendMessage($this->prefix . "你的金币不够!");
5355
return;
5456
}
5557
/** @var Chest $chest */
@@ -63,23 +65,23 @@ public function onPlayerInteract(PlayerInteractEvent $event)
6365
if ($item->getID() === $pID and $item->getDamage() === $pMeta) $itemNum += $item->getCount();
6466
}
6567
if ($itemNum < $shopInfo['saleNum']) {
66-
$player->sendMessage("This shop is out of stock!");
68+
$player->sendMessage($this->prefix . "此店铺已售空!");
6769
if (($p = $this->plugin->getServer()->getPlayer($shopInfo['shopOwner'])) !== null) {
68-
$p->sendMessage("Your ChestShop is out of stock! Replenish Item: ".ItemFactory::get($pID, $pMeta)->getName());
70+
$p->sendMessage($this->prefix . "你的个人箱子商店已售空,请补充: " . ItemFactory::get($pID, $pMeta)->getName());
6971
}
7072
return;
7173
}
7274

7375
$item = ItemFactory::get((int)$shopInfo['productID'], (int)$shopInfo['productMeta'], (int)$shopInfo['saleNum']);
7476
$chest->getInventory()->removeItem($item);
7577
$player->getInventory()->addItem($item);
76-
if(EconomyAPI::getInstance()->reduceMoney($player->getName(), $shopInfo['price'], false, "ChestShop") === EconomyAPI::RET_SUCCESS) {
77-
EconomyAPI::getInstance()->addMoney($shopInfo['shopOwner'], $shopInfo['price'], false, "ChestShop");
78-
}
78+
if (EconomyAPI::getInstance()->reduceMoney($player->getName(), $shopInfo['price'], false, "ChestShop") === EconomyAPI::RET_SUCCESS) {
79+
EconomyAPI::getInstance()->addMoney($shopInfo['shopOwner'], $shopInfo['price'], false, "ChestShop");
80+
}
7981

80-
$player->sendMessage("Completed transaction");
82+
$player->sendMessage($this->prefix . "蕉♂易成功");//This is G♂♂d!
8183
if (($p = $this->plugin->getServer()->getPlayer($shopInfo['shopOwner'])) !== null) {
82-
$p->sendMessage("{$player->getName()} purchased ".ItemFactory::get($pID, $pMeta)->getName()." for ".EconomyAPI::getInstance()->getMonetaryUnit().$shopInfo['price']);
84+
$p->sendMessage($this->prefix . "{$player->getName()} 购买 " . ItemFactory::get($pID, $pMeta)->getName() . " 花费了 " . EconomyAPI::getInstance()->getMonetaryUnit() . $shopInfo['price']);
8385
}
8486
break;
8587

@@ -90,7 +92,7 @@ public function onPlayerInteract(PlayerInteractEvent $event)
9092
"chestZ" => $block->getZ()
9193
]);
9294
if ($shopInfo !== false and $shopInfo['shopOwner'] !== $player->getName()) {
93-
$player->sendMessage("This chest has been protected!");
95+
$player->sendMessage($this->prefix . "这个箱子商店受保护!");
9496
$event->setCancelled();
9597
}
9698
break;
@@ -116,11 +118,11 @@ public function onPlayerBreakBlock(BlockBreakEvent $event)
116118
$shopInfo = $this->databaseManager->selectByCondition($condition);
117119
if ($shopInfo !== false) {
118120
if ($shopInfo['shopOwner'] !== $player->getName()) {
119-
$player->sendMessage("This sign has been protected!");
121+
$player->sendMessage($this->prefix . "这个箱子商店的木牌受保护!");
120122
$event->setCancelled();
121123
} else {
122124
$this->databaseManager->deleteByCondition($condition);
123-
$player->sendMessage("Closed your ChestShop");
125+
$player->sendMessage($this->prefix . "倒闭关店啦!");
124126
}
125127
}
126128
break;
@@ -134,11 +136,11 @@ public function onPlayerBreakBlock(BlockBreakEvent $event)
134136
$shopInfo = $this->databaseManager->selectByCondition($condition);
135137
if ($shopInfo !== false) {
136138
if ($shopInfo['shopOwner'] !== $player->getName()) {
137-
$player->sendMessage("This chest has been protected!");
139+
$player->sendMessage($this->prefix . "这个箱子商店受保护!");
138140
$event->setCancelled();
139141
} else {
140142
$this->databaseManager->deleteByCondition($condition);
141-
$player->sendMessage("Closed your ChestShop");
143+
$player->sendMessage($this->prefix . "倒闭关店啦");
142144
}
143145
}
144146
break;
@@ -165,10 +167,10 @@ public function onSignChange(SignChangeEvent $event)
165167
if (($chest = $this->getSideChest($sign)) === false) return;
166168

167169
$productName = ItemFactory::get($pID, $pMeta)->getName();
168-
$event->setLine(0, $shopOwner);
169-
$event->setLine(1, "Amount: $saleNum");
170-
$event->setLine(2, "Price: ".EconomyAPI::getInstance()->getMonetaryUnit().$price);
171-
$event->setLine(3, $productName);
170+
$event->setLine(0, "§6店主:§a " . $shopOwner);
171+
$event->setLine(1, "§b出售数量:§c {$saleNum}");
172+
$event->setLine(2, "§d需要的钱:§e " . EconomyAPI::getInstance()->getMonetaryUnit() . $price);
173+
$event->setLine(3, "§a物品名称:§f " . $productName);
172174

173175
$this->databaseManager->registerShop($shopOwner, $saleNum, $price, $pID, $pMeta, $sign, $chest);
174176
}
@@ -179,8 +181,8 @@ private function getSideChest(Position $pos)
179181
if ($block->getID() === Block::CHEST) return $block;
180182
$block = $pos->getLevel()->getBlock(new Vector3($pos->getX() - 1, $pos->getY(), $pos->getZ()));
181183
if ($block->getID() === Block::CHEST) return $block;
182-
$block = $pos->getLevel()->getBlock(new Vector3($pos->getX(), $pos->getY() - 1, $pos->getZ()));
183-
if ($block->getID() === Block::CHEST) return $block;
184+
$block = $pos->getLevel()->getBlock(new Vector3($pos->getX(), $pos->getY() - 1, $pos->getZ()));
185+
if ($block->getID() === Block::CHEST) return $block;
184186
$block = $pos->getLevel()->getBlock(new Vector3($pos->getX(), $pos->getY(), $pos->getZ() + 1));
185187
if ($block->getID() === Block::CHEST) return $block;
186188
$block = $pos->getLevel()->getBlock(new Vector3($pos->getX(), $pos->getY(), $pos->getZ() - 1));
@@ -190,6 +192,6 @@ private function getSideChest(Position $pos)
190192

191193
private function isItem($id)
192194
{
193-
return ItemFactory::isRegistered((int) $id);
195+
return ItemFactory::isRegistered((int)$id);
194196
}
195197
}

0 commit comments

Comments
 (0)