mirror of
https://e.coding.net/circlecloud/ItemMamager.git
synced 2024-11-13 00:28:54 +00:00
del .setting ReName to ItemManager...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
6250ddbeca
commit
0169108bd3
51
.classpath
51
.classpath
@ -1,20 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<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="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="output" path="target/classes"/>
|
||||
</classpath>
|
||||
<?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.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<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.8">
|
||||
<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>
|
||||
|
40
.gitignore
vendored
40
.gitignore
vendored
@ -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
|
2
.project
2
.project
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>TimeItem</name>
|
||||
<name>ItemMamager</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
@ -1,3 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
encoding/src=UTF-8
|
@ -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
|
@ -1,4 +0,0 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
69
pom.xml
69
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cn.CityCraft</groupId>
|
||||
<artifactId>TimeItem</artifactId>
|
||||
<artifactId>ItemMamager</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>TimeItem</name>
|
||||
<name>ItemMamager</name>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
@ -21,10 +18,43 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>cn.citycraft:PluginHelper</include>
|
||||
<include>org.mcstats.*:*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.mcstats</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.mcstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>cn.citycraft.PluginHelper</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
@ -32,6 +62,14 @@
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>citycraft-repo</id>
|
||||
<url>http://ci.citycraft.cn:8800/jenkins/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Plugin Metrics</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -40,8 +78,21 @@
|
||||
<type>jar</type>
|
||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>PluginHelper</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
<version>R8-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<description>物品管理器</description>
|
||||
</project>
|
@ -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 插件载入事件
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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 自动生成的构造函数存根
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.TimeItem.utils;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public class Misc {
|
||||
public static String TIME_TAG = "\u00A76时间物品";
|
||||
}
|
33
src/main/java/cn/citycraft/ItemMamager/ItemMamager.java
Normal file
33
src/main/java/cn/citycraft/ItemMamager/ItemMamager.java
Normal file
@ -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() {
|
||||
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
12
src/main/java/cn/citycraft/ItemMamager/utils/Misc.java
Normal file
12
src/main/java/cn/citycraft/ItemMamager/utils/Misc.java
Normal file
@ -0,0 +1,12 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.ItemMamager.utils;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public class Misc {
|
||||
public static String TIME_TAG = "\u00A76限时物品";
|
||||
}
|
14
src/main/resources/plugin.yml
Normal file
14
src/main/resources/plugin.yml
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user