Exemplo n.º 1
0
  @Override
  public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) {

    if (args.length == 2) {
      return CommandBase.getListOfStringsMatchingLastWord(
          args, MinecraftServer.getServer().getAllUsernames());
    }
    return null;
  }
Exemplo n.º 2
0
 @SuppressWarnings("unchecked")
 @Override
 public List<?> addTabCompletionOptions(ICommandSender sender, String[] args) {
   ArrayList<String> list = new ArrayList<String>();
   switch (args.length) {
     case 1:
       if (sender instanceof EntityPlayer) {
         list.addAll(CommandBase.getListOfStringsMatchingLastWord(args, playerCommands));
       } else {
         list.addAll(CommandBase.getListOfStringsMatchingLastWord(args, serverCommands));
       }
       break;
     case 2:
       if (args[0].equalsIgnoreCase("kick")
           || args[0].equalsIgnoreCase("setpass")
           || args[0].equalsIgnoreCase("unregister")) {
         list.addAll(
             CommandBase.getListOfStringsMatchingLastWord(
                 args,
                 FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames()));
       }
   }
   return list;
 }
  @Override
  public List<String> getTabCompletionOptions(
      MinecraftServer server,
      ICommandSender iCommandSender,
      String[] typedValue,
      @Nullable BlockPos pos) {
    if (!PlayerMPUtil.isPlayer(iCommandSender)) {
      return null;
    }
    if (typedValue.length == 1) {

      EntityPlayerMP player = (EntityPlayerMP) PlayerMPUtil.castToPlayer(iCommandSender);
      if (player == null) {
        return null;
      }

      ItemStack stack = player.getHeldItemMainhand();
      if (stack == null) {
        return null;
      }

      // Get Enchantment List
      @SuppressWarnings("unchecked")
      List<String> validEnchantmentNames = new ArrayList<String>();
      Map<String, Enchantment> validEnchantments = new HashMap<String, Enchantment>();
      for (Enchantment enchantment : Enchantment.REGISTRY) {
        if (enchantment != null) {
          String name = I18n.translateToLocal(enchantment.getName()).replaceAll(" ", "");
          validEnchantmentNames.add(name);
        }
      }

      String[] validEnchantmentArray = new String[validEnchantmentNames.size()];
      validEnchantmentArray = validEnchantmentNames.toArray(validEnchantmentArray);
      return CommandBase.getListOfStringsMatchingLastWord(typedValue, validEnchantmentArray);
    }

    return null;
  }