Skip to content

Commit 63c4dc8

Browse files
committed
added ticking entity problem for crash reports
1 parent f6f10bc commit 63c4dc8

File tree

11 files changed

+6801
-7
lines changed

11 files changed

+6801
-7
lines changed

lang/en.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,7 @@
6868
"bedrock-dbstorage-chain-problem": "Unable to decrypt world. Marketplace worlds can't be installed on dedicated servers.",
6969
"mod-incompatible-problem": "The mods '{{first-mod-name}}' and '{{second-mod-name}}' are incompatible.",
7070
"server-install-different-version-solution": "Install the version '{{software-version}}' of your server software.",
71-
"plugin-api-version-problem": "The plugin '{{plugin-name}}' needs version '{{software-version}}' of your server software."
71+
"plugin-api-version-problem": "The plugin '{{plugin-name}}' needs version '{{software-version}}' of your server software.",
72+
"ticking-entity-problem": "The entity '{{name}}' at the location {{location}} is causing issues while ticking.",
73+
"remove-entity-solution": "Remove the entity '{{name}}' at the location {{location}}."
7274
}

src/Analyser/CrashReport/MinecraftCrashReportAnalyser.php

+2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
use Aternos\Codex\Minecraft\Analyser\MinecraftAnalyser;
66
use Aternos\Codex\Minecraft\Analysis\Information\CrashReport\VanillaVersionInformation;
7+
use Aternos\Codex\Minecraft\Analysis\Problem\CrashReport\TickingEntityProblem;
78

