-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ticking entity problem for crash reports
- Loading branch information
Showing
11 changed files
with
6,801 additions
and
7 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
namespace Aternos\Codex\Minecraft\Analysis\Problem\CrashReport; | ||
|
||
abstract class CrashReportProblem extends \Aternos\Codex\Minecraft\Analysis\Problem\MinecraftProblem | ||
{ | ||
} |
153 changes: 153 additions & 0 deletions
153
src/Analysis/Problem/CrashReport/TickingEntityProblem.php
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,153 @@ | ||
<?php | ||
|
||
namespace Aternos\Codex\Minecraft\Analysis\Problem\CrashReport; | ||
|
||
use Aternos\Codex\Minecraft\Analysis\Solution\CrashReport\RemoveEntitySolution; | ||
use Aternos\Codex\Minecraft\Translator\Translator; | ||
|
||
class TickingEntityProblem extends CrashReportProblem | ||
{ | ||
const PATTERN_DESCRIPTION = "description"; | ||
const PATTERN_ENTITY_TYPE = "type"; | ||
const PATTERN_ENTITY_NAME = "name"; | ||
const PATTERN_ENTITY_LOCATION = "location"; | ||
|
||
protected ?string $matchedPattern = null; | ||
|
||
protected ?string $type = null; | ||
protected ?string $name = null; | ||
protected ?float $locationX = null; | ||
protected ?float $locationY = null; | ||
protected ?float $locationZ = null; | ||
|
||
public function getMessage(): string | ||
{ | ||
return Translator::getInstance()->getTranslation("ticking-entity-problem", [ | ||
"name" => $this->getName(), | ||
"location" => $this->getLocationX() . ", " . $this->getLocationY() . ", " . $this->getLocationZ() | ||
]); | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public static function getPatterns(): array | ||
{ | ||
return [ | ||
static::PATTERN_DESCRIPTION => "/^Description: Ticking entity$/", | ||
static::PATTERN_ENTITY_TYPE => "/Entity Type: ([\w:_]+)/", | ||
static::PATTERN_ENTITY_NAME => "/Entity Name: (.+)/", | ||
static::PATTERN_ENTITY_LOCATION => "/Entity's Exact location: (-?[\d.]+), (-?[\d.]+), (-?[\d.]+)/" | ||
]; | ||
} | ||
|
||
public function setMatches(array $matches, $patternKey): void | ||
{ | ||
$this->matchedPattern = $patternKey; | ||
switch ($patternKey) { | ||
case static::PATTERN_ENTITY_TYPE: | ||
$this->type = $matches[1]; | ||
break; | ||
case static::PATTERN_ENTITY_NAME: | ||
$this->name = $matches[1]; | ||
break; | ||
case static::PATTERN_ENTITY_LOCATION: | ||
$this->locationX = (float)$matches[1]; | ||
$this->locationY = (float)$matches[2]; | ||
$this->locationZ = (float)$matches[3]; | ||
break; | ||
} | ||
|
||
$this->addSolution(new RemoveEntitySolution()); | ||
$this->updateSolution(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function updateSolution(): void | ||
{ | ||
$this->solutions[0]->setName($this->getName()); | ||
$this->solutions[0]->setLocationX($this->getLocationX()); | ||
$this->solutions[0]->setLocationY($this->getLocationY()); | ||
$this->solutions[0]->setLocationZ($this->getLocationZ()); | ||
} | ||
|
||
/** | ||
* @param $insight | ||
* @return bool | ||
*/ | ||
public function isEqual($insight): bool | ||
{ | ||
if ($insight instanceof TickingEntityProblem) { | ||
$this->addInformationFromProblem($insight); | ||
return true; | ||
} | ||
return parent::isEqual($insight); | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getType(): ?string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @return float|null | ||
*/ | ||
public function getLocationX(): ?float | ||
{ | ||
return $this->locationX; | ||
} | ||
|
||
/** | ||
* @return float|null | ||
*/ | ||
public function getLocationY(): ?float | ||
{ | ||
return $this->locationY; | ||
} | ||
|
||
/** | ||
* @return float|null | ||
*/ | ||
public function getLocationZ(): ?float | ||
{ | ||
return $this->locationZ; | ||
} | ||
|
||
/** | ||
* @param static $problem | ||
* @return void | ||
*/ | ||
public function addInformationFromProblem(TickingEntityProblem $problem): void | ||
{ | ||
if ($problem->getName() !== null) { | ||
$this->name = $problem->getName(); | ||
} | ||
if ($problem->getType() !== null) { | ||
$this->type = $problem->getType(); | ||
} | ||
if ($problem->getLocationX() !== null) { | ||
$this->locationX = $problem->getLocationX(); | ||
} | ||
if ($problem->getLocationY() !== null) { | ||
$this->locationY = $problem->getLocationY(); | ||
} | ||
if ($problem->getLocationZ() !== null) { | ||
$this->locationZ = $problem->getLocationZ(); | ||
} | ||
$this->updateSolution(); | ||
} | ||
|
||
} |
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,8 @@ | ||
<?php | ||
|
||
namespace Aternos\Codex\Minecraft\Analysis\Solution\CrashReport; | ||
|
||
abstract class CrashReportSolution extends \Aternos\Codex\Minecraft\Analysis\Solution\MinecraftSolution | ||
{ | ||
|
||
} |
96 changes: 96 additions & 0 deletions
96
src/Analysis/Solution/CrashReport/RemoveEntitySolution.php
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,96 @@ | ||
<?php | ||
|
||
namespace Aternos\Codex\Minecraft\Analysis\Solution\CrashReport; | ||
|
||
use Aternos\Codex\Minecraft\Translator\Translator; | ||
|
||
class RemoveEntitySolution extends CrashReportSolution | ||
{ | ||
protected ?string $name; | ||
protected ?float $locationX; | ||
protected ?float $locationY; | ||
protected ?float $locationZ; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getMessage(): string | ||
{ | ||
return Translator::getInstance()->getTranslation("remove-entity-solution", [ | ||
"name" => $this->getName(), | ||
"location" => $this->getLocationX() . ", " . $this->getLocationY() . ", " . $this->getLocationZ() | ||
]); | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param string|null $name | ||
* @return $this | ||
*/ | ||
public function setName(?string $name): RemoveEntitySolution | ||
{ | ||
$this->name = $name; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return float|null | ||
*/ | ||
public function getLocationX(): ?float | ||
{ | ||
return $this->locationX; | ||
} | ||
|
||
/** | ||
* @param float|null $locationX | ||
* @return $this | ||
*/ | ||
public function setLocationX(?float $locationX): RemoveEntitySolution | ||
{ | ||
$this->locationX = $locationX; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return float|null | ||
*/ | ||
public function getLocationY(): ?float | ||
{ | ||
return $this->locationY; | ||
} | ||
|
||
/** | ||
* @param float|null $locationY | ||
* @return $this | ||
*/ | ||
public function setLocationY(?float $locationY): RemoveEntitySolution | ||
{ | ||
$this->locationY = $locationY; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return float|null | ||
*/ | ||
public function getLocationZ(): ?float | ||
{ | ||
return $this->locationZ; | ||
} | ||
|
||
/** | ||
* @param float|null $locationZ | ||
* @return $this | ||
*/ | ||
public function setLocationZ(?float $locationZ): RemoveEntitySolution | ||
{ | ||
$this->locationZ = $locationZ; | ||
return $this; | ||
} | ||
} |
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.