mirror of
https://e.coding.net/circlecloud/SimpleProtect.git
synced 2024-11-22 01:49:03 +00:00
opt plugin and update to 1.3 Release Version...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
36b66a1793
commit
ae86523045
19
pom.xml
19
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>SimpleProtect</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
<name>SimpleProtect</name>
|
||||
<description>Minecraft 服务器保护插件</description>
|
||||
<build>
|
||||
@ -33,14 +33,9 @@
|
||||
<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>
|
||||
@ -67,17 +62,13 @@
|
||||
<id>citycraft-repo</id>
|
||||
<url>${jenkins.url}/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Plugin Metrics</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
@ -85,12 +76,6 @@
|
||||
<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>
|
||||
|
@ -1,11 +1,8 @@
|
||||
package cn.citycraft.SimpleProtect;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.mcstats.Metrics;
|
||||
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
import cn.citycraft.PluginHelper.utils.VersionChecker;
|
||||
@ -20,23 +17,23 @@ 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 pluginname;
|
||||
public String servername;
|
||||
public Spam spam = new Spam(this);
|
||||
|
||||
public String getfullmsg(String path) {
|
||||
public String getfullmsg(final String path) {
|
||||
return servername + pluginname + " " + getmessage(path);
|
||||
}
|
||||
|
||||
public String getmessage(String path) {
|
||||
public String getmessage(final String path) {
|
||||
return config.getMessage(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getServer().getConsoleSender().sendMessage("==========" + servername + pluginname + "==========");
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
final PluginManager pm = Bukkit.getPluginManager();
|
||||
|
||||
if (config.getBoolean("Tip.Enable", true)) {
|
||||
pm.registerEvents(new Tip(this), this);
|
||||
@ -59,26 +56,20 @@ public class SimpleProtect extends JavaPlugin {
|
||||
getLogger().info("防止无限夜视作弊已加载!");
|
||||
}
|
||||
if (config.getBoolean("HighRedstone.Enable", true)) {
|
||||
HighRedstone redstone = new HighRedstone(this);
|
||||
final 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;
|
||||
final 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);
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,35 @@
|
||||
package cn.citycraft.SimpleProtect.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class CommandAdd extends BaseCommand {
|
||||
SimpleProtect plugin;
|
||||
|
||||
public CommandAdd(final SimpleProtect main) {
|
||||
super("add");
|
||||
this.plugin = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("禁言某个玩家");
|
||||
setPossibleArguments("<玩家名称>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final String pname = args[0];
|
||||
final Player p = Bukkit.getPlayer(pname);
|
||||
if (p != null) {
|
||||
plugin.spam.getCc().add(pname);
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.MuteOn").replace("%player%", p.getDisplayName()));
|
||||
} else {
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.OffLine"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.citycraft.SimpleProtect.command;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class CommandAdmin extends BaseCommand {
|
||||
SimpleProtect plugin;
|
||||
|
||||
public CommandAdmin(final SimpleProtect main) {
|
||||
super("admin");
|
||||
this.plugin = main;
|
||||
setMinimumArguments(1);
|
||||
setPossibleArguments("[on|off]");
|
||||
setDescription("开启管理员聊天模式");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final String toggle = args[0].toLowerCase();
|
||||
switch (toggle) {
|
||||
case "on":
|
||||
plugin.spam.setAdminchat(true);
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.AdminChatOn"));
|
||||
return;
|
||||
case "off":
|
||||
plugin.spam.setAdminchat(false);
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.AdminChatOff"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package cn.citycraft.SimpleProtect.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class CommandDel extends BaseCommand {
|
||||
SimpleProtect plugin;
|
||||
|
||||
public CommandDel(final SimpleProtect main) {
|
||||
super("delete", "del");
|
||||
this.plugin = main;
|
||||
setMinimumArguments(1);
|
||||
setDescription("解禁某个玩家");
|
||||
setPossibleArguments("<玩家名称>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final String pname = args[0];
|
||||
final Player p = Bukkit.getPlayer(pname);
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.citycraft.SimpleProtect.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.PluginHelper.utils.StringUtil;
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class CommandList extends BaseCommand {
|
||||
SimpleProtect plugin;
|
||||
|
||||
public CommandList(final SimpleProtect main) {
|
||||
super("list");
|
||||
this.plugin = main;
|
||||
setDescription("查看被禁言的玩家");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
sender.sendMessage(plugin.getfullmsg("Spam.MutePlayer"));
|
||||
StringUtil.sendStringArray(sender, plugin.spam.getCc(), "§6 - ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
if (args.length < 1) {
|
||||
return null;
|
||||
}
|
||||
final String subcmd = args[0].toLowerCase();
|
||||
switch (subcmd) {
|
||||
case "add":
|
||||
case "del":
|
||||
return plugin.spam.getCc();
|
||||
case "admin":
|
||||
final List<String> tg = new ArrayList<String>();
|
||||
tg.add("on");
|
||||
tg.add("off");
|
||||
return tg;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cn.citycraft.SimpleProtect.command;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class CommandReload extends BaseCommand {
|
||||
SimpleProtect plugin;
|
||||
|
||||
public CommandReload(final SimpleProtect main) {
|
||||
super("reload");
|
||||
this.plugin = main;
|
||||
setDescription("重载配置文件");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
plugin.onLoad();
|
||||
sender.sendMessage(plugin.pluginname + "§a配置文件已重载!");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.citycraft.SimpleProtect.command;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
public class CommandSetSpawn extends BaseCommand {
|
||||
SimpleProtect plugin;
|
||||
|
||||
public CommandSetSpawn(final SimpleProtect main) {
|
||||
super("setspawn");
|
||||
this.plugin = main;
|
||||
setOnlyPlayerExecutable();
|
||||
setDescription("配置保护插件出生点");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
||||
final 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"));
|
||||
}
|
||||
|
||||
}
|
@ -3,92 +3,45 @@
|
||||
*/
|
||||
package cn.citycraft.SimpleProtect.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.DefaultCommand;
|
||||
import cn.citycraft.PluginHelper.commands.HandlerSubCommand;
|
||||
import cn.citycraft.SimpleProtect.SimpleProtect;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
public class SimpleProtectCommand implements CommandExecutor {
|
||||
public class SimpleProtectCommand implements CommandExecutor, DefaultCommand {
|
||||
|
||||
HandlerSubCommand hsc;
|
||||
|
||||
SimpleProtect plugin;
|
||||
|
||||
/**
|
||||
* @param simpleProtect
|
||||
*/
|
||||
public SimpleProtectCommand(final SimpleProtect simpleProtect) {
|
||||
plugin = simpleProtect;
|
||||
hsc = new HandlerSubCommand(plugin);
|
||||
hsc.setDefaultCommand(this);
|
||||
hsc.registerCommand(new CommandAdd(plugin));
|
||||
hsc.registerCommand(new CommandAdmin(plugin));
|
||||
hsc.registerCommand(new CommandDel(plugin));
|
||||
hsc.registerCommand(new CommandList(plugin));
|
||||
hsc.registerCommand(new CommandReload(plugin));
|
||||
hsc.registerCommand(new CommandSetSpawn(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defaultExecute(final CommandSender sender, final Command command, final String label) throws CommandException {
|
||||
hsc.sendHelp(sender, label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
switch (args[0]) {
|
||||
case "setspawn":
|
||||
if (sender instanceof Player) {
|
||||
final 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(plugin.getfullmsg("Spam.MutePlayer"));
|
||||
for (final String player : plugin.spam.getCc()) {
|
||||
sender.sendMessage("§6 - " + player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
final 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;
|
||||
return hsc.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user