|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Dragonfly\PluginLib\Entity; |
| 4 | + |
| 5 | +use Df\Plugin\ItemStack; |
| 6 | +use Df\Plugin\Vec3; |
| 7 | +use Dragonfly\PluginLib\Actions\Actions; |
| 8 | + |
| 9 | +final class Player { |
| 10 | + public function __construct( |
| 11 | + private string $uuid, |
| 12 | + private string $name, |
| 13 | + private Actions $actions, |
| 14 | + ) {} |
| 15 | + |
| 16 | + public function getUuid(): string { |
| 17 | + return $this->uuid; |
| 18 | + } |
| 19 | + |
| 20 | + public function getName(): string { |
| 21 | + return $this->name; |
| 22 | + } |
| 23 | + |
| 24 | + public function sendMessage(string $message): void { |
| 25 | + $this->actions->chatToUuid($this->uuid, $message); |
| 26 | + } |
| 27 | + |
| 28 | + public function teleport(?Vec3 $position = null, ?Vec3 $rotation = null): void { |
| 29 | + $this->actions->teleportUuid($this->uuid, $position, $rotation); |
| 30 | + } |
| 31 | + |
| 32 | + public function kick(string $reason): void { |
| 33 | + $this->actions->kickUuid($this->uuid, $reason); |
| 34 | + } |
| 35 | + |
| 36 | + public function setGameMode(int $gameMode): void { |
| 37 | + $this->actions->setGameModeUuid($this->uuid, $gameMode); |
| 38 | + } |
| 39 | + |
| 40 | + public function giveItem(ItemStack $item): void { |
| 41 | + $this->actions->giveItemUuid($this->uuid, $item); |
| 42 | + } |
| 43 | + |
| 44 | + public function clearInventory(): void { |
| 45 | + $this->actions->clearInventoryUuid($this->uuid); |
| 46 | + } |
| 47 | + |
| 48 | + public function setHeldItems(?ItemStack $main = null, ?ItemStack $offhand = null): void { |
| 49 | + $this->actions->setHeldItemsUuid($this->uuid, $main, $offhand); |
| 50 | + } |
| 51 | + |
| 52 | + public function setHealth(float $health, ?float $maxHealth = null): void { |
| 53 | + $this->actions->setHealthUuid($this->uuid, $health, $maxHealth); |
| 54 | + } |
| 55 | + |
| 56 | + public function setFood(int $food): void { |
| 57 | + $this->actions->setFoodUuid($this->uuid, $food); |
| 58 | + } |
| 59 | + |
| 60 | + public function setExperience(?int $level = null, ?float $progress = null, ?int $amount = null): void { |
| 61 | + $this->actions->setExperienceUuid($this->uuid, $level, $progress, $amount); |
| 62 | + } |
| 63 | + |
| 64 | + public function setVelocity(Vec3 $velocity): void { |
| 65 | + $this->actions->setVelocityUuid($this->uuid, $velocity); |
| 66 | + } |
| 67 | + |
| 68 | + public function addEffect(int $effectType, int $level, int $durationMs, bool $showParticles = true): void { |
| 69 | + $this->actions->addEffectUuid($this->uuid, $effectType, $level, $durationMs, $showParticles); |
| 70 | + } |
| 71 | + |
| 72 | + public function removeEffect(int $effectType): void { |
| 73 | + $this->actions->removeEffectUuid($this->uuid, $effectType); |
| 74 | + } |
| 75 | + |
| 76 | + public function sendTitle(string $title, ?string $subtitle = null, ?int $fadeInMs = null, ?int $durationMs = null, ?int $fadeOutMs = null): void { |
| 77 | + $this->actions->sendTitleUuid($this->uuid, $title, $subtitle, $fadeInMs, $durationMs, $fadeOutMs); |
| 78 | + } |
| 79 | + |
| 80 | + public function sendPopup(string $message): void { |
| 81 | + $this->actions->sendPopupUuid($this->uuid, $message); |
| 82 | + } |
| 83 | + |
| 84 | + public function sendTip(string $message): void { |
| 85 | + $this->actions->sendTipUuid($this->uuid, $message); |
| 86 | + } |
| 87 | + |
| 88 | + public function playSound(int $sound, ?Vec3 $position = null, ?float $volume = null, ?float $pitch = null): void { |
| 89 | + $this->actions->playSoundUuid($this->uuid, $sound, $position, $volume, $pitch); |
| 90 | + } |
| 91 | + |
| 92 | + public function executeCommand(string $command): void { |
| 93 | + $this->actions->executeCommandUuid($this->uuid, $command); |
| 94 | + } |
| 95 | +} |
0 commit comments