1
0
mirror of https://e.coding.net/circlecloud/TeleportRandom.git synced 2024-12-26 16:38:49 +00:00

现在控制台无视权限和CD了!

This commit is contained in:
xjboss 2017-04-19 14:14:08 +08:00
parent 27ead9b23e
commit 03f978df05

View File

@ -64,10 +64,10 @@ public class TeleportRandom extends JavaPlugin implements CommandExecutor {
case 1: case 1:
throw new IllegalArgumentException(); throw new IllegalArgumentException();
case 2: case 2:
randomTP(Integer.parseInt(args[1]), p.getWorld(), p); randomTP(Integer.parseInt(args[1]), p.getWorld(), p,true);
return true; return true;
case 3: case 3:
randomTP(Integer.parseInt(args[1]), Bukkit.getWorld(args[2]), p); randomTP(Integer.parseInt(args[1]), Bukkit.getWorld(args[2]), p,true);
return true; return true;
} }
} }
@ -89,18 +89,21 @@ public class TeleportRandom extends JavaPlugin implements CommandExecutor {
config = new FileConfig(); config = new FileConfig();
} }
public void randomTP(final int limit, final World world, final Player p) { public void randomTP(final int limit, final World world, final Player p){
randomTP(limit,world,p,false);
}
public void randomTP(final int limit, final World world, final Player p, final boolean console) {
if (world == null || p == null) { throw new IllegalArgumentException(); } if (world == null || p == null) { throw new IllegalArgumentException(); }
getServer().getScheduler().runTaskAsynchronously(this, new Runnable() { getServer().getScheduler().runTaskAsynchronously(this, new Runnable() {
@Override @Override
public void run() { public void run() {
final long t = System.currentTimeMillis(); final long t = System.currentTimeMillis();
if (!p.hasPermission("tpr.nocd") && cd.keySet().contains(p.getName())) { if (!console&&!p.hasPermission("tpr.nocd") && cd.keySet().contains(p.getName())) {
final long leftTime = config.getLong("CD") / 20 - (t - cd.get(p.getName())) / 1000; final long leftTime = config.getLong("CD") / 20 - (t - cd.get(p.getName())) / 1000;
p.sendMessage(getPrefix() + config.getMessage("Message.CDs").replace("{0}", String.format("%s", leftTime))); p.sendMessage(getPrefix() + config.getMessage("Message.CDs").replace("{0}", String.format("%s", leftTime)));
return; return;
} }
if (!config.getStringList("AllowWorld").contains(world.getName())) { if (!console&&!config.getStringList("AllowWorld").contains(world.getName())) {
p.sendMessage(getPrefix() + config.getMessage("Message.NoPermWorld")); p.sendMessage(getPrefix() + config.getMessage("Message.NoPermWorld"));
return; return;
} }
@ -111,7 +114,7 @@ public class TeleportRandom extends JavaPlugin implements CommandExecutor {
} else { } else {
lr = limit; lr = limit;
final int lrLimit = config.getInt("Limit"); final int lrLimit = config.getInt("Limit");
if (lr > lrLimit) { if (!console&&lr > lrLimit) {
lr = lrLimit; lr = lrLimit;
p.sendMessage(String.format(getPrefix() + config.getMessage("Message.Wran"), lrLimit)); p.sendMessage(String.format(getPrefix() + config.getMessage("Message.Wran"), lrLimit));
} }