codex-minecraft icon indicating copy to clipboard operation
codex-minecraft copied to clipboard

Fix: Extract plugin name from error message with dot in plugin name

Open pavog opened this issue 10 months ago • 0 comments

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 $pluginPath is a path, the file name (and extension) is extracted.
  • If $pluginPath is the file name (and extension), nothing happens.
  • If $pluginPath is 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.

pavog avatar Feb 13 '25 14:02 pavog