Skip to content

Commit

Permalink
Fix #23
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPigGuy committed Nov 9, 2019
1 parent b675528 commit 3864cb0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/DaPigGuy/PiggyCustomEnchantsShop/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function onSignChange(SignChangeEvent $event): void
return;
}
if (($enchantment = CustomEnchantManager::getEnchantmentByName($lines[1])) === null) {
if (is_numeric($lines[1]) && ($enchantment = CustomEnchantManager::getEnchantment($lines[1])) !== null) {
if (is_numeric($lines[1]) && ($enchantment = CustomEnchantManager::getEnchantment((int)$lines[1])) !== null) {
$event->setLine(1, $enchantment->getName());
} else {
$event->setLine(1, TextFormat::RED . "Invalid enchantment.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(PiggyCustomEnchantsShop $plugin, string $name, strin
public function onRun(CommandSender $sender, string $aliasUsed, array $args): void
{
if (count($args) >= 3) {
if (($enchantment = CustomEnchantManager::getEnchantmentByName($args["enchantment"])) === null && ($enchantment = CustomEnchantManager::getEnchantment($args["enchantment"])) === null) {
if (($enchantment = CustomEnchantManager::getEnchantmentByName($args["enchantment"])) === null && ($enchantment = CustomEnchantManager::getEnchantment((int)$args["enchantment"])) === null) {
$sender->sendMessage(TextFormat::RED . "Invalid enchantment.");
return;
}
Expand All @@ -55,13 +55,13 @@ public function onRun(CommandSender $sender, string $aliasUsed, array $args): vo
$sender->sendMessage(TextFormat::RED . "Price must be numerical.");
return;
}
$this->plugin->getUIShopManager()->addShop(new UIShop($this->plugin->getUIShopManager()->getNextId(), CustomEnchantManager::getEnchantmentByName($args["enchantment"]) ?? CustomEnchantManager::getEnchantment($args["enchantment"]), (int)$args["level"], (int)$args["price"]));
$this->plugin->getUIShopManager()->addShop(new UIShop($this->plugin->getUIShopManager()->getNextId(), CustomEnchantManager::getEnchantmentByName($args["enchantment"]) ?? CustomEnchantManager::getEnchantment((int)$args["enchantment"]), (int)$args["level"], (int)$args["price"]));
$sender->sendMessage(TextFormat::GREEN . "Shop entry has been created.");
} else {
if ($sender instanceof Player) {
$form = new CustomForm(function (Player $player, ?array $data): void {
if ($data !== null) {
if (($enchantment = CustomEnchantManager::getEnchantmentByName($data[0])) === null && ($enchantment = CustomEnchantManager::getEnchantment($data[0])) === null) {
if (($enchantment = CustomEnchantManager::getEnchantmentByName($data[0])) === null && ($enchantment = CustomEnchantManager::getEnchantment((int)$data[0])) === null) {
$player->sendMessage(TextFormat::RED . "Invalid enchantment.");
return;
}
Expand All @@ -73,7 +73,7 @@ public function onRun(CommandSender $sender, string $aliasUsed, array $args): vo
$player->sendMessage(TextFormat::RED . "Price must be numerical.");
return;
}
$this->plugin->getUIShopManager()->addShop(new UIShop($this->plugin->getUIShopManager()->getNextId(), CustomEnchantManager::getEnchantmentByName($data[0]) ?? CustomEnchantManager::getEnchantment($data[0]), (int)$data[1], (int)$data[2]));
$this->plugin->getUIShopManager()->addShop(new UIShop($this->plugin->getUIShopManager()->getNextId(), CustomEnchantManager::getEnchantmentByName($data[0]) ?? CustomEnchantManager::getEnchantment((int)$data[0]), (int)$data[1], (int)$data[2]));
$player->sendMessage(TextFormat::GREEN . "Shop entry has been created.");

}
Expand Down

0 comments on commit 3864cb0

Please sign in to comment.