Skip to content

Commit

Permalink
Outline fully functional (#234), Added MWESelectionChangeEvent::TYPE_…
Browse files Browse the repository at this point in the history
…CREATE
  • Loading branch information
inxomnyaa committed Oct 3, 2021
1 parent bb31332 commit b6c62a9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/xenialdan/MagicWE2/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ public function onDropItem(PlayerDropItemEvent $event): void

public function onSelectionChange(MWESelectionChangeEvent $event): void
{
Loader::getInstance()->getLogger()->debug("Called " . $event->getEventName());
#Loader::getInstance()->getLogger()->debug("Called " . $event->getEventName());
$session = $event->getSession();
if ($session instanceof UserSession && $event->getPlayer() !== null) {
/** @var UserSession $session */
$session->createOrUpdateOutline($event->getSelection());
if ($session->isOutlineEnabled()) $session->createOrUpdateOutline($event->getSelection());
$session->sidebar->handleScoreboard($session);
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/xenialdan/MagicWE2/event/MWESelectionChangeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

class MWESelectionChangeEvent extends MWEEvent
{
public const TYPE_PLUGIN = 0;
public const TYPE_POS1 = 1;
public const TYPE_POS2 = 2;
public const TYPE_WORLD = 3;
public const TYPE_SHAPE = 4;
public const TYPE_CREATE = 0;
public const TYPE_PLUGIN = 1;
public const TYPE_POS1 = 2;
public const TYPE_POS2 = 3;
public const TYPE_WORLD = 4;
public const TYPE_SHAPE = 5;

private Selection $selection;
private ?Session $session = null;
Expand Down
4 changes: 4 additions & 0 deletions src/xenialdan/MagicWE2/selection/Selection.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public function __construct(UuidInterface $sessionUUID, World $world, ?int $minX
}
if ($shape !== null) $this->shape = $shape;
$this->setUUID(Uuid::uuid4());
try {
(new MWESelectionChangeEvent($this, MWESelectionChangeEvent::TYPE_CREATE))->call();
} catch (RuntimeException $e) {
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/xenialdan/MagicWE2/session/UserSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function setOutlineEnabled(bool $outlineEnabled): string
} else {
if ($this->outline instanceof Outline) {
$this->outline->remove();
$this->outline = null;
#$this->outline = null;
}
}
$this->sidebar?->handleScoreboard($this);
Expand Down
2 changes: 1 addition & 1 deletion src/xenialdan/MagicWE2/session/data/Outline.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public function setSelection(Selection $selection): self
$this->remove();
$this->updatePosition();
//TODO change position of fakeTile using reflection
#$this->fakeTile->setDirty();
$this->fakeTile->setShowBoundingBox(true)->setFromV3($selection->getPos1())->setToV3($selection->getPos2());
$this->fakeTile->setDirty();
$this->send();
return $this;
}
Expand Down

0 comments on commit b6c62a9

Please sign in to comment.