mirror of
https://e.coding.net/circlecloud/SimpleEssential.git
synced 2024-11-17 01:18:47 +00:00
add gc and world command...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
fa261fffcf
commit
ab8bff05c0
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>SimpleEssential</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2</version>
|
||||
<name>SimpleEssential</name>
|
||||
<description>轻量级基础插件</description>
|
||||
<build>
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import cn.citycraft.SimpleEssential.command.BaseCommand;
|
||||
import cn.citycraft.SimpleEssential.command.CommandBack;
|
||||
import cn.citycraft.SimpleEssential.command.CommandEnchantBench;
|
||||
import cn.citycraft.SimpleEssential.command.CommandGc;
|
||||
import cn.citycraft.SimpleEssential.command.CommandHat;
|
||||
import cn.citycraft.SimpleEssential.command.CommandHome;
|
||||
import cn.citycraft.SimpleEssential.command.CommandSetHome;
|
||||
@ -28,7 +29,8 @@ import cn.citycraft.SimpleEssential.command.CommandTpaccept;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTpdeny;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTphere;
|
||||
import cn.citycraft.SimpleEssential.command.CommandWorkBench;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.command.CommandWorld;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
import cn.citycraft.SimpleEssential.listen.PlayerLocationListen;
|
||||
import cn.citycraft.SimpleEssential.teleport.TeleportControl;
|
||||
import cn.citycraft.config.FileConfig;
|
||||
@ -50,22 +52,16 @@ public class SimpleEssential extends JavaPlugin {
|
||||
*/
|
||||
private List<BaseCommand> commandlist;
|
||||
|
||||
private void initTeleportControl() {
|
||||
int tpdelay = config.getInt("Teleport.delay", 3);
|
||||
String tpcontorlname = config.getMessage("Teleport.name");
|
||||
tpcontrol = new TeleportControl(this, tpcontorlname, tpdelay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (BaseCommand command : commandlist)
|
||||
if (command.isValidTrigger(label)) {
|
||||
if (!command.hasPermission(sender)) {
|
||||
sender.sendMessage(Language.getMessage("Base.no-permission"));
|
||||
sender.sendMessage(I18n.parse("Base.no-permission"));
|
||||
return true;
|
||||
}
|
||||
if (command.isOnlyPlayerExecutable() && !(sender instanceof Player)) {
|
||||
sender.sendMessage(Language.getMessage("Base.playercommand"));
|
||||
sender.sendMessage(I18n.parse("Base.playercommand"));
|
||||
return true;
|
||||
}
|
||||
if (args.length >= command.getMinimumArguments())
|
||||
@ -90,7 +86,7 @@ public class SimpleEssential extends JavaPlugin {
|
||||
@Override
|
||||
public void onLoad() {
|
||||
config = new FileConfig(this);
|
||||
Language.load(this);
|
||||
I18n.load(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,6 +118,8 @@ public class SimpleEssential extends JavaPlugin {
|
||||
registerCommand(new CommandWorkBench(this));
|
||||
registerCommand(new CommandSetSpawn(this));
|
||||
registerCommand(new CommandSpawn(this));
|
||||
registerCommand(new CommandGc(this));
|
||||
registerCommand(new CommandWorld(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,6 +132,12 @@ public class SimpleEssential extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
}
|
||||
|
||||
private void initTeleportControl() {
|
||||
int tpdelay = config.getInt("Teleport.delay", 3);
|
||||
String tpcontorlname = config.getMessage("Teleport.name");
|
||||
tpcontrol = new TeleportControl(this, tpcontorlname, tpdelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册事件
|
||||
*/
|
||||
|
@ -39,6 +39,13 @@ public abstract class BaseCommand {
|
||||
*/
|
||||
public abstract void execute(CommandSender sender, String label, String[] args) throws CommandException;
|
||||
|
||||
/**
|
||||
* 获得命令描述
|
||||
*
|
||||
* @return 命令描述
|
||||
*/
|
||||
public abstract String getDescription();
|
||||
|
||||
/**
|
||||
* 获得最小参数个数
|
||||
*
|
||||
@ -101,12 +108,10 @@ public abstract class BaseCommand {
|
||||
public final boolean isValidTrigger(String name) {
|
||||
if (this.name.equalsIgnoreCase(name))
|
||||
return true;
|
||||
if (aliases != null) {
|
||||
for (String alias : aliases) {
|
||||
if (aliases != null)
|
||||
for (String alias : aliases)
|
||||
if (alias.equalsIgnoreCase(name))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -24,13 +24,13 @@ public class CommandBack extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
plugin.tpcontrol.back((Player) sender);
|
||||
};
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
plugin.tpcontrol.back((Player) sender);
|
||||
public String getDescription() {
|
||||
return "回到上一个地点";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,4 +42,9 @@ public class CommandBack extends BaseCommand {
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,11 @@ public class CommandEnchantBench extends BaseCommand {
|
||||
p.openEnchanting(null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "打开随声附魔台";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
|
@ -0,0 +1,65 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
import cn.citycraft.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* 传送到顶部命令
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月12日下午2:04:05
|
||||
*
|
||||
*/
|
||||
public class CommandGc extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandGc(SimpleEssential main) {
|
||||
super("gc", "mem");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
if (label.equalsIgnoreCase("gc"))
|
||||
rt.gc();
|
||||
sender.sendMessage(I18n.parse("Gc.Processors", rt.availableProcessors()));
|
||||
sender.sendMessage(I18n.parse("Gc.maxMem", StringUtil.b2mb(rt.maxMemory())));
|
||||
sender.sendMessage(I18n.parse("Gc.totalMem", StringUtil.b2mb(rt.totalMemory())));
|
||||
sender.sendMessage(I18n.parse("Gc.freeMem", StringUtil.b2mb(rt.freeMemory())));
|
||||
for (World wd : Bukkit.getWorlds())
|
||||
sender.sendMessage(I18n.parse("World.info", wd.getName(), wd.getEnvironment().toString(), wd.getLoadedChunks().length, wd.getEntities().size(), wd.getPlayers().size()));
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "清理内存";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
|
||||
/**
|
||||
* @Author 代小呆 created in 2015年8月16日下午1:44:22
|
||||
@ -23,8 +23,26 @@ public class CommandHat extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
if (p.getItemInHand() == null) {
|
||||
sender.sendMessage(I18n.parse("Hat.empty"));
|
||||
return;
|
||||
} else {
|
||||
ItemStack hand = p.getItemInHand();
|
||||
p.setItemInHand(null);
|
||||
ItemStack helmet = p.getInventory().getHelmet();
|
||||
if (!(helmet == null))
|
||||
p.getInventory().addItem(helmet);
|
||||
p.getInventory().setHelmet(hand);
|
||||
sender.sendMessage(I18n.parse("Hat.enjoy"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "把手上的方块带在手上";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,22 +51,8 @@ public class CommandHat extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
if (p.getItemInHand() == null) {
|
||||
sender.sendMessage(Language.getMessage("Hat.empty"));
|
||||
return;
|
||||
} else {
|
||||
ItemStack hand = p.getItemInHand();
|
||||
p.setItemInHand(null);
|
||||
ItemStack helmet = p.getInventory().getHelmet();
|
||||
if (!(helmet == null)) {
|
||||
p.getInventory().addItem(helmet);
|
||||
}
|
||||
p.getInventory().setHelmet(hand);
|
||||
sender.sendMessage(Language.getMessage("Hat.enjoy"));
|
||||
}
|
||||
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
|
||||
/**
|
||||
* 传送回家的命令
|
||||
@ -27,20 +27,20 @@ public class CommandHome extends BaseCommand {
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
Location loc = p.getBedSpawnLocation();
|
||||
if (loc == null) {
|
||||
p.sendMessage(Language.getMessage("Teleport.homelose"));
|
||||
p.sendMessage(I18n.parse("Teleport.homelose"));
|
||||
return;
|
||||
}
|
||||
plugin.tpcontrol.magicTeleport(p, loc);
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "回到家";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,4 +52,9 @@ public class CommandHome extends BaseCommand {
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
|
||||
/**
|
||||
* 设置家的命令
|
||||
@ -25,21 +25,20 @@ public class CommandSetHome extends BaseCommand {
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
Block b = p.getLocation().getBlock();
|
||||
if (b.getType() == Material.BED_BLOCK) {
|
||||
p.setBedSpawnLocation(b.getLocation(), true);
|
||||
p.sendMessage(Language.getMessage("Teleport.sethomesuccess"));
|
||||
} else {
|
||||
p.sendMessage(Language.getMessage("Teleport.sethomeerror"));
|
||||
}
|
||||
p.sendMessage(I18n.parse("Teleport.sethomesuccess"));
|
||||
} else
|
||||
p.sendMessage(I18n.parse("Teleport.sethomeerror"));
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "设置家";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,4 +50,9 @@ public class CommandSetHome extends BaseCommand {
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||
@ -30,9 +30,14 @@ public class CommandSetSpawn extends BaseCommand {
|
||||
Player p = (Player) sender;
|
||||
Location loc = p.getLocation();
|
||||
p.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
p.sendMessage(Language.getMessage("Teleport.setspawn", p.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
p.sendMessage(I18n.parse("Teleport.setspawn", p.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "设置出生点";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
|
@ -29,6 +29,11 @@ public class CommandSpawn extends BaseCommand {
|
||||
plugin.tpcontrol.magicTeleport(p, p.getWorld().getSpawnLocation());
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "回到主城";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
import cn.citycraft.SimpleEssential.utils.EffectUtil;
|
||||
|
||||
/**
|
||||
@ -30,22 +30,12 @@ public class CommandSuicide extends BaseCommand {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
List<ItemStack> drops = Arrays.asList(p.getInventory().getContents());
|
||||
int deoppedexp = (int) Math.floor(p.getExp());
|
||||
String deathMessage = Language.getMessage("Suicide.msg");
|
||||
String deathMessage = I18n.parse("Suicide.msg");
|
||||
PlayerDeathEvent pd = new PlayerDeathEvent(p, drops, deoppedexp, deathMessage);
|
||||
plugin.getServer().getPluginManager().callEvent(pd);
|
||||
Bukkit.broadcastMessage(pd.getDeathMessage());
|
||||
@ -53,6 +43,21 @@ public class CommandSuicide extends BaseCommand {
|
||||
p.setHealth(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "自杀";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
|
||||
/**
|
||||
* 传送到顶部命令
|
||||
@ -30,13 +30,18 @@ public class CommandTop extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
Location loc = p.getLocation();
|
||||
int top = loc.getWorld().getHighestBlockYAt(loc);
|
||||
loc.setY(top);
|
||||
p.teleport(loc);
|
||||
p.sendMessage(I18n.parse("Teleport.top"));
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
public String getDescription() {
|
||||
return "传送到最高点";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,12 +50,12 @@ public class CommandTop extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
Location loc = p.getLocation();
|
||||
int top = loc.getWorld().getHighestBlockYAt(loc);
|
||||
loc.setY(top);
|
||||
p.teleport(loc);
|
||||
p.sendMessage(Language.getMessage("Teleport.top"));
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
||||
|
||||
/**
|
||||
@ -31,13 +31,22 @@ public class CommandTpa extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(I18n.parse("Base.offline", args[0]));
|
||||
return;
|
||||
}
|
||||
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPA);
|
||||
sender.sendMessage(I18n.parse("Teleport.tpsend"));
|
||||
target.sendMessage(new String[] { I18n.parse("Teleport.tpa", sender.getName()),
|
||||
I18n.parse("Teleport.tpaccept"),
|
||||
I18n.parse("Teleport.tpdeny") });
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "<目标玩家>";
|
||||
public String getDescription() {
|
||||
return "传送到玩家";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,18 +55,12 @@ public class CommandTpa extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(Language.getMessage("Base.offline", args[0]));
|
||||
return;
|
||||
public String getPossibleArguments() {
|
||||
return "<目标玩家>";
|
||||
}
|
||||
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPA);
|
||||
sender.sendMessage(Language.getMessage("Teleport.tpsend"));
|
||||
target.sendMessage(new String[] {
|
||||
Language.getMessage("Teleport.tpa", sender.getName()),
|
||||
Language.getMessage("Teleport.tpaccept"),
|
||||
Language.getMessage("Teleport.tpdeny")
|
||||
});
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -28,13 +28,13 @@ public class CommandTpaccept extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
plugin.tpcontrol.accept((Player) sender);
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
public String getDescription() {
|
||||
return "接受传送";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,7 +43,12 @@ public class CommandTpaccept extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
plugin.tpcontrol.accept((Player) sender);
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,14 @@ public class CommandTpdeny extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
plugin.tpcontrol.accept((Player) sender);
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
public String getDescription() {
|
||||
return "拒绝传送";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -40,8 +41,12 @@ public class CommandTpdeny extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
plugin.tpcontrol.accept((Player) sender);
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
||||
|
||||
/**
|
||||
@ -29,21 +29,19 @@ public class CommandTphere extends BaseCommand {
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(Language.getMessage("Base.offline", args[0]));
|
||||
sender.sendMessage(I18n.parse("Base.offline", args[0]));
|
||||
return;
|
||||
}
|
||||
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPH);
|
||||
sender.sendMessage(Language.getMessage("Teleport.tpsend"));
|
||||
target.sendMessage(new String[] {
|
||||
Language.getMessage("Teleport.tphere", sender.getName()),
|
||||
Language.getMessage("Teleport.tpaccept"),
|
||||
Language.getMessage("Teleport.tpdeny")
|
||||
});
|
||||
sender.sendMessage(I18n.parse("Teleport.tpsend"));
|
||||
target.sendMessage(new String[] { I18n.parse("Teleport.tphere", sender.getName()),
|
||||
I18n.parse("Teleport.tpaccept"),
|
||||
I18n.parse("Teleport.tpdeny") });
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
public String getDescription() {
|
||||
return "邀请玩家";
|
||||
};
|
||||
|
||||
@Override
|
||||
@ -55,4 +53,9 @@ public class CommandTphere extends BaseCommand {
|
||||
public String getPossibleArguments() {
|
||||
return "<目标玩家>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ public class CommandWorkBench extends BaseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Bukkit.getPlayer(sender.getName()).openWorkbench(null, true);
|
||||
};
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Bukkit.getPlayer(sender.getName()).openWorkbench(null, true);
|
||||
public String getDescription() {
|
||||
return "随身工作台";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,4 +42,9 @@ public class CommandWorkBench extends BaseCommand {
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||
*/
|
||||
public class CommandWorld extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandWorld(SimpleEssential main) {
|
||||
super("world", "seworld");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
p.sendMessage(I18n.parse("World.title"));
|
||||
for (World wd : Bukkit.getWorlds())
|
||||
p.sendMessage(I18n.parse("World.info", wd.getName(), wd.getEnvironment().toString(), wd.getLoadedChunks().length, wd.getEntities().size(), wd.getPlayers().size()));
|
||||
case 1:
|
||||
World wd = Bukkit.getWorld(args[1]);
|
||||
if (wd != null)
|
||||
p.teleport(wd.getSpawnLocation());
|
||||
else
|
||||
p.sendMessage(I18n.parse("World.unknow", args[1]));
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "[世界名称|世界序号]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -4,16 +4,16 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cn.citycraft.config.FileConfig;
|
||||
|
||||
public class Language {
|
||||
public class I18n {
|
||||
private static String CONFIG_NAME = "language.yml";
|
||||
private static FileConfig config;
|
||||
|
||||
public static String getMessage(String path) {
|
||||
public static String parse(String path) {
|
||||
return config.getMessage(path);
|
||||
}
|
||||
|
||||
public static String getMessage(String path, Object... args) {
|
||||
return String.format(getMessage(path), args);
|
||||
public static String parse(String path, Object... args) {
|
||||
return String.format(parse(path), args);
|
||||
}
|
||||
|
||||
public static void load(Plugin p) {
|
@ -14,7 +14,7 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.config.I18n;
|
||||
import cn.citycraft.SimpleEssential.utils.EffectUtil;
|
||||
|
||||
/**
|
||||
@ -46,7 +46,7 @@ public class TeleportControl {
|
||||
Player target = ti.getTarget();
|
||||
Location loc = null;
|
||||
if (!target.isOnline()) {
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.offline"));
|
||||
player.sendMessage(TpControlName + I18n.parse("Teleport.offline"));
|
||||
return;
|
||||
}
|
||||
if (ti.getTptype() == TeleportType.TPA) {
|
||||
@ -56,12 +56,12 @@ public class TeleportControl {
|
||||
target = player;
|
||||
loc = ti.getTarget().getLocation();
|
||||
}
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.accept", target.getDisplayName()));
|
||||
target.sendMessage(TpControlName + Language.getMessage("Teleport.acceptfrom", player.getDisplayName()));
|
||||
player.sendMessage(TpControlName + I18n.parse("Teleport.accept", target.getDisplayName()));
|
||||
target.sendMessage(TpControlName + I18n.parse("Teleport.acceptfrom", player.getDisplayName()));
|
||||
magicTeleport(target, loc, TpDelay);
|
||||
return;
|
||||
}
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.none"));
|
||||
player.sendMessage(TpControlName + I18n.parse("Teleport.none"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,7 +89,7 @@ public class TeleportControl {
|
||||
if (loc != null) {
|
||||
magicTeleport(player, loc, 3);
|
||||
} else {
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.nobackloc"));
|
||||
player.sendMessage(TpControlName + I18n.parse("Teleport.nobackloc"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,12 +104,12 @@ public class TeleportControl {
|
||||
if (ti != null) {
|
||||
Player target = ti.getTarget();
|
||||
if (target.isOnline()) {
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.deny", target.getDisplayName()));
|
||||
target.sendMessage(TpControlName + Language.getMessage("Teleport.denyfrom", player.getDisplayName()));
|
||||
player.sendMessage(TpControlName + I18n.parse("Teleport.deny", target.getDisplayName()));
|
||||
target.sendMessage(TpControlName + I18n.parse("Teleport.denyfrom", player.getDisplayName()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.none"));
|
||||
player.sendMessage(TpControlName + I18n.parse("Teleport.none"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -137,7 +137,7 @@ public class TeleportControl {
|
||||
public void magicTeleport(final Player player, final Location loc, final int delay) {
|
||||
int petime = delay * 20 + 10;
|
||||
setLastloc(player, player.getLocation());
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.tp", delay, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ()));
|
||||
player.sendMessage(TpControlName + I18n.parse("Teleport.tp", delay, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ()));
|
||||
List<PotionEffect> pe = new ArrayList<PotionEffect>();
|
||||
pe.add(new PotionEffect(PotionEffectType.SLOW, petime, 255));
|
||||
pe.add(new PotionEffect(PotionEffectType.CONFUSION, petime, 255));
|
||||
|
@ -32,3 +32,12 @@ Suicide:
|
||||
Hat:
|
||||
empty: '§c看上去你手上什么都没有啊!'
|
||||
enjoy: '§2享受你的新帽子吧!'
|
||||
Gc:
|
||||
Processors: '§6使用核心: §a%s'
|
||||
maxMem: '§6最大内存: §a%s'
|
||||
totalMem: '§6已用内存: §a%s'
|
||||
freeMem: '§6空闲内存: §a%s'
|
||||
World:
|
||||
title: '§6当前服务器的启用的世界如下'
|
||||
info: '§6名称: §a%s §b- §6类型: §a%s §6区块: §a%s §6实体数: §a%s §6玩家数: §a%s'
|
||||
unknow: '§c未知的世界 §a%s'
|
@ -95,6 +95,18 @@ commands:
|
||||
usage: §6使用 §a/spawn §6返回世界出生点!
|
||||
permission: se.spawn
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
gc:
|
||||
description: 清理内存
|
||||
aliases: [mem,semem,segc]
|
||||
usage: §6使用 §a/gc §6清理内存!
|
||||
permission: se.gc
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
world:
|
||||
description: 清理内存
|
||||
aliases: [seworld]
|
||||
usage: §6使用 §a/world [世界名称|世界序号] §6进行传送!
|
||||
permission: se.world
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
|
||||
permissions:
|
||||
se.*:
|
||||
|
Loading…
Reference in New Issue
Block a user