Skip to content

Commit

Permalink
a little change
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerahikada committed Jan 30, 2019
1 parent 193cad3 commit 4ed4c85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Baton
main: Nerahikada\Baton
version: 1.1.0.12
api: [3.0.0, 3.0.0-ALHPA7, 3.0.0-ALHPA8, 3.0.0-ALPHA9, 3.0.0-ALPHA10, 3.0.0-ALPHA11, 3.0.0-ALPHA12]
version: 1.2.0
api: [3.0.0, 4.0.0]
load: POSTWORLD
author: ねらひかだ
description: 警棒プラグイン
website: https://github.com/Nerahikada | https://twitter.com/Nerahikada
website: https://github.com/Nerahikada/Baton
commands:
baton:
description: "警棒プラグインのコマンド"
Expand Down
12 changes: 5 additions & 7 deletions src/Nerahikada/Baton.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function onEnable(){
];
}

public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool{
public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{
if(!$sender->isOp()) return true;
// 可変関数(コールバック関数)
$callable = $this->commandHandler[strtolower(array_shift($args))] ?? $this->commandHandler["help"];
Expand Down Expand Up @@ -115,9 +115,7 @@ public function onGiveCommand(CommandSender $sender, array $args){
$item->setCustomName("警棒");

$enchantment = Enchantment::getEnchantment(Enchantment::PROTECTION);
if(strpos((new \ReflectionClass("pocketmine\item\Item"))->getMethod("addEnchantment")->getParameters()[0]->getClass()->getName(), "EnchantmentInstance")){
$enchantment = new \pocketmine\item\enchantment\EnchantmentInstance($enchantment, 1);
}
$enchantment = new \pocketmine\item\enchantment\EnchantmentInstance($enchantment, 1);
$item->addEnchantment($enchantment);

$name = strtolower(implode(" ", $args));
Expand Down Expand Up @@ -146,9 +144,9 @@ public function onDamage(EntityDamageEvent $event){
$player = $event->getEntity();
$item = $damager->getInventory()->getItemInHand();
if(
$damager instanceof Player && $player instanceof Player &&
$item->getId() === Item::STICK && $item->hasEnchantments() &&
($damager->isOp() || $this->moderators->exists($damager->getName(), true))
$damager instanceof Player && $player instanceof Player
&& $item->getId() === Item::STICK && $item->hasEnchantments()
&& ($damager->isOp() || $this->moderators->exists($damager->getName(), true))
){
$pos = $this->config->get("pos");
$pos = new Position($pos["x"], $pos["y"] + 0.1, $pos["z"], $this->getServer()->getLevelByName($pos["world"]));
Expand Down

0 comments on commit 4ed4c85

Please sign in to comment.