forked from jojoe77777/Slapper
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
1,304 additions
and
951 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace slapper; | ||
|
||
use pocketmine\command\CommandSender; | ||
use pocketmine\lang\Language; | ||
use pocketmine\lang\Translatable; | ||
use pocketmine\permission\DefaultPermissions; | ||
use pocketmine\permission\PermissibleBase; | ||
use pocketmine\permission\PermissibleDelegateTrait; | ||
use pocketmine\Server; | ||
|
||
class SlapperCommandSender implements CommandSender{ | ||
use PermissibleDelegateTrait; | ||
|
||
protected ?int $lineHeight = null; | ||
|
||
private Server $server; | ||
private Language $language; | ||
|
||
public function __construct(private Main $plugin){ | ||
$this->server = $plugin->getServer(); | ||
$this->language = $this->server->getLanguage(); | ||
$this->perm = new PermissibleBase([DefaultPermissions::ROOT_OPERATOR => true]); | ||
} | ||
|
||
public function getServer() : Server{ | ||
return $this->server; | ||
} | ||
|
||
public function getLanguage() : Language{ | ||
return $this->language; | ||
} | ||
|
||
public function sendMessage(Translatable|string $message) : void{ | ||
if($message instanceof Translatable){ | ||
$message = $this->language->translate($message); | ||
} | ||
|
||
$logger = $this->plugin->getLogger(); | ||
foreach(explode("\n", trim($message)) as $line){ | ||
$logger->info($line); | ||
} | ||
} | ||
|
||
public function getName() : string{ | ||
return $this->plugin->getName(); | ||
} | ||
|
||
public function getScreenLineHeight() : int{ | ||
return $this->lineHeight ?? PHP_INT_MAX; | ||
} | ||
|
||
public function setScreenLineHeight(?int $height) : void{ | ||
if($height !== null and $height < 1){ | ||
throw new \InvalidArgumentException("Line height must be at least 1"); | ||
} | ||
$this->lineHeight = $height; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace slapper; | ||
|
||
use slapper; | ||
|
||
interface SlapperInterface | ||
{ | ||
|
||
/** @return string[] */ | ||
public function getCommands(): array; | ||
|
||
public function addCommand(string $command): void; | ||
|
||
public function hasCommand(string $command): bool; | ||
|
||
public function removeCommand(string $command): void; | ||
|
||
public function setSlapperVersion(string $version): void; | ||
|
||
public function getSlapperVersion(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.