89
class MinecraftCrashReportAnalyser extends MinecraftAnalyser
910
{
1011
public function __construct()
1112
{
1213
$this->addPossibleInsightClass(VanillaVersionInformation::class);
14+
$this->addPossibleInsightClass(TickingEntityProblem::class);
1315
}
1416
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Aternos\Codex\Minecraft\Analysis\Problem\CrashReport;
4+
5+
abstract class CrashReportProblem extends \Aternos\Codex\Minecraft\Analysis\Problem\MinecraftProblem
6+
{
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?php
2+
3+
namespace Aternos\Codex\Minecraft\Analysis\Problem\CrashReport;
4+
5+
use Aternos\Codex\Minecraft\Analysis\Solution\CrashReport\RemoveEntitySolution;
6+
use Aternos\Codex\Minecraft\Translator\Translator;
7+
8+
class TickingEntityProblem extends CrashReportProblem
9+
{
10+
const PATTERN_DESCRIPTION = "description";
11+
const PATTERN_ENTITY_TYPE = "type";
12+
const PATTERN_ENTITY_NAME = "name";
13+
const PATTERN_ENTITY_LOCATION = "location";
14+
15+
protected ?string $matchedPattern = null;
16+
17+
protected ?string $type = null;
18+
protected ?string $name = null;
19+
protected ?float $locationX = null;
20+
protected ?float $locationY = null;
21+
protected ?float $locationZ = null;
22+
23+
public function getMessage(): string
24+
{
25+
return Translator::getInstance()->getTranslation("ticking-entity-problem", [
26+
"name" => $this->getName(),
27+
"location" => $this->getLocationX() . ", " . $this->getLocationY() . ", " . $this->getLocationZ()
28+
]);
29+
}
30+
31+
/**
32+
* @return string[]
33+
*/
34+
public static function getPatterns(): array
35+
{
36+
return [
37+
static::PATTERN_DESCRIPTION => "/^Description: Ticking entity$/",
38+
static::PATTERN_ENTITY_TYPE => "/Entity Type: ([\w:_]+)/",
39+
static::PATTERN_ENTITY_NAME => "/Entity Name: (.+)/",
40+
static::PATTERN_ENTITY_LOCATION => "/Entity's Exact location: (-?[\d.]+), (-?[\d.]+), (-?[\d.]+)/"
41+
];
42+
}
43+
44+
public function setMatches(array $matches, $patternKey): void
45+
{
46+
$this->matchedPattern = $patternKey;
47+
switch ($patternKey) {
48+
case static::PATTERN_ENTITY_TYPE:
49+
$this->type = $matches[1];
50+
break;
51+
case static::PATTERN_ENTITY_NAME:
52+
$this->name = $matches[1];
53+
break;
54+
case static::PATTERN_ENTITY_LOCATION:
55+
$this->locationX = (float)$matches[1];
56+
$this->locationY = (float)$matches[2];
57+
$this->locationZ = (float)$matches[3];
58+
break;
59+
}
60+
61+
$this->addSolution(new RemoveEntitySolution());
62+
$this->updateSolution();
63+
}
64+
65+
/**
66+
* @return void
67+
*/
68+
protected function updateSolution(): void
69+
{
70+
$this->solutions[0]->setName($this->getName());
71+
$this->solutions[0]->setLocationX($this->getLocationX());
72+
$this->solutions[0]->setLocationY($this->getLocationY());
73+
$this->solutions[0]->setLocationZ($this->getLocationZ());
74+
}
75+
76+
/**
77+
* @param $insight
78+
* @return bool
79+
*/
80+
public function isEqual($insight): bool
81+
{
82+
if ($insight instanceof TickingEntityProblem) {
83+
$this->addInformationFromProblem($insight);
84+
return true;
85+
}
86+
return parent::isEqual($insight);
87+
}
88+
89+
/**
90+
* @return string|null
91+
*/
92+
public function getType(): ?string
93+
{
94+
return $this->type;
95+
}
96+
97+
/**
98+
* @return string|null
99+
*/
100+
public function getName(): ?string
101+
{
102+
return $this->name;
103+
}
104+
105+
/**
106+
* @return float|null
107+
*/
108+
public function getLocationX(): ?float
109+
{
110+
return $this->locationX;
111+
}
112+
113+
/**
114+
* @return float|null
115+
*/
116+
public function getLocationY(): ?float
117+
{
118+
return $this->locationY;
119+
}
120+
121+
/**
122+
* @return float|null
123+
*/
124+
public function getLocationZ(): ?float
125+
{
126+
return $this->locationZ;
127+
}
128+
129+
/**
130+
* @param static $problem
131+
* @return void
132+
*/
133+
public function addInformationFromProblem(TickingEntityProblem $problem): void
134+
{
135+
if ($problem->getName() !== null) {
136+
$this->name = $problem->getName();
137+
}
138+
if ($problem->getType() !== null) {
139+
$this->type = $problem->getType();
140+
}
141+
if ($problem->getLocationX() !== null) {
142+
$this->locationX = $problem->getLocationX();
143+
}
144+
if ($problem->getLocationY() !== null) {
145+
$this->locationY = $problem->getLocationY();
146+
}
147+
if ($problem->getLocationZ() !== null) {
148+
$this->locationZ = $problem->getLocationZ();
149+
}
150+
$this->updateSolution();
151+
}
152+
153+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Aternos\Codex\Minecraft\Analysis\Solution\CrashReport;
4+
5+
abstract class CrashReportSolution extends \Aternos\Codex\Minecraft\Analysis\Solution\MinecraftSolution
6+
{
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
namespace Aternos\Codex\Minecraft\Analysis\Solution\CrashReport;
4+
5+
use Aternos\Codex\Minecraft\Translator\Translator;
6+
7+
class RemoveEntitySolution extends CrashReportSolution
8+
{
9+
protected ?string $name;
10+
protected ?float $locationX;
11+
protected ?float $locationY;
12+
protected ?float $locationZ;
13+
14+
/**
15+
* @inheritDoc
16+
*/
17+
public function getMessage(): string
18+
{
19+
return Translator::getInstance()->getTranslation("remove-entity-solution", [
20+
"name" => $this->getName(),
21+
"location" => $this->getLocationX() . ", " . $this->getLocationY() . ", " . $this->getLocationZ()
22+
]);
23+
}
24+
25+
/**
26+
* @return string|null
27+
*/
28+
public function getName(): ?string
29+
{
30+
return $this->name;
31+
}
32+
33+
/**
34+
* @param string|null $name
35+
* @return $this
36+
*/
37+
public function setName(?string $name): RemoveEntitySolution
38+
{
39+
$this->name = $name;
40+
return $this;
41+
}
42+
43+
/**
44+
* @return float|null
45+
*/
46+
public function getLocationX(): ?float
47+
{
48+
return $this->locationX;
49+
}
50+
51+
/**
52+
* @param float|null $locationX
53+
* @return $this
54+
*/
55+
public function setLocationX(?float $locationX): RemoveEntitySolution
56+
{
57+
$this->locationX = $locationX;
58+
return $this;
59+
}
60+
61+
/**
62+
* @return float|null
63+
*/
64+
public function getLocationY(): ?float
65+
{
66+
return $this->locationY;
67+
}
68+
69+
/**
70+
* @param float|null $locationY
71+
* @return $this
72+
*/
73+
public function setLocationY(?float $locationY): RemoveEntitySolution
74+
{
75+
$this->locationY = $locationY;
76+
return $this;
77+
}
78+
79+
/**
80+
* @return float|null
81+
*/
82+
public function getLocationZ(): ?float
83+
{
84+
return $this->locationZ;
85+
}
86+
87+
/**
88+
* @param float|null $locationZ
89+
* @return $this
90+
*/
91+
public function setLocationZ(?float $locationZ): RemoveEntitySolution
92+
{
93+
$this->locationZ = $locationZ;
94+
return $this;
95+
}
96+
}

src/Log/CrashReport/ForgeCrashReportLog.php

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class ForgeCrashReportLog extends MinecraftCrashReportLog
88
{
9+
910
public function getSoftware(): string
1011
{
1112
return "Forge";

0 commit comments

Comments
 (0)