Ejemplo n.º 1
0
  @Override
  public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
      return true;
    }

    long seed;
    if (sender instanceof Player) {
      seed = ((Player) sender).getLevel().getSeed();
    } else {
      seed = sender.getServer().getDefaultLevel().getSeed();
    }

    sender.sendMessage(new TranslationContainer("commands.seed.success", String.valueOf(seed)));

    return true;
  }
Ejemplo n.º 2
0
  @Override
  public boolean execute(CommandSender sender, String label, String[] args) {
    if (!this.plugin.isEnabled()) return false;
    if (!sender.hasPermission("economyapi.command.setlang")) {
      sender.sendMessage(TextFormat.RED + "You don't have permission to use this command.");
      return false;
    }

    if (args.length < 1) {
      sender.sendMessage(TextFormat.RED + "Usage: " + this.getUsage());
      return true;
    }
    String lang = args[0];

    // TODO
    return true;
  }
Ejemplo n.º 3
0
 public boolean tip(CommandSender sender, Object... s) {
   if (sender == null) return Message.LNG_PRINT_FAIL.log(this.name());
   Player player = sender instanceof Player ? (Player) sender : null;
   String message = getText(s);
   if (player == null) sender.sendMessage(message);
   else player.sendTip(message);
   return true;
 }
Ejemplo n.º 4
0
 @Override
 public boolean execute(CommandSender sender, String commandLabel, String[] args) {
   if (!this.testPermission(sender)) {
     return true;
   }
   sender.getServer().setAutoSave(false);
   Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.disabled"));
   return true;
 }
Ejemplo n.º 5
0
 @Override
 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
   switch (command.getName()) {
     case "example":
       try {
         this.getLogger()
             .info(
                 Utils.readFile(new File(this.getDataFolder(), "string.txt"))
                     + " "
                     + sender.getName());
       } catch (IOException e) {
         throw new RuntimeException(e);
       }
       break;
   }
   return true;
 }
Ejemplo n.º 6
0
 public boolean tip(int seconds, CommandSender sender, Object... s) {
   if (sender == null) return Message.LNG_PRINT_FAIL.log(this.name());
   final Player player = sender instanceof Player ? (Player) sender : null;
   final String message = getText(s);
   if (player == null) sender.sendMessage(message);
   else
     for (int i = 0; i < seconds; i++)
       Server.getInstance()
           .getScheduler()
           .scheduleDelayedTask(
               new Runnable() {
                 public void run() {
                   if (player.isOnline()) player.sendTip(message);
                 }
               },
               20 * i);
   return true;
 }
