问题是,当FDevTools([nukkit] https://github.com/NukkitX/Nukkit的插件编译器和插件加载器)尝试查找类时,它返回适当的错误,因为该类不存在,但我不理解为什么要首先找班呢?
这是在FDevtools中引发错误的相关行 https://github.com/jasin/FDevTools/blob/master/src/main/java/moe/berd/FDevTools/SourcePluginClassLoader.java#L41
尝试加载的两个类是
jasin.mcmmo.datatypes.player.PlayerProfileBeanInfo
jasin.mcmmo.datatypes.player.PlayerProfileCustomizer
我试图弄清楚生成类名的地方无济于事。
使用snakeyaml的调用代码
public class FlatFileDatabase implements Database {
private String path;
public FlatFileDatabase(String path) {
this.path = path;
}
public PlayerProfile loadPlayerProfile(String name, UUID uuid, boolean create) {
PlayerProfile profile = new PlayerProfile();
File file = new File(this.path + File.separator + name);
PlayerProfileRepresenter representer = new PlayerProfileRepresenter();
Yaml yaml = new Yaml(new CustomClassLoaderConstructor(FlatFileDatabase.class.getClassLoader()));
if(file.exists()) {
try {
profile = yaml.loadAs(new FileInputStream(file), PlayerProfile.class);
} catch(Exception e) {
System.out.println(e);
}
} else if(create) {
try {
profile.setName(name);
profile.setUUID(uuid.toString());
FileWriter writer = new FileWriter(file, false);
yaml.dump(profile, writer);
} catch(Exception e) { }
}
return profile;
}
private class PlayerProfileRepresenter extends Representer {
@Override
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue, Tag customTag) {
if("loaded".equals(property.getName())) {
return null;
} else {
return super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
}
}
}
}
package jasin.mcmmo.datatypes.player;
import cn.nukkit.Player;
import java.beans.*;
public class PlayerProfile {
public String name;
public String UUID;
public boolean loaded;
//private Player player;
public PlayerProfile() {}
public PlayerProfile(Player player) {
//this.player = player;
}
public PlayerProfile(String name, String uuid) {
this.name = name;
this.UUID = uuid;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getUUID() {
return this.UUID;
}
public void setUUID(String uuid) {
this.UUID = uuid;
}
@Transient
public boolean isLoaded() {
return true;
}
public void setLoaded(boolean loaded) {
this.loaded = loaded;
}
}
16:28:01 [错误] [FDevTools] java.lang.ClassNotFoundException:jasin.mcmmo.datatypes.player.PlayerProfileBeanInfo
16:28:01 [错误] [FDevTools] java.lang.ClassNotFoundException:jasin.mcmmo.datatypes.player.PlayerProfileCustomizer
预期结果是不应加载那些类PlayerProfileBeanInfo和PlayerProfileCustomizer,因为它们不存在。或不应该存在afaik。我对snakeyaml的工作方式缺少什么,它需要这些类吗?我很肯定我在这里缺少细微差别,但我找不到。