mirror of
https://e.coding.net/circlecloud/SimpleProtect.git
synced 2025-11-24 21:26:19 +00:00
use PluginHelper and update Vetsion...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
83
src/main/java/cn/citycraft/SimpleProtect/SimpleProtect.java
Normal file
83
src/main/java/cn/citycraft/SimpleProtect/SimpleProtect.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package cn.citycraft.SimpleProtect;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
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.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 Spam spam = new Spam(this);
|
||||
public FileConfig config;
|
||||
|
||||
public String getfullmsg(String path) {
|
||||
return servername + pluginname + " " + getmessage(path);
|
||||
}
|
||||
|
||||
public String getmessage(String path) {
|
||||
return config.getMessage(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getServer().getConsoleSender().sendMessage("==========" + servername + pluginname + "==========");
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
|
||||
if (config.getBoolean("Tip.Enable", true)) {
|
||||
pm.registerEvents(new Tip(this), this);
|
||||
getLogger().info("保护插件提醒功能已加载!");
|
||||
}
|
||||
if (config.getBoolean("SafeNetherDoor.Enable", true)) {
|
||||
pm.registerEvents(new NetherDoor(this), this);
|
||||
getLogger().info("防止登录卡地狱门已加载!");
|
||||
}
|
||||
if (config.getBoolean("BreakFarm.Enable", true)) {
|
||||
pm.registerEvents(new BreakFarm(this), this);
|
||||
getLogger().info("防止玩家踩坏耕地已加载!");
|
||||
}
|
||||
if (config.getBoolean("Explosion.Enable", true)) {
|
||||
pm.registerEvents(new Explosion(), this);
|
||||
getLogger().info("防止爆炸破坏地形已加载!");
|
||||
}
|
||||
if (config.getBoolean("Nightvision.Enable", true)) {
|
||||
pm.registerEvents(new Nightvision(this), this);
|
||||
getLogger().info("防止无限夜视作弊已加载!");
|
||||
}
|
||||
if (config.getBoolean("HighRedstone.Enable", true)) {
|
||||
HighRedstone redstone = new HighRedstone(this);
|
||||
pm.registerEvents(redstone, this);
|
||||
Bukkit.getScheduler().runTaskTimer(this, redstone, 20, 20);
|
||||
getLogger().info("防止玩家高频红石已加载!");
|
||||
}
|
||||
|
||||
if (config.getBoolean("Spam.Enable", true)) {
|
||||
Bukkit.getPluginManager().registerEvents(spam, this);
|
||||
int resettime = config.getInt("Spam.MuteReset") * 20;
|
||||
Bukkit.getScheduler().runTaskTimer(this, spam, resettime, resettime);
|
||||
getLogger().info("防止玩家聊天刷屏已加载!");
|
||||
}
|
||||
getCommand("simpleprotect").setExecutor(new SimpleProtectCommand(this));
|
||||
getServer().getConsoleSender().sendMessage("==========" + servername + pluginname + "==========");
|
||||
new VersionChecker(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
config = new FileConfig(this);
|
||||
servername = getmessage("servername");
|
||||
pluginname = getmessage("pluginname");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleProtect.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public class SimpleProtectCommand implements CommandExecutor {
|
||||
|
||||
SimpleProtect plugin;
|
||||
|
||||
/**
|
||||
* @param simpleProtect
|
||||
*/
|
||||
public SimpleProtectCommand(SimpleProtect simpleProtect) {
|
||||
plugin = simpleProtect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
switch (args[0]) {
|
||||
case "setspawn":
|
||||
if (sender instanceof Player) {
|
||||
Location l = ((Player) sender).getLocation();
|
||||
plugin.config.set("SafeNetherDoor.World", l.getWorld().getName());
|
||||
plugin.config.set("SafeNetherDoor.X", l.getBlockX());
|
||||
plugin.config.set("SafeNetherDoor.Y", l.getBlockY());
|
||||
plugin.config.set("SafeNetherDoor.Z", l.getBlockZ());
|
||||
sender.sendMessage(plugin.pluginname + plugin.config.getMessage("SafeNetherDoor.Set"));
|
||||
}
|
||||
return true;
|
||||
case "reload":
|
||||
plugin.onLoad();
|
||||
sender.sendMessage(plugin.pluginname + "§a配置文件已重载!");
|
||||
return true;
|
||||
case "list":
|
||||
sender.sendMessage("§c当前被禁言的玩家有: ");
|
||||
for (String player : plugin.spam.getCc())
|
||||
sender.sendMessage("§6 - " + player);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
Player p = Bukkit.getPlayer(args[1]);
|
||||
switch (args[0]) {
|
||||
case "add":
|
||||
if (p != null) {
|
||||
plugin.spam.getCc().add(p.getName());
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.MuteOn").replace("%player%", p.getDisplayName()));
|
||||
} else
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.OffLine"));
|
||||
return true;
|
||||
case "del":
|
||||
if (p != null && plugin.spam.getCc().contains(p.getName())) {
|
||||
plugin.spam.getCc().remove(p);
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.MuteOff").replace("%player%", p.getDisplayName()));
|
||||
} else
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.NotMute"));
|
||||
return true;
|
||||
case "admin":
|
||||
if (args[1].equalsIgnoreCase("on")) {
|
||||
plugin.spam.setAdminchat(true);
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.AdminChatOn"));
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("off")) {
|
||||
plugin.spam.setAdminchat(false);
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.AdminChatOff"));
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cn.citycraft.SimpleProtect.listen;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class BreakFarm implements Listener {
|
||||
|
||||
SimpleProtect plugin;
|
||||
|
||||
public BreakFarm(SimpleProtect main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void soilChangePlayer(PlayerInteractEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (event.getAction().equals(Action.PHYSICAL)
|
||||
&& event.getClickedBlock().getType().equals(Material.SOIL)) {
|
||||
event.getPlayer().sendMessage(plugin.getfullmsg("BreakFarm.Tip"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void soilChangeEntity(EntityInteractEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (event.getEntityType() != EntityType.PLAYER
|
||||
&& event.getBlock().getType().equals(Material.SOIL)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.citycraft.SimpleProtect.listen;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
public class Explosion implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onExplosion(EntityExplodeEvent event) {
|
||||
event.blockList().clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package cn.citycraft.SimpleProtect.listen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class HighRedstone implements Runnable, Listener {
|
||||
|
||||
HashMap<Block, Integer> map = new HashMap<Block, Integer>();
|
||||
HashMap<Block, Player> pmap = new HashMap<Block, Player>();
|
||||
SimpleProtect plugin;
|
||||
ArrayList<Player> tipop = new ArrayList<Player>();
|
||||
|
||||
public HighRedstone(SimpleProtect main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRedClock(BlockRedstoneEvent event) {
|
||||
Block rb = event.getBlock();
|
||||
if (rb.getType() == Material.REDSTONE_WIRE)
|
||||
put(event.getBlock());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void RedStonePlace(BlockPlaceEvent event) {
|
||||
Block rb = event.getBlock();
|
||||
Player rp = event.getPlayer();
|
||||
if (rb.getType() == Material.REDSTONE_WIRE)
|
||||
pmap.put(rb, rp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
for (Entry<Block, Integer> entry : map.entrySet())
|
||||
if (entry.getValue() > plugin.config.getLong("HighRedstone.Maxevents"))
|
||||
blocks.add(entry.getKey());
|
||||
Boolean tip = true;
|
||||
for (Block block : blocks) {
|
||||
World rw = block.getWorld();
|
||||
int rx = block.getX();
|
||||
int ry = block.getY();
|
||||
int rz = block.getZ();
|
||||
Player rp = pmap.get(block);
|
||||
if (rp != null)
|
||||
if (rp.isOp() || rp.hasPermission("sp.ignore.highredstone")) {
|
||||
if (!tipop.contains(rp)) {
|
||||
rp.sendMessage(plugin.getfullmsg("HighRedstone.Admin"));
|
||||
tipop.add(rp);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (tip) {
|
||||
Bukkit.broadcastMessage(plugin.getfullmsg("HighRedstone.Find").replaceAll("%world%", rw.getName()).replaceAll("%x%", rx + "").replaceAll("%y%", ry + "").replaceAll("%z%", rz + ""));
|
||||
if (rp != null) {
|
||||
Bukkit.broadcastMessage(plugin.getfullmsg("HighRedstone.Check").replaceAll("%player%", rp.getName()));
|
||||
pmap.remove(block);
|
||||
}
|
||||
tip = !tip;
|
||||
}
|
||||
block.breakNaturally();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.citycraft.SimpleProtect.listen;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class NetherDoor implements Listener {
|
||||
|
||||
public FileConfiguration getConfig;
|
||||
protected Location spawn;
|
||||
|
||||
SimpleProtect plugin;
|
||||
|
||||
public NetherDoor(SimpleProtect main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
// public NetherDoor() {
|
||||
// throw new UnsupportedOperationException("Not yet implemented");
|
||||
// }
|
||||
@EventHandler
|
||||
public void onJoin(final PlayerJoinEvent e) {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Player p = e.getPlayer();
|
||||
Location loc = p.getLocation();
|
||||
World world = loc.getWorld();
|
||||
double x = loc.getX();
|
||||
double y = loc.getY();
|
||||
double z = loc.getZ();
|
||||
Location loc_top = new Location(world, x, y + 1.0D, z);
|
||||
Location loc_bottom = new Location(world, x, y - 1.0D, z);
|
||||
Location loc_xleft = 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_zright = new Location(world, x, y, z - 1.0D);
|
||||
if (loc_top.getBlock().getType() == Material.PORTAL || loc_bottom.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"));
|
||||
World lworld = Bukkit.getWorld((String) plugin.config.get("SafeNetherDoor.World", "world"));
|
||||
double lx = plugin.config.getInt("SafeNetherDoor.X", 0);
|
||||
double ly = plugin.config.getInt("SafeNetherDoor.Y", 0);
|
||||
double lz = plugin.config.getInt("SafeNetherDoor.Z", 0);
|
||||
spawn = new Location(lworld, lx, ly, lz);
|
||||
p.teleport(spawn);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(plugin, 15);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package cn.citycraft.SimpleProtect.listen;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class Nightvision implements Listener {
|
||||
|
||||
SimpleProtect plugin;
|
||||
|
||||
public Nightvision(SimpleProtect main) {
|
||||
plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnBlockBreak(BlockBreakEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (p.hasPermission("sp.ignore.nightvision") || p.isOp()) {
|
||||
return;
|
||||
}
|
||||
int light = p.getLocation().getBlock().getLightLevel();
|
||||
if (light > 0) {
|
||||
return;
|
||||
}
|
||||
Block b = e.getBlock();
|
||||
Material blockid = b.getType();
|
||||
Location loc = b.getLocation();
|
||||
World World = loc.getWorld();
|
||||
int x = loc.getBlockX();
|
||||
int y = loc.getBlockY();
|
||||
int z = loc.getBlockZ();
|
||||
Location loc_top = new Location(World, x, y + 1, z);
|
||||
if (loc_top.getBlock().getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
Collection<PotionEffect> effect = p.getActivePotionEffects();
|
||||
Iterator<PotionEffect> iterator = effect.iterator();
|
||||
Boolean flag = Boolean.valueOf(false);
|
||||
while (iterator.hasNext()) {
|
||||
PotionEffect element = (PotionEffect) iterator.next();
|
||||
if (element.toString().toUpperCase().contains("NIGHT_VISION")) {
|
||||
flag = Boolean.valueOf(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag.booleanValue()) {
|
||||
if (blockid == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
if (blockid == Material.STONE || blockid == Material.GOLD_ORE
|
||||
|| blockid == Material.IRON_ORE
|
||||
|| blockid == Material.COAL_ORE
|
||||
|| blockid == Material.DIAMOND_ORE
|
||||
|| blockid == Material.REDSTONE_ORE
|
||||
|| blockid == Material.LAPIS_ORE
|
||||
|| blockid == Material.EMERALD_ORE) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(plugin.getfullmsg("Nightvision.Tip"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
152
src/main/java/cn/citycraft/SimpleProtect/listen/Spam.java
Normal file
152
src/main/java/cn/citycraft/SimpleProtect/listen/Spam.java
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates and open the template in the editor.
|
||||
*/
|
||||
package cn.citycraft.SimpleProtect.listen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
*/
|
||||
public class Spam implements Runnable, Listener {
|
||||
|
||||
private final HashMap<String, Long> lT;
|
||||
private final HashMap<String, String> lC;
|
||||
HashMap<String, Integer> tc = new HashMap<String, Integer>();
|
||||
List<String> cc = new ArrayList<String>();
|
||||
String AntiMsg;
|
||||
|
||||
boolean adminchat;
|
||||
|
||||
SimpleProtect plugin;
|
||||
|
||||
public Spam(SimpleProtect main) {
|
||||
plugin = main;
|
||||
this.lT = new HashMap<String, Long>();
|
||||
this.lC = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
public boolean AntiChat(String n, String s) {
|
||||
String lm = lC.get(n);
|
||||
Long lt = lT.get(n);
|
||||
long nt = System.currentTimeMillis() / 1000;
|
||||
if (lm == null || lt == null) {
|
||||
AntiMsg = "";
|
||||
SaveMsg(n, s);
|
||||
return false;
|
||||
}
|
||||
if (lt + plugin.config.getLong("Spam.ChatWait", 1) > nt) {
|
||||
AntiMsg = plugin.getmessage("Spam.TooMuchChat");
|
||||
return true;
|
||||
}
|
||||
if (lm.equals(s))
|
||||
if (lt + plugin.config.getLong("Spam.SameChatWait", 5) > nt) {
|
||||
AntiMsg = plugin.getmessage("Spam.TooMuchSameChat");
|
||||
return true;
|
||||
}
|
||||
AntiMsg = "";
|
||||
SaveMsg(n, s);
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean CommandWait(String n, String s) {
|
||||
String lm = lC.get(n);
|
||||
Long lt = lT.get(n);
|
||||
long nt = System.currentTimeMillis() / 1000;
|
||||
if (lm == null || lt == null) {
|
||||
AntiMsg = "";
|
||||
SaveMsg(n, s);
|
||||
return false;
|
||||
}
|
||||
if (lt + plugin.config.getLong("Spam.CommandWait", 1) > nt) {
|
||||
AntiMsg = plugin.getmessage("Spam.TooMuchCommand");
|
||||
return true;
|
||||
}
|
||||
if (lm.equals(s))
|
||||
if (lt + plugin.config.getLong("Spam.SameCommandWait", 3) > nt) {
|
||||
AntiMsg = plugin.getmessage("Spam.TooMuchSameCommand");
|
||||
return true;
|
||||
}
|
||||
SaveMsg(n, s);
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> getCc() {
|
||||
return cc;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void PlayerChat(AsyncPlayerChatEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
String n = p.getName();
|
||||
String s = e.getMessage();
|
||||
if (p.hasPermission("sp.ignore.spam"))
|
||||
return;
|
||||
if (adminchat) {
|
||||
p.sendMessage(plugin.getfullmsg("Spam.AdminChat"));
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (cc.contains(p)) {
|
||||
p.sendMessage(plugin.getfullmsg("Spam.MuteMsg"));
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (AntiChat(n, s)) {
|
||||
p.sendMessage(plugin.servername + plugin.pluginname + AntiMsg);
|
||||
e.setCancelled(true);
|
||||
put(p);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void PlayerCommand(PlayerCommandPreprocessEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
String n = p.getName();
|
||||
String s = e.getMessage();
|
||||
if (p.hasPermission("sp.ignore.spam"))
|
||||
return;
|
||||
if (CommandWait(n, s)) {
|
||||
p.sendMessage(plugin.servername + plugin.pluginname + AntiMsg);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void put(Player p) {
|
||||
if (tc.containsKey(p.getName())) {
|
||||
int t = tc.get(p.getName());
|
||||
if (t > plugin.config.getLong("Spam.MuteCheck", 3)) {
|
||||
p.sendMessage(plugin.getfullmsg("Spam.MuteMsg"));
|
||||
cc.add(p.getName());
|
||||
} else
|
||||
tc.put(p.getName(), t + 1);
|
||||
} else
|
||||
tc.put(p.getName(), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
tc.clear();
|
||||
}
|
||||
|
||||
public void SaveMsg(String n, String s) {
|
||||
lC.put(n, s);
|
||||
lT.put(n, System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
public void setAdminchat(boolean adminchat) {
|
||||
this.adminchat = adminchat;
|
||||
}
|
||||
|
||||
}
|
||||
29
src/main/java/cn/citycraft/SimpleProtect/listen/Tip.java
Normal file
29
src/main/java/cn/citycraft/SimpleProtect/listen/Tip.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package cn.citycraft.SimpleProtect.listen;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class Tip implements Listener {
|
||||
SimpleProtect plugin;
|
||||
|
||||
public Tip(SimpleProtect instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(final PlayerJoinEvent e) {
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, () -> {
|
||||
Player p = e.getPlayer();
|
||||
String[] msg = plugin.config.getStringArray("Tip.Message");
|
||||
for (String s : msg) {
|
||||
s = s.replaceAll("&", "§");
|
||||
p.sendMessage(plugin.servername + plugin.pluginname + s);
|
||||
}
|
||||
} , 15);
|
||||
}
|
||||
|
||||
}
|
||||
74
src/main/resources/config.yml
Normal file
74
src/main/resources/config.yml
Normal file
@@ -0,0 +1,74 @@
|
||||
#本文件为保护插件的主配置文件
|
||||
version: 1.0
|
||||
#服务器名称
|
||||
servername: ''
|
||||
#插件名称
|
||||
pluginname: '&6[&b保护系统&6]&r'
|
||||
#登陆提示
|
||||
Tip:
|
||||
#是否开启
|
||||
Enable: false
|
||||
Message:
|
||||
- '&a服务器已开启保护功能!'
|
||||
- '&c将会实时监控您的操作!'
|
||||
- '&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为防止您卡在地狱门,现在将您传送回主城!'
|
||||
Set: '&a新的传送点已设置!'
|
||||
World: world
|
||||
X: 0
|
||||
Y: 70
|
||||
Z: 0
|
||||
|
||||
#刷屏保护
|
||||
Spam:
|
||||
#是否开启
|
||||
Enable: true
|
||||
ChatWait: 3
|
||||
SameChatWait: 8
|
||||
CommandWait: 2
|
||||
SameCommandWait: 3
|
||||
MuteCheck: 3
|
||||
MuteReset: 3
|
||||
TooMuchChat: '请不要短时间内发送大量消息'
|
||||
TooMuchSameChat: '请不要短时间内发送相同的信息'
|
||||
TooMuchCommand: '请不要短时间内发送大量命令'
|
||||
TooMuchSameCommand: '请不要短时间内发送相同的命令'
|
||||
MuteOn: '&a已允许玩家 %player% &a聊天!'
|
||||
MuteOff: '§c已禁止玩家 %player% §c聊天!'
|
||||
OffLine: '&c玩家不存在或不在线!'
|
||||
NotMute: '&c玩家未被禁言或不存在!'
|
||||
AdminChatOn: '&a服务器已开启管理员聊天!'
|
||||
AdminChatOff: '&c服务器已关闭管理员聊天!'
|
||||
AdminChat: '&c服务器已开启管理员聊天!'
|
||||
MuteMsg: '&c您由于多次刷屏已被禁言,请联系管理解禁!'
|
||||
39
src/main/resources/plugin.yml
Normal file
39
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
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:
|
||||
simpleprotect:
|
||||
description: 简单保护插件
|
||||
aliases: [sp,smp]
|
||||
usage: §b使用/sp help 查看帮助!
|
||||
permission: sp.*
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
permissions:
|
||||
sp.*:
|
||||
description: 插件所有权限!
|
||||
default: op
|
||||
children:
|
||||
sp.setspawn: true
|
||||
sp.ignore.*: true
|
||||
sp.setspawn:
|
||||
description: 允许配置插件出生点!
|
||||
default: op
|
||||
sp.ignore.*:
|
||||
description: 允许忽略插件的检测!
|
||||
default: op
|
||||
children:
|
||||
sp.ignore.highredstone: true
|
||||
sp.ignore.nightvision: true
|
||||
sp.ignore.spam: true
|
||||
sp.ignore.nightvision:
|
||||
description: 允许零亮度挖矿!
|
||||
default: op
|
||||
sp.ignore.highredstone:
|
||||
description: 允许忽略高频检测限制!
|
||||
default: op
|
||||
sp.ignore.spam:
|
||||
description: 允许忽略刷屏限制!
|
||||
default: op
|
||||
Reference in New Issue
Block a user