68 lines
2.0 KiB
Java
68 lines
2.0 KiB
Java
/**
|
|
*
|
|
*/
|
|
package cn.citycraft.SimpleEssential.command;
|
|
|
|
import java.util.logging.Level;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.Chunk;
|
|
import org.bukkit.World;
|
|
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.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(final SimpleEssential main) {
|
|
super("world", "seworld");
|
|
this.plugin = main;
|
|
setPossibleArguments("[世界名称|世界序号]");
|
|
}
|
|
|
|
@Override
|
|
public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
|
|
switch (args.length) {
|
|
case 0:
|
|
sender.sendMessage(I18n.p("World.title"));
|
|
for (final World wd : Bukkit.getWorlds()) {
|
|
int tileEntities = 0;
|
|
try {
|
|
for (final Chunk chunk : wd.getLoadedChunks()) {
|
|
tileEntities += chunk.getTileEntities().length;
|
|
}
|
|
} catch (final ClassCastException ex) {
|
|
org.bukkit.Bukkit.getLogger().log(Level.SEVERE, "无法读取区块信息 错误世界: " + wd, ex);
|
|
}
|
|
sender.sendMessage(I18n.p("World.info", wd.getName(), wd.getEnvironment().toString(), wd.getLoadedChunks().length, wd.getEntities().size(), tileEntities, wd.getPlayers().size()));
|
|
}
|
|
break;
|
|
case 1:
|
|
final World wd = Bukkit.getWorld(args[0]);
|
|
if (wd != null) {
|
|
if (sender instanceof Player) {
|
|
((Player) sender).teleport(wd.getSpawnLocation());
|
|
} else {
|
|
sender.sendMessage(ChatColor.RED + I18n.p("Base.playercommand"));
|
|
}
|
|
} else {
|
|
sender.sendMessage(I18n.p("World.unknow", args[1]));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|