codex-minecraft
codex-minecraft copied to clipboard
Fix: Extract plugin name from error message with dot in plugin name
Problem
If a plugin has a dot in its name, the part after the . in the name is cut off. This is because this part is interpreted as a file extension and is not returned by
pathinfo($pluginPath, PATHINFO_FILENAME)
In the function extractPluginName(string $pluginPath): string we have to expeect that $pluginPath can be a path, a file name or a plugin name. Therefore, we must not simply cut it off after the .. Otherwise, for example, mclo.gs becomes just mclo, see this example: https://mclo.gs/4UEgJ73
Solution We always extract the complete file name using
pathinfo($pluginPath, PATHINFO_BASENAME)
- If
$pluginPathis a path, the file name (and extension) is extracted. - If
$pluginPathis the file name (and extension), nothing happens. - If
$pluginPathis only the plugin name, nothing happens.
We then check whether the result ends with .jar. We can assume that it does, because plugins must always be a .jar file. Other files are not loaded from the server.