Add check for legacy API method calls on plugins

This commit is contained in:
KingRainbow44 2023-06-01 14:18:53 -04:00
parent fd40575cb4
commit deaa13c2af
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
12 changed files with 32 additions and 15 deletions

View File

@ -1,17 +1,18 @@
package emu.grasscutter.plugin;
import static emu.grasscutter.utils.lang.Language.translate;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.server.event.*;
import emu.grasscutter.utils.*;
import lombok.*;
import javax.annotation.Nullable;
import java.io.*;
import java.lang.reflect.Method;
import java.net.*;
import java.util.*;
import java.util.jar.*;
import javax.annotation.Nullable;
import lombok.*;
import static emu.grasscutter.utils.lang.Language.translate;
/** Manages the server's plugins and the event system. */
public final class PluginManager {
@ -216,9 +217,14 @@ public final class PluginManager {
Grasscutter.getLogger().info(translate("plugin.enabling_plugin", name));
try {
plugin.onEnable();
return;
} catch (NoSuchMethodError ignored) {
Grasscutter.getLogger().error(translate("plugin.invalid_api.outdated", name));
} catch (Throwable exception) {
Grasscutter.getLogger().error(translate("plugin.enabling_failed", name), exception);
}
this.disablePlugin(plugin);
});
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "Failed to disable plugin: %s",
"invalid_api": {
"not_present": "Plugin %s does not specify an API version.",
"lower": "Plugin %s is using API version %s, while the server is using API version %s."
"lower": "Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "Plugin %s is using an outdated API method."
}
}
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "Error al desactivar el plugin: %s",
"invalid_api": {
"not_present": "🇺🇸Plugin %s does not specify an API version.",
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s."
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "🇺🇸Plugin %s is using an outdated API method."
}
}
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "Impossible de désactiver le plugin %s",
"invalid_api": {
"not_present": "🇺🇸Plugin %s does not specify an API version.",
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s."
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "🇺🇸Plugin %s is using an outdated API method."
}
}
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "Impossibile disabilitare il plug-in: %s",
"invalid_api": {
"not_present": "🇺🇸Plugin %s does not specify an API version.",
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s."
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "🇺🇸Plugin %s is using an outdated API method."
}
}
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "プラグインの無効化に失敗しました: %s",
"invalid_api": {
"not_present": "🇺🇸Plugin %s does not specify an API version.",
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s."
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "🇺🇸Plugin %s is using an outdated API method."
}
}
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "플러그인을 비활성화하는데 실패했습니다: %s",
"invalid_api": {
"not_present": "🇺🇸Plugin %s does not specify an API version.",
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s."
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "🇺🇸Plugin %s is using an outdated API method."
}
}
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "Nie udało się wyłączyć pluginu: %s",
"invalid_api": {
"not_present": "🇺🇸Plugin %s does not specify an API version.",
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s."
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "🇺🇸Plugin %s is using an outdated API method."
}
}
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "🇺🇸Failed to disable plugin: %s",
"invalid_api": {
"not_present": "🇺🇸Plugin %s does not specify an API version.",
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s."
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "🇺🇸Plugin %s is using an outdated API method."
}
}
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "Ошибка отключения Плагина: %s",
"invalid_api": {
"not_present": "🇺🇸Plugin %s does not specify an API version.",
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s."
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "🇺🇸Plugin %s is using an outdated API method."
}
}
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "无法禁用插件:%s",
"invalid_api": {
"not_present": "🇺🇸Plugin %s does not specify an API version.",
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s."
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "🇺🇸Plugin %s is using an outdated API method."
}
}
}

View File

@ -463,7 +463,8 @@
"disabling_failed": "🇺🇸Failed to disable plugin: %s",
"invalid_api": {
"not_present": "🇺🇸Plugin %s does not specify an API version.",
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s."
"lower": "🇺🇸Plugin %s is using API version %s, while the server is using API version %s.",
"outdated": "🇺🇸Plugin %s is using an outdated API method."
}
}
}