Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"plugin-remove-solution": "Remove the plugin '{{plugin-name}}'.",
"file-delete-solution": "Delete the file '{{file-path}}'.",
"file-edit-solution": "Edit the file '{{file-path}}'.",
"folder-create-solution": "Create the folder '{{folder-path}}'.",
"mod-install-different-version-solution": "Install a different version of the mod '{{mod-name}}'.",
"mod-install-solution": "Install the mod '{{mod-name}}'.",
"mod-install-solution-with-version": "Install the mod '{{mod-name}}' with version {{mod-version}}.",
Expand All @@ -59,6 +60,7 @@
"forge-install-different-version-solution": "Install a different Forge version.",
"malformed-encoding-problem": "Something (probably the MOTD) contains malformed formatting codes.",
"change-motd-solution": "Change the server MOTD.",
"code-of-conduct-folder-missing-problem": "The Code of Conduct folder does not exist.",
"bedrock-authentication-whitelist-problem": "Using a whitelist without online authentication is not allowed.",
"bedrock-authentication-allowlist-problem": "Using an allowlist without online authentication is not allowed.",
"disable-whitelist-solution": "Disable the whitelist.",
Expand Down
13 changes: 7 additions & 6 deletions src/Analyser/VanillaAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Aternos\Codex\Minecraft\Analysis\Information\Vanilla\VanillaVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\AquaticWorldOnOlderVersionProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\AuthServerProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\CodeOfConductFolderMissingProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\MalformedEncodingProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\OldPlayerDirectoryProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\OverworldSettingsMissingProblem;
Expand All @@ -14,13 +15,13 @@ class VanillaAnalyser extends MinecraftAnalyser
{
public function __construct()
{
$this->addPossibleInsightClass(VanillaVersionInformation::class);

$this->addPossibleInsightClass(OldPlayerDirectoryProblem::class);
$this->addPossibleInsightClass(AquaticWorldOnOlderVersionProblem::class);
$this->addPossibleInsightClass(TickingBlockEntityProblem::class);
$this->addPossibleInsightClass(MalformedEncodingProblem::class);
$this->addPossibleInsightClass(AuthServerProblem::class);
$this->addPossibleInsightClass(CodeOfConductFolderMissingProblem::class);
$this->addPossibleInsightClass(MalformedEncodingProblem::class);
$this->addPossibleInsightClass(OldPlayerDirectoryProblem::class);
$this->addPossibleInsightClass(OverworldSettingsMissingProblem::class);
$this->addPossibleInsightClass(TickingBlockEntityProblem::class);
$this->addPossibleInsightClass(VanillaVersionInformation::class);
}
}
}
2 changes: 1 addition & 1 deletion src/Analysis/Problem/Fabric/FabricDuplicateModProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ public function setMatches(array $matches, mixed $patternKey): void
$this->setModName($matches[3]);
$this->addSolution(new FileDeleteSolution($matches[4], FilePathType::ABSOLUTE));
}
}
}
37 changes: 37 additions & 0 deletions src/Analysis/Problem/Vanilla/CodeOfConductFolderMissingProblem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Aternos\Codex\Minecraft\Analysis\Problem\Vanilla;

use Aternos\Codex\Minecraft\Analysis\Solution\Folder\FolderCreateSolution;
use Aternos\Codex\Minecraft\Translator\Translator;

class CodeOfConductFolderMissingProblem extends VanillaProblem
{
/**
* @inheritDoc
*/
public function getMessage(): string
{
return Translator::getInstance()->getTranslation("code-of-conduct-folder-missing-problem");
}

/**
* @inheritDoc
*/
public static function getPatterns(): array
{
return [
'/Failed to start the minecraft server\njava\.lang\.IllegalArgumentException\: Code of Conduct folder does not exist: (.*)/'
];
}

/**
* @inheritDoc
*/
public function setMatches(array $matches, mixed $patternKey): void
{
// usually "codeofconduct"
$folder = $matches[1];
$this->addSolution(new FolderCreateSolution($folder));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ public function getMessage(): string
{
return parent::getMessage() . " " . Translator::getInstance()->getTranslation("authme-shutdown-solution");
}
}
}
2 changes: 1 addition & 1 deletion src/Analysis/Solution/File/FileEditSolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ public function processEdit(string $fileContent): ?string
{
return preg_replace($this->getPattern(), $this->getReplacement(), $fileContent);
}
}
}
2 changes: 1 addition & 1 deletion src/Analysis/Solution/File/FilePathType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ enum FilePathType
{
case RELATIVE;
case ABSOLUTE;
}
}
2 changes: 1 addition & 1 deletion src/Analysis/Solution/File/FileSolution.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ public function isAbsolutePath(): bool
{
return $this->getType() === FilePathType::ABSOLUTE;
}
}
}
17 changes: 17 additions & 0 deletions src/Analysis/Solution/Folder/FolderCreateSolution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Aternos\Codex\Minecraft\Analysis\Solution\Folder;

