mirror of
https://e.coding.net/circlecloud/DataStorage.git
synced 2024-12-04 04:08:53 +00:00
feat: 使用新的类库
Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
parent
f3bca9a69c
commit
e28c3a00fb
31
.classpath
31
.classpath
@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<classpath>
|
|
||||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
|
||||||
</classpath>
|
|
23
.project
23
.project
@ -1,23 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>DataStorage</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
Binary file not shown.
165
pom.xml
165
pom.xml
@ -1,92 +1,77 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>cn.citycraft</groupId>
|
<groupId>pw.yumc</groupId>
|
||||||
<artifactId>DataStorage</artifactId>
|
<artifactId>DataStorage</artifactId>
|
||||||
<version>1.0.1</version>
|
<version>1.1</version>
|
||||||
<name>DataStorage</name>
|
<build>
|
||||||
<build>
|
<finalName>${project.artifactId}</finalName>
|
||||||
<finalName>${project.name}</finalName>
|
<resources>
|
||||||
<resources>
|
<resource>
|
||||||
<resource>
|
<directory>src/main/resources</directory>
|
||||||
<directory>src/main/resources</directory>
|
<filtering>true</filtering>
|
||||||
<filtering>true</filtering>
|
</resource>
|
||||||
</resource>
|
</resources>
|
||||||
</resources>
|
<plugins>
|
||||||
<plugins>
|
<plugin>
|
||||||
<plugin>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>2.4.3</version>
|
||||||
<configuration>
|
<executions>
|
||||||
<source>1.7</source>
|
<execution>
|
||||||
<target>1.7</target>
|
<phase>package</phase>
|
||||||
</configuration>
|
<goals>
|
||||||
</plugin>
|
<goal>shade</goal>
|
||||||
<plugin>
|
</goals>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<configuration>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
<version>2.3</version>
|
<minimizeJar>true</minimizeJar>
|
||||||
<configuration>
|
<artifactSet>
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
<includes>
|
||||||
<minimizeJar>true</minimizeJar>
|
<include>pw.yumc:YumCore</include>
|
||||||
<artifactSet>
|
</includes>
|
||||||
<includes>
|
</artifactSet>
|
||||||
<include>cn.citycraft:PluginHelper</include>
|
<relocations>
|
||||||
</includes>
|
<relocation>
|
||||||
</artifactSet>
|
<pattern>pw.yumc.YumCore</pattern>
|
||||||
<relocations>
|
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||||
<relocation>
|
</relocation>
|
||||||
<pattern>cn.citycraft.PluginHelper</pattern>
|
</relocations>
|
||||||
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
</configuration>
|
||||||
</relocation>
|
</execution>
|
||||||
</relocations>
|
</executions>
|
||||||
</configuration>
|
</plugin>
|
||||||
<executions>
|
</plugins>
|
||||||
<execution>
|
</build>
|
||||||
<phase>package</phase>
|
<ciManagement>
|
||||||
<goals>
|
<system>Jenkins</system>
|
||||||
<goal>shade</goal>
|
<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
|
||||||
</goals>
|
</ciManagement>
|
||||||
</execution>
|
<properties>
|
||||||
</executions>
|
<update.description>§d更新命令以及参数...</update.description>
|
||||||
</plugin>
|
<env.BUILD_NUMBER>DEV</env.BUILD_NUMBER>
|
||||||
</plugins>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</build>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<properties>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
</properties>
|
||||||
<update.description>§d更新命令以及参数...</update.description>
|
<repositories>
|
||||||
<env.BUILD_NUMBER>Debug</env.BUILD_NUMBER>
|
<repository>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<id>yumc-repo</id>
|
||||||
</properties>
|
<url>http://repo.yumc.pw/content/groups/public/</url>
|
||||||
<repositories>
|
</repository>
|
||||||
<repository>
|
</repositories>
|
||||||
<id>spigot-repo</id>
|
<distributionManagement>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<repository>
|
||||||
</repository>
|
<id>jtb</id>
|
||||||
<repository>
|
<name>YUMC</name>
|
||||||
<id>citycraft-repo</id>
|
<url>http://repo.yumc.pw/content/repositories/yumcenter/</url>
|
||||||
<url>${jenkins.url}/plugin/repository/everything/</url>
|
</repository>
|
||||||
</repository>
|
</distributionManagement>
|
||||||
</repositories>
|
<dependencies>
|
||||||
<dependencies>
|
<dependency>
|
||||||
<dependency>
|
<groupId>pw.yumc</groupId>
|
||||||
<groupId>org.spigotmc</groupId>
|
<artifactId>YumCore</artifactId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<version>1.7</version>
|
||||||
<type>jar</type>
|
</dependency>
|
||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
</dependencies>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.citycraft</groupId>
|
|
||||||
<artifactId>PluginHelper</artifactId>
|
|
||||||
<type>jar</type>
|
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.clip</groupId>
|
|
||||||
<artifactId>PlaceholderAPI</artifactId>
|
|
||||||
<version>1.8.6</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${project.basedir}/lib/PlaceholderAPI.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
</project>
|
@ -1,139 +0,0 @@
|
|||||||
package cn.citycraft.DataStorage;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
|
||||||
import cn.citycraft.PluginHelper.pluginapi.PluginAPI;
|
|
||||||
import cn.citycraft.PluginHelper.sql.DataBase;
|
|
||||||
import cn.citycraft.PluginHelper.sql.KeyValue;
|
|
||||||
import cn.citycraft.PluginHelper.sql.MySQLCore;
|
|
||||||
import cn.citycraft.PluginHelper.sql.SQLiteCore;
|
|
||||||
import me.clip.placeholderapi.PlaceholderHook;
|
|
||||||
|
|
||||||
public class DataStorage extends JavaPlugin {
|
|
||||||
FileConfig config;
|
|
||||||
DataBase db;
|
|
||||||
String kfields = "key";
|
|
||||||
String tableName;
|
|
||||||
String vfields = "value";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
|
||||||
if (args.length > 1) {
|
|
||||||
final String subcmd = args[0];
|
|
||||||
final String key = args[1];
|
|
||||||
final KeyValue kv = new KeyValue(kfields, key);
|
|
||||||
int value = 0;
|
|
||||||
int dbValue = 0;
|
|
||||||
try {
|
|
||||||
value = Integer.valueOf(args[2]);
|
|
||||||
dbValue = Integer.valueOf(db.dbSelectFirst(tableName, vfields, kv));
|
|
||||||
} catch (final Exception e) {
|
|
||||||
}
|
|
||||||
if (args.length > 2 && value != 0) {
|
|
||||||
switch (subcmd) {
|
|
||||||
case "add":
|
|
||||||
if (db.dbUpdate(tableName, new KeyValue(vfields, value + dbValue), kv) != 0) {
|
|
||||||
sender.sendMessage("§a成功给了 §3" + key + " §a添加了 §e" + value + " §a目前的值为 §d" + (value + dbValue));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("§c操作失败 请查看后台错误 (添加删除需要初始化)!");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "del":
|
|
||||||
if (db.dbUpdate(tableName, new KeyValue(vfields, dbValue - value), kv) != 0) {
|
|
||||||
sender.sendMessage("§a成功给了 §3" + key + " §c减少了 §e" + value + " §a目前的值为 §d" + (dbValue - value));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("§c操作失败 请查看后台错误 (添加删除需要初始化)!");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "create":
|
|
||||||
if (db.dbInsert(tableName, kv.add(vfields, value)) != 0) {
|
|
||||||
sender.sendMessage("§a成功创建了 §3" + key + " §a初始值为 §d" + value);
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("§c操作失败 请查看后台错误!");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args.length > 1) {
|
|
||||||
switch (subcmd) {
|
|
||||||
case "remove":
|
|
||||||
if (db.dbDelete(tableName, kv) != 0) {
|
|
||||||
sender.sendMessage("§a成功移除了 §3" + key);
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("§c操作失败 请查看后台错误 (添加删除需要初始化)!");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "test":
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
sender.sendMessage("§6语句测试: §3" + PluginAPI.PlaceholderAPI((Player) sender, key));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("§c控制台无法测试语句!");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final String[] help = new String[] { "§6========= [§b" + this.getName() + "§6] 插件帮助列表=========",
|
|
||||||
"§6/dd §acreate key value §6- §b创建键key设置值为value!",
|
|
||||||
"§6/dd §aadd key value §6- §b键key的值添加value!",
|
|
||||||
"§6/dd §adel key value §6- §b键key的值减少value!",
|
|
||||||
"§6/dd §aremove key §6- §b移除key!" };
|
|
||||||
sender.sendMessage(help);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
if (db != null) {
|
|
||||||
db.close();
|
|
||||||
}
|
|
||||||
PluginAPI.PlaceholderUnhook("dd");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
final ConfigurationSection cfg = config.getConfigurationSection("Data.MySQL");
|
|
||||||
if (config.getMessage("Data.FileSystem").equalsIgnoreCase("MySQL")) {
|
|
||||||
db = new DataBase(new MySQLCore(cfg));
|
|
||||||
} else {
|
|
||||||
db = new DataBase(new SQLiteCore(this, cfg));
|
|
||||||
}
|
|
||||||
tableName = config.getMessage("Data.MySQL.tablename");
|
|
||||||
if (db.testConnect()) {
|
|
||||||
this.getLogger().info("数据库连接成功,检查数据表是否存在...");
|
|
||||||
if (!db.isTableExists(tableName)) {
|
|
||||||
this.getLogger().info("数据表不存在,新建表" + tableName + "...");
|
|
||||||
if (!db.createTables(tableName, new KeyValue(kfields, "VARCHAR(30) PRIMARY KEY").add(vfields, "INT"), "UNIQUE (`key`)")) {
|
|
||||||
this.getLogger().info("数据表" + tableName + "创建失败,请尝试手动创建并重启服务器...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.getLogger().warning("数据库连接失败!");
|
|
||||||
this.getServer().getPluginManager().disablePlugin(this);
|
|
||||||
}
|
|
||||||
final boolean result = PluginAPI.PlaceholderHook("dd", new PlaceholderHook() {
|
|
||||||
@Override
|
|
||||||
public String onPlaceholderRequest(final Player arg0, final String arg1) {
|
|
||||||
return db.dbSelectFirst(tableName, vfields, new KeyValue(kfields, arg1));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (result) {
|
|
||||||
this.getLogger().info("发现 PlaceholderAPI 已关联...");
|
|
||||||
} else {
|
|
||||||
Bukkit.getConsoleSender().sendMessage("§c发现 PlaceholderAPI 但是关联失败了!!!失败了!!!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoad() {
|
|
||||||
config = new FileConfig(this);
|
|
||||||
}
|
|
||||||
}
|
|
157
src/main/java/pw/yumc/DataStorage/DataStorage.java
Normal file
157
src/main/java/pw/yumc/DataStorage/DataStorage.java
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
package pw.yumc.DataStorage;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
|
import me.clip.placeholderapi.PlaceholderHook;
|
||||||
|
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;
|
||||||
|
import pw.yumc.YumCore.sql.DataBase;
|
||||||
|
import pw.yumc.YumCore.sql.core.KeyValue;
|
||||||
|
|
||||||
|
public class DataStorage extends JavaPlugin implements Executor {
|
||||||
|
FileConfig config;
|
||||||
|
DataBase db;
|
||||||
|
String kfields = "key";
|
||||||
|
String tableName;
|
||||||
|
String vfields = "value";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
config = new FileConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
initDataBase();
|
||||||
|
hookPAPI();
|
||||||
|
new CommandSub("dd", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initDataBase() {
|
||||||
|
db = DataBase.create(this, config.getConfigurationSection("Data"));
|
||||||
|
tableName = config.getMessage("Data.MySQL.tablename");
|
||||||
|
if (db.testConnect()) {
|
||||||
|
this.getLogger().info("数据库连接成功,检查数据表是否存在...");
|
||||||
|
if (!db.isTableExists(tableName)) {
|
||||||
|
this.getLogger().info("数据表不存在,新建表" + tableName + "...");
|
||||||
|
if (!db.createTables(tableName, new KeyValue(kfields, "VARCHAR(30) PRIMARY KEY").add(vfields, "INT"), "UNIQUE (`key`)")) {
|
||||||
|
this.getLogger().info("数据表" + tableName + "创建失败,请尝试手动创建并重启服务器...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.getLogger().warning("数据库连接失败!");
|
||||||
|
this.getServer().getPluginManager().disablePlugin(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hookPAPI() {
|
||||||
|
final boolean result = PlaceholderAPI.registerPlaceholderHook("dd", new PlaceholderHook() {
|
||||||
|
@Override
|
||||||
|
public String onPlaceholderRequest(final Player arg0, final String arg1) {
|
||||||
|
return db.dbSelectFirst(tableName, vfields, new KeyValue(kfields, arg1));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (result) {
|
||||||
|
this.getLogger().info("发现 PlaceholderAPI 已关联...");
|
||||||
|
} else {
|
||||||
|
Bukkit.getConsoleSender().sendMessage("§6[§bDataStorage§6] §c发现 PlaceholderAPI 但是关联失败了!!!失败了!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cmd
|
||||||
|
@Help(value = "创建一个键值对", possibleArguments = "<键> <值>")
|
||||||
|
public void create(CommandSender sender, String key, Integer value) {
|
||||||
|
try {
|
||||||
|
if (createValue(key, value)) {
|
||||||
|
sender.sendMessage("§a成功创建了 §3" + key + " §a初始值为 §d" + value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sender.sendMessage("§c操作失败 请查看后台错误 (添加删除需要初始化)!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cmd
|
||||||
|
@Help(value = "移除一个键值对", possibleArguments = "<键>")
|
||||||
|
public void remove(CommandSender sender, String key, Integer value) {
|
||||||
|
try {
|
||||||
|
if (removeValue(key)) {
|
||||||
|
sender.sendMessage("§a成功移除了 §3" + key);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sender.sendMessage("§c操作失败 请查看后台错误 (添加删除需要初始化)!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cmd
|
||||||
|
@Help(value = "键key的值添加value", possibleArguments = "<键> <值>")
|
||||||
|
public void add(CommandSender sender, String key, Integer value) {
|
||||||
|
try {
|
||||||
|
if (incValue(key, value)) {
|
||||||
|
sender.sendMessage("§a成功给了 §3" + key + " §a增加了 §e" + value + " §a目前的值为 §d" + getValue(key));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sender.sendMessage("§c操作失败 请查看后台错误 (添加删除需要初始化)!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cmd
|
||||||
|
@Help(value = "键key的值添加value", possibleArguments = "<键> <值>")
|
||||||
|
public void del(CommandSender sender, String key, Integer value) {
|
||||||
|
try {
|
||||||
|
if (decValue(key, value)) {
|
||||||
|
sender.sendMessage("§a成功给了 §3" + key + " §c减少了 §e" + value + " §a目前的值为 §d" + getValue(key));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sender.sendMessage("§c操作失败 请查看后台错误 (添加删除需要初始化)!");
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean createValue(String key, int value) throws SQLException {
|
||||||
|
return db.getDataBaseCore().update("INSERT INTO " + tableName + " (" + kfields + ", " + vfields + ") VALUES ('" + key + "', '" + value + "')") != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean removeValue(String key) throws SQLException {
|
||||||
|
return db.getDataBaseCore().update("DELETE FROM " + tableName + " WHERE " + kfields + " = '" + key + "'") != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean incValue(String key, int value) throws SQLException {
|
||||||
|
return db.getDataBaseCore().update("UPDATE " + tableName + " SET " + vfields + " = " + vfields + " + " + value + " WHERE " + kfields + " = '" + key + "'") != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean decValue(String key, int value) throws SQLException {
|
||||||
|
return db.getDataBaseCore().update("UPDATE " + tableName + " SET " + vfields + " = " + vfields + " + " + value + " WHERE " + kfields + " = '" + key + "'") != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getValue(String key) throws SQLException {
|
||||||
|
ResultSet result = db.getDataBaseCore().query("SELECT " + vfields + " FROM " + tableName + " WHERE " + kfields + " = '" + key + "' LIMIT 1");
|
||||||
|
if (result.next()) { return result.getInt(1); }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
if (db != null) {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
PlaceholderAPI.unregisterPlaceholderHook("dd");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,7 @@ description: ${project.description}
|
|||||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||||
version: ${project.version}-Build#${env.BUILD_NUMBER}
|
version: ${project.version}-Build#${env.BUILD_NUMBER}
|
||||||
author: 喵♂呜
|
author: 喵♂呜
|
||||||
website: ${jenkins.url}/job/${project.artifactId}/
|
website: ${ciManagement.url}
|
||||||
depend: [PlaceholderAPI]
|
depend: [PlaceholderAPI]
|
||||||
commands:
|
commands:
|
||||||
${project.artifactId}:
|
${project.artifactId}:
|
||||||
|
Loading…
Reference in New Issue
Block a user