1
0
mirror of https://e.coding.net/circlecloud/SimpleProtect.git synced 2024-11-22 01:49:03 +00:00

Merge remote-tracking branch 'Coding/master'

Conflicts:
	src/cn/citycraft/SimpleProtect/SimpleProtect.java
	src/config.yml


Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-07-26 17:31:17 +08:00
commit dbbba9741e
5 changed files with 98 additions and 152 deletions

View File

@ -1,79 +0,0 @@
package cn.citycraft.SimpleProtect;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import cn.citycraft.SimpleProtect.config.Config;
import cn.citycraft.SimpleProtect.listen.BreakFarm;
import cn.citycraft.SimpleProtect.listen.Explosion;
import cn.citycraft.SimpleProtect.listen.HighRedstone;
import cn.citycraft.SimpleProtect.listen.NetherDoor;
import cn.citycraft.SimpleProtect.listen.Nightvision;
import cn.citycraft.SimpleProtect.listen.Spam;
import cn.citycraft.SimpleProtect.listen.Tip;
public class SimpleProtect extends JavaPlugin {
public String servername;
public String pluginname;
public String getfullmsg(String path) {
return servername + pluginname + " " + getmessage(path);
}
public String getmessage(String path) {
return Config.getMessage(path);
}
@Override
public void onEnable() {
getLogger().info("==========" + servername + pluginname + "==========");
PluginManager pm = Bukkit.getPluginManager();
if (Config.getInstance().getBoolean("Tip.Enable", true)) {
pm.registerEvents(new Tip(this), this);
getLogger().info("保护插件提醒功能已加载!");
}
if (Config.getInstance().getBoolean("SafeNetherDoor.Enable", true)) {
pm.registerEvents(new NetherDoor(this), this);
getLogger().info("防止登录卡地狱门已加载!");
}
if (Config.getInstance().getBoolean("BreakFarm.Enable", true)) {
pm.registerEvents(new BreakFarm(this), this);
getLogger().info("防止玩家踩坏耕地已加载!");
}
if (Config.getInstance().getBoolean("Explosion.Enable", true)) {
pm.registerEvents(new Explosion(), this);
getLogger().info("防止爆炸破坏地形已加载!");
}
if (Config.getInstance().getBoolean("Nightvision.Enable", true)) {
pm.registerEvents(new Nightvision(this), this);
getLogger().info("防止无限夜视作弊已加载!");
}
if (Config.getInstance().getBoolean("HighRedstone.Enable", true)) {
HighRedstone redstone = new HighRedstone(this);
pm.registerEvents(redstone, this);
Bukkit.getScheduler().runTaskTimer(this, redstone, 20, 20);
getLogger().info("防止玩家高频红石已加载!");
}
if (Config.getInstance().getBoolean("Spam.Enable", true)) {
Spam spam = new Spam(this);
Bukkit.getPluginManager().registerEvents(spam, this);
Bukkit.getScheduler().runTaskTimer(this, spam, 20, 20);
getCommand("spam").setExecutor(spam);
getLogger().info("防止玩家聊天刷屏已加载!");
}
getLogger().info("==========" + servername + pluginname + "==========");
}
@Override
public void onLoad() {
Config.load(this, "1.0");
servername = getmessage("servername");
pluginname = getmessage("pluginname");
}
}

View File

