mirror of
https://e.coding.net/circlecloud/Soulbound.git
synced 2024-11-22 01:49:09 +00:00
using PluginHelper and update...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
5ab2ac354c
commit
37963894f3
67
pom.xml
67
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.me.tft_02.soulbound</groupId>
|
||||
<artifactId>Soulbound</artifactId>
|
||||
<version>1.1.10-SNAPSHOT</version>
|
||||
<version>1.1.12</version>
|
||||
<name>Soulbound</name>
|
||||
<url>https://github.com/TfT-02/Soulbound</url>
|
||||
<issueManagement>
|
||||
@ -12,13 +12,10 @@
|
||||
</issueManagement>
|
||||
<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>
|
||||
@ -30,13 +27,50 @@
|
||||
<target>1.7</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>
|
||||
<repository>
|
||||
<id>mengcraft-repo</id>
|
||||
<url>http://ci.mengcraft.com:8080/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>mengcraft-repo</id>
|
||||
<url>http://ci.mengcraft.com:8080/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>citycraft-repo</id>
|
||||
<url>http://ci.citycraft.cn:8800/jenkins/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
@ -49,8 +83,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>Soulbound items for your RPG servers!</description>
|
||||
</project>
|
||||
|
@ -1,102 +0,0 @@
|
||||
package com.me.tft_02.soulbound.configs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class ConfigLoader extends FileConfig {
|
||||
protected static FileConfig config;
|
||||
protected static boolean tip = true;
|
||||
protected static Plugin plugin;
|
||||
|
||||
public ConfigLoader(Plugin p, File file) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, null, true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, File file, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, null, res);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, File file, String ver) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, ver, true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, File file, String ver, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, ver, res);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), null,
|
||||
true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), null, res);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename, String ver) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), ver, true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename, String ver, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), ver, true);
|
||||
}
|
||||
|
||||
public static FileConfig getInstance() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public FileConfig loadConfig(Plugin p, File file, String ver, boolean res) {
|
||||
tip = res ;
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
p.getLogger().info("创建新的文件夹" + file.getAbsolutePath() + "...");
|
||||
}
|
||||
if (!file.exists()) {
|
||||
fileCreate(p, file, res);
|
||||
} else {
|
||||
if (ver != null) {
|
||||
FileConfig configcheck = init(file);
|
||||
String version = configcheck.getString("version");
|
||||
if (version == null || !version.equals(ver)) {
|
||||
p.saveResource(file.getName(), true);
|
||||
p.getLogger().warning(
|
||||
"配置文件: " + file.getName() + " 版本过低 正在升级...");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tip)
|
||||
p.getLogger().info(
|
||||
"载入配置文件: " + file.getName()
|
||||
+ (ver != null ? " 版本: " + ver : ""));
|
||||
return init(file);
|
||||
}
|
||||
|
||||
private void fileCreate(Plugin p, File file, boolean res) {
|
||||
if (res) {
|
||||
p.saveResource(file.getName(), false);
|
||||
} else {
|
||||
try {
|
||||
p.getLogger().info("创建新的配置文件" + file.getAbsolutePath() + "...");
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
p.getLogger().info("配置文件" + file.getName() + "创建失败...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveError(File file) {
|
||||
plugin.getLogger().info("配置文件" + file.getName() + "保存错误...");
|
||||
}
|
||||
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
package com.me.tft_02.soulbound.configs;
|
||||
|
||||
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.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
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.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 {
|
||||
|
||||
public static FileConfig init(File file) {
|
||||
return FileConfig.loadConfiguration(file);
|
||||
}
|
||||
|
||||
public static FileConfig loadConfiguration(File file) {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
FileConfig config = new FileConfig();
|
||||
try {
|
||||
config.load(file);
|
||||
} catch (FileNotFoundException ex) {
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
protected final DumperOptions yamlOptions = new DumperOptions();
|
||||
|
||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||
|
||||
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
||||
yamlRepresenter, yamlOptions);
|
||||
|
||||
@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());
|
||||
}
|
||||
@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,63 +0,0 @@
|
||||
package com.me.tft_02.soulbound.configs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Message extends ConfigLoader {
|
||||
private static String CONFIG_NAME = "message.yml";
|
||||
private static FileConfig instance;
|
||||
private static File file;
|
||||
|
||||
public Message(Plugin p) {
|
||||
super(p, CONFIG_NAME);
|
||||
file = new File(p.getDataFolder(), CONFIG_NAME);
|
||||
instance = super.getInstance();
|
||||
}
|
||||
|
||||
public Message(Plugin p, String ver) {
|
||||
super(p, CONFIG_NAME, ver);
|
||||
instance = super.getInstance();
|
||||
}
|
||||
|
||||
public static void load(Plugin p) {
|
||||
new Message(p);
|
||||
}
|
||||
|
||||
public static void load(Plugin p, String ver) {
|
||||
new Message(p, ver);
|
||||
}
|
||||
|
||||
public static FileConfig getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static String getMessage(String path) {
|
||||
String message = instance.getString(path);
|
||||
if (message != null)
|
||||
message = message.replaceAll("&", "§");
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String getHead(String path, String prevName) {
|
||||
String message = instance.getString(path);
|
||||
if (message != null)
|
||||
message = message.replaceAll("&", "§").replaceAll("%player%",
|
||||
prevName);
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String[] getStringArray(String path) {
|
||||
return instance.getStringList(path).toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
try {
|
||||
instance.save(file);
|
||||
} catch (IOException e) {
|
||||
saveError(file);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.me.tft_02.soulbound.util;
|
||||
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
import com.me.tft_02.soulbound.Soulbound;
|
||||
|
||||
public class LogFilter implements Filter {
|
||||
private boolean debug;
|
||||
|
||||
public LogFilter(Soulbound plugin) {
|
||||
// Doing a config loading lite here, because we can't depend on the config loader to have loaded before any debug messages are sent
|
||||
debug = plugin.getConfig().getBoolean("General.Verbose_Logging");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoggable(LogRecord record) {
|
||||
if (record.getMessage().contains("[Debug]") && !debug) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package com.me.tft_02.soulbound.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
/**
|
||||
* 自动更新类
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月14日下午4:01:15
|
||||
*/
|
||||
public class VersionChecker implements Listener {
|
||||
Plugin plugin;
|
||||
public String checkurl = "https://coding.net/u/502647092/p/%s/git/raw/%s/src/plugin.yml";
|
||||
public String branch = "master";
|
||||
|
||||
/**
|
||||
* @param plugin
|
||||
* - 插件
|
||||
*/
|
||||
public VersionChecker(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.versioncheck(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param plugin
|
||||
* - 插件
|
||||
* @param branch
|
||||
* - 分支名称
|
||||
*/
|
||||
public VersionChecker(Plugin plugin, String branch) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.branch = branch;
|
||||
this.versioncheck(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件更新链接
|
||||
*
|
||||
* @param pluginName
|
||||
* - 插件名称
|
||||
* @param branch
|
||||
* - 插件分支
|
||||
* @return 更新链接
|
||||
*/
|
||||
public String getCheckUrl(String pluginName, String branch) {
|
||||
return String.format(checkurl, pluginName, branch);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
if (e.getPlayer().isOp()) {
|
||||
this.versioncheck(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始更新
|
||||
*
|
||||
* @param player
|
||||
* - 获取更新的玩家(null则默认为控制台)
|
||||
*/
|
||||
public void versioncheck(final Player player) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String readURL = getCheckUrl(plugin.getName(), branch);
|
||||
FileConfiguration config;
|
||||
String currentVersion = plugin.getDescription().getVersion();
|
||||
try {
|
||||
URL url = new URL(readURL);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), Charsets.UTF_8));
|
||||
config = YamlConfiguration.loadConfiguration(br);
|
||||
String newVersion = config.getString("version");
|
||||
br.close();
|
||||
if (!newVersion.equals(currentVersion)) {
|
||||
String[] msg = new String[] {
|
||||
ChatColor.GREEN + plugin.getName() + " 插件最新版本 v" + newVersion,
|
||||
ChatColor.RED + "服务器运行版本: v" + currentVersion,
|
||||
ChatColor.GOLD + "插件更新网站: " + ChatColor.BLUE + plugin.getDescription().getWebsite()
|
||||
};
|
||||
if (player != null) {
|
||||
player.sendMessage(msg);
|
||||
} else {
|
||||
plugin.getServer().getConsoleSender().sendMessage(msg);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("版本更新检查失败!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,8 @@
|
||||
package com.me.tft_02.soulbound;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -18,14 +14,15 @@ import com.me.tft_02.soulbound.commands.SoulboundCommand;
|
||||
import com.me.tft_02.soulbound.commands.UnbindCommand;
|
||||
import com.me.tft_02.soulbound.config.Config;
|
||||
import com.me.tft_02.soulbound.config.ItemsConfig;
|
||||
import com.me.tft_02.soulbound.configs.Message;
|
||||
import com.me.tft_02.soulbound.hooks.EpicBossRecodedListener;
|
||||
import com.me.tft_02.soulbound.listeners.BlockListener;
|
||||
import com.me.tft_02.soulbound.listeners.EntityListener;
|
||||
import com.me.tft_02.soulbound.listeners.InventoryListener;
|
||||
import com.me.tft_02.soulbound.listeners.PlayerListener;
|
||||
import com.me.tft_02.soulbound.util.LogFilter;
|
||||
import com.me.tft_02.soulbound.util.VersionChecker;
|
||||
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
||||
|
||||
public class Soulbound extends JavaPlugin {
|
||||
/* File Paths */
|
||||
@ -38,25 +35,32 @@ public class Soulbound extends JavaPlugin {
|
||||
|
||||
// Checks for hooking into other plugins
|
||||
public static boolean epicBossRecodedEnabled = false;
|
||||
|
||||
public static boolean loreLocksEnabled = false;
|
||||
FileConfig msgcfg;
|
||||
FileConfig config;
|
||||
// Update Check
|
||||
private boolean updateAvailable;
|
||||
|
||||
public static String getMainDirectory() {
|
||||
return mainDirectory;
|
||||
}
|
||||
|
||||
// Update Check
|
||||
private boolean updateAvailable;
|
||||
|
||||
public void debug(String message) {
|
||||
public void debug(final String message) {
|
||||
getLogger().info("[Debug] " + message);
|
||||
}
|
||||
|
||||
public String getlang(String type) {
|
||||
@Override
|
||||
public FileConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public String getlang(final String type) {
|
||||
return this.getmessage("Message." + type);
|
||||
}
|
||||
|
||||
public String getmessage(String path) {
|
||||
String message = Message.getInstance().getString(path).replaceAll("&", "§");
|
||||
public String getmessage(final String path) {
|
||||
final String message = msgcfg.getMessage(path);
|
||||
return message;
|
||||
}
|
||||
|
||||
@ -64,34 +68,6 @@ public class Soulbound extends JavaPlugin {
|
||||
return updateAvailable;
|
||||
}
|
||||
|
||||
public FileConfiguration Loadcfg(File cfgfile) {
|
||||
if (!cfgfile.exists()) {
|
||||
saveResource(cfgfile.getName(), false);
|
||||
return YamlConfiguration.loadConfiguration(cfgfile);
|
||||
} else
|
||||
return YamlConfiguration.loadConfiguration(cfgfile);
|
||||
}
|
||||
|
||||
public void LoadConfig(FileConfiguration cfg, File cfgfile) throws FileNotFoundException,
|
||||
IOException, InvalidConfigurationException {
|
||||
if (!cfgfile.exists()) {
|
||||
saveResource(cfgfile.getName(), false);
|
||||
cfg.load(cfgfile);
|
||||
} else {
|
||||
cfg.load(cfgfile);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadConfigFiles() {
|
||||
Config.getInstance();
|
||||
ItemsConfig.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Message.load(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Run things on enable.
|
||||
*/
|
||||
@ -118,8 +94,25 @@ public class Soulbound extends JavaPlugin {
|
||||
new VersionChecker(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
msgcfg = new FileConfig(this, "message.yml");
|
||||
config = new FileConfig(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
msgcfg.reload();
|
||||
config.reload();
|
||||
}
|
||||
|
||||
private void loadConfigFiles() {
|
||||
Config.getInstance();
|
||||
ItemsConfig.getInstance();
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvents(new PlayerListener(), this);
|
||||
pm.registerEvents(new InventoryListener(), this);
|
||||
pm.registerEvents(new EntityListener(), this);
|
@ -6,15 +6,13 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.me.tft_02.soulbound.Soulbound;
|
||||
import com.me.tft_02.soulbound.configs.Message;
|
||||
|
||||
public class SoulboundCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
sender.sendMessage(Soulbound.p.getlang("VERSION")
|
||||
+ Soulbound.p.getDescription().getVersion());
|
||||
sender.sendMessage(Soulbound.p.getlang("VERSION") + Soulbound.p.getDescription().getVersion());
|
||||
return printUsage(sender);
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
@ -32,39 +30,14 @@ public class SoulboundCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean reloadConfiguration(CommandSender sender) {
|
||||
if (sender instanceof Player && !sender.hasPermission("soulbound.commands.reload")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Soulbound.p.reloadConfig();
|
||||
Message.load(Soulbound.p);
|
||||
sender.sendMessage(Soulbound.p.getlang("RELOAD"));
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean helpPages(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(Soulbound.p.getlang("CAN_NOT_USE_ON_CONSOLE"));
|
||||
return false;
|
||||
}
|
||||
if (args.length >= 2 && Integer.parseInt(args[1]) > 0) {
|
||||
getHelpPage(Integer.parseInt(args[1]), sender);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void getHelpPage(int page, CommandSender sender) {
|
||||
int maxPages = 2;
|
||||
int nextPage = page + 1;
|
||||
private void getHelpPage(final int page, final CommandSender sender) {
|
||||
final int maxPages = 2;
|
||||
final int nextPage = page + 1;
|
||||
if (page > maxPages) {
|
||||
sender.sendMessage(Soulbound.p.getlang("PAGE_NOT_EXIST".replace("%maxPages%", maxPages
|
||||
+ "")));
|
||||
sender.sendMessage(Soulbound.p.getlang("PAGE_NOT_EXIST".replace("%maxPages%", maxPages + "")));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(Soulbound.p.getlang("HELP_TITLE").replace("%page%", page + "")
|
||||
.replace("%maxPages%", maxPages + ""));
|
||||
sender.sendMessage(Soulbound.p.getlang("HELP_TITLE").replace("%page%", page + "").replace("%maxPages%", maxPages + ""));
|
||||
if (page == 1) {
|
||||
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK"));
|
||||
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_1"));
|
||||
@ -104,8 +77,29 @@ public class SoulboundCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean printUsage(CommandSender sender) {
|
||||
private boolean helpPages(final CommandSender sender, final String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(Soulbound.p.getlang("CAN_NOT_USE_ON_CONSOLE"));
|
||||
return false;
|
||||
}
|
||||
if (args.length >= 2 && Integer.parseInt(args[1]) > 0) {
|
||||
getHelpPage(Integer.parseInt(args[1]), sender);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean printUsage(final CommandSender sender) {
|
||||
sender.sendMessage(Soulbound.p.getlang("CMD_USE"));
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean reloadConfiguration(final CommandSender sender) {
|
||||
if (sender instanceof Player && !sender.hasPermission("soulbound.commands.reload")) {
|
||||
return false;
|
||||
}
|
||||
Soulbound.p.reloadConfig();
|
||||
sender.sendMessage(Soulbound.p.getlang("RELOAD"));
|
||||
return false;
|
||||
}
|
||||
}
|
23
src/main/java/com/me/tft_02/soulbound/util/LogFilter.java
Normal file
23
src/main/java/com/me/tft_02/soulbound/util/LogFilter.java
Normal file
@ -0,0 +1,23 @@
|
||||
package com.me.tft_02.soulbound.util;
|
||||
|
||||
import java.util.logging.Filter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
import com.me.tft_02.soulbound.Soulbound;
|
||||
|
||||
public class LogFilter implements Filter {
|
||||
private final boolean debug;
|
||||
|
||||
public LogFilter(final Soulbound plugin) {
|
||||
// Doing a config loading lite here, because we can't depend on the config loader to have loaded before any debug messages are sent
|
||||
debug = plugin.getConfig().getBoolean("General.Verbose_Logging");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoggable(final LogRecord record) {
|
||||
if (record.getMessage().contains("[Debug]") && !debug) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -34,17 +34,7 @@ Soulbound:
|
||||
/enchant
|
||||
|
||||
Dependency_Plugins:
|
||||
DiabloDrops:
|
||||
BindOnPickup: Legendary, Rare, Unidentified
|
||||
BindOnUse: Magical
|
||||
BindOnEquip: Set
|
||||
EpicBossRecoded:
|
||||
BindOnPickup: true
|
||||
BindOnUse: false
|
||||
BindOnEquip: false
|
||||
LoreLocks:
|
||||
Bind_Keys: true
|
||||
MythicDrops:
|
||||
BindOnPickup: common, uncommon, rare
|
||||
BindOnUse: terric, netheric
|
||||
BindOnEquip: endric
|
||||
BindOnEquip: false
|
@ -1,10 +1,10 @@
|
||||
name: Soulbound
|
||||
version: 1.1.11
|
||||
author: TfT_02,喵♂呜
|
||||
name: ${project.artifactId}
|
||||
description: ${project.description}
|
||||
authors: [TfT_02,喵♂呜]
|
||||
version: ${project.version}
|
||||
main: com.me.tft_02.soulbound.Soulbound
|
||||
website: http://ci.citycraft.cn:8800/jenkins/job/Soulbound/
|
||||
description: Soulbound items for your RPG servers!
|
||||
softdepend: [EpicBossRecoded, LoreLocks]
|
||||
softdepend: [EpicBossRecoded]
|
||||
commands:
|
||||
soulbound:
|
||||
description: Usage /soulbound
|
Loading…
Reference in New Issue
Block a user