diff --git a/.classpath b/.classpath index 4c682ec..29fe624 100644 --- a/.classpath +++ b/.classpath @@ -1,20 +1,31 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index 09e3bc9..043fc2a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,38 @@ -/bin/ -/target/ +# Eclipse stuff +/.settings + +# netbeans +/nbproject + +# we use maven! +/build.xml + +# maven +/target +/repo + +# vim +.*.sw[a-p] + +# various other potential build files +/build +/bin +/dist +/manifest.mf + +/world + +# Mac filesystem dust +*.DS_Store + +# intellij +*.iml +*.ipr +*.iws +.idea/ + +# Project Stuff +/src/main/resources/Soulbound + +# Atlassian Stuff +/atlassian-ide-plugin.xml \ No newline at end of file diff --git a/.project b/.project index 5fd3185..c9ce808 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - TimeItem + ItemMamager diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 7a53139..0000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 -encoding/src=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index ec4300d..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/pom.xml b/pom.xml index 9640c67..25ca001 100644 --- a/pom.xml +++ b/pom.xml @@ -2,18 +2,15 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 cn.CityCraft - TimeItem + ItemMamager 0.0.1-SNAPSHOT - TimeItem + ItemMamager ${project.name} - src - src - - **/*.java - + src/main/resources + true @@ -21,10 +18,43 @@ maven-compiler-plugin 3.1 - 1.7 - 1.7 + 1.8 + 1.8 + + org.apache.maven.plugins + maven-shade-plugin + 2.3 + + false + true + + + cn.citycraft:PluginHelper + org.mcstats.*:* + + + + + org.mcstats + ${project.groupId}.${project.artifactId}.mcstats + + + cn.citycraft.PluginHelper + ${project.groupId}.${project.artifactId} + + + + + + package + + shade + + + + @@ -32,6 +62,14 @@ spigot-repo https://hub.spigotmc.org/nexus/content/groups/public/ + + citycraft-repo + http://ci.citycraft.cn:8800/jenkins/plugin/repository/everything/ + + + Plugin Metrics + http://repo.mcstats.org/content/repositories/public + @@ -40,8 +78,21 @@ jar 1.8.3-R0.1-SNAPSHOT + + cn.citycraft + PluginHelper + jar + 1.0 + + + org.mcstats.bukkit + metrics + R8-SNAPSHOT + compile + UTF-8 + 物品管理器 \ No newline at end of file diff --git a/src/cn/citycraft/TimeItem/TimeItem.java b/src/cn/citycraft/TimeItem/TimeItem.java deleted file mode 100644 index f4763cf..0000000 --- a/src/cn/citycraft/TimeItem/TimeItem.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - */ -package cn.citycraft.TimeItem; - -import org.bukkit.plugin.java.JavaPlugin; - -import cn.citycraft.TimeItem.listen.PlayerListen; - -/** - * @author 蒋天蓓 - * - */ -public class TimeItem extends JavaPlugin { - @Override - public void onDisable() { - // TODO 插件卸载事件 - } - - @Override - public void onEnable() { - this.getServer().getPluginManager().registerEvents(new PlayerListen(this), this); - } - - @Override - public void onLoad() { - // TODO 插件载入事件 - } -} diff --git a/src/cn/citycraft/TimeItem/config/FileConfig.java b/src/cn/citycraft/TimeItem/config/FileConfig.java deleted file mode 100644 index 885e713..0000000 --- a/src/cn/citycraft/TimeItem/config/FileConfig.java +++ /dev/null @@ -1,194 +0,0 @@ -package cn.citycraft.TimeItem.config; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.io.Writer; -import java.util.logging.Logger; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.configuration.Configuration; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.configuration.file.YamlConstructor; -import org.bukkit.configuration.file.YamlRepresenter; -import org.bukkit.plugin.Plugin; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.representer.Representer; - -import com.google.common.base.Charsets; -import com.google.common.io.Files; - -/** - * An implementation of {@link Configuration} which saves all files in Yaml. - * Note that this - * implementation is not synchronized. - */ -public class FileConfig extends YamlConfiguration { - protected File file; - protected Logger loger; - protected Plugin plugin; - - protected final DumperOptions yamlOptions = new DumperOptions(); - - protected final Representer yamlRepresenter = new YamlRepresenter(); - - protected final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions); - - private FileConfig(File file) { - Validate.notNull(file, "File cannot be null"); - this.file = file; - loger = Bukkit.getLogger(); - init(file); - } - - private FileConfig(InputStream stream) { - loger = Bukkit.getLogger(); - init(stream); - } - - public FileConfig(Plugin plugin, File file) { - Validate.notNull(file, "File cannot be null"); - Validate.notNull(plugin, "Plugin cannot be null"); - this.plugin = plugin; - this.file = file; - loger = plugin.getLogger(); - check(file); - init(file); - } - - public FileConfig(Plugin plugin, String filename) { - this(plugin, new File(plugin.getDataFolder(), filename)); - } - - private void check(File file) { - String filename = file.getName(); - InputStream stream = plugin.getResource(filename); - try { - if (!file.exists()) { - file.getParentFile().mkdirs(); - if (stream == null) { - file.createNewFile(); - loger.info("配置文件 " + filename + " 不存在 创建新文件..."); - } else { - plugin.saveResource(filename, true); - loger.info("配置文件 " + filename + " 不存在 从插件释放..."); - } - } else { - FileConfig newcfg = new FileConfig(stream); - FileConfig oldcfg = new FileConfig(file); - String newver = newcfg.getString("version"); - String oldver = oldcfg.getString("version"); - if (newver != null && newver != oldver) { - loger.warning("配置文件: " + filename + " 版本 " + oldver + " 过低 正在升级到 " + newver + " ..."); - try { - oldcfg.save(new File(file.getParent(), filename + ".backup")); - loger.warning("配置文件: " + filename + " 已备份为 " + filename + ".backup !"); - } catch (IOException e) { - loger.warning("配置文件: " + filename + "备份失败!"); - } - plugin.saveResource(filename, true); - loger.info("配置文件: " + filename + "升级成功!"); - } - } - } catch (IOException e) { - loger.info("配置文件 " + filename + " 创建失败..."); - } - } - - private void init(File file) { - Validate.notNull(file, "File cannot be null"); - FileInputStream stream; - try { - stream = new FileInputStream(file); - init(stream); - } catch (FileNotFoundException e) { - loger.info("配置文件 " + file.getName() + " 不存在..."); - } - } - - private void init(InputStream stream) { - Validate.notNull(stream, "Stream cannot be null"); - try { - this.load(new InputStreamReader(stream, Charsets.UTF_8)); - } catch (IOException ex) { - loger.info("配置文件 " + file.getName() + " 读取错误..."); - } catch (InvalidConfigurationException ex) { - loger.info("配置文件 " + file.getName() + " 格式错误..."); - } - } - - @Override - public void load(File file) throws FileNotFoundException, IOException, InvalidConfigurationException { - Validate.notNull(file, "File cannot be null"); - final FileInputStream stream = new FileInputStream(file); - load(new InputStreamReader(stream, Charsets.UTF_8)); - } - - @Override - public void load(Reader reader) throws IOException, InvalidConfigurationException { - BufferedReader input = (reader instanceof BufferedReader) ? (BufferedReader) reader : new BufferedReader(reader); - StringBuilder builder = new StringBuilder(); - try { - String line; - while ((line = input.readLine()) != null) { - builder.append(line); - builder.append('\n'); - } - } finally { - input.close(); - } - loadFromString(builder.toString()); - } - - public void reload() { - init(file); - } - - public void save() { - if (file == null) { - loger.info("未定义配置文件路径 保存失败!"); - } - try { - this.save(file); - } catch (IOException e) { - loger.info("配置文件 " + file.getName() + " 保存错误..."); - e.printStackTrace(); - } - } - - @Override - public void save(File file) throws IOException { - Validate.notNull(file, "File cannot be null"); - Files.createParentDirs(file); - String data = saveToString(); - Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8); - try { - writer.write(data); - } finally { - writer.close(); - } - } - - @Override - public String saveToString() { - yamlOptions.setIndent(options().indent()); - yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); - yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); - String header = buildHeader(); - String dump = yaml.dump(getValues(false)); - if (dump.equals(BLANK_CONFIG)) { - dump = ""; - } - return header + dump; - } -} diff --git a/src/cn/citycraft/TimeItem/listen/PlayerListen.java b/src/cn/citycraft/TimeItem/listen/PlayerListen.java deleted file mode 100644 index c4def6c..0000000 --- a/src/cn/citycraft/TimeItem/listen/PlayerListen.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * - */ -package cn.citycraft.TimeItem.listen; - -import org.bukkit.event.Listener; -import org.bukkit.plugin.Plugin; - -/** - * @author Administrator - * - */ -public class PlayerListen implements Listener { - - /** - * @param timeItem - */ - public PlayerListen(Plugin timeItem) { - // TODO 自动生成的构造函数存根 - } - -} diff --git a/src/cn/citycraft/TimeItem/utils/Misc.java b/src/cn/citycraft/TimeItem/utils/Misc.java deleted file mode 100644 index 10bd63d..0000000 --- a/src/cn/citycraft/TimeItem/utils/Misc.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * - */ -package cn.citycraft.TimeItem.utils; - -/** - * @author Administrator - * - */ -public class Misc { - public static String TIME_TAG = "\u00A76时间物品"; -} diff --git a/src/main/java/cn/citycraft/ItemMamager/ItemMamager.java b/src/main/java/cn/citycraft/ItemMamager/ItemMamager.java new file mode 100644 index 0000000..f87ea02 --- /dev/null +++ b/src/main/java/cn/citycraft/ItemMamager/ItemMamager.java @@ -0,0 +1,33 @@ +/** + * + */ +package cn.citycraft.ItemMamager; + +import org.bukkit.plugin.java.JavaPlugin; + +import cn.citycraft.ItemMamager.commands.BindCommand; +import cn.citycraft.ItemMamager.listen.PlayerListen; +import cn.citycraft.PluginHelper.commands.HandlerCommand; + +/** + * 物品管理器主类 + * + * @author 蒋天蓓 + * + */ +public class ItemMamager extends JavaPlugin { + + @Override + public void onEnable() { + this.getServer().getPluginManager().registerEvents(new PlayerListen(this), this); + HandlerCommand cmdhandler = new HandlerCommand(this); + cmdhandler.registerCommand(new BindCommand()); + this.getCommand("im").setExecutor(cmdhandler); + this.getCommand("im").setTabCompleter(cmdhandler); + } + + @Override + public void onLoad() { + + } +} diff --git a/src/main/java/cn/citycraft/ItemMamager/commands/BindCommand.java b/src/main/java/cn/citycraft/ItemMamager/commands/BindCommand.java new file mode 100644 index 0000000..25bf415 --- /dev/null +++ b/src/main/java/cn/citycraft/ItemMamager/commands/BindCommand.java @@ -0,0 +1,45 @@ +package cn.citycraft.ItemMamager.commands; + +import org.bukkit.command.CommandException; +import org.bukkit.command.CommandSender; + +import cn.citycraft.PluginHelper.commands.BaseCommand; + +public class BindCommand extends BaseCommand { + + public BindCommand() { + super("imbind"); + // TODO 自动生成的构造函数存根 + } + + @Override + public void execute(CommandSender sender, String label, String[] args) throws CommandException { + // TODO 自动生成的方法存根 + + } + + @Override + public String getDescription() { + // TODO 自动生成的方法存根 + return null; + } + + @Override + public int getMinimumArguments() { + // TODO 自动生成的方法存根 + return 0; + } + + @Override + public String getPossibleArguments() { + // TODO 自动生成的方法存根 + return null; + } + + @Override + public boolean isOnlyPlayerExecutable() { + // TODO 自动生成的方法存根 + return false; + } + +} diff --git a/src/main/java/cn/citycraft/ItemMamager/listen/PlayerListen.java b/src/main/java/cn/citycraft/ItemMamager/listen/PlayerListen.java new file mode 100644 index 0000000..b41d1ac --- /dev/null +++ b/src/main/java/cn/citycraft/ItemMamager/listen/PlayerListen.java @@ -0,0 +1,24 @@ +/** + * + */ +package cn.citycraft.ItemMamager.listen; + +import org.bukkit.event.Listener; + +import cn.citycraft.ItemMamager.ItemMamager; + +/** + * @author Administrator + * + */ +public class PlayerListen implements Listener { + ItemMamager plugin; + + /** + * @param timeItem + */ + public PlayerListen(ItemMamager timeItem) { + plugin = timeItem; + } + +} diff --git a/src/main/java/cn/citycraft/ItemMamager/utils/Misc.java b/src/main/java/cn/citycraft/ItemMamager/utils/Misc.java new file mode 100644 index 0000000..4abc6c0 --- /dev/null +++ b/src/main/java/cn/citycraft/ItemMamager/utils/Misc.java @@ -0,0 +1,12 @@ +/** + * + */ +package cn.citycraft.ItemMamager.utils; + +/** + * @author Administrator + * + */ +public class Misc { + public static String TIME_TAG = "\u00A76限时物品"; +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..877a1a3 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,14 @@ +name: ${project.artifactId} +description: ${project.description} +main: ${project.groupId}.${project.artifactId}.${project.artifactId} +version: ${project.version} +auther: 喵♂呜 +website: http://ci.citycraft.cn:8800/jenkins/job/${project.artifactId}/ +commands: + im: + description: 物品管理器 + usage: §b使用/im help 查看帮助! +permissions: + im.reload: + description: 重新载入插件! + default: op \ No newline at end of file