mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-16 05:02:20 +01:00
WIP fix for comment version number
This commit is contained in:
parent
d9783c8d73
commit
49fa079f13
@ -21,6 +21,7 @@ public class Config<T> {
|
||||
|
||||
private AbstractDatabaseHandler<T> handler;
|
||||
private Logger logger;
|
||||
private Addon addon;
|
||||
|
||||
public Config(BentoBox plugin, Class<T> type) {
|
||||
this.logger = plugin.getLogger();
|
||||
@ -29,6 +30,7 @@ public class Config<T> {
|
||||
|
||||
public Config(Addon addon, Class<T> type) {
|
||||
this.logger = addon.getLogger();
|
||||
this.addon = addon;
|
||||
handler = new YamlDatabase().getConfig(type);
|
||||
}
|
||||
|
||||
@ -77,6 +79,8 @@ public class Config<T> {
|
||||
* @param instance to save
|
||||
*/
|
||||
public boolean saveConfigObject(T instance) {
|
||||
// Set the addon (may be null)
|
||||
handler.setAddon(addon);
|
||||
try {
|
||||
handler.saveObject(instance);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException
|
||||
|
@ -5,6 +5,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
|
||||
/**
|
||||
* An abstract class that handles insert/select-operations into/from a database
|
||||
@ -34,6 +35,27 @@ public abstract class AbstractDatabaseHandler<T> {
|
||||
|
||||
protected BentoBox plugin;
|
||||
|
||||
/**
|
||||
* The addon that is accessing the database, if any.
|
||||
*/
|
||||
private Addon addon;
|
||||
|
||||
/**
|
||||
* Get the addon that is accessing the database, if any. May be null.
|
||||
* @return the addon
|
||||
*/
|
||||
public Addon getAddon() {
|
||||
return addon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the addon that is accessing the database, if any.
|
||||
* @param addon the addon to set
|
||||
*/
|
||||
public void setAddon(Addon addon) {
|
||||
this.addon = addon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -433,7 +433,7 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
// Store placeholder
|
||||
config.set(parent + random, " ");
|
||||
// Create comment
|
||||
yamlComments.put(random, "# " + comment.replace(TextVariables.VERSION, plugin.getDescription().getVersion()));
|
||||
yamlComments.put(random, "# " + comment.replace(TextVariables.VERSION, Objects.isNull(getAddon()) ? plugin.getDescription().getVersion() : getAddon().getDescription().getVersion()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user