Ejemplo n.º 7
0
 @Override
 public boolean execute(CommandSender sender, String commandLabel, String[] args) {
   if (!this.testPermission(sender)) {
     return true;
   }
   if (args.length < 2) {
     sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
     return true;
   }
   Player player = sender.getServer().getPlayer(args[0]);
   if (player == null) {
     sender.sendMessage(
         new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
     return true;
   }
   if (args[1].equalsIgnoreCase("clear")) {
     for (Effect effect : player.getEffects().values()) {
       player.removeEffect(effect.getId());
     }
     sender.sendMessage(
         new TranslationContainer("commands.effect.success.removed.all", player.getDisplayName()));
     return true;
   }
   Effect effect;
   try {
     effect = Effect.getEffect(Integer.parseInt(args[1]));
   } catch (NumberFormatException | ServerException a) {
     try {
       effect = Effect.getEffectByName(args[1]);
     } catch (Exception e) {
       sender.sendMessage(new TranslationContainer("commands.effect.notFound", args[1]));
       return true;
     }
   }
   int duration = 300;
   int amplification = 0;
   if (args.length >= 3) {
     try {
       duration = Integer.valueOf(args[2]);
     } catch (NumberFormatException a) {
       sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
       return true;
     }
     if (!(effect instanceof InstantEffect)) {
       duration *= 20;
     }
   } else if (effect instanceof InstantEffect) {
     duration = 1;
   }
   if (args.length >= 4) {
     try {
       amplification = Integer.valueOf(args[3]);
     } catch (NumberFormatException a) {
       sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
       return true;
     }
   }
   if (args.length >= 5) {
     String v = args[4].toLowerCase();
     if (v.matches("(?i)|on|true|t|1")) {
       effect.setVisible(false);
     }
   }
   if (duration == 0) {
     if (!player.hasEffect(effect.getId())) {
       if (player.getEffects().size() == 0) {
         sender.sendMessage(
             new TranslationContainer(
                 "commands.effect.failure.notActive.all", player.getDisplayName()));
       } else {
         sender.sendMessage(
             new TranslationContainer(
                 "commands.effect.failure.notActive",
                 new String[] {effect.getName(), player.getDisplayName()}));
       }
       return true;
     }
     player.removeEffect(effect.getId());
     sender.sendMessage(
         new TranslationContainer(
             "commands.effect.success.removed",
             new String[] {effect.getName(), player.getDisplayName()}));
   } else {
     effect.setDuration(duration).setAmplifier(amplification);
     player.addEffect(effect);
     Command.broadcastCommandMessage(
         sender,
         new TranslationContainer(
             "%commands.effect.success",
             new String[] {
               effect.getName(),
               String.valueOf(effect.getId()),
               String.valueOf(effect.getAmplifier()),
               player.getDisplayName(),
               String.valueOf(effect.getDuration() / 20)
             }));
   }
   return true;
 }
Ejemplo n.º 8
0
 @Override
 public boolean execute(CommandSender commandSender, String s, String[] strings) {
   commandSender.sendMessage("???");
   return false;
 }
Ejemplo n.º 9
0
 public boolean execute(CommandSender sender, String commandLabel, String[] args) {
   if (!sender.hasPermission(this.getPermission())) {
     Message.YOU_DONT_HAVE_PERMISSION.print(sender, 'c');
   } else {
     if (args.length >= 1) {
       switch (args[0]) {
         case "tp":
           if (args.length == 3) {
             Player p = this.plugin.getServer().getPlayer(args[2]);
             if (p == null) {
               p = this.plugin.sortedListPlayers(args[0]);
               if (p == null) {
                 Message.UNKNOWN_PLAYER.print(sender, "prefix:&7[&aWorld&7]", 'c');
                 return true;
               }
             }
             if (sender.hasPermission("toolspro.commands.world")
                 || sender.hasPermission("toolspro.commands.world.other")
                 || sender.hasPermission("toolspro.commands.world." + args[1])) {
               if (p.getLevel().getName().equalsIgnoreCase(args[1])) {
                 Message.CMD_WORLD_TP_PLAYER_ALREADY_IN_THIS_WORLD.print(
                     sender, "prefix:&7[&aWorld&7]", 'c');
                 return false;
               } else if (!p.getServer().isLevelGenerated(args[1])) {
                 Message.CMD_WORLD_TP_NOT_FOUND.print(sender, "prefix:&7[&aWorld&7]", 'c');
                 return false;
               } else if (!p.getServer().isLevelLoaded(args[1])) {
                 Message.CMD_WORLD_TP_NOT_LOADED.print(sender, "prefix:&7[&aWorld&7]", 'c');
                 if (!p.getServer().loadLevel(args[1])) {
                   Message.CMD_WORLD_TP_ERROR_LOADING.print(sender, "prefix:&7[&aWorld&7]", 'c');
                   return false;
                 }
               }
               p.teleport(this.plugin.getServer().getLevelByName(args[1]).getSafeSpawn());
               Message.CMD_WORLD_TP_SENDER.print(
                   sender, "prefix:&7[&aWorld&7]", 'a', 'b', p.getName(), args[1]);
               Message.CMD_WORLD_TP_PLAYER_MESSAGE.print(
                   p, "prefix:&7[&aWorld&7]", 'a', 'b', args[1]);
             } else {
               Message.CMD_WORLD_TP_PLAYER_PERMISSION.print(sender, "prefix:&7[&aWorld&7]", 'c');
             }
           } else {
             if (sender instanceof Player) {
               if (args.length == 2) {
                 if (sender.hasPermission("toolspro.commands.world")
                     || sender.hasPermission("toolspro.world." + args[1].toLowerCase())) {
                   if (((Player) sender).getLevel().getName().equalsIgnoreCase(args[1])) {
                     Message.CMD_WORLD_TP_SENDER_ALREADY_IN_THIS_WORLD.print(
                         sender, "prefix:&7[&aWorld&7]", 'c');
                     return false;
                   } else if (!sender.getServer().isLevelGenerated(args[1])) {
                     Message.CMD_WORLD_TP_NOT_FOUND.print(sender, "prefix:&7[&aWorld&7]", 'c');
                     return false;
                   } else if (!sender.getServer().isLevelLoaded(args[1])) {
                     Message.CMD_WORLD_TP_NOT_LOADED.print(sender, "prefix:&7[&aWorld&7]", 'c');
                     if (!sender.getServer().loadLevel(args[1])) {
                       Message.CMD_WORLD_TP_ERROR_LOADING.print(
                           sender, "prefix:&7[&aWorld&7]", 'c');
                       return false;
                     }
                   }
                   ((Player) sender)
                       .teleport(this.plugin.getServer().getLevelByName(args[1]).getSafeSpawn());
                   Message.CMD_WORLD_TP.print(sender, "prefix:&7[&aWorld&7]", 'a');
                 } else {
                   Message.CMD_WORLD_TP_SENDER_NO_PERMISSION.print(
                       sender, "prefix:&7[&aWorld&7]", 'c');
                 }
               } else {
                 Message.CMD_WORLD_USAGE_TP.print(sender, "prefix:&7[&aWorld&7]", 'c');
               }
             } else {
               Message.NEED_PLAYER.print(sender, "prefix:&7[&aWorld&7]", 'c');
             }
           }
           return true;
         case "create":
           if (sender.hasPermission("toolspro.commands.world.create")) {
             if (args.length >= 2) {
               if (!sender.getServer().isLevelGenerated(args[1])) {
                 long seed = System.currentTimeMillis();
                 Class generator;
                 if (args.length <= 2) {
                   generator = Generator.getGenerator(Generator.TYPE_INFINITE);
                 } else {
                   int type;
                   switch (args[2].toLowerCase()) {
                     case "old":
                       type = Generator.TYPE_OLD;
                       break;
                     case "infinite":
                     default:
                       type = Generator.TYPE_INFINITE;
                       break;
                     case "flat":
                       type = Generator.TYPE_FLAT;
                       break;
                   }
                   generator = Generator.getGenerator(type);
                 }
                 sender
                     .getServer()
                     .generateLevel(
                         args[1], seed == 0 ? System.currentTimeMillis() : seed, generator);
                 Message.CMD_WORLD_CREATE.print(sender, "prefix:&7[&aWorld&7]", 'a', 'b', args[1]);
               } else {
                 Message.CMD_WORLD_CREATE_ALREADY_EXISTS.print(
                     sender, "prefix:&7[&aWorld&7]", 'c');
               }
             } else {
               return Message.CMD_WORLD_USAGE_CREATE.print(sender, "prefix:&7[&aWorld&7]", 'c');
             }
           } else {
             return Message.YOU_DONT_HAVE_PERMISSION.print(sender, 'c');
           }
           return true;
         default:
           return Message.CMD_WORLD_USAGE.print(sender, "prefix:&7[&aWorld&7]", 'c');
       }
     } else {
       return Message.CMD_WORLD_USAGE.print(sender, "prefix:&7[&aWorld&7]", 'c');
     }
   }
   return true;
 }
Ejemplo n.º 10
0
 /**
  * Send message to Player or to ConsoleSender
  *
  * @param sender
  * @param s
  * @return
  */
 public boolean print(CommandSender sender, Object... s) {
   if (sender == null) return Message.LNG_PRINT_FAIL.log(this.name());
   sender.sendMessage(getText(s));
   return true;
 }