diff --git a/.classpath b/.classpath
deleted file mode 100644
index bea39b1..0000000
--- a/.classpath
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.project b/.project
deleted file mode 100644
index 27333f3..0000000
--- a/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- DataStorage
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.m2e.core.maven2Builder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.m2e.core.maven2Nature
-
-
diff --git a/lib/PlaceholderAPI.jar b/lib/PlaceholderAPI.jar
deleted file mode 100644
index 01da9ea..0000000
Binary files a/lib/PlaceholderAPI.jar and /dev/null differ
diff --git a/pom.xml b/pom.xml
index 003c15d..eba8e6d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,92 +1,77 @@
- 4.0.0
- cn.citycraft
- DataStorage
- 1.0.1
- DataStorage
-
- ${project.name}
-
-
- src/main/resources
- true
-
-
-
-
- maven-compiler-plugin
- 3.1
-
-
- 1.7
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 2.3
-
- false
- true
-
-
- cn.citycraft:PluginHelper
-
-
-
-
- cn.citycraft.PluginHelper
- ${project.groupId}.${project.artifactId}
-
-
-
-
-
- package
-
- shade
-
-
-
-
-
-
-
- http://ci.citycraft.cn:8080
- §d更新命令以及参数...
- Debug
- UTF-8
-
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/groups/public/
-
-
- citycraft-repo
- ${jenkins.url}/plugin/repository/everything/
-
-
-
-
- org.spigotmc
- spigot-api
- jar
- 1.8.8-R0.1-SNAPSHOT
-
-
- cn.citycraft
- PluginHelper
- jar
- 1.0
-
-
- me.clip
- PlaceholderAPI
- 1.8.6
- system
- ${project.basedir}/lib/PlaceholderAPI.jar
-
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ pw.yumc
+ DataStorage
+ 1.1
+
+ ${project.artifactId}
+
+
+ src/main/resources
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.4.3
+
+
+ package
+
+ shade
+
+
+ false
+ true
+
+
+ pw.yumc:YumCore
+
+
+
+
+ pw.yumc.YumCore
+ ${project.groupId}.${project.artifactId}
+
+
+
+
+
+
+
+
+
+ Jenkins
+ http://ci.yumc.pw/job/${project.artifactId}/
+
+
+ §d更新命令以及参数...
+ DEV
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+ yumc-repo
+ http://repo.yumc.pw/content/groups/public/
+
+
+
+
+ jtb
+ YUMC
+ http://repo.yumc.pw/content/repositories/yumcenter/
+
+
+
+
+ pw.yumc
+ YumCore
+ 1.7
+
+
\ No newline at end of file
diff --git a/src/main/java/cn/citycraft/DataStorage/DataStorage.java b/src/main/java/cn/citycraft/DataStorage/DataStorage.java
deleted file mode 100644
index 7f2590a..0000000
--- a/src/main/java/cn/citycraft/DataStorage/DataStorage.java
+++ /dev/null
@@ -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);
- }
-}
diff --git a/src/main/java/pw/yumc/DataStorage/DataStorage.java b/src/main/java/pw/yumc/DataStorage/DataStorage.java
new file mode 100644
index 0000000..d2bf801
--- /dev/null
+++ b/src/main/java/pw/yumc/DataStorage/DataStorage.java
@@ -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");
+ }
+
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index c973986..55bf33b 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -3,7 +3,7 @@ description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}-Build#${env.BUILD_NUMBER}
author: 喵♂呜
-website: ${jenkins.url}/job/${project.artifactId}/
+website: ${ciManagement.url}
depend: [PlaceholderAPI]
commands:
${project.artifactId}: