扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 63|回复: 0

[转载发布] rpgmaker-plugin-conflict-finder 自动寻找插件之间的冲突

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    昨天 17:34
  • 签到天数: 112 天

    连续签到: 2 天

    [LV.6]常住居民II

    2332

    主题

    398

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10541
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13299

    灌水之王

    发表于 2025-2-3 04:21:39 | 显示全部楼层 |阅读模式


    Hi,这是我开发的新工具,能够帮助查找插件冲突。
    最新版本的下载连结在Github上。下载完后双击打开conflict-finder即可使用。

    本工具是利用分析插件的执行顺序及写法来判断冲突,加密混淆过或写法比较特别的插件无法正确的被判断。找到插件之间的冲突后,本工具能够建议插件的摆放位置,藉由调换顺序来解决某些部分的冲突。
    然而,不是所有的插件冲突都可以藉由调换顺序来解决,RPG Maker常见的几种插件冲突有:

    覆盖(Overwrite)

    A插件
    1. const _Game_Player_searchLimit = Game_Player.prototype.searchLimit;Game_Player.prototype.searchLimit = function() { if (this.isDashing()) { return 999; } return _Game_Player_searchLimit.call(this);};复制代码
    复制代码
    B插件
    1. Game_Party.prototype.maxItems = function(item) { return 999;};复制代码
    复制代码
    A插件的作用完全被覆盖而失效了。如果是不小心覆盖的,就可能会导致错误发生。当A插件使用了别名(Alias)进行了补丁(Patching),而B插件是直接覆盖时,藉由调换两者顺序,可能可以让两个插件都能有作用。但是如果两者都是覆盖的写法,那则无法简单进行调换来解决。

    另一种是:

    过时(Outdated)

    原始
    1. Game_Character.prototype.searchLimit = function() { return 12;};复制代码
    复制代码
    A插件
    1. const _GamePlayer_searchLimit = Game_Player.prototype.searchLimit;Game_Player.prototype.searchLimit = function() { if (this.isDashing()) { return 999; } return _GamePlayer_searchLimit.call(this);};复制代码
    复制代码
    B插件
    1. Game_Character.prototype.searchLimit = function() { return 0;};复制代码
    复制代码
    因为Game_Player本身没有searchLimit方法,而是继承自Game_Character,所以A插件的searchLimit 储存着的是Game_CharactersearchLimit。当B插件后来再修改了searchLimit,A插件的searchLimit仍然是旧的,调换两者的顺序也能解决此问题。

    利用一种函数式的别名补丁方法,可以避免发生此问题:
    1. /** * Automatically choose whether to alias itself or the parent class. * * @param {Object} aliasClass - Use "Foo.prototype" for instance methods and "Foo" for static methods. * @param {string} methodName - The name of the method to alias. * @returns {Function} - The aliased method, callable with "call" or "apply". */PluginManager.alias = function(aliasClass, methodName) { if (aliasClass.hasOwnProperty(methodName)) { return aliasClass[methodName]; } else { const superClass = Object.getPrototypeOf(aliasClass); const superMethod = function(...args) { return superClass[methodName].apply(this, args); }; return superMethod; }};复制代码
    复制代码
    1. const _GamePlayer_searchLimit = Game_Player.prototype.searchLimit;复制代码
    复制代码
    改成
    1. const _GamePlayer_searchLimit = PluginManager.alias(Game_Player.prototype, "searchLimit");复制代码
    复制代码
    即可自动判断当前类别有没有此方法,没有的话,则会在调用时自动呼叫父类的方法来获取最新的状态。


                本帖来自P1论坛作者moonyoulove,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=496622  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-3-13 03:58 , Processed in 0.140304 second(s), 58 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表