Ebean 错误 - 模型未增强?

Ebean error - model is not enhanced?

Spigot 显然在 1.12 中删除了对 Ebean 的支持,所以我要切换到手动 Ebean。我已经能够自己修复大部分错误,但这一个超出了我的范围。我已经尝试了所有不同的 Maven 增强插件等,但是 none 似乎完全可以修复它。

错误:https://gyazo.com/50cf77c853ceb492e5389394d37c6088

代码:

    MysqlDataSource dataSource = new MysqlDataSource();
    dataSource.setUser(getConfig().getString("database.username"));
    dataSource.setPassword(getConfig().getString("database.password"));
    dataSource.setServerName(getConfig().getString("database.url"));
    dataSource.setDatabaseName("minecraft");
    ServerConfig config = new ServerConfig();
    config.setDataSource(dataSource);
    config.setDefaultServer(true);
    config.setRegister(true);
    config.setClasses(getDatabaseClasses());
    if (getConfig().getBoolean("database.rebuild")) {
        config.setDdlGenerate(true);
    }
    config.setDdlRun(true);
    EbeanServerFactory.create(config);

过滤数据:

@Entity
@Table(name = "erudition_filters")
public class FilterData extends Model {

@Id
private long id;

@NotNull
private String world;

private double x, y, z;

public double getX() {
    return x;
}

public void setX(double x) {
    this.x = x;
}

public double getY() {
    return y;
}

public void setY(double y) {
    this.y = y;
}

public double getZ() {
    return z;
}

public void setZ(double z) {
    this.z = z;
}

public void setLocation(Location location) {
    setWorld(location.getWorld().getName());
    setX(location.getX());
    setY(location.getY());
    setZ(location.getZ());
}

public Location getLocation() {
    return new Location(Bukkit.getWorld(getWorld()), getX(), getY(), getZ());
}

@Lob
@NotNull
private String itemsString;

public Inventory getItems() {
    try {
        if (getItemsString() == null)
            return null;
        return getItemsString().equals("none") ? null : ItemSerializer.fromBase64(getItemsString());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

public void setItems(Inventory items) {
    setItemsString(items == null ? "none" : ItemSerializer.toBase64(items));
}

public static FilterData createFilterData(Block block) {
    FilterData data = new FilterData();
    data.setLocation(block.getLocation());
    data.setItems(null);
    saveFilter(data);
    return data;
}

public String getItemsString() {
    return itemsString;
}

public void setItemsString(String itemsString) {
    this.itemsString = itemsString;
}

public String getWorld() {
    return world;
}

public void setWorld(String world) {
    this.world = world;
}

public static List<FilterData> getAllFilters() {
    return Ebean.getDefaultServer().find(FilterData.class).findList();
}

public static FilterData getFilter(Location location) {
    FilterData data;

    if (location.getBlock().hasMetadata("filterid")) {
        data = Ebean.getDefaultServer().find(FilterData.class,
                location.getBlock().getMetadata("filterid").get(0).asInt());
        if (data != null) {
            data.setLocation(location);
            return data;
        }
    }
    List<FilterData> filterDataList = Ebean.getDefaultServer().find(FilterData.class).where()
            .eq("world", location.getWorld().getName()).eq("x", location.getBlockX()).eq("y", location.getBlockY())
            .eq("z", location.getBlockZ()).findList();
    if (filterDataList.isEmpty())
        return null;
    if (filterDataList.size() > 1) {
        for (int i = 1; i < filterDataList.size(); i++) {
            if (filterDataList.get(i) == null)
                continue;
            deleteFilter(filterDataList.get(i));
        }
    }
    return filterDataList.get(0);
}

public static void saveFilter(FilterData data) {
    Ebean.getDefaultServer().save(data);
}

public static void updateFilter(FilterData data) {
    deleteFilter(Ebean.getDefaultServer().find(FilterData.class, data.getId()));
    Ebean.getDefaultServer().insert(data);
}

public static void deleteFilter(FilterData data) {
    Ebean.getDefaultServer().delete(data);
}

public long getId() {
    return id;
}

public boolean supports(ItemStack item) {
    if (getItems() == null)
        return false;
    for (ItemStack supportedItem : getItems()) {
        if (supportedItem == null)
            continue;
        if (supportedItem.getType() == item.getType() && (supportedItem.getData().equals(item.getData())))
            return true;
    }
    return false;
}

public void setId(long id) {
    this.id = id;
}
}

我使用 Gradle 而不是 Maven,我很容易让它工作。 (从字面上看只是添加了插件{ id "com.github.kt3k.ebean.enhance" 版本 "3.0.0" } 一开始它与 Gradle)

一起工作