mirror of
https://e.coding.net/circlecloud/SimpleProtect.git
synced 2024-11-22 01:49:03 +00:00
use PluginHelper and update Vetsion...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
25d4709b3c
commit
08891e9770
69
pom.xml
69
pom.xml
@ -1,19 +1,17 @@
|
|||||||
<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>cn.citycraft</groupId>
|
||||||
<artifactId>SimpleProtect</artifactId>
|
<artifactId>SimpleProtect</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.1</version>
|
||||||
<name>SimpleProtect</name>
|
<name>SimpleProtect</name>
|
||||||
|
<description>Minecraft 服务器保护插件</description>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.name}</finalName>
|
<finalName>${project.name}</finalName>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src</directory>
|
<directory>src/main/resources</directory>
|
||||||
<excludes>
|
<filtering>true</filtering>
|
||||||
<exclude>**/*.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -21,10 +19,43 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>3.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -32,6 +63,14 @@
|
|||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
</repository>
|
</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>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -40,6 +79,18 @@
|
|||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
package cn.citycraft.SimpleProtect.config;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public class Config extends ConfigLoader {
|
|
||||||
private static String CONFIG_NAME = "config.yml";
|
|
||||||
private static FileConfig instance;
|
|
||||||
private static File file;
|
|
||||||
|
|
||||||
public Config(Plugin p) {
|
|
||||||
super(p, CONFIG_NAME);
|
|
||||||
file = new File(p.getDataFolder(), CONFIG_NAME);
|
|
||||||
instance = super.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Config(Plugin p, String ver) {
|
|
||||||
super(p, CONFIG_NAME, ver);
|
|
||||||
instance = super.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void load(Plugin p) {
|
|
||||||
new Config(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void load(Plugin p, String ver) {
|
|
||||||
new Config(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[] 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,102 +0,0 @@
|
|||||||
package cn.citycraft.SimpleProtect.config;
|
|
||||||
|
|
||||||
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.getParentFile().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,108 +0,0 @@
|
|||||||
package cn.citycraft.SimpleProtect.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.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,111 +0,0 @@
|
|||||||
package cn.citycraft.SimpleProtect.utils;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
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.checkurl = 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 (IOException e) {
|
|
||||||
plugin.getLogger().warning("版本更新检查失败!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -4,8 +4,9 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||||
|
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
||||||
import cn.citycraft.SimpleProtect.command.SimpleProtectCommand;
|
import cn.citycraft.SimpleProtect.command.SimpleProtectCommand;
|
||||||
import cn.citycraft.SimpleProtect.config.Config;
|
|
||||||
import cn.citycraft.SimpleProtect.listen.BreakFarm;
|
import cn.citycraft.SimpleProtect.listen.BreakFarm;
|
||||||
import cn.citycraft.SimpleProtect.listen.Explosion;
|
import cn.citycraft.SimpleProtect.listen.Explosion;
|
||||||
import cn.citycraft.SimpleProtect.listen.HighRedstone;
|
import cn.citycraft.SimpleProtect.listen.HighRedstone;
|
||||||
@ -13,71 +14,69 @@ import cn.citycraft.SimpleProtect.listen.NetherDoor;
|
|||||||
import cn.citycraft.SimpleProtect.listen.Nightvision;
|
import cn.citycraft.SimpleProtect.listen.Nightvision;
|
||||||
import cn.citycraft.SimpleProtect.listen.Spam;
|
import cn.citycraft.SimpleProtect.listen.Spam;
|
||||||
import cn.citycraft.SimpleProtect.listen.Tip;
|
import cn.citycraft.SimpleProtect.listen.Tip;
|
||||||
import cn.citycraft.SimpleProtect.utils.VersionChecker;
|
|
||||||
|
|
||||||
public class SimpleProtect extends JavaPlugin {
|
public class SimpleProtect extends JavaPlugin {
|
||||||
|
|
||||||
public String servername;
|
public String servername;
|
||||||
public String pluginname;
|
public String pluginname;
|
||||||
public Spam spam = new Spam(this);
|
public Spam spam = new Spam(this);
|
||||||
|
public FileConfig config;
|
||||||
|
|
||||||
public String getfullmsg(String path) {
|
public String getfullmsg(String path) {
|
||||||
return servername + pluginname + " " + getmessage(path);
|
return servername + pluginname + " " + getmessage(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getmessage(String path) {
|
public String getmessage(String path) {
|
||||||
return Config.getMessage(path);
|
return config.getMessage(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getServer().getConsoleSender().sendMessage(
|
getServer().getConsoleSender().sendMessage("==========" + servername + pluginname + "==========");
|
||||||
"==========" + servername + pluginname + "==========");
|
|
||||||
PluginManager pm = Bukkit.getPluginManager();
|
PluginManager pm = Bukkit.getPluginManager();
|
||||||
|
|
||||||
if (Config.getInstance().getBoolean("Tip.Enable", true)) {
|
if (config.getBoolean("Tip.Enable", true)) {
|
||||||
pm.registerEvents(new Tip(this), this);
|
pm.registerEvents(new Tip(this), this);
|
||||||
getLogger().info("保护插件提醒功能已加载!");
|
getLogger().info("保护插件提醒功能已加载!");
|
||||||
}
|
}
|
||||||
if (Config.getInstance().getBoolean("SafeNetherDoor.Enable", true)) {
|
if (config.getBoolean("SafeNetherDoor.Enable", true)) {
|
||||||
pm.registerEvents(new NetherDoor(this), this);
|
pm.registerEvents(new NetherDoor(this), this);
|
||||||
getLogger().info("防止登录卡地狱门已加载!");
|
getLogger().info("防止登录卡地狱门已加载!");
|
||||||
}
|
}
|
||||||
if (Config.getInstance().getBoolean("BreakFarm.Enable", true)) {
|
if (config.getBoolean("BreakFarm.Enable", true)) {
|
||||||
pm.registerEvents(new BreakFarm(this), this);
|
pm.registerEvents(new BreakFarm(this), this);
|
||||||
getLogger().info("防止玩家踩坏耕地已加载!");
|
getLogger().info("防止玩家踩坏耕地已加载!");
|
||||||
}
|
}
|
||||||
if (Config.getInstance().getBoolean("Explosion.Enable", true)) {
|
if (config.getBoolean("Explosion.Enable", true)) {
|
||||||
pm.registerEvents(new Explosion(), this);
|
pm.registerEvents(new Explosion(), this);
|
||||||
getLogger().info("防止爆炸破坏地形已加载!");
|
getLogger().info("防止爆炸破坏地形已加载!");
|
||||||
}
|
}
|
||||||
if (Config.getInstance().getBoolean("Nightvision.Enable", true)) {
|
if (config.getBoolean("Nightvision.Enable", true)) {
|
||||||
pm.registerEvents(new Nightvision(this), this);
|
pm.registerEvents(new Nightvision(this), this);
|
||||||
getLogger().info("防止无限夜视作弊已加载!");
|
getLogger().info("防止无限夜视作弊已加载!");
|
||||||
}
|
}
|
||||||
if (Config.getInstance().getBoolean("HighRedstone.Enable", true)) {
|
if (config.getBoolean("HighRedstone.Enable", true)) {
|
||||||
HighRedstone redstone = new HighRedstone(this);
|
HighRedstone redstone = new HighRedstone(this);
|
||||||
pm.registerEvents(redstone, this);
|
pm.registerEvents(redstone, this);
|
||||||
Bukkit.getScheduler().runTaskTimer(this, redstone, 20, 20);
|
Bukkit.getScheduler().runTaskTimer(this, redstone, 20, 20);
|
||||||
getLogger().info("防止玩家高频红石已加载!");
|
getLogger().info("防止玩家高频红石已加载!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getBoolean("Spam.Enable", true)) {
|
if (config.getBoolean("Spam.Enable", true)) {
|
||||||
Bukkit.getPluginManager().registerEvents(spam, this);
|
Bukkit.getPluginManager().registerEvents(spam, this);
|
||||||
int resettime = Config.getInstance().getInt("Spam.MuteReset") * 20;
|
int resettime = config.getInt("Spam.MuteReset") * 20;
|
||||||
Bukkit.getScheduler().runTaskTimer(this, spam, resettime, resettime);
|
Bukkit.getScheduler().runTaskTimer(this, spam, resettime, resettime);
|
||||||
getLogger().info("防止玩家聊天刷屏已加载!");
|
getLogger().info("防止玩家聊天刷屏已加载!");
|
||||||
}
|
}
|
||||||
getCommand("simpleprotect").setExecutor(new SimpleProtectCommand(this));
|
getCommand("simpleprotect").setExecutor(new SimpleProtectCommand(this));
|
||||||
getServer().getConsoleSender().sendMessage(
|
getServer().getConsoleSender().sendMessage("==========" + servername + pluginname + "==========");
|
||||||
"==========" + servername + pluginname + "==========");
|
|
||||||
new VersionChecker(this);
|
new VersionChecker(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
Config.load(this, "1.0");
|
config = new FileConfig(this);
|
||||||
servername = getmessage("servername");
|
servername = getmessage("servername");
|
||||||
pluginname = getmessage("pluginname");
|
pluginname = getmessage("pluginname");
|
||||||
}
|
}
|
@ -11,7 +11,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||||
import cn.citycraft.SimpleProtect.config.Config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
@ -36,11 +35,11 @@ public class SimpleProtectCommand implements CommandExecutor {
|
|||||||
case "setspawn":
|
case "setspawn":
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Location l = ((Player) sender).getLocation();
|
Location l = ((Player) sender).getLocation();
|
||||||
Config.getInstance().set("SafeNetherDoor.World", l.getWorld().getName());
|
plugin.config.set("SafeNetherDoor.World", l.getWorld().getName());
|
||||||
Config.getInstance().set("SafeNetherDoor.X", l.getBlockX());
|
plugin.config.set("SafeNetherDoor.X", l.getBlockX());
|
||||||
Config.getInstance().set("SafeNetherDoor.Y", l.getBlockY());
|
plugin.config.set("SafeNetherDoor.Y", l.getBlockY());
|
||||||
Config.getInstance().set("SafeNetherDoor.Z", l.getBlockZ());
|
plugin.config.set("SafeNetherDoor.Z", l.getBlockZ());
|
||||||
sender.sendMessage(plugin.pluginname + Config.getMessage("SafeNetherDoor.Set"));
|
sender.sendMessage(plugin.pluginname + plugin.config.getMessage("SafeNetherDoor.Set"));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "reload":
|
case "reload":
|
||||||
@ -49,9 +48,8 @@ public class SimpleProtectCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
case "list":
|
case "list":
|
||||||
sender.sendMessage("§c当前被禁言的玩家有: ");
|
sender.sendMessage("§c当前被禁言的玩家有: ");
|
||||||
for (String player : plugin.spam.getCc()) {
|
for (String player : plugin.spam.getCc())
|
||||||
sender.sendMessage("§6 - " + player);
|
sender.sendMessage("§6 - " + player);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -62,20 +60,16 @@ public class SimpleProtectCommand implements CommandExecutor {
|
|||||||
case "add":
|
case "add":
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
plugin.spam.getCc().add(p.getName());
|
plugin.spam.getCc().add(p.getName());
|
||||||
sender.sendMessage(plugin.getfullmsg("Spam.MuteOn").replace("%player%",
|
sender.sendMessage(plugin.getfullmsg("Spam.MuteOn").replace("%player%", p.getDisplayName()));
|
||||||
p.getDisplayName()));
|
} else
|
||||||
} else {
|
|
||||||
sender.sendMessage(plugin.getfullmsg("Spam.OffLine"));
|
sender.sendMessage(plugin.getfullmsg("Spam.OffLine"));
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
case "del":
|
case "del":
|
||||||
if (p != null && plugin.spam.getCc().contains(p.getName())) {
|
if (p != null && plugin.spam.getCc().contains(p.getName())) {
|
||||||
plugin.spam.getCc().remove(p);
|
plugin.spam.getCc().remove(p);
|
||||||
sender.sendMessage(plugin.getfullmsg("Spam.MuteOff").replace("%player%",
|
sender.sendMessage(plugin.getfullmsg("Spam.MuteOff").replace("%player%", p.getDisplayName()));
|
||||||
p.getDisplayName()));
|
} else
|
||||||
} else {
|
|
||||||
sender.sendMessage(plugin.getfullmsg("Spam.NotMute"));
|
sender.sendMessage(plugin.getfullmsg("Spam.NotMute"));
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
case "admin":
|
case "admin":
|
||||||
if (args[1].equalsIgnoreCase("on")) {
|
if (args[1].equalsIgnoreCase("on")) {
|
@ -16,7 +16,6 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
|
|
||||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||||
import cn.citycraft.SimpleProtect.config.Config;
|
|
||||||
|
|
||||||
public class HighRedstone implements Runnable, Listener {
|
public class HighRedstone implements Runnable, Listener {
|
||||||
|
|
||||||
@ -32,38 +31,24 @@ public class HighRedstone implements Runnable, Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRedClock(BlockRedstoneEvent event) {
|
public void onRedClock(BlockRedstoneEvent event) {
|
||||||
Block rb = event.getBlock();
|
Block rb = event.getBlock();
|
||||||
if (rb.getType() == Material.REDSTONE_WIRE) {
|
if (rb.getType() == Material.REDSTONE_WIRE)
|
||||||
put(event.getBlock());
|
put(event.getBlock());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void put(Block block) {
|
|
||||||
if (map.containsKey(block)) {
|
|
||||||
int i = map.remove(block);
|
|
||||||
map.put(block, i + 1);
|
|
||||||
} else {
|
|
||||||
map.put(block, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void RedStonePlace(BlockPlaceEvent event) {
|
public void RedStonePlace(BlockPlaceEvent event) {
|
||||||
Block rb = event.getBlock();
|
Block rb = event.getBlock();
|
||||||
Player rp = event.getPlayer();
|
Player rp = event.getPlayer();
|
||||||
if (rb.getType() == Material.REDSTONE_WIRE) {
|
if (rb.getType() == Material.REDSTONE_WIRE)
|
||||||
pmap.put(rb, rp);
|
pmap.put(rb, rp);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
List<Block> blocks = new ArrayList<Block>();
|
List<Block> blocks = new ArrayList<Block>();
|
||||||
for (Entry<Block, Integer> entry : map.entrySet()) {
|
for (Entry<Block, Integer> entry : map.entrySet())
|
||||||
if (entry.getValue() > Config.getInstance().getLong(
|
if (entry.getValue() > plugin.config.getLong("HighRedstone.Maxevents"))
|
||||||
"HighRedstone.Maxevents")) {
|
|
||||||
blocks.add(entry.getKey());
|
blocks.add(entry.getKey());
|
||||||
}
|
|
||||||
}
|
|
||||||
Boolean tip = true;
|
Boolean tip = true;
|
||||||
for (Block block : blocks) {
|
for (Block block : blocks) {
|
||||||
World rw = block.getWorld();
|
World rw = block.getWorld();
|
||||||
@ -71,7 +56,7 @@ public class HighRedstone implements Runnable, Listener {
|
|||||||
int ry = block.getY();
|
int ry = block.getY();
|
||||||
int rz = block.getZ();
|
int rz = block.getZ();
|
||||||
Player rp = pmap.get(block);
|
Player rp = pmap.get(block);
|
||||||
if (rp != null) {
|
if (rp != null)
|
||||||
if (rp.isOp() || rp.hasPermission("sp.ignore.highredstone")) {
|
if (rp.isOp() || rp.hasPermission("sp.ignore.highredstone")) {
|
||||||
if (!tipop.contains(rp)) {
|
if (!tipop.contains(rp)) {
|
||||||
rp.sendMessage(plugin.getfullmsg("HighRedstone.Admin"));
|
rp.sendMessage(plugin.getfullmsg("HighRedstone.Admin"));
|
||||||
@ -79,16 +64,10 @@ public class HighRedstone implements Runnable, Listener {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (tip) {
|
if (tip) {
|
||||||
Bukkit.broadcastMessage(plugin.getfullmsg("HighRedstone.Find")
|
Bukkit.broadcastMessage(plugin.getfullmsg("HighRedstone.Find").replaceAll("%world%", rw.getName()).replaceAll("%x%", rx + "").replaceAll("%y%", ry + "").replaceAll("%z%", rz + ""));
|
||||||
.replaceAll("%world%", rw.getName())
|
|
||||||
.replaceAll("%x%", rx + "").replaceAll("%y%", ry + "")
|
|
||||||
.replaceAll("%z%", rz + ""));
|
|
||||||
if (rp != null) {
|
if (rp != null) {
|
||||||
Bukkit.broadcastMessage(plugin.getfullmsg(
|
Bukkit.broadcastMessage(plugin.getfullmsg("HighRedstone.Check").replaceAll("%player%", rp.getName()));
|
||||||
"HighRedstone.Check").replaceAll("%player%",
|
|
||||||
rp.getName()));
|
|
||||||
pmap.remove(block);
|
pmap.remove(block);
|
||||||
}
|
}
|
||||||
tip = !tip;
|
tip = !tip;
|
||||||
@ -97,4 +76,12 @@ public class HighRedstone implements Runnable, Listener {
|
|||||||
}
|
}
|
||||||
map.clear();
|
map.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void put(Block block) {
|
||||||
|
if (map.containsKey(block)) {
|
||||||
|
int i = map.remove(block);
|
||||||
|
map.put(block, i + 1);
|
||||||
|
} else
|
||||||
|
map.put(block, 1);
|
||||||
|
}
|
||||||
}
|
}
|
@ -12,7 +12,6 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||||
import cn.citycraft.SimpleProtect.config.Config;
|
|
||||||
|
|
||||||
public class NetherDoor implements Listener {
|
public class NetherDoor implements Listener {
|
||||||
|
|
||||||
@ -46,18 +45,13 @@ public class NetherDoor implements Listener {
|
|||||||
Location loc_xright = new Location(world, x - 1.0D, y, z);
|
Location loc_xright = new Location(world, x - 1.0D, y, z);
|
||||||
Location loc_zleft = new Location(world, x, y, z + 1.0D);
|
Location loc_zleft = new Location(world, x, y, z + 1.0D);
|
||||||
Location loc_zright = new Location(world, x, y, z - 1.0D);
|
Location loc_zright = new Location(world, x, y, z - 1.0D);
|
||||||
if (loc_top.getBlock().getType() == Material.PORTAL
|
if (loc_top.getBlock().getType() == Material.PORTAL || loc_bottom.getBlock().getType() == Material.PORTAL || loc_xleft.getBlock().getType() == Material.PORTAL
|
||||||
|| loc_bottom.getBlock().getType() == Material.PORTAL
|
|| loc_xright.getBlock().getType() == Material.PORTAL || loc_zleft.getBlock().getType() == Material.PORTAL || loc_zright.getBlock().getType() == Material.PORTAL) {
|
||||||
|| loc_xleft.getBlock().getType() == Material.PORTAL
|
|
||||||
|| loc_xright.getBlock().getType() == Material.PORTAL
|
|
||||||
|| loc_zleft.getBlock().getType() == Material.PORTAL
|
|
||||||
|| loc_zright.getBlock().getType() == Material.PORTAL) {
|
|
||||||
p.sendMessage(plugin.getfullmsg("SafeNetherDoor.Tip"));
|
p.sendMessage(plugin.getfullmsg("SafeNetherDoor.Tip"));
|
||||||
World lworld = Bukkit.getWorld((String) Config.getInstance().get(
|
World lworld = Bukkit.getWorld((String) plugin.config.get("SafeNetherDoor.World", "world"));
|
||||||
"SafeNetherDoor.World", "world"));
|
double lx = plugin.config.getInt("SafeNetherDoor.X", 0);
|
||||||
double lx = Config.getInstance().getInt("SafeNetherDoor.X", 0);
|
double ly = plugin.config.getInt("SafeNetherDoor.Y", 0);
|
||||||
double ly = Config.getInstance().getInt("SafeNetherDoor.Y", 0);
|
double lz = plugin.config.getInt("SafeNetherDoor.Z", 0);
|
||||||
double lz = Config.getInstance().getInt("SafeNetherDoor.Z", 0);
|
|
||||||
spawn = new Location(lworld, lx, ly, lz);
|
spawn = new Location(lworld, lx, ly, lz);
|
||||||
p.teleport(spawn);
|
p.teleport(spawn);
|
||||||
}
|
}
|
@ -14,7 +14,6 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||||
import cn.citycraft.SimpleProtect.config.Config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -47,16 +46,15 @@ public class Spam implements Runnable, Listener {
|
|||||||
SaveMsg(n, s);
|
SaveMsg(n, s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (lt + Config.getInstance().getLong("Spam.ChatWait", 1) > nt) {
|
if (lt + plugin.config.getLong("Spam.ChatWait", 1) > nt) {
|
||||||
AntiMsg = plugin.getmessage("Spam.TooMuchChat");
|
AntiMsg = plugin.getmessage("Spam.TooMuchChat");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (lm.equals(s)) {
|
if (lm.equals(s))
|
||||||
if (lt + Config.getInstance().getLong("Spam.SameChatWait", 5) > nt) {
|
if (lt + plugin.config.getLong("Spam.SameChatWait", 5) > nt) {
|
||||||
AntiMsg = plugin.getmessage("Spam.TooMuchSameChat");
|
AntiMsg = plugin.getmessage("Spam.TooMuchSameChat");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
AntiMsg = "";
|
AntiMsg = "";
|
||||||
SaveMsg(n, s);
|
SaveMsg(n, s);
|
||||||
return false;
|
return false;
|
||||||
@ -71,16 +69,15 @@ public class Spam implements Runnable, Listener {
|
|||||||
SaveMsg(n, s);
|
SaveMsg(n, s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (lt + Config.getInstance().getLong("Spam.CommandWait", 1) > nt) {
|
if (lt + plugin.config.getLong("Spam.CommandWait", 1) > nt) {
|
||||||
AntiMsg = plugin.getmessage("Spam.TooMuchCommand");
|
AntiMsg = plugin.getmessage("Spam.TooMuchCommand");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (lm.equals(s)) {
|
if (lm.equals(s))
|
||||||
if (lt + Config.getInstance().getLong("Spam.SameCommandWait", 3) > nt) {
|
if (lt + plugin.config.getLong("Spam.SameCommandWait", 3) > nt) {
|
||||||
AntiMsg = plugin.getmessage("Spam.TooMuchSameCommand");
|
AntiMsg = plugin.getmessage("Spam.TooMuchSameCommand");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
SaveMsg(n, s);
|
SaveMsg(n, s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -129,16 +126,14 @@ public class Spam implements Runnable, Listener {
|
|||||||
public void put(Player p) {
|
public void put(Player p) {
|
||||||
if (tc.containsKey(p.getName())) {
|
if (tc.containsKey(p.getName())) {
|
||||||
int t = tc.get(p.getName());
|
int t = tc.get(p.getName());
|
||||||
if (t > Config.getInstance().getLong("Spam.MuteCheck", 3)) {
|
if (t > plugin.config.getLong("Spam.MuteCheck", 3)) {
|
||||||
p.sendMessage(plugin.getfullmsg("Spam.MuteMsg"));
|
p.sendMessage(plugin.getfullmsg("Spam.MuteMsg"));
|
||||||
cc.add(p.getName());
|
cc.add(p.getName());
|
||||||
} else {
|
} else
|
||||||
tc.put(p.getName(), t + 1);
|
tc.put(p.getName(), t + 1);
|
||||||
}
|
} else
|
||||||
} else {
|
|
||||||
tc.put(p.getName(), 1);
|
tc.put(p.getName(), 1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
@ -6,7 +6,6 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||||
import cn.citycraft.SimpleProtect.config.Config;
|
|
||||||
|
|
||||||
public class Tip implements Listener {
|
public class Tip implements Listener {
|
||||||
SimpleProtect plugin;
|
SimpleProtect plugin;
|
||||||
@ -17,19 +16,14 @@ public class Tip implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(final PlayerJoinEvent e) {
|
public void onJoin(final PlayerJoinEvent e) {
|
||||||
plugin.getServer().getScheduler()
|
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, () -> {
|
||||||
.runTaskLaterAsynchronously(plugin, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
String[] msg = Config.getStringArray("Tip.Message");
|
String[] msg = plugin.config.getStringArray("Tip.Message");
|
||||||
for (String s : msg) {
|
for (String s : msg) {
|
||||||
s = s.replaceAll("&", "§");
|
s = s.replaceAll("&", "§");
|
||||||
p.sendMessage(plugin.servername + plugin.pluginname
|
p.sendMessage(plugin.servername + plugin.pluginname + s);
|
||||||
+ s);
|
|
||||||
}
|
}
|
||||||
}
|
} , 15);
|
||||||
}, 15);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
name: SimpleProtect
|
name: ${project.artifactId}
|
||||||
main: cn.citycraft.SimpleProtect.SimpleProtect
|
description: ${project.description}
|
||||||
website: http://ci.citycraft.cn:8800/jenkins/job/SimpleProtect/
|
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||||
version: 0.0.2
|
version: ${project.version}
|
||||||
|
auther: 喵♂呜
|
||||||
|
website: http://ci.citycraft.cn:8800/jenkins/job/${project.artifactId}/
|
||||||
commands:
|
commands:
|
||||||
simpleprotect:
|
simpleprotect:
|
||||||
description: 简单保护插件
|
description: 简单保护插件
|
Loading…
Reference in New Issue
Block a user