1
0
mirror of https://e.coding.net/circlecloud/SimpleEssential.git synced 2024-11-17 01:18:47 +00:00

add new Command Sudo and update...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-09-29 20:48:52 +08:00
parent df46033903
commit b6b66ff3fb
4 changed files with 54 additions and 4 deletions

View File

@ -32,7 +32,7 @@ public class CommandGc extends BaseCommand {
* @param name
*/
public CommandGc(final SimpleEssential main) {
super("gc", "mem");
super("gc", "mem", "segc", "semem");
this.plugin = main;
setDescription("清理内存");
}
@ -40,7 +40,7 @@ public class CommandGc extends BaseCommand {
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final Runtime rt = Runtime.getRuntime();
if (label.equalsIgnoreCase("gc")) {
if (label.equalsIgnoreCase("gc") || label.equalsIgnoreCase("segc")) {
rt.gc();
}
sender.sendMessage(I18n.p("Gc.runTime", StringUtil.formatDate(SystemUtil.getRunTime())));

View File

@ -0,0 +1,49 @@
/**
*
*/
package cn.citycraft.SimpleEssential.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.PluginHelper.utils.StringUtil;
import cn.citycraft.SimpleEssential.SimpleEssential;
import cn.citycraft.SimpleEssential.config.I18n;
/**
* 传送到顶部命令
*
* @author 蒋天蓓
* 2015年8月12日下午2:04:05
*
*/
public class CommandSudo extends BaseCommand {
SimpleEssential plugin;
/**
* @param name
*/
public CommandSudo(final SimpleEssential main) {
super("sudo", "sesudo");
this.plugin = main;
setMinimumArguments(2);
setPossibleArguments("<玩家> <命令>");
setDescription("强制玩家执行命令");
}
@Override
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
final Player p = Bukkit.getPlayer(args[0]);
if (p == null) {
sender.sendMessage(I18n.p("Base.offline", args[0]));
return;
}
final String cmd = StringUtil.consolidateStrings(args, 1);
p.performCommand(cmd);
sender.sendMessage(I18n.p("Sudo", args[0], cmd));
}
}

View File

@ -1,5 +1,5 @@
#本文件为保护插件的主配置文件
version: 1.0
Version: 1.0
#服务器名称
servername: ''
#插件名称

View File

@ -41,4 +41,5 @@ Gc:
World:
title: '§6当前服务器的启用的世界如下'
info: '§a%s §3- §a%s §6区块: §a%s §6实体: §a%s §6tiles: §a%s §6玩家: §a%s'
unknow: '§c未知的世界 §a%s'
unknow: '§c未知的世界 §a%s'
Sudo: '§6玩家: §a%s §6已执行命令 §b%s'