mirror of
https://e.coding.net/circlecloud/SimpleProtect.git
synced 2024-11-22 01:49:03 +00:00
fix spam config error...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
1661e5cf99
commit
ef43de56e8
@ -1,13 +1,10 @@
|
|||||||
package cn.citycraft.SimpleProtect;
|
package cn.citycraft.SimpleProtect;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
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.SimpleProtect.command.SimpleProtectCommand;
|
||||||
import cn.citycraft.SimpleProtect.config.Config;
|
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;
|
||||||
@ -22,6 +19,7 @@ public class SimpleProtect extends JavaPlugin {
|
|||||||
|
|
||||||
public String servername;
|
public String servername;
|
||||||
public String pluginname;
|
public String pluginname;
|
||||||
|
public Spam spam = new Spam(this);
|
||||||
|
|
||||||
public String getfullmsg(String path) {
|
public String getfullmsg(String path) {
|
||||||
return servername + pluginname + " " + getmessage(path);
|
return servername + pluginname + " " + getmessage(path);
|
||||||
@ -31,35 +29,10 @@ public class SimpleProtect extends JavaPlugin {
|
|||||||
return Config.getMessage(path);
|
return Config.getMessage(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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();
|
|
||||||
Config.getInstance().set("SafeNetherDoor.World", l.getWorld().getName());
|
|
||||||
Config.getInstance().set("SafeNetherDoor.X", l.getBlockX());
|
|
||||||
Config.getInstance().set("SafeNetherDoor.Y", l.getBlockY());
|
|
||||||
Config.getInstance().set("SafeNetherDoor.Z", l.getBlockZ());
|
|
||||||
sender.sendMessage(pluginname + Config.getMessage("SafeNetherDoor.Set"));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case "reload":
|
|
||||||
onLoad();
|
|
||||||
sender.sendMessage(pluginname + "§a配置文件已重载!");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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.getInstance().getBoolean("Tip.Enable", true)) {
|
||||||
@ -90,14 +63,12 @@ public class SimpleProtect extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getBoolean("Spam.Enable", true)) {
|
if (Config.getInstance().getBoolean("Spam.Enable", true)) {
|
||||||
Spam spam = new Spam(this);
|
|
||||||
Bukkit.getPluginManager().registerEvents(spam, this);
|
Bukkit.getPluginManager().registerEvents(spam, this);
|
||||||
int resettime = Config.getInstance().getInt("Spam.MuteReset") * 20;
|
int resettime = Config.getInstance().getInt("Spam.MuteReset") * 20;
|
||||||
Bukkit.getScheduler().runTaskTimer(this, spam, resettime, resettime);
|
Bukkit.getScheduler().runTaskTimer(this, spam, resettime, resettime);
|
||||||
getCommand("spam").setExecutor(spam);
|
|
||||||
getLogger().info("防止玩家聊天刷屏已加载!");
|
getLogger().info("防止玩家聊天刷屏已加载!");
|
||||||
}
|
}
|
||||||
|
getCommand("simpleprotect").setExecutor(new SimpleProtectCommand(this));
|
||||||
getServer().getConsoleSender().sendMessage(
|
getServer().getConsoleSender().sendMessage(
|
||||||
"==========" + servername + pluginname + "==========");
|
"==========" + servername + pluginname + "==========");
|
||||||
new VersionChecker(this);
|
new VersionChecker(this);
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
import cn.citycraft.SimpleProtect.config.Config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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();
|
||||||
|
Config.getInstance().set("SafeNetherDoor.World", l.getWorld().getName());
|
||||||
|
Config.getInstance().set("SafeNetherDoor.X", l.getBlockX());
|
||||||
|
Config.getInstance().set("SafeNetherDoor.Y", l.getBlockY());
|
||||||
|
Config.getInstance().set("SafeNetherDoor.Z", l.getBlockZ());
|
||||||
|
sender.sendMessage(plugin.pluginname + Config.getMessage("SafeNetherDoor.Set"));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case "reload":
|
||||||
|
plugin.onLoad();
|
||||||
|
sender.sendMessage(plugin.pluginname + "§a配置文件已重载!");
|
||||||
|
return true;
|
||||||
|
case "list":
|
||||||
|
|
||||||
|
break;
|
||||||
|
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;
|
||||||
|
|
||||||
|
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"));
|
||||||
|
}
|
||||||
|
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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,12 +3,10 @@
|
|||||||
*/
|
*/
|
||||||
package cn.citycraft.SimpleProtect.listen;
|
package cn.citycraft.SimpleProtect.listen;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -16,19 +14,22 @@ 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author 蒋天蓓
|
* @author 蒋天蓓
|
||||||
*/
|
*/
|
||||||
public class Spam implements Runnable, Listener, CommandExecutor {
|
public class Spam implements Runnable, Listener {
|
||||||
|
|
||||||
private final HashMap<String, Long> lT;
|
private final HashMap<String, Long> lT;
|
||||||
private final HashMap<String, String> lC;
|
private final HashMap<String, String> lC;
|
||||||
HashMap<Player, Integer> tc = new HashMap<Player, Integer>();
|
HashMap<String, Integer> tc = new HashMap<String, Integer>();
|
||||||
HashMap<Player, Player> cc = new HashMap<Player, Player>();
|
List<String> cc = new ArrayList<String>();
|
||||||
String AntiMsg;
|
String AntiMsg;
|
||||||
|
|
||||||
boolean adminchat;
|
boolean adminchat;
|
||||||
|
|
||||||
SimpleProtect plugin;
|
SimpleProtect plugin;
|
||||||
|
|
||||||
public Spam(SimpleProtect main) {
|
public Spam(SimpleProtect main) {
|
||||||
@ -46,12 +47,12 @@ public class Spam implements Runnable, Listener, CommandExecutor {
|
|||||||
SaveMsg(n, s);
|
SaveMsg(n, s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (lt + plugin.getConfig().getLong("Spam.ChatWait", 1) > nt) {
|
if (lt + Config.getInstance().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 + plugin.getConfig().getLong("Spam.SameChatWait", 5) > nt) {
|
if (lt + Config.getInstance().getLong("Spam.SameChatWait", 5) > nt) {
|
||||||
AntiMsg = plugin.getmessage("Spam.TooMuchSameChat");
|
AntiMsg = plugin.getmessage("Spam.TooMuchSameChat");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -70,12 +71,12 @@ public class Spam implements Runnable, Listener, CommandExecutor {
|
|||||||
SaveMsg(n, s);
|
SaveMsg(n, s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (lt + plugin.getConfig().getLong("Spam.CommandWait", 1) > nt) {
|
if (lt + Config.getInstance().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 + plugin.getConfig().getLong("Spam.SameCommandWait", 3) > nt) {
|
if (lt + Config.getInstance().getLong("Spam.SameCommandWait", 3) > nt) {
|
||||||
AntiMsg = plugin.getmessage("Spam.TooMuchSameCommand");
|
AntiMsg = plugin.getmessage("Spam.TooMuchSameCommand");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -84,46 +85,8 @@ public class Spam implements Runnable, Listener, CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public List<String> getCc() {
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
return cc;
|
||||||
if (command.getName().equalsIgnoreCase("sp")) {
|
|
||||||
if (args.length == 2) {
|
|
||||||
Player p = Bukkit.getPlayer(args[1]);
|
|
||||||
if (args[0].equalsIgnoreCase("add")) {
|
|
||||||
if (p != null) {
|
|
||||||
cc.put(p, p);
|
|
||||||
sender.sendMessage(plugin.getfullmsg("Spam.MuteOn").replace("%player%",
|
|
||||||
p.getDisplayName()));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(plugin.getfullmsg("Spam.OffLine"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("del")) {
|
|
||||||
if (p != null && cc.containsKey(p)) {
|
|
||||||
cc.remove(p);
|
|
||||||
sender.sendMessage(plugin.getfullmsg("Spam.MuteOff").replace("%player%",
|
|
||||||
p.getDisplayName()));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(plugin.getfullmsg("Spam.NotMute"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args[0].equalsIgnoreCase("admin")) {
|
|
||||||
if (args[1].equalsIgnoreCase("on")) {
|
|
||||||
adminchat = true;
|
|
||||||
sender.sendMessage(plugin.getfullmsg("Spam.AdminChatOn"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args[1].equalsIgnoreCase("off")) {
|
|
||||||
adminchat = false;
|
|
||||||
sender.sendMessage(plugin.getfullmsg("Spam.AdminChatOff"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
@ -138,7 +101,7 @@ public class Spam implements Runnable, Listener, CommandExecutor {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cc.containsKey(p)) {
|
if (cc.contains(p)) {
|
||||||
p.sendMessage(plugin.getfullmsg("Spam.MuteMsg"));
|
p.sendMessage(plugin.getfullmsg("Spam.MuteMsg"));
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -164,16 +127,16 @@ public class Spam implements Runnable, Listener, CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void put(Player p) {
|
public void put(Player p) {
|
||||||
if (tc.containsKey(p)) {
|
if (tc.containsKey(p.getName())) {
|
||||||
int t = tc.get(p);
|
int t = tc.get(p.getName());
|
||||||
if (t > plugin.getConfig().getLong("Spam.MuteCheck", 3)) {
|
if (t > Config.getInstance().getLong("Spam.MuteCheck", 3)) {
|
||||||
p.sendMessage(plugin.getfullmsg("Spam.MuteMsg"));
|
p.sendMessage(plugin.getfullmsg("Spam.MuteMsg"));
|
||||||
cc.put(p, p);
|
cc.add(p.getName());
|
||||||
} else {
|
} else {
|
||||||
tc.put(p, t + 1);
|
tc.put(p.getName(), t + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tc.put(p, 1);
|
tc.put(p.getName(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,4 +150,8 @@ public class Spam implements Runnable, Listener, CommandExecutor {
|
|||||||
lT.put(n, System.currentTimeMillis() / 1000);
|
lT.put(n, System.currentTimeMillis() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAdminchat(boolean adminchat) {
|
||||||
|
this.adminchat = adminchat;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ pluginname: '&6[&b保护系统&6]&r'
|
|||||||
#登陆提示
|
#登陆提示
|
||||||
Tip:
|
Tip:
|
||||||
#是否开启
|
#是否开启
|
||||||
Enable: true
|
Enable: false
|
||||||
Message:
|
Message:
|
||||||
- '&a服务器已开启保护功能!'
|
- '&a服务器已开启保护功能!'
|
||||||
- '&c将会实时监控您的操作!'
|
- '&c将会实时监控您的操作!'
|
||||||
@ -72,4 +72,3 @@ Spam:
|
|||||||
AdminChatOff: '&c服务器已关闭管理员聊天!'
|
AdminChatOff: '&c服务器已关闭管理员聊天!'
|
||||||
AdminChat: '&c服务器已开启管理员聊天!'
|
AdminChat: '&c服务器已开启管理员聊天!'
|
||||||
MuteMsg: '&c您由于多次刷屏已被禁言,请联系管理解禁!'
|
MuteMsg: '&c您由于多次刷屏已被禁言,请联系管理解禁!'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user