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

master
xjboss 2017-04-19 14:14:08 +08:00
parent 27ead9b23e
commit 03f978df05
1 changed files with 9 additions and 6 deletions

View File

@ -64,10 +64,10 @@ public class TeleportRandom extends JavaPlugin implements CommandExecutor {
case 1:
throw new IllegalArgumentException();
case 2:
randomTP(Integer.parseInt(args[1]), p.getWorld(), p);
randomTP(Integer.parseInt(args[1]), p.getWorld(), p,true);
return true;
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;
}
}
@ -89,18 +89,21 @@ public class TeleportRandom extends JavaPlugin implements CommandExecutor {
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(); }
getServer().getScheduler().runTaskAsynchronously(this, new Runnable() {
@Override
public void run() {
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;
p.sendMessage(getPrefix() + config.getMessage("Message.CDs").replace("{0}", String.format("%s", leftTime)));
return;
}
if (!config.getStringList("AllowWorld").contains(world.getName())) {
if (!console&&!config.getStringList("AllowWorld").contains(world.getName())) {
p.sendMessage(getPrefix() + config.getMessage("Message.NoPermWorld"));
return;
}
@ -111,7 +114,7 @@ public class TeleportRandom extends JavaPlugin implements CommandExecutor {
} else {
lr = limit;
final int lrLimit = config.getInt("Limit");
if (lr > lrLimit) {
if (!console&&lr > lrLimit) {
lr = lrLimit;
p.sendMessage(String.format(getPrefix() + config.getMessage("Message.Wran"), lrLimit));
}