Skip to content

Commit

Permalink
Final bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkorn2324 committed Jun 10, 2020
1 parent f6c61bb commit 07fb39f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 27 deletions.
5 changes: 4 additions & 1 deletion src/kitkb/commands/KbInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ public function execute(CommandSender $sender, $commandLabel, array $args)
}

$kbInfo = $kitManager->getKit($kitName)->getKbInfo();
$sender->sendMessage($kbInfo->display());
$sender->sendMessage(
TextFormat::BLUE . "Kit Information" . TextFormat::DARK_GRAY . ": " . TextFormat::WHITE .
$kitName . "\n" . $kbInfo->display()
);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/kitkb/commands/knockback/KBSpeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function execute(CommandSender $sender, $commandLabel, array $args)
$kit->getKbInfo()->update(KitKb::KB_SPEED, $value);
$kitManager->updateKit($kit);

$sender->sendMessage(TextFormat::GREEN . " Successfully updated the kb speed of the kit.");
$sender->sendMessage(TextFormat::GREEN . "Successfully updated the kb speed of the kit.");

return true;
}
Expand Down
24 changes: 5 additions & 19 deletions src/kitkb/commands/knockback/KnockbackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,14 @@ protected function canExecute(CommandSender $sender, array $args)
return false;
}

switch($this->type)
{
case KitKb::KB_X:
case KitKb::KB_Y:
$checker = is_float($value) || is_int($value);
break;
default:
$checker = is_int($value);
}

if(isset($checker))
if(!is_numeric($value))
{

if(!$checker)
{
$type = $this->type === KitKb::KB_SPEED ? "whole number (EX: 5, 10)" : "decimal (0.4)";
$sender->sendMessage(TextFormat::RED . "Failed to update the kit's kb. The input value must be a {$type}.");
}

return $checker;
$type = $this->type === KitKb::KB_SPEED ? "whole number (EX: 5, 10)" : "decimal (0.4)";
$sender->sendMessage(TextFormat::RED . "Failed to update the kit's kb. The input value must be a {$type}.");
return false;
}

return false;
return true;
}
}
2 changes: 1 addition & 1 deletion src/kitkb/commands/knockback/XKBCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function execute(CommandSender $sender, $commandLabel, array $args)
$kit->getKbInfo()->update(KitKb::KB_X, $value);
$kitManager->updateKit($kit);

$sender->sendMessage(TextFormat::GREEN . " Successfully updated the x-kb of the kit.");
$sender->sendMessage(TextFormat::GREEN . "Successfully updated the x-kb of the kit.");

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kitkb/commands/knockback/YKBCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function execute(CommandSender $sender, $commandLabel, array $args)
$kit->getKbInfo()->update(KitKb::KB_Y, $value);
$kitManager->updateKit($kit);

$sender->sendMessage(TextFormat::GREEN . " Successfully updated the y-kb of the kit.");
$sender->sendMessage(TextFormat::GREEN . "Successfully updated the y-kb of the kit.");

return true;
}
Expand Down
7 changes: 3 additions & 4 deletions src/kitkb/kits/KbInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public function update(string $key, $val) {

switch($key) {
case KitKb::KB_X:
$this->xKb = $val;
$this->xKb = (float)$val;
break;
case KitKb::KB_Y:
$this->yKb = $val;
$this->yKb = (float)$val;
break;
case KitKb::KB_SPEED:
$this->speed = $val;
$this->speed = (int)$val;
break;
}
}
Expand All @@ -103,7 +103,6 @@ public function toArray() {
public function display()
{
$displayArray = [
TextFormat::BLUE . "Kit Information" . TextFormat::DARK_GRAY . ": " . TextFormat::WHITE . $this->name,
TextFormat::GOLD . "KB-X" . TextFormat::DARK_GRAY . ": " . TextFormat::WHITE . $this->xKb,
TextFormat::GOLD . "KB-Y" . TextFormat::DARK_GRAY . ": " . TextFormat::WHITE . $this->yKb,
TextFormat::GOLD . "KB-Speed" . TextFormat::DARK_GRAY . ": " . TextFormat::WHITE . $this->speed
Expand Down

0 comments on commit 07fb39f

Please sign in to comment.