mirror of
https://e.coding.net/circlecloud/SimpleEssential.git
synced 2024-11-17 01:18:47 +00:00
update I18n.p and gc add runtime...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
f9e2ee8e3e
commit
48654099f1
@ -57,11 +57,11 @@ public class SimpleEssential extends JavaPlugin {
|
|||||||
for (BaseCommand command : commandlist)
|
for (BaseCommand command : commandlist)
|
||||||
if (command.isValidTrigger(label)) {
|
if (command.isValidTrigger(label)) {
|
||||||
if (!command.hasPermission(sender)) {
|
if (!command.hasPermission(sender)) {
|
||||||
sender.sendMessage(I18n.parse("Base.no-permission"));
|
sender.sendMessage(I18n.p("Base.no-permission"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (command.isOnlyPlayerExecutable() && !(sender instanceof Player)) {
|
if (command.isOnlyPlayerExecutable() && !(sender instanceof Player)) {
|
||||||
sender.sendMessage(I18n.parse("Base.playercommand"));
|
sender.sendMessage(I18n.p("Base.playercommand"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length >= command.getMinimumArguments())
|
if (args.length >= command.getMinimumArguments())
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||||
import cn.citycraft.SimpleEssential.config.I18n;
|
import cn.citycraft.SimpleEssential.config.I18n;
|
||||||
import cn.citycraft.utils.StringUtil;
|
import cn.citycraft.utils.StringUtil;
|
||||||
|
import cn.citycraft.utils.SystemUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 传送到顶部命令
|
* 传送到顶部命令
|
||||||
@ -35,12 +36,13 @@ public class CommandGc extends BaseCommand {
|
|||||||
Runtime rt = Runtime.getRuntime();
|
Runtime rt = Runtime.getRuntime();
|
||||||
if (label.equalsIgnoreCase("gc"))
|
if (label.equalsIgnoreCase("gc"))
|
||||||
rt.gc();
|
rt.gc();
|
||||||
sender.sendMessage(I18n.parse("Gc.Processors", rt.availableProcessors()));
|
sender.sendMessage(I18n.p("Gc.runTime", StringUtil.formatDate(SystemUtil.getRunTime())));
|
||||||
sender.sendMessage(I18n.parse("Gc.maxMem", StringUtil.b2mb(rt.maxMemory())));
|
sender.sendMessage(I18n.p("Gc.Processors", rt.availableProcessors()));
|
||||||
sender.sendMessage(I18n.parse("Gc.totalMem", StringUtil.b2mb(rt.totalMemory())));
|
sender.sendMessage(I18n.p("Gc.maxMem", StringUtil.b2mb(rt.maxMemory())));
|
||||||
sender.sendMessage(I18n.parse("Gc.freeMem", StringUtil.b2mb(rt.freeMemory())));
|
sender.sendMessage(I18n.p("Gc.totalMem", StringUtil.b2mb(rt.totalMemory())));
|
||||||
|
sender.sendMessage(I18n.p("Gc.freeMem", StringUtil.b2mb(rt.freeMemory())));
|
||||||
for (World wd : Bukkit.getWorlds())
|
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()));
|
sender.sendMessage(I18n.p("World.info", wd.getName(), wd.getEnvironment().toString(), wd.getLoadedChunks().length, wd.getEntities().size(), wd.getPlayers().size()));
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,7 @@ public class CommandHat extends BaseCommand {
|
|||||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (p.getItemInHand() == null) {
|
if (p.getItemInHand() == null) {
|
||||||
sender.sendMessage(I18n.parse("Hat.empty"));
|
sender.sendMessage(I18n.p("Hat.empty"));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
ItemStack hand = p.getItemInHand();
|
ItemStack hand = p.getItemInHand();
|
||||||
@ -35,7 +35,7 @@ public class CommandHat extends BaseCommand {
|
|||||||
if (!(helmet == null))
|
if (!(helmet == null))
|
||||||
p.getInventory().addItem(helmet);
|
p.getInventory().addItem(helmet);
|
||||||
p.getInventory().setHelmet(hand);
|
p.getInventory().setHelmet(hand);
|
||||||
sender.sendMessage(I18n.parse("Hat.enjoy"));
|
sender.sendMessage(I18n.p("Hat.enjoy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class CommandHome extends BaseCommand {
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
Location loc = p.getBedSpawnLocation();
|
Location loc = p.getBedSpawnLocation();
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
p.sendMessage(I18n.parse("Teleport.homelose"));
|
p.sendMessage(I18n.p("Teleport.homelose"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.tpcontrol.magicTeleport(p, loc);
|
plugin.tpcontrol.magicTeleport(p, loc);
|
||||||
|
@ -31,9 +31,9 @@ public class CommandSetHome extends BaseCommand {
|
|||||||
Block b = p.getLocation().getBlock();
|
Block b = p.getLocation().getBlock();
|
||||||
if (b.getType() == Material.BED_BLOCK) {
|
if (b.getType() == Material.BED_BLOCK) {
|
||||||
p.setBedSpawnLocation(b.getLocation(), true);
|
p.setBedSpawnLocation(b.getLocation(), true);
|
||||||
p.sendMessage(I18n.parse("Teleport.sethomesuccess"));
|
p.sendMessage(I18n.p("Teleport.sethomesuccess"));
|
||||||
} else
|
} else
|
||||||
p.sendMessage(I18n.parse("Teleport.sethomeerror"));
|
p.sendMessage(I18n.p("Teleport.sethomeerror"));
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +30,7 @@ public class CommandSetSpawn extends BaseCommand {
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
Location loc = p.getLocation();
|
Location loc = p.getLocation();
|
||||||
p.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
p.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||||
p.sendMessage(I18n.parse("Teleport.setspawn", p.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
p.sendMessage(I18n.p("Teleport.setspawn", p.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +35,7 @@ public class CommandSuicide extends BaseCommand {
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
List<ItemStack> drops = Arrays.asList(p.getInventory().getContents());
|
List<ItemStack> drops = Arrays.asList(p.getInventory().getContents());
|
||||||
int deoppedexp = (int) Math.floor(p.getExp());
|
int deoppedexp = (int) Math.floor(p.getExp());
|
||||||
String deathMessage = I18n.parse("Suicide.msg");
|
String deathMessage = I18n.p("Suicide.msg");
|
||||||
PlayerDeathEvent pd = new PlayerDeathEvent(p, drops, deoppedexp, deathMessage);
|
PlayerDeathEvent pd = new PlayerDeathEvent(p, drops, deoppedexp, deathMessage);
|
||||||
plugin.getServer().getPluginManager().callEvent(pd);
|
plugin.getServer().getPluginManager().callEvent(pd);
|
||||||
Bukkit.broadcastMessage(pd.getDeathMessage());
|
Bukkit.broadcastMessage(pd.getDeathMessage());
|
||||||
|
@ -36,7 +36,7 @@ public class CommandTop extends BaseCommand {
|
|||||||
int top = loc.getWorld().getHighestBlockYAt(loc);
|
int top = loc.getWorld().getHighestBlockYAt(loc);
|
||||||
loc.setY(top);
|
loc.setY(top);
|
||||||
p.teleport(loc);
|
p.teleport(loc);
|
||||||
p.sendMessage(I18n.parse("Teleport.top"));
|
p.sendMessage(I18n.p("Teleport.top"));
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,14 +34,14 @@ public class CommandTpa extends BaseCommand {
|
|||||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
sender.sendMessage(I18n.parse("Base.offline", args[0]));
|
sender.sendMessage(I18n.p("Base.offline", args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPA);
|
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPA);
|
||||||
sender.sendMessage(I18n.parse("Teleport.tpsend"));
|
sender.sendMessage(I18n.p("Teleport.tpsend"));
|
||||||
target.sendMessage(new String[] { I18n.parse("Teleport.tpa", sender.getName()),
|
target.sendMessage(new String[] { I18n.p("Teleport.tpa", sender.getName()),
|
||||||
I18n.parse("Teleport.tpaccept"),
|
I18n.p("Teleport.tpaccept"),
|
||||||
I18n.parse("Teleport.tpdeny") });
|
I18n.p("Teleport.tpdeny") });
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,14 +29,14 @@ public class CommandTphere extends BaseCommand {
|
|||||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
sender.sendMessage(I18n.parse("Base.offline", args[0]));
|
sender.sendMessage(I18n.p("Base.offline", args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPH);
|
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPH);
|
||||||
sender.sendMessage(I18n.parse("Teleport.tpsend"));
|
sender.sendMessage(I18n.p("Teleport.tpsend"));
|
||||||
target.sendMessage(new String[] { I18n.parse("Teleport.tphere", sender.getName()),
|
target.sendMessage(new String[] { I18n.p("Teleport.tphere", sender.getName()),
|
||||||
I18n.parse("Teleport.tpaccept"),
|
I18n.p("Teleport.tpaccept"),
|
||||||
I18n.parse("Teleport.tpdeny") });
|
I18n.p("Teleport.tpdeny") });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,15 +31,15 @@ public class CommandWorld extends BaseCommand {
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
p.sendMessage(I18n.parse("World.title"));
|
p.sendMessage(I18n.p("World.title"));
|
||||||
for (World wd : Bukkit.getWorlds())
|
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()));
|
p.sendMessage(I18n.p("World.info", wd.getName(), wd.getEnvironment().toString(), wd.getLoadedChunks().length, wd.getEntities().size(), wd.getPlayers().size()));
|
||||||
case 1:
|
case 1:
|
||||||
World wd = Bukkit.getWorld(args[1]);
|
World wd = Bukkit.getWorld(args[1]);
|
||||||
if (wd != null)
|
if (wd != null)
|
||||||
p.teleport(wd.getSpawnLocation());
|
p.teleport(wd.getSpawnLocation());
|
||||||
else
|
else
|
||||||
p.sendMessage(I18n.parse("World.unknow", args[1]));
|
p.sendMessage(I18n.p("World.unknow", args[1]));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,15 +8,15 @@ public class I18n {
|
|||||||
private static String CONFIG_NAME = "language.yml";
|
private static String CONFIG_NAME = "language.yml";
|
||||||
private static FileConfig config;
|
private static FileConfig config;
|
||||||
|
|
||||||
public static String parse(String path) {
|
|
||||||
return config.getMessage(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String parse(String path, Object... args) {
|
|
||||||
return String.format(parse(path), args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void load(Plugin p) {
|
public static void load(Plugin p) {
|
||||||
config = new FileConfig(p, CONFIG_NAME);
|
config = new FileConfig(p, CONFIG_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String p(String path, Object... args) {
|
||||||
|
return String.format(p(path), args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String p(String path) {
|
||||||
|
return config.getMessage(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class TeleportControl {
|
|||||||
Player target = ti.getTarget();
|
Player target = ti.getTarget();
|
||||||
Location loc = null;
|
Location loc = null;
|
||||||
if (!target.isOnline()) {
|
if (!target.isOnline()) {
|
||||||
player.sendMessage(TpControlName + I18n.parse("Teleport.offline"));
|
player.sendMessage(TpControlName + I18n.p("Teleport.offline"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ti.getTptype() == TeleportType.TPA) {
|
if (ti.getTptype() == TeleportType.TPA) {
|
||||||
@ -56,12 +56,12 @@ public class TeleportControl {
|
|||||||
target = player;
|
target = player;
|
||||||
loc = ti.getTarget().getLocation();
|
loc = ti.getTarget().getLocation();
|
||||||
}
|
}
|
||||||
player.sendMessage(TpControlName + I18n.parse("Teleport.accept", target.getDisplayName()));
|
player.sendMessage(TpControlName + I18n.p("Teleport.accept", target.getDisplayName()));
|
||||||
target.sendMessage(TpControlName + I18n.parse("Teleport.acceptfrom", player.getDisplayName()));
|
target.sendMessage(TpControlName + I18n.p("Teleport.acceptfrom", player.getDisplayName()));
|
||||||
magicTeleport(target, loc, TpDelay);
|
magicTeleport(target, loc, TpDelay);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.sendMessage(TpControlName + I18n.parse("Teleport.none"));
|
player.sendMessage(TpControlName + I18n.p("Teleport.none"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,11 +86,10 @@ public class TeleportControl {
|
|||||||
*/
|
*/
|
||||||
public void back(Player player) {
|
public void back(Player player) {
|
||||||
Location loc = lastlocList.get(player);
|
Location loc = lastlocList.get(player);
|
||||||
if (loc != null) {
|
if (loc != null)
|
||||||
magicTeleport(player, loc, 3);
|
magicTeleport(player, loc, 3);
|
||||||
} else {
|
else
|
||||||
player.sendMessage(TpControlName + I18n.parse("Teleport.nobackloc"));
|
player.sendMessage(TpControlName + I18n.p("Teleport.nobackloc"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -104,12 +103,12 @@ public class TeleportControl {
|
|||||||
if (ti != null) {
|
if (ti != null) {
|
||||||
Player target = ti.getTarget();
|
Player target = ti.getTarget();
|
||||||
if (target.isOnline()) {
|
if (target.isOnline()) {
|
||||||
player.sendMessage(TpControlName + I18n.parse("Teleport.deny", target.getDisplayName()));
|
player.sendMessage(TpControlName + I18n.p("Teleport.deny", target.getDisplayName()));
|
||||||
target.sendMessage(TpControlName + I18n.parse("Teleport.denyfrom", player.getDisplayName()));
|
target.sendMessage(TpControlName + I18n.p("Teleport.denyfrom", player.getDisplayName()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.sendMessage(TpControlName + I18n.parse("Teleport.none"));
|
player.sendMessage(TpControlName + I18n.p("Teleport.none"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +136,7 @@ public class TeleportControl {
|
|||||||
public void magicTeleport(final Player player, final Location loc, final int delay) {
|
public void magicTeleport(final Player player, final Location loc, final int delay) {
|
||||||
int petime = delay * 20 + 10;
|
int petime = delay * 20 + 10;
|
||||||
setLastloc(player, player.getLocation());
|
setLastloc(player, player.getLocation());
|
||||||
player.sendMessage(TpControlName + I18n.parse("Teleport.tp", delay, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ()));
|
player.sendMessage(TpControlName + I18n.p("Teleport.tp", delay, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ()));
|
||||||
List<PotionEffect> pe = new ArrayList<PotionEffect>();
|
List<PotionEffect> pe = new ArrayList<PotionEffect>();
|
||||||
pe.add(new PotionEffect(PotionEffectType.SLOW, petime, 255));
|
pe.add(new PotionEffect(PotionEffectType.SLOW, petime, 255));
|
||||||
pe.add(new PotionEffect(PotionEffectType.CONFUSION, petime, 255));
|
pe.add(new PotionEffect(PotionEffectType.CONFUSION, petime, 255));
|
||||||
@ -149,9 +148,8 @@ public class TeleportControl {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (System.currentTimeMillis() < timeoutmark) {
|
while (System.currentTimeMillis() < timeoutmark) {
|
||||||
if (player.isOnline()) {
|
if (player.isOnline())
|
||||||
EffectUtil.run(player.getLocation(), lrng, Effect.MOBSPAWNER_FLAMES, Effect.PORTAL);
|
EffectUtil.run(player.getLocation(), lrng, Effect.MOBSPAWNER_FLAMES, Effect.PORTAL);
|
||||||
}
|
|
||||||
lrng++;
|
lrng++;
|
||||||
try {
|
try {
|
||||||
Thread.sleep(128);
|
Thread.sleep(128);
|
||||||
@ -160,14 +158,10 @@ public class TeleportControl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
|
||||||
@Override
|
if (player.isOnline())
|
||||||
public void run() {
|
player.teleport(loc);
|
||||||
if (player.isOnline()) {
|
} , delay * 20);
|
||||||
player.teleport(loc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, delay * 20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#本文件为基础插件的语言配置文件
|
#本文件为基础插件的语言配置文件
|
||||||
version: 1.0
|
version: 1.2
|
||||||
#基础语言配置
|
#基础语言配置
|
||||||
Base:
|
Base:
|
||||||
offline: "§c玩家 %s 不存在或不在线!"
|
offline: "§c玩家 %s 不存在或不在线!"
|
||||||
@ -33,11 +33,12 @@ Hat:
|
|||||||
empty: '§c看上去你手上什么都没有啊!'
|
empty: '§c看上去你手上什么都没有啊!'
|
||||||
enjoy: '§2享受你的新帽子吧!'
|
enjoy: '§2享受你的新帽子吧!'
|
||||||
Gc:
|
Gc:
|
||||||
Processors: '§6使用核心: §a%s'
|
runTime: '§6运行时间: §a%s'
|
||||||
|
Processors: '§6CPU核心: §a%s'
|
||||||
maxMem: '§6最大内存: §a%s'
|
maxMem: '§6最大内存: §a%s'
|
||||||
totalMem: '§6已用内存: §a%s'
|
totalMem: '§6已用内存: §a%s'
|
||||||
freeMem: '§6空闲内存: §a%s'
|
freeMem: '§6空闲内存: §a%s'
|
||||||
World:
|
World:
|
||||||
title: '§6当前服务器的启用的世界如下'
|
title: '§6当前服务器的启用的世界如下'
|
||||||
info: '§6名称: §a%s §b- §6类型: §a%s §6区块: §a%s §6实体数: §a%s §6玩家数: §a%s'
|
info: '§a%s §3-- §a%s §6区块: §a%s §6实体数: §a%s §6玩家数: §a%s'
|
||||||
unknow: '§c未知的世界 §a%s'
|
unknow: '§c未知的世界 §a%s'
|
Loading…
Reference in New Issue
Block a user