@ -17,7 +17,8 @@ import cn.citycraft.SimpleProtect.config.Config;
public class NetherDoor implements Listener { public class NetherDoor implements Listener {
public FileConfiguration getConfig; public FileConfiguration getConfig;
public Location spawn; protected Location spawn;
SimpleProtect plugin; SimpleProtect plugin;
public NetherDoor(SimpleProtect main) { public NetherDoor(SimpleProtect main) {
@ -52,15 +53,11 @@ public class NetherDoor implements Listener {
|| loc_zleft.getBlock().getType() == Material.PORTAL || loc_zleft.getBlock().getType() == Material.PORTAL
|| loc_zright.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 World lworld = Bukkit.getWorld((String) Config.getInstance().get(
.getWorld((String) Config.getInstance().get( "SafeNetherDoor.World", "world"));
"SafeNetherDoor.World", "world")); double lx = Config.getInstance().getInt("SafeNetherDoor.X", 0);
double lx = Config.getInstance().getInt("SafeNetherDoor.X", double ly = Config.getInstance().getInt("SafeNetherDoor.Y", 0);
0); double lz = Config.getInstance().getInt("SafeNetherDoor.Z", 0);
double ly = Config.getInstance().getInt("SafeNetherDoor.Y",
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);
} }

View File

@ -0,0 +1,73 @@
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;
public class VersionChecker implements Listener {
Plugin plugin;
public VersionChecker(Plugin plugin) {
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
this.VersionCheck(null);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
if (e.getPlayer().isOp()) {
this.VersionCheck(e.getPlayer());
}
}
public void VersionCheck(final Player player) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
String website = plugin.getDescription().getWebsite();
String readURL = website
+ (website.substring(website.length() - 1).equals("/") ? "" : "/")
+ "/lastSuccessfulBuild/artifact/src/plugin.yml";
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("版本更新检查失败!");
}
}
});
}
}

View File

@ -1,62 +0,0 @@
#本文件为保护插件的主配置文件
version: 1.0
#服务器名称
servername: ''
#插件名称
pluginname: '&6[&b保护系统&6]&r'
#登陆提示
Tip:
#是否开启
Enable: true
Message:
- '&a服务器已开启保护功能'
- '&c将会实时监控您的操作'
- '&b城市世界请圈地后建筑'
- '&e挖矿请带上火把或药水'
#耕地保护配置
BreakFarm:
#是否开启
Enable: true
Tip: '&c服务器已开启耕地保护请不要踩庄稼'
#爆炸保护配置
Explosion:
#是否开启
Enable: true
#高频红石检测
HighRedstone:
#是否开启
Enable: true
Maxevents: 35
Find: '&c发现高频红石 &3世界%world% &d坐标 X:%x% Y:%y% Z:%z% §a已清理'
Check: '&c高频红石数据监测 &5上述高频红石由 &6玩家&a%player%& 6放置'
Admin: '&c发现您放置高频红石,由于您是管理员,在服务器重启之前此高频将不会被清理,请用完后及时清理!'
#防止无限夜视
Nightvision:
#是否开启
Enable: true
Tip: '&c为防止无限夜视作弊以阻止挖矿请插火把或用夜视药水'
#安全地狱门
SafeNetherDoor:
#是否开启
Enable: true
Tip: '&5为防止您卡在地狱门现在将您传送回主城'
World: world
X: -51
Y: 73
Z: 38
#刷屏保护
Spam:
#是否开启
Enable: true
ChatWait: 3
SameChatWait: 8
CommandWait: 2
SameCommandWait: 3
KickCheck: 3
KickReset: 10

View File

@ -1,7 +1,24 @@
name: SimpleProtect name: SimpleProtect
main: cn.citycraft.SimpleProtect.SimpleProtect main: cn.citycraft.SimpleProtect.SimpleProtect
version: 0.0.1 website: http://ci.citycraft.cn:8800/jenkins/job/SimpleProtect/
version: 0.0.2
commands:
simpleprotect:
description: 简单保护插件
aliaese: [sp]
usage: §b使用/sp help 查看帮助!
permission: sp.*
permission-message: §c你没有 <permission> 的权限来执行此命令!
permissions: permissions:
sp.*:
description: 插件所有权限!
default: op
children:
sp.setspawn: true
sp.ignore.*: true
sp.setspawn:
description: 允许配置插件出生点!
default: op
sp.ignore.*: sp.ignore.*:
description: 允许忽略插件的检测! description: 允许忽略插件的检测!
default: op default: op