mirror of
https://github.com/CarmJos/EasyPlugin.git
synced 2026-06-05 00:58:17 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 80042aead7 | |||
| 024efc7690 | |||
| 54bf188c5c |
+7
-27
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU General Public License v3.0</name>
|
||||
<url>https://opensource.org/licenses/GPL-3.0</url>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
@@ -51,34 +51,14 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--通过 bom 快捷导入所有相关模块-->
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-common</artifactId>
|
||||
<artifactId>easyplugin-bom</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-lp</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-placeholderapi</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-vault</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
</properties>
|
||||
|
||||
<artifactId>easyplugin-bom</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>00-EasyPlugin-Bom</name>
|
||||
<description>轻松插件汇总导入模块,允许快捷导入相关的接口并避免版本不一致问题。</description>
|
||||
<url>https://github.com/CarmJos/EasyPlugin</url>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-main</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-configuration</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-command</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-database</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-gui</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-placeholderapi</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-vault</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-lp</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-main</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-configuration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-database</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-gui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-command</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-placeholderapi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-vault</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-lp</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
+23
-32
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU General Public License v3.0</name>
|
||||
<url>https://opensource.org/licenses/GPL-3.0</url>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
@@ -50,40 +50,31 @@
|
||||
</ciManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!--通过 bom 快捷导入所有相关模块-->
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-main</artifactId>
|
||||
<artifactId>easyplugin-bom</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
<type>pom</type>
|
||||
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-placeholderapi</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-lp</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-vault</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-command</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-configuration</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-gui</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.parent.groupId}</groupId>
|
||||
<artifactId>easyplugin-database</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU General Public License v3.0</name>
|
||||
<url>https://opensource.org/licenses/GPL-3.0</url>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
@@ -57,6 +57,73 @@
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!--
|
||||
ConfigUpdater - to save the comments in default configuration.
|
||||
-> https://github.com/tchristofferson/Config-Updater
|
||||
-->
|
||||
<groupId>com.tchristofferson</groupId>
|
||||
<artifactId>ConfigUpdater</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.tchristofferson.configupdater</pattern>
|
||||
<shadedPattern>cc.carm.lib.easyplugin.configuration.updater</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
||||
<exclude>META-INF/*.txt</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+1
-4
@@ -49,10 +49,7 @@ public class ConfigStringCast<V> extends FileConfigCachedValue<V> {
|
||||
}
|
||||
|
||||
public void set(@Nullable String value) {
|
||||
getSourceOptional().ifPresent(source -> {
|
||||
source.getConfig().set(getSectionName(), value);
|
||||
source.save();
|
||||
});
|
||||
setIfPresent(value, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+58
-20
@@ -1,15 +1,17 @@
|
||||
package cc.carm.lib.easyplugin.configuration.file;
|
||||
|
||||
|
||||
import com.tchristofferson.configupdater.ConfigUpdater;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public class FileConfig {
|
||||
|
||||
public static Supplier<FileConfig> pluginConfiguration = null;
|
||||
@@ -28,34 +30,69 @@ public class FileConfig {
|
||||
private long updateTime;
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final File fileFolder;
|
||||
private final String fileName;
|
||||
|
||||
private final String resourcePath;
|
||||
|
||||
private File file;
|
||||
private FileConfiguration config;
|
||||
|
||||
public FileConfig(final JavaPlugin plugin) {
|
||||
public FileConfig(@NotNull JavaPlugin plugin) throws IOException {
|
||||
this(plugin, "config.yml");
|
||||
}
|
||||
|
||||
public FileConfig(final JavaPlugin plugin, final String name) {
|
||||
public FileConfig(@NotNull JavaPlugin plugin,
|
||||
@NotNull String fileName) throws IOException {
|
||||
this(plugin, fileName, fileName);
|
||||
}
|
||||
|
||||
public FileConfig(@NotNull JavaPlugin plugin, @NotNull String resourcePath,
|
||||
@NotNull String fileName) throws IOException {
|
||||
this(plugin, resourcePath, plugin.getDataFolder(), fileName);
|
||||
}
|
||||
|
||||
public FileConfig(@NotNull JavaPlugin plugin, @NotNull String resourcePath,
|
||||
@NotNull File fileFolder, @NotNull String fileName) throws IOException {
|
||||
this.plugin = plugin;
|
||||
this.fileName = name;
|
||||
this.resourcePath = resourcePath;
|
||||
this.fileFolder = fileFolder;
|
||||
this.fileName = fileName;
|
||||
|
||||
initFile();
|
||||
}
|
||||
|
||||
private void initFile() {
|
||||
this.updateTime = System.currentTimeMillis();
|
||||
this.file = new File(plugin.getDataFolder(), fileName);
|
||||
if (!this.file.exists()) {
|
||||
if (!this.file.getParentFile().exists()) {
|
||||
boolean success = this.file.getParentFile().mkdirs();
|
||||
private void initFile() throws IOException {
|
||||
if (!getFileFolder().exists()) getFileFolder().mkdirs();
|
||||
this.file = new File(getFileFolder(), fileName);
|
||||
|
||||
if (!file.exists()) {
|
||||
InputStream resourceStream = plugin.getResource(resourcePath);
|
||||
if (resourceStream == null) {
|
||||
throw new IOException("The resource " + resourcePath + " cannot find in " + plugin.getName() + " !");
|
||||
}
|
||||
plugin.saveResource(fileName, true);
|
||||
|
||||
OutputStream out = new FileOutputStream(file);
|
||||
byte[] buffer = new byte[1024];
|
||||
|
||||
int readBytes;
|
||||
while ((readBytes = resourceStream.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, readBytes);
|
||||
}
|
||||
|
||||
out.close();
|
||||
resourceStream.close();
|
||||
|
||||
ConfigUpdater.update(plugin, resourcePath, file); // Save comments
|
||||
}
|
||||
|
||||
this.updateTime = System.currentTimeMillis();
|
||||
this.config = YamlConfiguration.loadConfiguration(this.file);
|
||||
}
|
||||
|
||||
public File getFileFolder() {
|
||||
return fileFolder;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
@@ -64,15 +101,16 @@ public class FileConfig {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
getConfig().save(getFile());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public JavaPlugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
public void save() throws IOException {
|
||||
getConfig().save(getFile());
|
||||
ConfigUpdater.update(plugin, resourcePath, file); // Save comments
|
||||
}
|
||||
|
||||
public void reload() throws IOException {
|
||||
this.updateTime = System.currentTimeMillis();
|
||||
if (getFile().exists()) {
|
||||
this.config = YamlConfiguration.loadConfiguration(getFile());
|
||||
|
||||
+24
-1
@@ -4,6 +4,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class FileConfigValue {
|
||||
@@ -25,7 +26,29 @@ public abstract class FileConfigValue {
|
||||
}
|
||||
|
||||
public void save() {
|
||||
getSourceOptional().ifPresent(FileConfig::save);
|
||||
getSourceOptional().ifPresent(fileConfig -> {
|
||||
try {
|
||||
fileConfig.save();
|
||||
} catch (Exception ex) {
|
||||
fileConfig.getPlugin().getLogger().severe("Could not save the " + fileConfig.getFile() + " .");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setIfPresent(@Nullable Object value, boolean save) {
|
||||
getConfigOptional().ifPresent(configuration -> configuration.set(getSectionName(), value));
|
||||
if (save) save();
|
||||
}
|
||||
|
||||
public void createSection(Map<?, ?> values) {
|
||||
getConfigOptional().ifPresent(configuration -> {
|
||||
if (values == null) {
|
||||
configuration.set(getSectionName(), null);
|
||||
} else {
|
||||
configuration.createSection(getSectionName(), values);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public @Nullable FileConfig getSource() {
|
||||
|
||||
+4
-4
@@ -62,6 +62,10 @@ public class ConfigMessageList extends ConfigValueList<String> {
|
||||
}
|
||||
}
|
||||
|
||||
public void send(@Nullable CommandSender sender, String[] params, Object[] values) {
|
||||
MessageUtils.sendWithPlaceholders(sender, get(), params, values);
|
||||
}
|
||||
|
||||
public void sendToAll(String[] params, Object[] values) {
|
||||
Bukkit.getOnlinePlayers().forEach(pl -> MessageUtils.sendWithPlaceholders(pl, get(), params, values));
|
||||
}
|
||||
@@ -78,10 +82,6 @@ public class ConfigMessageList extends ConfigValueList<String> {
|
||||
}
|
||||
}
|
||||
|
||||
public void send(@Nullable CommandSender sender, String[] params, Object[] values) {
|
||||
MessageUtils.sendWithPlaceholders(sender, get(), params, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable FileConfig getSource() {
|
||||
return source == null ? FileConfig.getMessageConfiguration() : source;
|
||||
|
||||
+9
-6
@@ -32,8 +32,14 @@ public class ConfigValue<V> extends FileConfigValue {
|
||||
|
||||
public V get() {
|
||||
return getConfigOptional()
|
||||
.map(config -> castValue(config.get(getSectionName()), clazz, this.defaultValue))
|
||||
.orElse(setDefault()); // 如果没有默认值,就把配置写进去,便于配置
|
||||
.map(config -> {
|
||||
if (config.contains(getSectionName())) {
|
||||
return castValue(config.get(getSectionName()), clazz, this.defaultValue);
|
||||
} else {
|
||||
return setDefault(); // 如果没有默认值,就把配置写进去,便于配置
|
||||
}
|
||||
})
|
||||
.orElse(defaultValue);
|
||||
}
|
||||
|
||||
public @NotNull Optional<V> getOptional() {
|
||||
@@ -41,10 +47,7 @@ public class ConfigValue<V> extends FileConfigValue {
|
||||
}
|
||||
|
||||
public void set(@Nullable V value) {
|
||||
getSourceOptional().ifPresent(source -> {
|
||||
source.getConfig().set(getSectionName(), value);
|
||||
source.save();
|
||||
});
|
||||
setIfPresent(value, true);
|
||||
}
|
||||
|
||||
public V setDefault() {
|
||||
|
||||
+1
-4
@@ -57,10 +57,7 @@ public class ConfigValueList<V> extends FileConfigValue {
|
||||
}
|
||||
|
||||
public void set(@Nullable ArrayList<V> value) {
|
||||
getSourceOptional().ifPresent(source -> {
|
||||
source.getConfig().set(getSectionName(), value);
|
||||
source.save();
|
||||
});
|
||||
setIfPresent(value, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-4
@@ -50,10 +50,7 @@ public class ConfigValueMap<K, V> extends FileConfigCachedValue<Map<K, V>> {
|
||||
}
|
||||
|
||||
public void set(@Nullable Map<K, V> valuesMap) {
|
||||
getSourceOptional().ifPresent(source -> {
|
||||
source.getConfig().createSection(getSectionName(), valuesMap);
|
||||
source.save();
|
||||
});
|
||||
createSection(valuesMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU General Public License v3.0</name>
|
||||
<url>https://opensource.org/licenses/GPL-3.0</url>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<dependency>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easysql-beecp</artifactId>
|
||||
<version>0.2.4</version>
|
||||
<version>0.2.6</version>
|
||||
<optional>true</optional>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
+30
-4
@@ -1,8 +1,9 @@
|
||||
package cc.carm.lib.easyplugin.database;
|
||||
|
||||
import cc.carm.lib.easysql.api.SQLManager;
|
||||
import cc.carm.lib.easysql.api.builder.TableCreateBuilder;
|
||||
import cc.carm.lib.easysql.api.builder.TableQueryBuilder;
|
||||
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateAction;
|
||||
import cc.carm.lib.easysql.api.action.PreparedSQLUpdateBatchAction;
|
||||
import cc.carm.lib.easysql.api.builder.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -19,7 +20,8 @@ public class DatabaseTable {
|
||||
this(tableName, columns, null);
|
||||
}
|
||||
|
||||
public DatabaseTable(@NotNull String tableName, @NotNull String[] columns, @Nullable String tableSettings) {
|
||||
public DatabaseTable(@NotNull String tableName, @NotNull String[] columns,
|
||||
@Nullable String tableSettings) {
|
||||
this.tableName = tableName;
|
||||
this.columns = columns;
|
||||
this.tableSettings = tableSettings;
|
||||
@@ -45,7 +47,31 @@ public class DatabaseTable {
|
||||
}
|
||||
|
||||
public TableQueryBuilder createQuery(SQLManager sqlManager) {
|
||||
return sqlManager.createQuery().inTable(tableName);
|
||||
return sqlManager.createQuery().inTable(getTableName());
|
||||
}
|
||||
|
||||
public DeleteBuilder createDelete(SQLManager sqlManager) {
|
||||
return sqlManager.createDelete(getTableName());
|
||||
}
|
||||
|
||||
public UpdateBuilder createUpdate(SQLManager sqlManager) {
|
||||
return sqlManager.createUpdate(getTableName());
|
||||
}
|
||||
|
||||
public InsertBuilder<PreparedSQLUpdateAction> createInsert(SQLManager sqlManager) {
|
||||
return sqlManager.createInsert(getTableName());
|
||||
}
|
||||
|
||||
public InsertBuilder<PreparedSQLUpdateBatchAction> createInsertBatch(SQLManager sqlManager) {
|
||||
return sqlManager.createInsertBatch(getTableName());
|
||||
}
|
||||
|
||||
public ReplaceBuilder<PreparedSQLUpdateAction> createReplace(SQLManager sqlManager) {
|
||||
return sqlManager.createReplace(getTableName());
|
||||
}
|
||||
|
||||
public ReplaceBuilder<PreparedSQLUpdateBatchAction> createReplaceBatch(SQLManager sqlManager) {
|
||||
return sqlManager.createReplaceBatch(getTableName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU General Public License v3.0</name>
|
||||
<url>https://opensource.org/licenses/GPL-3.0</url>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<licenses>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU General Public License v3.0</name>
|
||||
<url>https://opensource.org/licenses/GPL-3.0</url>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -14,8 +14,13 @@
|
||||
<groupId>cc.carm.lib</groupId>
|
||||
<artifactId>easyplugin-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.1.2</version>
|
||||
<version>1.2.0</version>
|
||||
<modules>
|
||||
|
||||
<module>easyplugin-bom</module>
|
||||
<module>easyplugin-all</module>
|
||||
<module>easyplugin-common</module>
|
||||
|
||||
<module>easyplugin-main</module>
|
||||
|
||||
<module>easyplugin-database</module>
|
||||
@@ -25,10 +30,8 @@
|
||||
|
||||
<module>easyplugin-vault</module>
|
||||
<module>easyplugin-placeholderapi</module>
|
||||
|
||||
<module>easyplugin-all</module>
|
||||
<module>easyplugin-common</module>
|
||||
<module>easyplugin-lp</module>
|
||||
|
||||
</modules>
|
||||
|
||||
<name>EasyPlugin</name>
|
||||
@@ -46,8 +49,8 @@
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU General Public License v3.0</name>
|
||||
<url>https://opensource.org/licenses/GPL-3.0</url>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/MIT</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user