use Aternos\Codex\Analysis\AutomatableSolutionInterface;
use Aternos\Codex\Minecraft\Translator\Translator;

class FolderCreateSolution extends FolderSolution implements AutomatableSolutionInterface
{
/**
* @inheritDoc
*/
public function getMessage(): string
{
return Translator::getInstance()->getTranslation("folder-create-solution", ["folder-path" => $this->getPath()]);
}
}
90 changes: 90 additions & 0 deletions src/Analysis/Solution/Folder/FolderSolution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

namespace Aternos\Codex\Minecraft\Analysis\Solution\Folder;

use Aternos\Codex\Minecraft\Analysis\Solution\File\FilePathType;
use Aternos\Codex\Minecraft\Analysis\Solution\MinecraftSolution;

abstract class FolderSolution extends MinecraftSolution
{
/**
* @param string $path The relative path (without a starting slash) or absolute path to the folder.
* If the path is relative, it will be treated as relative to the Minecraft server root directory.
* @param FilePathType $type Is the path relative or absolute?
*/
public function __construct(
protected string $path,
protected FilePathType $type = FilePathType::RELATIVE
)
{
}

/**
* Set the relative path
* The path is relative to the Minecraft server root directory without a starting slash
*
* @param string $path
* @return $this
*/
public function setRelativePath(string $path): static
{
$this->path = $path;
$this->type = FilePathType::RELATIVE;
return $this;
}

/**
* Set the absolute path
*
* @param string $path
* @return $this
*/
public function setAbsolutePath(string $path): static
{
$this->path = $path;
$this->type = FilePathType::ABSOLUTE;
return $this;
}

/**
* Get the path
* If isRelative() the path is relative to the Minecraft server root directory without a starting slash
*
* @return string
*/
public function getPath(): string
{
return $this->path;
}

/**
* Get the type of the path (absolute or relative)
*
* @return FilePathType
*/
public function getType(): FilePathType
{
return $this->type;
}

/**
* Check if the path is relative
* The path is relative to the Minecraft server root directory without a starting slash
*
* @return bool
*/
public function isRelative(): bool
{
return $this->getType() === FilePathType::RELATIVE;
}

/**
* Check if the path is absolute
*
* @return bool
*/
public function isAbsolutePath(): bool
{
return $this->getType() === FilePathType::ABSOLUTE;
}
}
150 changes: 150 additions & 0 deletions test/data/Vanilla/vanilla-code-of-conduct.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"id": "vanilla\/server",
"name": "Vanilla",
"type": "Server Log",
"version": null,
"title": "Vanilla Server Log",
"entries": [
{
"level": 6,
"time": null,
"prefix": "[14:20:38] [ServerMain\/INFO]:",
"lines": [
{
"number": 1,
"content": "[14:20:38] [ServerMain\/INFO]: Environment: Environment[sessionHost=https:\/\/sessionserver.mojang.com, servicesHost=https:\/\/api.minecraftservices.com, profilesHost=https:\/\/api.mojang.com, name=PROD]"
}
]
},
{
"level": 6,
"time": null,
"prefix": "[14:20:41] [ServerMain\/INFO]:",
"lines": [
{
"number": 2,
"content": "[14:20:41] [ServerMain\/INFO]: Loaded 1461 recipes"
}
]
},
{
"level": 6,
"time": null,
"prefix": "[14:20:41] [ServerMain\/INFO]:",
"lines": [
{
"number": 3,
"content": "[14:20:41] [ServerMain\/INFO]: Loaded 1574 advancements"
}
]
},
{
"level": 3,
"time": null,
"prefix": "[14:20:41] [ServerMain\/ERROR]:",
"lines": [
{
"number": 4,
"content": "[14:20:41] [ServerMain\/ERROR]: Failed to start the minecraft server"
},
{
"number": 5,
"content": "java.lang.IllegalArgumentException: Code of Conduct folder does not exist: codeofconduct"
},
{
"number": 6,
"content": "\tat aro.bU(SourceFile:119) ~[server-1.21.10.jar:?]"
},
{
"number": 7,
"content": "\tat aro.<init>(SourceFile:110) ~[server-1.21.10.jar:?]"
},
{
"number": 8,
"content": "\tat net.minecraft.server.Main.a(SourceFile:221) ~[server-1.21.10.jar:?]"
},
{
"number": 9,
"content": "\tat net.minecraft.server.MinecraftServer.a(SourceFile:304) ~[server-1.21.10.jar:?]"
},
{
"number": 10,
"content": "\tat net.minecraft.server.Main.main(SourceFile:220) ~[server-1.21.10.jar:?]"
},
{
"number": 11,
"content": "\tat net.minecraft.bundler.Main.lambda$run$0(Main.java:54) ~[?:?]"
},
{
"number": 12,
"content": "\tat java.base\/java.lang.Thread.run(Thread.java:1583) [?:?]"
},
{
"number": 13,
"content": ""
}
]
}
],
"analysis": {
"problems": [
{
"message": "The Code of Conduct folder does not exist.",
"counter": 1,
"entry": {
"level": 3,
"time": null,
"prefix": "[14:20:41] [ServerMain\/ERROR]:",
"lines": [
{
"number": 4,
"content": "[14:20:41] [ServerMain\/ERROR]: Failed to start the minecraft server"
},
{
"number": 5,
"content": "java.lang.IllegalArgumentException: Code of Conduct folder does not exist: codeofconduct"
},
{
"number": 6,
"content": "\tat aro.bU(SourceFile:119) ~[server-1.21.10.jar:?]"
},
{
"number": 7,
"content": "\tat aro.<init>(SourceFile:110) ~[server-1.21.10.jar:?]"
},
{
"number": 8,
"content": "\tat net.minecraft.server.Main.a(SourceFile:221) ~[server-1.21.10.jar:?]"
},
{
"number": 9,
"content": "\tat net.minecraft.server.MinecraftServer.a(SourceFile:304) ~[server-1.21.10.jar:?]"
},
{
"number": 10,
"content": "\tat net.minecraft.server.Main.main(SourceFile:220) ~[server-1.21.10.jar:?]"
},
{
"number": 11,
"content": "\tat net.minecraft.bundler.Main.lambda$run$0(Main.java:54) ~[?:?]"
},
{
"number": 12,
"content": "\tat java.base\/java.lang.Thread.run(Thread.java:1583) [?:?]"
},
{
"number": 13,
"content": ""
}
]
},
"solutions": [
{
"message": "Create the folder 'codeofconduct'."
}
]
}
],
"information": []
}
}
12 changes: 12 additions & 0 deletions test/data/Vanilla/vanilla-code-of-conduct.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[14:20:38] [ServerMain/INFO]: Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, profilesHost=https://api.mojang.com, name=PROD]
[14:20:41] [ServerMain/INFO]: Loaded 1461 recipes
[14:20:41] [ServerMain/INFO]: Loaded 1574 advancements
[14:20:41] [ServerMain/ERROR]: Failed to start the minecraft server
java.lang.IllegalArgumentException: Code of Conduct folder does not exist: codeofconduct
at aro.bU(SourceFile:119) ~[server-1.21.10.jar:?]
at aro.<init>(SourceFile:110) ~[server-1.21.10.jar:?]
at net.minecraft.server.Main.a(SourceFile:221) ~[server-1.21.10.jar:?]
at net.minecraft.server.MinecraftServer.a(SourceFile:304) ~[server-1.21.10.jar:?]
at net.minecraft.server.Main.main(SourceFile:220) ~[server-1.21.10.jar:?]
at net.minecraft.bundler.Main.lambda$run$0(Main.java:54) ~[?:?]
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Loading