Open 502647092 opened 4 years ago
Thanks for your report. The problem is probably caused by ProGuard inlining inject
from the superclass AbstractInjectConfig in InjectConfig:
public InjectConfig(FileConfig config) {
inject(config);
}
I can't reproduce it yet. If you can share these two compiled class files, that may help.
For now, you can probably work around it by keeping the inject method
-keepclassmembers class pw.yumc.SurvivalGamesKits.config.inject.AbstractInjectConfig { *** inject(...); }
or by disabling method inlining
-optimizations !method/inlining/*
if i close
code/removal/advanced
this error has goneproguard.conf
``` # -----不缩小----- #-dontshrink # -----不优化----- #-dontoptimize -optimizationpasses 1 #-optimizations code/removal/advanced # -----忽略所有警告----- #-dontwarn -dontnote # -----混淆时应用侵入式重载----- -overloadaggressively # -----启用混淆字典----- -dontobfuscate -obfuscationdictionary obf.dict -classobfuscationdictionary obf.dict -packageobfuscationdictionary obf.dict # -----保留所有属性 -keepattributes ** # -----保护所有实体中的字段名称----- -keepclassmembers class * implements java.io.Serializable {SurvivalGamesKits.java
``` package pw.yumc.SurvivalGamesKits; import java.io.File; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import me.wazup.survivalgames.SurvivalGames; import pw.yumc.SurvivalGamesKits.config.SGKConfig; import pw.yumc.SurvivalGamesKits.item.ItemManager; import pw.yumc.SurvivalGamesKits.listener.PlayerListener; import pw.yumc.YumCore.bukkit.Log; import pw.yumc.YumCore.commands.CommandSub; import pw.yumc.YumCore.commands.annotation.Cmd; import pw.yumc.YumCore.commands.annotation.Help; import pw.yumc.YumCore.commands.interfaces.Executor; import pw.yumc.YumCore.config.FileConfig; public class SurvivalGamesKits extends JavaPlugin implements Executor { private SurvivalGames sgMain; private FileConfig kits; private SGKConfig config; @Override public FileConfiguration getConfig() { return config.getConfig(); } public FileConfig getKits() { return kits; } public SGKConfig getSgkConfig() { return config; } public SurvivalGames getSgMain() { return sgMain; } @Override public void onEnable() { final Plugin plugin = Bukkit.getPluginManager().getPlugin("SurvivalGames"); if (plugin == null) { setEnabled(false); return; } File kitsFile = new File("plugins/SurvivalGames", "kits.yml"); if (kitsFile.exists()) { kits = new FileConfig(kitsFile); ItemManager.loadKits(); } else { Log.w("未找到 SurvivalGames 目录下的 kits.yml 文件. 如果是第一次启动 请稍候执行 reload 重新加载!"); } sgMain = (SurvivalGames) plugin; new CommandSub("SurvivalGamesKits", this); new PlayerListener(); } @Override public void onLoad() { config = new SGKConfig(); } @Cmd(permission = "SurvivalGamesKits.reload") @Help("重载配置文件") public void reload(CommandSender sender) { config.reload(); kits.reload(); ItemManager.loadKits(); Log.sender(sender, "§a配置文件已重载!"); } } ```SGKConfig.java
``` package pw.yumc.SurvivalGamesKits.config; import pw.yumc.YumCore.config.annotation.ConfigNode; import pw.yumc.YumCore.config.inject.InjectConfig; /** * @author 喵♂呜 * @since 2016年9月19日 下午7:35:57 */ public class SGKConfig extends InjectConfig { @ConfigNode("Select.OriginTitle") private String sotitle; @ConfigNode("Select.NowTitle") private String sntitle; private Boolean GiveCompassAtStart; private String CompassName; private String Message; private String NoNext; private Boolean SavePage; /** * @return the compassName */ public String getCompassName() { return CompassName; } /** * @return the giveCompassAtStart */ public Boolean getGiveCompassAtStart() { return GiveCompassAtStart; } /** * @return the message */ public String getMessage() { return Message; } /** * @return the noNext */ public String getNoNext() { return NoNext; } /** * @return the savePage */ public Boolean isSavePage() { return SavePage; } /** * @return the sntitle */ public String getSelNowTitle() { return sntitle; } /** * @return the sotitle */ public String getSelOriTitle() { return sotitle; } public Boolean isGiveCompassAtStart() { return GiveCompassAtStart; } } ```InjectConfig.java
``` package pw.yumc.YumCore.config.inject; import java.io.File; import pw.yumc.YumCore.config.FileConfig; /** * 配置自动载入类 * * @since 2016年7月5日 上午8:53:57 * @author 喵♂呜 */ public abstract class InjectConfig extends AbstractInjectConfig { public InjectConfig() { this(new FileConfig()); } public InjectConfig(File file) { this(new FileConfig(file)); } public InjectConfig(FileConfig config) { inject(config); } public InjectConfig(String name) { this(new FileConfig(name)); } /** * 获得配置文件 * * @return 配置文件 */ public FileConfig getConfig() { return (FileConfig) config; } /** * 重载配置文件 */ public void reload() { getConfig().reload(); inject(config); } /** * 自动化保存 */ public void save() { save(config); getConfig().save(); } } ```FileConfig.java
``` package pw.yumc.YumCore.config; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Set; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.MemorySection; import org.bukkit.configuration.file.YamlConfiguration; import pw.yumc.YumCore.bukkit.Log; /** * 一个继承于 {@link YamlConfiguration} 的配置文件类 * 强制UTF-8编码处理所有的文件信息 * * @author 喵♂呜 * @version 1.0 * @since 2015年11月7日 下午2:36:07 */ public class FileConfig extends AbstractConfig { protected static String VERSION = "Version"; private static char ALT_COLOR_CHAR = '&'; private static String DEFAULT = "config.yml"; private static String DATA_FORMANT = "yyyyMMddHHmmss"; private static String CONFIG_BACKUP = "配置: %s 已备份为 %s !"; private static String CONFIG_UPDATED = "配置: %s 升级成功 版本 %s !"; private static String CONFIG_OVERRIDE = "配置: %s 将覆盖原有字段数据..."; private static String CONFIG_NOT_FOUND = "配置: 文件 %s 不存在!"; private static String CONFIG_READ_ERROR = "配置: %s 读取错误..."; private static String CONFIG_SAVE_ERROR = "配置: %s 保存错误..."; private static String CONFIG_UPDATE_WARN = "配置: %s 版本 %s 过低 正在升级到 %s ..."; private static String CONFIG_CREATE_ERROR = "配置: %s 创建失败..."; private static String CONFIG_FORMAT_ERROR = "配置: %s 格式错误..."; private static String CONFIG_BACKUP_ERROR = "配置: %s 备份失败 异常: %s !"; private static String CONFIG_UPDATE_VALUE = "配置: 更新字段 %s 的值为 %s ..."; private static String CONFIG_BACKUP_AND_RESET = "配置: %s 格式错误 已备份为 %s 并恢复默认配置!"; private static String CONFIG_NOT_FOUND_IN_JAR = "配置: 从插件内部未找到预置的 %s 文件!"; private static String CONFIG_READ_COMMENT_ERROR = "配置: 读取文件注释信息失败!"; private static String STREAM_NOT_BE_NULL = "数据流不能为 NULL"; protected File file; private CommentConfig commentConfig; /** * 实例化默认配置文件 */ public FileConfig() { this(DEFAULT); } /** * 从文件载入配置 * * @param file * 配置文件名称 */ public FileConfig(File file) { Validate.notNull(file, FILE_NOT_BE_NULL); init(file); } /** * 从文件载入配置 * * @param parent * 文件夹 * @param filename * 配置文件名称 */ public FileConfig(File parent, String filename) { init(new File(parent, filename), true); } /** * 从数据流载入配置文件 * * @param stream * 数据流 */ public FileConfig(InputStream stream) { init(stream); } /** * 从文件载入配置 * * @param filename * 配置文件名称 */ public FileConfig(String filename) { init(new File(plugin.getDataFolder(), filename), true); } /** * 从文件载入配置 * * @param parent * 文件夹 * @param filename * 配置文件名称 */ public FileConfig(String parent, String filename) { init(new File(parent, filename), true); } /** * 添加到List末尾 * * @param